diff --git a/examples/Example1/example1.cpp b/examples/Example1/example1.cpp index 469eee83b..8607d9d4b 100644 --- a/examples/Example1/example1.cpp +++ b/examples/Example1/example1.cpp @@ -48,7 +48,7 @@ int main(int argc, char **argv) } // Initialization of default Run manager - auto *runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); + std::unique_ptr runManager(G4RunManagerFactory::CreateRunManager()); // auto *runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Serial); // Detector geometry: @@ -84,7 +84,5 @@ int main(int argc, char **argv) // owned and deleted by the run manager, so they should not // be deleted in the main() program ! - delete runManager; - return err; } diff --git a/examples/common/src/FTFP_BERT_AdePT.cc b/examples/common/src/FTFP_BERT_AdePT.cc index 13b2ca82c..b5d702b77 100644 --- a/examples/common/src/FTFP_BERT_AdePT.cc +++ b/examples/common/src/FTFP_BERT_AdePT.cc @@ -39,7 +39,7 @@ FTFP_BERT_AdePT::FTFP_BERT_AdePT(G4int ver) // Register the EM physics to use for tracking on CPU // RegisterPhysics(new G4EmStandardPhysics()); - RegisterPhysics(new HepEMPhysics()); + RegisterPhysics(new HepEMPhysics(ver)); // Register the AdePT physics RegisterPhysics(new AdePTPhysics()); diff --git a/examples/common/src/FTFP_BERT_HepEm.cc b/examples/common/src/FTFP_BERT_HepEm.cc index f00f016d8..53dc99508 100644 --- a/examples/common/src/FTFP_BERT_HepEm.cc +++ b/examples/common/src/FTFP_BERT_HepEm.cc @@ -36,7 +36,7 @@ FTFP_BERT_HepEm::FTFP_BERT_HepEm(G4int ver) // EM Physics // RegisterPhysics( new G4EmStandardPhysics(ver)); - RegisterPhysics(new HepEMPhysics()); + RegisterPhysics(new HepEMPhysics(ver)); // Synchroton Radiation & GN Physics // comenting out to remove gamma- and lepto-nuclear processes diff --git a/include/AdePT/integration/HepEMPhysics.hh b/include/AdePT/integration/HepEMPhysics.hh index 0163c6549..1960e8074 100644 --- a/include/AdePT/integration/HepEMPhysics.hh +++ b/include/AdePT/integration/HepEMPhysics.hh @@ -4,12 +4,14 @@ #ifndef HepEMPhysics_h #define HepEMPhysics_h 1 -#include "G4VPhysicsConstructor.hh" +// #include "G4VPhysicsConstructor.hh" +#include "G4EmStandardPhysics.hh" #include "globals.hh" -class HepEMPhysics : public G4VPhysicsConstructor { +// class HepEMPhysics : public G4VPhysicsConstructor { +class HepEMPhysics : public G4EmStandardPhysics { public: - HepEMPhysics(const G4String &name = "G4HepEm-physics-list"); + HepEMPhysics(int ver, const G4String &name = "G4HepEm-physics-list"); ~HepEMPhysics(); public: diff --git a/src/HepEMPhysics.cc b/src/HepEMPhysics.cc index 10ee3a1fd..5d3e77809 100644 --- a/src/HepEMPhysics.cc +++ b/src/HepEMPhysics.cc @@ -5,6 +5,7 @@ // include the G4HepEmProcess from the G4HepEm lib. #include "G4HepEmProcess.hh" +#include "G4HepEmTrackingManager.hh" #include "G4ParticleDefinition.hh" #include "G4ProcessManager.hh" @@ -42,7 +43,8 @@ #include "G4ionIonisation.hh" #include "G4NuclearStopping.hh" -HepEMPhysics::HepEMPhysics(const G4String &name) : G4VPhysicsConstructor(name) +HepEMPhysics::HepEMPhysics(int ver, const G4String &name) : G4EmStandardPhysics(ver, name) +// HepEMPhysics::HepEMPhysics(int ver, const G4String &name) : G4VPhysicsConstructor(name) { G4EmParameters *param = G4EmParameters::Instance(); param->SetDefaults(); @@ -50,7 +52,6 @@ HepEMPhysics::HepEMPhysics(const G4String &name) : G4VPhysicsConstructor(name) // Range factor: (can be set from the G4 macro) param->SetMscRangeFactor(0.04); - // SetPhysicsType(bElectromagnetic); } @@ -59,71 +60,80 @@ HepEMPhysics::~HepEMPhysics() {} void HepEMPhysics::ConstructProcess() { + G4EmStandardPhysics::ConstructProcess(); + + // Register custom tracking manager for e-/e+ and gammas. + auto *trackingManager = new G4HepEmTrackingManager(); + G4Electron::Definition()->SetTrackingManager(trackingManager); + G4Positron::Definition()->SetTrackingManager(trackingManager); + G4Gamma::Definition()->SetTrackingManager(trackingManager); - G4PhysicsListHelper *ph = G4PhysicsListHelper::GetPhysicsListHelper(); + // // Integration trough G4 process: - // from G4EmStandardPhysics - G4EmBuilder::PrepareEMPhysics(); + // G4PhysicsListHelper *ph = G4PhysicsListHelper::GetPhysicsListHelper(); - G4EmParameters *param = G4EmParameters::Instance(); + // // from G4EmStandardPhysics + // G4EmBuilder::PrepareEMPhysics(); + + // G4EmParameters *param = G4EmParameters::Instance(); - // processes used by several particles - G4hMultipleScattering *hmsc = new G4hMultipleScattering("ionmsc"); + // // processes used by several particles + // G4hMultipleScattering *hmsc = new G4hMultipleScattering("ionmsc"); - // nuclear stopping is enabled if th eenergy limit above zero - G4double nielEnergyLimit = param->MaxNIELEnergy(); - G4NuclearStopping *pnuc = nullptr; - if (nielEnergyLimit > 0.0) { - pnuc = new G4NuclearStopping(); - pnuc->SetMaxKinEnergy(nielEnergyLimit); - } - // end of G4EmStandardPhysics + // // nuclear stopping is enabled if th eenergy limit above zero + // G4double nielEnergyLimit = param->MaxNIELEnergy(); + // G4NuclearStopping *pnuc = nullptr; + // if (nielEnergyLimit > 0.0) { + // pnuc = new G4NuclearStopping(); + // pnuc->SetMaxKinEnergy(nielEnergyLimit); + // } + // // end of G4EmStandardPhysics - // creae the only one G4HepEm process that will be assigned to e-/e+ and gamma - G4HepEmProcess *hepEmProcess = new G4HepEmProcess(); + // // creae the only one G4HepEm process that will be assigned to e-/e+ and gamma + // G4HepEmProcess *hepEmProcess = new G4HepEmProcess(); - // Add standard EM Processes - // - auto aParticleIterator = GetParticleIterator(); - aParticleIterator->reset(); - while ((*aParticleIterator)()) { - G4ParticleDefinition *particle = aParticleIterator->value(); - G4String particleName = particle->GetParticleName(); + // // Add standard EM Processes + // // + // auto aParticleIterator = GetParticleIterator(); + // aParticleIterator->reset(); + // while ((*aParticleIterator)()) { + // G4ParticleDefinition *particle = aParticleIterator->value(); + // G4String particleName = particle->GetParticleName(); - if (particleName == "gamma") { + // if (particleName == "gamma") { - // Add G4HepEm process to gamma: includes Conversion, Compton and photoelectric effect. - particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); + // // Add G4HepEm process to gamma: includes Conversion, Compton and photoelectric effect. + // particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); - } else if (particleName == "e-") { + // } else if (particleName == "e-") { - // Add G4HepEm process to e-: includes Ionisation and Bremsstrahlung for e- - particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); + // // Add G4HepEm process to e-: includes Ionisation and Bremsstrahlung for e- + // particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); - } else if (particleName == "e+") { + // } else if (particleName == "e+") { - // Add G4HepEm process to e+: includes Ionisation, Bremsstrahlung and e+e- - // annihilation into 2 gamma interactions for e+ - particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); - } - } + // // Add G4HepEm process to e+: includes Ionisation, Bremsstrahlung and e+e- + // // annihilation into 2 gamma interactions for e+ + // particle->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1); + // } + // } - // from G4EmStandardPhysics + // // from G4EmStandardPhysics - // generic ion - G4ParticleDefinition *particle = G4GenericIon::GenericIon(); - G4ionIonisation *ionIoni = new G4ionIonisation(); - ph->RegisterProcess(hmsc, particle); - ph->RegisterProcess(ionIoni, particle); - if (nullptr != pnuc) { - ph->RegisterProcess(pnuc, particle); - } + // // generic ion + // G4ParticleDefinition *particle = G4GenericIon::GenericIon(); + // G4ionIonisation *ionIoni = new G4ionIonisation(); + // ph->RegisterProcess(hmsc, particle); + // ph->RegisterProcess(ionIoni, particle); + // if (nullptr != pnuc) { + // ph->RegisterProcess(pnuc, particle); + // } - // muons, hadrons ions - G4EmBuilder::ConstructCharged(hmsc, pnuc); + // // muons, hadrons ions + // G4EmBuilder::ConstructCharged(hmsc, pnuc); - // extra configuration - G4EmModelActivator mact(GetPhysicsName()); + // // extra configuration + // G4EmModelActivator mact(GetPhysicsName()); - // end of G4EmStandardPhysics + // // end of G4EmStandardPhysics }