Segmentation fault with G4LivermorePhotoElectricModel

Hello,
I got a segmentation fault while using G4LivermorePhotoElectricModel::CrossSectionPerVolume in a code like :

G4LivermorePhotoElectricModel* CrossSectionHandlerPhoto = new G4LivermorePhotoElectricModel;
// Get the G4ParticleTable
  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();

  // Get the G4ParticleDefinition for a photon
 G4ParticleDefinition* gamma = particleTable->FindParticle("gamma");
 const G4MaterialTable* Table = G4Material::GetMaterialTable();
 double E = 1.;

for (unsigned int mat = 0; mat < Table->size(); ++mat) {
    const G4Material* M = Table->at(mat);
   CrossSectionHandlerPhoto->CrossSectionPerVolume(M, gamma,E);    
 }

the debug with gdb told me that the segmentation fault is coming from G4ElementData::InitialiseForComponent but I have no idea how it happend. The seg fault is here for whatever materials.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff45ac48f in G4ElementData::InitialiseForComponent(int, int) ()
   from /geant4-v11.1.0-install/lib/libG4materials.so
(gdb) bt
#0  0x00007ffff45ac48f in G4ElementData::InitialiseForComponent(int, int) ()
   from /geant4-v11.1.0-install/lib/libG4materials.so
#1  0x00007ffff52c4b3f in G4LivermorePhotoElectricModel::ReadData(int) ()
   from /geant4-v11.1.0-install/lib/libG4processes.so
#2  0x00007ffff52c717f in G4LivermorePhotoElectricModel::ComputeCrossSectionPerAtom(G4ParticleDefinition const*, double, double, double, double, double) ()
   from /geant4-v11.1.0-install/lib/libG4processes.so
#3  0x00007ffff54cf472 in G4VEmModel::CrossSectionPerVolume(G4Material const*, G4ParticleDefinition const*, double, double, double) ()
   from /geant4-v11.1.0-install/lib/libG4processes.so
#4  0x00007ffff52c73a8 in G4LivermorePhotoElectricModel::CrossSectionPerVolume(G4Material const*, G4ParticleDefinition const*, double, double, double) ()

Ok I have found the solution. G4LivermorePhotoElectricModel need to be initialise otherwise you get a segmentation fault.

G4DataVector Data;
CrossSectionHandlerPhoto->Initialise(gamma,Data);
1 Like

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