Problem 1462

Summary: geometry (false?) overlap with polycone and gdml parser issue
Product: Geant4 Reporter: Anselmo <anselmo.meregaglia>
Component: geometry/solidsAssignee: tatiana.nikitina
Status: RESOLVED FIXED    
Severity: normal    
Priority: P5    
Version: 9.5   
Hardware: All   
OS: All   
Attachments: Fix in GetPointOnSurface for G4Polycone

Description Anselmo 2013-03-25 18:25:24 CET
Dear all,

I use g4polycones and I have two different issues.

-If I use the constructor that uses vertex as input my geometry is fine (no overlaps) but when I export it into GDML with G4GDMLParser I get an issue since it does not understand that I used that specific G4polycone constructor and it looks for minimum radius and maximum radius taking of course wrong values.

-If I use the constructor that uses the minimum and maximum radius for the G4Polycon definition the exported geometry in GDML is fine. However there is an overlap warning in geant when this is checked.
I have tested all I could and I could not observe (neither graphically nor using output of geantino steps) the overlap at all.

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
     issued by : G4PVPlacement::CheckOverlaps()
Overlap with mother volume !
         Overlap is detected for volume GaseousArgon
         with its mother volume InnerCryostat_Logic
         at mother local point (-174.791,160.267,558.047), overlapping by at least: 688.304 um 
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

I give you here below the two polycones I used so that you could include them in a simple code and see if you observe the same error.

Thank you very much in advance for any help.
Best regards,

    Anselmo Meregaglia


 const double myTwoPi = 2*M_PI; 
 G4double crrmin[25]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 G4double crR[25]={0,44.81,83.625,109.215,136.94,162.58,208.37,232.09,246.24,256,256,261.359,267,292,292,267,256.5,256.5,251.07,240.585,207.19,147.485,84.26,33.365,0};
 G4double crZ[25]={626,624,619,614,607,599,581.35,564,544,505.72,483,478.5,476.5,476.5,450.5,450,443.5,-237.82,-266,-286,-313.46,-336,-351,-357,-358.11};

 G4Polycone *fSolidInnerCryostat  = new G4Polycone( "InnerCryostat_Solid", 0, myTwoPi, 25 ,crZ,crrmin,crR );
 fLogicInnerCryostat  = new G4LogicalVolume( fSolidInnerCryostat, stainlessMat, "InnerCryostat_Logic" );
 fPhysicInnerCryostat = new G4PVPlacement( 0, G4ThreeVector(), fLogicInnerCryostat, "InnerCryostat", 0 , false, 0);

G4double rmingas[10]={0,0,0,0,0,0,0,0,0,0};
G4double gasArR[10]={0,86.61,163.17,202.39,212.425,226.04,241.85,251.77,251.97,251.97};
G4double gasArZ[10]={621.41,614,594,578.61,574,564,544,505.72,505.7,444};

G4Polycone *fSolidGasArgon  = new G4Polycone( "GaseousArgon_Solid", 0, myTwoPi, 10, gasArZ, rmingas,gasArR  );
fLogicGasArgon  = new G4LogicalVolume( fSolidGasArgon, Scintillator, "GaseousArgon_Logic" );
fPhysicGasArgon = new G4PVPlacement( 0, G4ThreeVector(),  fLogicGasArgon,"GaseousArgon", fLogicInnerCryostat, false, 0, true );
Comment 1 Anselmo 2013-03-26 11:50:23 CET
Dear Tatiana,

I am writing to you since I saw you are in charge of the bug 1462 I reported.

As far as my problem with GDML is concerned I noticed something weird concerning the function
SetOriginalParameters used by G4Polycone when the vertex are given.

If I set a polycone with the following vertexes


0 z 444 r 0
1 z 444 r 251.97
2 z -237.82 r 251.97
3 z -276 r 241.89
4 z -310.72 r 202.37
5 z -336 r 131.27
6 z -351 r 53.13
7 z -353.52 r 0

I get as output of the G4PoliconeHistorical

0 z -276 rmin 202.37 rmax 241.89
1 z -237.82 rmin 131.27 rmax 251.97
2 z 444 rmin 53.13 rmax 251.97
3 z 444 rmin 0 rmax 0

therefore less planes and Rmin which is not always zero as it should be.

I am not sure if I am misunderstanding something but this is clearly not the same solid and if I am correct the SetOriginalParameter function has to be modified.
I changed it in my case (with a small hack to avoid two planes at the same Z) and now my geometry exports correctly in GDML!
What do you think?

The issue of overlapping is however still not clear to me though.

Best regards,

	Anselmo
Comment 2 tatiana.nikitina 2013-03-26 22:53:16 CET
Dear Anselmo,
Thank you for reporting this problem and for your help.
By investigating I found that false overlap in CheckOverlaps() is coming from an error in G4Polycone in GetPointOnSurface().
I'm working on the fix for this method.

About the issue with the constructor by vertexes, could you give more details about changes you made to make it work?

Thank you in advance,
Best Regards,
Tatiana.
Comment 3 Anselmo 2013-03-27 10:26:16 CET
Dear Tatiana,
thanks for your answer.

For the gdml conversion of the polycones constructed using the vertexes I think the issue is in the SetOriginalParameters() function which fills the G4PolyconeHistorical  which is never used if I am correct but in the GDML parser.

If I understood it correctly (this is at least my case) the constructor with the vertexes should always have Rmin set to zero and Rmax should be the Radius of the vertex. The only problem is that in the vertex constructor you can have two Rvertex at the same Z which is not allowed in the other one and which would fail in the GDML parser.
I fixed this in a "dirty way" (this is anyway only for visualization and the geometry for the physics simulation is still correct) shifting the Z coordinate in this case by a tiny amount (1e-5mm) and it works for me.

I give you the code I put directly in the G4Polycone.cc but which should eventually go replacing the inline definition of SetOriginalParameters() in G4Polycone.icc.
I guess you will do something better and cleaner at the end but at least you know where it has to be fixed.

Best regards,

    Anselmo


//
// Constructor (generic parameters)
//
G4Polycone::G4Polycone( const G4String& name, 
                              G4double phiStart,
                              G4double phiTotal,
                              G4int    numRZ,
                        const G4double r[],
                        const G4double z[]   )
  : G4VCSGfaceted( name ), genericPcon(true)
{
  G4ReduciblePolygon *rz = new G4ReduciblePolygon( r, z, numRZ );
  
  Create( phiStart, phiTotal, rz );
  
  // Set original_parameters struct for consistency
  //
  //wrong function!!!
  //SetOriginalParameters(); //wrong, replaced
  //Hacked by hand
  original_parameters = new G4PolyconeHistorical();
  
  original_parameters->Start_angle = phiStart;
  original_parameters->Opening_angle = phiTotal;
  original_parameters->Num_z_planes = numRZ;
  original_parameters->Z_values = new G4double[numRZ];
  original_parameters->Rmin = new G4double[numRZ];
  original_parameters->Rmax = new G4double[numRZ];

  G4double prevZ(0);
  G4int nflat(0);
  G4int direction(0);

  if(z[numRZ]>z[0])
    direction=1;
  else
    direction=-1;

  for(int ii=0;ii<numRZ;ii++)
    {
      if(ii==0)
	{
	  original_parameters->Z_values[ii] = z[ii];
	  original_parameters->Rmin[ii] = 0;
	  original_parameters->Rmax[ii] = r[ii];
	  prevZ=z[ii];
	}
      else
	{
	  if(z[ii]!=prevZ)
	    {
	      original_parameters->Z_values[ii] = z[ii];
	      original_parameters->Rmin[ii] = 0;
	      original_parameters->Rmax[ii] = r[ii];
	      prevZ=z[ii];
	      nflat=0;
	    }
	  else
	    {
	      original_parameters->Z_values[ii] = z[ii]+(direction)*1e-5*(nflat+1);
	      original_parameters->Rmin[ii] = 0;
	      original_parameters->Rmax[ii] = r[ii];
	      prevZ=z[ii];
	      nflat++;
	    }
	}

    }

  delete rz;
}
Comment 4 tatiana.nikitina 2013-03-27 11:59:44 CET
Dear Anselmo,
Thank you very much for your help.
Method SetOriginalParameters() fails when G4Polycone has vertexes with the same Z, it will be repaired.

Best Regards,
Tatiana.
Comment 5 tatiana.nikitina 2013-04-23 15:23:56 CEST
Created attachment 213 [details]
Fix in GetPointOnSurface for G4Polycone
Comment 6 tatiana.nikitina 2013-04-23 15:26:44 CEST
Dear Aselmo,

First problem with false overlap is fixed.
You can find corrected file G4Polycone.cc in the attachment.
Work on second problem with SetOriginalParameters() is in progress.

Best Regards,
Tatiana.
Comment 7 tatiana.nikitina 2013-07-29 10:14:36 CEST
Dear Anselmo,

The second problem for SetOriginalParameters() is fixed.
In case on constructor of G4Polycone by vertices, algorithm convert this Polycone to G4Polycone with planes(Rmin,Rmax and Z), when it possible. If conversion is not possible, algorithm detects this. 
Fix will be available in next geant4 release.

I'm still working on GDML in order to be able to export both types of G4Polycones(using both constructors).

Best Regards,
Tatiana Nikitina.
Comment 8 tatiana.nikitina 2013-09-12 10:57:29 CEST
Dear Anselmo,

GenericPolycone and GenericPolyhedra are added to GDML and will be in the next Geant4 release.
Thank you for reporting this problem and  for all your help.

Best Regards,
Tatiana.