Message: G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface() Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface() 

Forum: Run Management
Date: 16 Mar, 2018
From: Stefan E. Mueller <Stefan E. Mueller>

Dear all,

I am just debugging a Geant4 application of a colleague of mine in which we get warnings like this:

Checking overlaps for volume Tripple Cluster Casing ... 
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
      issued by : G4PVPlacement::CheckOverlaps()
Overlap with mother volume !
          Overlap is detected for volume Tripple Cluster Casing
          with its mother volume World
          at mother local point (-1.02845e+07,2.51897e-09,-2.91064e+08), overlapping by at least: 291.061 km 
NOTE: Reached maximum fixed number -1- of overlaps reports for this volume !
*** This is just a warning message. ***

I tracked this done to the call to G4Cons::GetPointOnSurface() in source/geometry/solids/CSG/src/G4Cons.cc, coming from G4PVPlacement::CheckOverlaps(...). 

The volume "Tripple Cluster Casing" is a simple cylinder with r=115mm and z=706mm, but apparently since it is imported from a GDML-file it is defined as 
a cone.

Now what I found is that the line 2166 in G4Cons.cc

chose  = G4RandFlat::shoot(0.,Aone+Atwo+Athree+Afour+2.*Afive); 

sometimes yields (very large) negative numbers for the variable "chose", which is not what I'd naively expect from this call to G4RandFlat::shoot.

In the next lines, the several cases for the different surfaces of the cone on which the point should sit are sampled via 

if( (chose >= 0.) && (chose < Aone) )
  {
...
} 
  else if( (chose >= Aone) && (chose <= Aone + Atwo) )
  {
...
}
 (more cases probed, but always "chose" > 0.)
...
  else
  { 
    zRand  = G4RandFlat::shoot(-1.*fDz,fDz);
    rRand1 = G4RandFlat::shoot(fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2),
                               fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2)); 
    return G4ThreeVector (rRand1*std::cos(fSPhi+fDPhi),
                          rRand1*std::sin(fSPhi+fDPhi), zRand);
  }

So indeed if "chose" is negative, one ends up with this last "else"-case, in which (again) G4RandFlat::shoot(..) gives very negative numbers for zRand and rRand1:

(gdb) p zRand
$44 = -291063511.72417974
(gdb) p rRand1
$45 = -10284491.597954744

and consequently the "surface"-point which is returned back to G4PVPlacement::CheckOverlaps(..) has coordinates which are far off the geometry:

(gdb) p point
$46 = {dx = -10284491.597954744, dy = 2.5189739432586253e-09, 
  dz = -291063511.72417974, static tolerance = 2.22045e-14}

And this triggers the above warning.

I tried to find out what G4RandFlat::shoot(..) is supposed to do and what it means if it returns a negative value from a positive interval, but was not succesful. Maybe somebody could shed some light on this problem?

I am using geant4.10.04p01 with gcc 7.2.0, compiled in "debug" mode and with multithreading support enabled (but never used...). System is Debian 4.14.13-1 (2018-01-14) x86_64 GNU/Linux (problem was also seen with on other machines with geant4.10.04).

Random number engine is initialized like this:

        //choose the Random engine
        CLHEP::HepRandom::setTheEngine(new CLHEP::Ranlux64Engine);
        // get new randomseed at every start
        time_t systime = time(NULL);
        CLHEP::HepRandom::setTheSeed(systime);

Is this a legitimate way to do this? Maybe that is where the problem comes from?

Cheers,

Stefan

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface()   (Asai, Makoto - 16 Mar, 2018)
1 None: Re: G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface()   (Gabriele Cosmo - 16 Mar, 2018)
2 Ok: Re: G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface()   (Stefan E. Mueller - 22 Mar, 2018)
 Add Message Add Message
to: "G4RandFlat::shoot(0,..) gives negative number in G4Cons::GetPointOnSurface()"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]