27 #include "G4ParticleTable.hh"
28 #include "G4ParticleDefinition.hh"
29 #include "G4SystemOfUnits.hh"
30 #include "G4PhysicalConstants.hh"
31 #include "G4Version.hh"
39 #include "G4RunManager.hh"
41 using namespace DD4hep::Simulation;
65 G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
66 std::ifstream pdgFile(
m_pdgfile.c_str(), std::ifstream::in );
68 if (!pdgFile.is_open()) {
75 while ( !pdgFile.eof() ) {
78 getline( pdgFile, linebuf );
81 if (linebuf.substr(0,1) ==
"#")
continue;
82 if (linebuf.substr(0,2) ==
"//")
continue;
85 if (linebuf.empty())
continue;
95 std::istringstream istr(linebuf);
97 istr >> pdg >> nam >> charge >> mass >> width >> lifetime;
102 if(width<0) width = 0;
115 if (width == 0 && lifetime > 0) {
120 G4ParticleDefinition* p = theParticleTable->FindParticle(pdg);
123 if (abs(pdg)>80 && abs(pdg)<=100) {
133 p =
new G4ParticleDefinition(
156 G4cout <<
"Loaded extra particles using file: " <<
m_pdgfile << G4endl;
160 G4ParticleTable::G4PTblDicIterator* ParticleIterator = ctor.particleIterator();
161 #if G4VERSION_NUMBER < 940
162 if ( 0 == _scatter ) _scatter=
new G4hMultipleScattering();
163 if ( 0 == _ionise ) _ionise=
new G4hIonisation()
164 if ( 0 == _decay ) _decay=new G4Decay()
166 while((*ParticleIterator)()) {
167 G4ParticleDefinition* pdef = ParticleIterator->value();
168 G4ProcessManager* pmgr = pdef->GetProcessManager();
169 if (pdef->GetParticleType() ==
"extra") {
170 if (pdef->GetPDGCharge() != 0) {
171 #if G4VERSION_NUMBER < 940
172 pmgr->AddProcess(_scatter, -1, 1, 1);
173 pmgr->AddProcess(_ionise, -1, 2, 2);
174 pmgr->AddProcess(_decay, -1, -1, 2);
176 pmgr->AddProcess(
new G4hMultipleScattering(), -1, 1, 1);
177 pmgr->AddProcess(
new G4hIonisation(), -1, 2, 2);
178 pmgr->AddProcess(
new G4Decay(), -1, -1, 2);
183 #if G4VERSION_NUMBER < 940
184 pmgr->AddProcess(_scatter=
new G4hMultipleScattering(), -1, 1, 1);
185 pmgr->AddProcess(_decay=
new G4Decay(), -1, -1, 2);
188 pmgr->AddProcess(
new G4Decay(), -1, -1, 2);
Implementation base of a Geant4 physics constructor.
Geant4ExtraParticles(Geant4Context *ctxt, const std::string &nam)
Standard constructor with initailization parameters.
virtual void constructProcess(Constructor &ctor)
Callback to construct processes (uses the G4 particle table)
void deletePtr(T *&p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
static const double hbar_Planck
G4hMultipleScattering * m_scatter
static const double c_light
Generic context to extend user, run and event information.
void info(const char *fmt,...) const
Support of info messages.
virtual void constructParticle(Constructor &ctor)
Callback to construct particles.
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
virtual ~Geant4ExtraParticles()
Default destructor.