Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume declaration order violation (should not be able to reference what is next) #5

Open
Zelenyy opened this issue Jul 29, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@Zelenyy
Copy link
Member

Zelenyy commented Jul 29, 2019

Package don't make true order of volume structure.
Code:

            structure {
                val matref = GDMLRef<GDMLMaterial>("G4_AIR")
                val worldBox = [email protected]("World", 100, 100, 100)
                val volWorld = volume("world", matref, worldBox.ref()){}
                val segment = [email protected]("InnerTube", 20, 5.0){
                    rmin = 17
                    deltaphi = 60
                    aunit = "degree"
                }
                val vol = volume("vol1", matref, segment.ref()) {}
                [email protected] = volWorld.ref()
                [email protected] {
                    physVolume(vol.ref()) {
                        positionref = ref("box_position")
                        rotationref = ref("Rot1")
                    }
                }
            }

Result --- volume vol1 define after its using:

   <structure>
        <volume name="world">
            <physvol>
                <volumeref ref="vol1"></volumeref>
                <positionref ref="box_position"></positionref>
                <rotationref ref="Rot1"></rotationref>
            </physvol>
            <materialref ref="G4_AIR"></materialref>
            <solidref ref="World"></solidref>
        </volume>
        <volume name="vol1"> 
            <materialref ref="G4_AIR"></materialref>
            <solidref ref="InnerTube"></solidref>
        </volume>
    </structure>

In my gdml dsl i sorted tag by its children:

    override fun compareTo(other: VOLUME): Int {
        if (dependenciesVolumeList.contains(other.name)){
            return 1
        }
        if (other.dependenciesVolumeList.contains(this.name)){
            return -1
        }
        return 0
    }
@altavir
Copy link
Member

altavir commented Jul 29, 2019

The usage of world is no correct in generator anyway. It is meant for access only. I will create a separate issue for that.

As for the rest, it is possible to add additional sorting operation before conversion to string. For large files, it could be expensive though.

@Zelenyy
Copy link
Member Author

Zelenyy commented Jul 29, 2019

The usage of world is no correct in generator anyway.

It does not matter, I think this bug will reproduction for any volume if his usage will be split on several part.

@Zelenyy
Copy link
Member Author

Zelenyy commented Jul 29, 2019

World should not be used in generator

How to set world volume?

@altavir
Copy link
Member

altavir commented Jul 29, 2019

World is defined here: https://github.com/mipt-npm/gdml.kt/blob/4369ac0477f0bb6eaede6d09fae068b0c242220a/src/commonMain/kotlin/scientifik/gdml/GDML.kt#L45. It uses the one in setup, otherwise takes first declared volume in structure. The second clause could create some problems. I've opened #6 for that.

@altavir
Copy link
Member

altavir commented Jul 29, 2019

The usage of world is no correct in generator anyway.

It does not matter, I think this bug will reproduction for any volume if his usage will be split on several part.

It is not a bug per se. The problem is that you say that GEANT does not read the whole structure before starting to interpret it. So the behavior needs to be adjusted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants