Problem 216

Summary: infinite loop while tracking e-
Product: Geant4 Reporter: V.Hejny
Component: geometry/solidsAssignee: Vladimir.Grichine
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: other   
Hardware: PC   
OS: Linux   

Description V.Hejny 2001-02-04 01:10:26 CET
While simulating the response of a 5x5 PWO Matrix Geant (4.3.0) enters an
infinite loop when tracking e- (so far only seen with these particles)
with a somewhat lower energy (within the first 1000 events). The 25 modules
are made of segments of G4Sphere. When changing to G4Box the problem
disappears (>100000 events). The physics list used is from ExN04.

The verbose tracking output is:
*********************************************************************************************************
* G4Track Information:   Particle = gamma,   Track ID = 21,   Parent ID = 3
*********************************************************************************************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng
NextVolume ProcName
    0 1.43e+03   -0.763    -4.05      16.8        0        0         0
PD_physical           initStep
    1 1.46e+03     1.66    -10.2      16.8        0     36.7      36.7
expHall           Transportation
    2 1.47e+03     1.86    -10.7      16.8        0     3.03      39.8
PD_physical           Transportation
    3 1.55e+03      7.4    -24.9         0        0       84       124
PD_physical           conv
    :----- List of 2ndaries - #SpawnInStep=  2(Rest= 0,Along= 0,Post= 2),
#SpawnTotal=  2 ---------------
    :  1.55e+03       7.4     -24.9      4.54 e-
    :  1.55e+03       7.4     -24.9      11.2 e+
    :-----------------------------------------------------------------
EndOf2ndaries Info ---------------
[...]

*********************************************************************************************************
* G4Track Information:   Particle = e-,   Track ID = 37,   Parent ID = 21
*********************************************************************************************************

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng
NextVolume ProcName
    0 1.55e+03      7.4    -24.9      4.54        0        0         0
PD_physical           initStep
    1 1.55e+03     7.45      -25      3.63    0.916     0.99      0.99
PD_physical           Transportation
    2 1.55e+03     7.45      -25      3.63        0        0      0.99
PD_physical           Transportation
    3 1.55e+03     7.45      -25      3.63        0        0      0.99
PD_physical           Transportation
    4 1.55e+03     7.45      -25      3.63        0        0      0.99
PD_physical           Transportation
and so on ...

It seems that the particle is on the surface of a volume. I've read that
there is a problem report on BREPSolids, but as far as I see G4Sphere
is no BREP.

The detector is constructed like this:

  G4double dAngleC = 2.05/140 * radian;
  G4double dAngleS = 0.05/140 * radian;
  G4double dAngleAll = dAngleC + dAngleS;

  for (G4int i=0; i<5; i++) {
    for (G4int j=0; j<5; j++) {

      digit1 = G4int((5.*i+j+1)/10.);
      digit2 = (5*i+j+1) - digit1*10;
      crystal_name = "PD"+G4String(char('0'+digit1))+G4String(char('0'+digit2));

      G4double phiS   = -3.*dAngleS-2.5*dAngleC+i*dAngleAll;
      if (phiS<0) phiS += 2.*M_PI;
      G4double thetaS = M_PI/2.-3.*dAngleS-2.5*dAngleC+j*dAngleAll;

      G4Sphere *s1 = new G4Sphere("PWOPart1",
				  140*cm, 	// inner radius
				  155*cm, 	// outer radius
				  phiS, 	// start phi
				  dAngleC,	// delta phi
				  thetaS, 	// start theta
				  dAngleC       // delta theta
				);

      PD_log_crystal
	= new G4LogicalVolume(s1,PWO,crystal_name);

      sprintf(text,"/mydet/ring%02d",5*i+j+1);
      PWOSD* pdsd = new PWOSD(G4String(text),1);
      SDMan->AddNewDetector(pdsd);
      PD_log_crystal->SetSensitiveDetector(pdsd);

      G4VisAttributes *pd_att = new G4VisAttributes(G4Color(0,1,1)); // magenta
      PD_log_crystal->SetVisAttributes(pd_att);

      PD_physical =
	new G4PVPlacement(0,G4ThreeVector(0,0,0),
			  "PD_physical", PD_log_crystal,
			  experimentalHall_phys,false,0);

    }
  }

The code with G4Box that worked is this:

  G4double dlC = 2.05*cm;
  G4double dlS = 0.05*cm;
  G4double dlAll = dlS + dlC;

  for (G4int i=0; i<5; i++) {
    for (G4int j=0; j<5; j++) {

      digit1 = G4int((5.*i+j+1)/10.);
      digit2 = (5*i+j+1) - digit1*10;
      crystal_name = "PD"+G4String(char('0'+digit1))+G4String(char('0'+digit2));

      G4Box *s1 = new G4Box("PWOPart1",7.5*cm, 1.025*cm, 1.025*cm);

      PD_log_crystal
	= new G4LogicalVolume(s1,PWO,crystal_name);

      sprintf(text,"/mydet/ring%02d",5*i+j+1);
      PWOSD* pdsd = new PWOSD(G4String(text),1);
      SDMan->AddNewDetector(pdsd);
      PD_log_crystal->SetSensitiveDetector(pdsd);

      G4VisAttributes *pd_att = new G4VisAttributes(G4Color(0,1,1)); // magenta
      PD_log_crystal->SetVisAttributes(pd_att);

      PD_physical =
	new G4PVPlacement(0,
			  G4ThreeVector(147.5*cm,(i-2)*dlAll,(j-2)*dlAll),
			  "PD_physical", PD_log_crystal,
			  experimentalHall_phys,false,0);

    }
  }

I observed the same with version 4.2!
Comment 1 Vladimir.Grichine 2002-01-30 08:58:59 CET
Bug was fixed in G4Sphere::Inside. It was responsible for the problem