nOfCollision in a realWorldLogVol yields SegFault

I struggle with the nOfCollision scorer attached to a realWorldLogVol, reproducibly giving me a SegFault:

Thread 2 "XYZ" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff4741700 (LWP 396225)]
0x00007ffff5819297 in G4TouchableHistory::GetReplicaNumber(int) const () from /.../geant4_10_07_p03/geant4_10_07_p03-install/lib/

Same with version 11.0.0.


/score/create/realWorldLogVol sensorchip
/score/quantity/volumeFlux volumeFlux
/score/filter/particle gammaFilter gamma
/score/quantity/nOfCollision nOfCollision
/score/filter/particle gammaFilter gamma

Detector construction:

    G4Box* sensor = new G4Box( "sensorchip", (pixelSize * Nx) / 2.0, (pixelSize * Ny) / 2.0, pixelThickness/ 2.0);
    G4LogicalVolume* sensorLV = new G4LogicalVolume(sensor, Silizium, sensor->GetName());
    new G4PVPlacement( sensorRotation1, sensorPosition1, sensorLV, sensor->GetName(), fWorldVolume, false, 0, checkOverlap);
    new G4PVPlacement( sensorRotation2, sensorPosition2, sensorLV, sensor->GetName(), fWorldVolume, false, 1, checkOverlap);

Commenting out the #/score/quantity/nOfCollision nOfCollision makes it run just fine.

Any ideas what I do wrong here? i think realWorldLogVols should work in principle: geant4/ at geant4-11.0-release · Geant4/geant4 · GitHub

Seems to be independent of G4RunManagerType::MT or G4RunManagerType::SerialOnly
The code descends into


where it crashes because of G4int i = touchable->GetReplicaNumber(fDepthi);.

Since it is only one volume, and not a 3D mesh, isn’t G4PSNofCollision3D the wrong place to go for the index?

Comparing source/digits_hits/utils/src/

      if(shape == MeshShape::realWorldLogVol || shape == MeshShape::probe)
        ps = new G4PSNofCollision3D(token[0], mesh->GetCopyNumberLevel());
        ps = new G4PSNofCollision3D(token[0]);


      G4PSPopulation* ps = nullptr;
      if(shape == MeshShape::realWorldLogVol || shape == MeshShape::probe)
        ps = new G4PSPopulation(token[0], mesh->GetCopyNumberLevel());
        ps = new G4PSPopulation3D(token[0]);

→ line 637 must read ps = new G4PSNofCollision(token[0], mesh->GetCopyNumberLevel()); without the 3D.

just tested, works like a charm :slight_smile:

edit: bug report :white_check_mark:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.