Created attachment 113 [details] The geometry with Matlab I have described a geometry with the constructor G4ExtrudedSolid: std::vector<G4TwoVector> MLCLeaf_xz_section[40]; for( int i=0; i<MLC_num_leaves; i++ ) { // Do distortion according to second coordinate (subleaves get wider at bottom) // Placement in detector geometry is included in x coordinate, every leaf is to be placed at 0 MLCLeaf_xz_section[i].push_back( G4TwoVector((-0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+37.5)) / MLCLeaf_upper_z), 37.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+37.5)) / MLCLeaf_upper_z), 37.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+3.5)) / MLCLeaf_upper_z), 3.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+3.5)) / MLCLeaf_upper_z), 3.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+(-37.5))) / MLCLeaf_upper_z), -37.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+(-37.5))) / MLCLeaf_upper_z), -37.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+1.5)) / MLCLeaf_upper_z), 1.5*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(37.5+1.5)) / MLCLeaf_upper_z), 1.5*mm) ); } for( int i=0; i<40; i++ ) { // Build xz-cross section of sub-leaves // as G4ExtrudedSolid, for intersection with // rounded yz-section G4ExtrudedSolid* MLCLeaf_xz_solid = new G4ExtrudedSolid( "MLCLeaf_xz_solid", MLCLeaf_xz_section[i], MLCLeaf_half_y, 0, 1, 0, 1 ); MLCPosLeaf_log[i] = new G4LogicalVolume( MLCLeaf_xz_solid, CollAlloy, "MLCPosLeaf_log" ); char Name[20]; sprintf(Name,"MLCPosLeaf_phys%d",i); MLCPosLeaf_phys[i] = new G4PVPlacement( 0, //G4ThreeVector( (i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch, G4ThreeVector( 0, // x position is part of solid (displaced origin) //MLCPosLeafPosition(i), //MLCPosLeafPositionSimple(i), //ZLeafPosition() // leaf is now asymmetric in z, point of reference is in center 0,0 ), MLCPosLeaf_log[i], Name, experimentalHall_log, false, 0 ,true); I have drawn the geometry with help of Matlab, and I know there is not a overlap. In fact, when I do the check in the constructor I get that the geometry is Ok. However, when I run the executable, I get Warnings Message like: WARNING - G4Navigator::ComputeStep() Track stuck, not moving for 10 steps in volume -MLCPosLeaf_phys2- at point (-54.5915,-37.5,56.1911) direction: (0.110958,-0.417173,-0.902028). Potential geometry or navigation problem ! Trying pushing it of 1e-07 mm ... If i do the test in the prompt, with /geometry/test I get: Idle> /geometry/test/direction 0.110958 -0.417173 -0.902028 mm Idle> /geometry/test/position -54.5915 -37.5 56.1911 mm Idle> /geometry/test/line_test GeomTest Error: SolidProblem Solid has odd number of intersection points Solid name = MLCLeaf_xz_solid Local position = -5.45915 -3.75 5.61911 cm GeomTest Error: SolidProblem Solid has odd number of intersection points Solid name = MLCLeaf_xz_solid Local position = -5.45915 -3.75 5.61911 cm GeomTest Error: SolidProblem Unmatched intersection point Solid name = MLCLeaf_xz_solid Local position = -5.45915 -3.75 5.61911 cm GeomTest Error: SolidProblem Unmatched intersection point Solid name = MLCLeaf_xz_solid Local position = -5.45915 -3.75 5.61911 cm GeomTest: no daughter volume extending outside mother detected. GeomTest: no overlapping daughters detected. or Idle> geometry/test/position -41.4217 37.5 42.423 mm Idle> geometry/test/direction -0.125948 0.281505-0.951258 mm 0.281505-0.951258: double value expected. Parameter is wrong type and/or is not omittable (index 1) Idle> geometry/test/direction -0.125948 0.281505 -0.951258 mm Idle> geometry/test/line_test GeomTest Error: SolidProblem Solid has odd number of intersection points Solid name = MLCLeaf_xz_solid Local position = -4.14217 3.75 4.2423 cm GeomTest Error: SolidProblem Solid has odd number of intersection points Solid name = MLCLeaf_xz_solid Local position = -4.14217 3.75 4.2423 cm GeomTest Error: SolidProblem Unmatched intersection point Solid name = MLCLeaf_xz_solid Local position = -4.14217 3.75 4.2423 cm GeomTest Error: SolidProblem Unmatched intersection point Solid name = MLCLeaf_xz_solid Local position = -4.14217 3.75 4.2423 cm GeomTest: no daughter volume extending outside mother detected. GeomTest Error: Overlapping daughter volumes The volumes MLCPosLeaf_phys8[0] and MLCPosLeaf_phys6[0], both daughters of volume expHall[0], appear to overlap at the following points in global coordinates: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the mother coordinate system are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the coordinate system of MLCPosLeaf_phys8[0] are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the coordinate system of MLCPosLeaf_phys6[0] are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 GeomTest Error: Overlapping daughter volumes The volumes MLCPosLeaf_phys8[0] and MLCPosLeaf_phys7[0], both daughters of volume expHall[0], appear to overlap at the following points in global coordinates: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the mother coordinate system are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the coordinate system of MLCPosLeaf_phys8[0] are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 Which in the coordinate system of MLCPosLeaf_phys7[0] are: length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------ 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 0.65498 -4.05968 3.56562 4.86535 -4.14217 3.75 4.2423 I attached the geometry Skizze done with Matlab and the image that I get with Geant4; one can see in bothe, that there is no overlap. My Colleague had a problem with this geometry 3 years ago, he posted in Forum: http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/847.html and he thinks perhaps it is the same bug, which was not total fixed. Thank you very much in advance, and if there is some questions (or it is not a bug, but an error of my simulation) you can write me to: nescobarcorral@ukaachen.de Nuria
Created attachment 114 [details] A picture of the geometry with Geant4
Dear Nuria, In order to investigate your case, we need also to know the parameters which you use in your geometry: MLC_num_leaves, MLCLeaf_upper_pitch, MLCLeaf_upper_z, MLCLeaf_half_y. Could you, please, provide their values? Thank you, Ivana
I cannot give the values which I use in my Simulation due an agreemet with the firma, but I have rounded the numbers and I gtet the same error. INow the geometry is: std::vector<G4TwoVector> MLCLeaf_xz_section[40]; for( int i=0; i<MLC_num_leaves; i++ ) { // Do distortion according to second coordinate (subleaves get wider at bottom) // Placement in detector geometry is included in x coordinate, every leaf is to be placed at 0 MLCLeaf_xz_section[i].push_back( G4TwoVector((-0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+40)) / MLCLeaf_upper_z), 40*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+40)) / MLCLeaf_upper_z), 40*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+4)) / MLCLeaf_upper_z), 4*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+4)) / MLCLeaf_upper_z), 4*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector(( 0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+(-40))) / MLCLeaf_upper_z), -40*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+(-40))) / MLCLeaf_upper_z), -40*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-1.675*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+2)) / MLCLeaf_upper_z), 2*mm) ); MLCLeaf_xz_section[i].push_back( G4TwoVector((-0.955*mm+(i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch) * ((MLCLeaf_upper_z+(40+2)) / MLCLeaf_upper_z), 2*mm) ); } for( int i=0; i<40; i++ ) { // Build xz-cross section of sub-leaves // as G4ExtrudedSolid, for intersection with // rounded yz-section G4ExtrudedSolid* MLCLeaf_xz_solid = new G4ExtrudedSolid( "MLCLeaf_xz_solid", MLCLeaf_xz_section[i], MLCLeaf_half_y, 0, 1, 0, 1 ); MLCPosLeaf_log[i] = new G4LogicalVolume( MLCLeaf_xz_solid, CollAlloy, "MLCPosLeaf_log" ); char Name[20]; sprintf(Name,"MLCPosLeaf_phys%d",i); MLCPosLeaf_phys[i] = new G4PVPlacement( 0, //G4ThreeVector( (i-MLC_num_leaves/2+0.5) * MLCLeaf_upper_pitch, G4ThreeVector( 0, // x position is part of solid (displaced origin) //MLCPosLeafPosition(i), //MLCPosLeafPositionSimple(i), //ZLeafPosition() // leaf is now asymmetric in z, point of reference is in center 0,0 ), MLCPosLeaf_log[i], Name, experimentalHall_log, false, 0 ,true); } Where the values are: MLC_num_leaves = 40; MLCLeaf_upper_pitch = 3mm; MLCLeaf_upper_z=300mm; MLCLeaf_half_y=80mm; Regards, Nuria
Created attachment 115 [details] the patch with a fix in Geant4 source
Dear Nuria, Thank you for providing the parameters; could you, please, check that the attached patch fixes your problem? Thank you, Ivana P.S. To apply the patch: cd my_path/geant4 patch -p0 --posix < patch.txt and after sourcing your environment: cd my_path/geant4/source/geometry/solids/specific make
Hello Ivana, I have tested it, but it has not worked. I have done: :~/Desktop/Geant4/geant4.9.4> patch -p0 --posix < patch.txt patching file source/geometry/solids/specific/src/G4ExtrudedSolid.cc nuria@st-nuria:~/Desktop/Geant4/geant4.9.4> nuria@st-nuria:~/Desktop/Geant4/geant4.9.4> cd source/geometry/solids/specific/ nuria@st-nuria:~/Desktop/Geant4/geant4.9.4/source/geometry/solids/specific> make Making dependency for file src/G4VTwistSurface.cc ... Making dependency for file src/G4VTwistedFaceted.cc ... Making dependency for file src/G4VFacet.cc ... Making dependency for file src/G4VCSGfaceted.cc ... Making dependency for file src/G4TwistTubsSide.cc ... Making dependency for file src/G4TwistTubsHypeSide.cc ... Making dependency for file src/G4TwistTubsFlatSide.cc ... Making dependency for file src/G4TwistTrapParallelSide.cc ... Making dependency for file src/G4TwistTrapFlatSide.cc ... Making dependency for file src/G4TwistTrapAlphaSide.cc ... Making dependency for file src/G4TwistedTubs.cc ... Making dependency for file src/G4TwistedTrd.cc ... Making dependency for file src/G4TwistedTrap.cc ... Making dependency for file src/G4TwistedBox.cc ... Making dependency for file src/G4TwistBoxSide.cc ... Making dependency for file src/G4TriangularFacet.cc ... Making dependency for file src/G4Tet.cc ... Making dependency for file src/G4TessellatedSolid.cc ... Making dependency for file src/G4TessellatedGeometryAlgorithms.cc ... Making dependency for file src/G4SolidExtentList.cc ... Making dependency for file src/G4ReduciblePolygon.cc ... Making dependency for file src/G4QuadrangularFacet.cc ... Making dependency for file src/G4PolyPhiFace.cc ... Making dependency for file src/G4PolyhedraSide.cc ... Making dependency for file src/G4Polyhedra.cc ... Making dependency for file src/G4PolyconeSide.cc ... Making dependency for file src/G4Polycone.cc ... Making dependency for file src/G4Paraboloid.cc ... Making dependency for file src/G4IntersectingCone.cc ... Making dependency for file src/G4Hype.cc ... Making dependency for file src/G4GenericTrap.cc ... Making dependency for file src/G4ExtrudedSolid.cc ... Making dependency for file src/G4EnclosingCylinder.cc ... Making dependency for file src/G4EllipticalTube.cc ... Making dependency for file src/G4EllipticalCone.cc ... Making dependency for file src/G4Ellipsoid.cc ... Making dependency for file src/G4ClippablePolygon.cc ... Compiling G4ClippablePolygon.cc ... Compiling G4Ellipsoid.cc ... Compiling G4EllipticalCone.cc ... Compiling G4EllipticalTube.cc ... Compiling G4EnclosingCylinder.cc ... Compiling G4ExtrudedSolid.cc ... ^[[B^[[B^[[BCompiling G4GenericTrap.cc ... Compiling G4Hype.cc ... Compiling G4IntersectingCone.cc ... Compiling G4Paraboloid.cc ... Compiling G4Polycone.cc ... Compiling G4PolyconeSide.cc ... Compiling G4Polyhedra.cc ... Compiling G4PolyhedraSide.cc ... Compiling G4PolyPhiFace.cc ... Compiling G4QuadrangularFacet.cc ... Compiling G4ReduciblePolygon.cc ... Compiling G4SolidExtentList.cc ... Compiling G4TessellatedGeometryAlgorithms.cc ... Compiling G4TessellatedSolid.cc ... Compiling G4Tet.cc ... Compiling G4TriangularFacet.cc ... Compiling G4TwistBoxSide.cc ... Compiling G4TwistedBox.cc ... Compiling G4TwistedTrap.cc ... Compiling G4TwistedTrd.cc ... Compiling G4TwistedTubs.cc ... Compiling G4TwistTrapAlphaSide.cc ... Compiling G4TwistTrapFlatSide.cc ... Compiling G4TwistTrapParallelSide.cc ... Compiling G4TwistTubsFlatSide.cc ... Compiling G4TwistTubsHypeSide.cc ... Compiling G4TwistTubsSide.cc ... Compiling G4VCSGfaceted.cc ... Compiling G4VFacet.cc ... Compiling G4VTwistedFaceted.cc ... Compiling G4VTwistSurface.cc ... Creating shared library /home/nuria/Desktop/Geant4/geant4.9.4/lib/Linux-g++/libG4specsolids.so ... Then, I have compiled again my program, and I executed it, and unfortunately I get the same: WARNING - G4Navigator::ComputeStep() Track stuck, not moving for 10 steps in volume -MLCPosLeaf_phys6- at point (-44.8557,40,75.6615) direction: (-0.715295,0.629635,-0.303171). Potential geometry or navigation problem ! Trying pushing it of 1e-07 mm ... WARNING - G4Navigator::ComputeStep() Track stuck, not moving for 10 steps in volume -MLCPosLeaf_phys12- at point (-21.5761,40,42.3328) direction: (-0.265895,0.658614,-0.703937). Potential geometry or navigation problem ! Trying pushing it of 1e-07 mm ... WARNING - G4Navigator::ComputeStep() Track stuck, not moving for 10 steps in volume -MLCPosLeaf_phys8- at point (-36.0721,40,31.3654) direction: (-0.297352,0.758968,-0.579266). Potential geometry or navigation problem ! Trying pushing it of 1e-07 mm ... Than you very much for your dedication, regards, Nuria
This is strange, as on my side all these warnings disappeared after this fix. Could you, please, check the following 1. In order to be sure that you really run with the updated library, add a following line in source/geometry/solids/specific/src/G4ExtrudedSolid.cc after these lines: EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const { // Override the base class function as it fails in case of concave polygon. // Project the point in the original polygon scale and check if it is inside // for each triangle. G4cout << "Calling G4ExtrudedSolid::Inside" << G4endl; // ADD and also check, that there is a line if ( IsSameLineSegment(pscaled, fPolygon[i], fPolygon[j]) ) and not if ( IsSameLine(pscaled, fPolygon[i], fPolygon[j]) ) After adding this line, recompile your code and rerun your application. You should see lot's of messages above. 2. If your update with the fix was ok (you see the added messages) and the warning are still present; then change the line added before and add one more line here: EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const { // Override the base class function as it fails in case of concave polygon. // Project the point in the original polygon scale and check if it is inside // for each triangle. G4cout << "Calling G4TessellatedSolid::Inside" << G4endl; return G4TessellatedSolid::Inside(p); // ADD Let me know the result. Thanks
Dear Ivana, I have not seen the added messages... I have done make only in my_path/geant4/source/geometry/solids/specific Should I compile again the entire Geant4 Simulation? Thank you in advance, Nuria
No, it should be sufficient just to recompile in geometry/solids/specific directory. The checks which I proposed in my previous comments are to be sure that you really use the recompiled code in your application. And the second test will activate an alternative method in G4ExtrudedSolid which can also fix the problem. So, please, try the two steps above and let me know what happens. Thank you,
Hello, The problem is that I have recompile geometry/solids/specific but my application does not use this recompiled code, that is why I do not see the added messages. The line: if ( IsSameLineSegment(pscaled, fPolygon[i], fPolygon[j]) ) is in the code. What can I do in order that my code use the recompiled code? Thank you in advance, Nuria (In reply to comment #9) > No, it should be sufficient just to recompile in geometry/solids/specific > directory. The checks which I proposed in my previous comments are to be sure > that you really use the recompiled code in your application. > And the second test will activate an alternative method in G4ExtrudedSolid > which can also fix the problem. So, please, try the two steps above and let me > know what happens. > > Thank you,
Then I will need to know more about the options which you use to build Geant4. If you install Geant4 in a different directory than where you build it you may need to run again: ./Configure -install Also if you do not use shared libraries, you need to recompile your application. If you use shared libraries and have more than one Geant4 installations on your machine, you should check that you have the right path in LD_LIBRARY_PATH. If the above tips do not help, let me know what building procedure you use and also your Geant4 environment script setup generated by Configure. Best regards, Ivana
Hello Ivana, I have compiled Geant4 installation, so: make clean ./Configure -build ./Configure -install and now it works! I do not get more warning Messages! Thank you very much Nuria
That's good news. The fix is now included in Geant4 development version and will be available in the next patch to the release. Best regards,
(In reply to comment #13) > That's good news. The fix is now included in Geant4 development version and > will be available in the next patch to the release. > > Best regards, Hello Ivana, I have some bad news...when I use a big number of events than I get again the same warning. Now it is very low statistic, for example, if I do run/beamOn 100000 I get only one warning. I have added the line return G4TessellatedSolid::Inside(p); // ADD in the G4Extrudesolid.cc like you told me in comment 7 and then recompiled Geant4 and then I have not any warning. Is it Ok if I leave this line in the code? Than you in advance, Nuria