20 #include "TDatabasePDG.h"
21 #include "TParticlePDG.h"
22 #include "G4ParticleTable.hh"
23 #include "G4ParticleDefinition.hh"
24 #include "G4VProcess.hh"
25 #include "G4ChargedGeantino.hh"
26 #include "G4Geantino.hh"
30 using namespace DD4hep;
31 using namespace DD4hep::Simulation;
40 : ref(1), id(c.id), g4Parent(c.g4Parent), reason(c.reason), mask(c.mask),
41 steps(c.steps), secondaries(c.secondaries), pdgID(c.pdgID),
42 status(c.status), charge(0),
43 vsx(c.vsx), vsy(c.vsy), vsz(c.vsz),
44 vex(c.vex), vey(c.vey), vez(c.vez),
45 psx(c.psx), psy(c.psy), psz(c.psz),
46 pex(c.pex), pey(c.pey), pez(c.pez),
47 mass(c.mass), time(c.time), properTime(c.properTime),
48 parents(c.parents), daughters(c.daughters), extension(),
61 : ref(1), id(0), g4Parent(0), reason(0), mask(0),
62 steps(0), secondaries(0), pdgID(0),
64 vsx(0.0), vsy(0.0), vsz(0.0),
65 vex(0.0), vey(0.0), vez(0.0),
66 psx(0.0), psy(0.0), psz(0.0),
67 pex(0.0), pey(0.0), pez(0.0),
68 mass(0.0), time(0.0), properTime(0.0),
69 daughters(), extension(), process(0)
78 : ref(1), id(part_id), g4Parent(0), reason(0), mask(0),
79 steps(0), secondaries(0), pdgID(0),
81 vsx(0.0), vsy(0.0), vsz(0.0),
82 vex(0.0), vey(0.0), vez(0.0),
83 psx(0.0), psy(0.0), psz(0.0),
84 pex(0.0), pey(0.0), pez(0.0),
85 mass(0.0), time(0.0), properTime(0.0),
86 daughters(), extension(), process(0)
137 #if __cplusplus >= 201103L
149 std::set<int>::iterator j =
daughters.find(id_daughter);
155 G4ParticleTable* tab = G4ParticleTable::GetParticleTable();
156 G4ParticleDefinition* def = tab->FindParticle(
particle->
pdgID);
159 return G4Geantino::Definition();
160 return G4ChargedGeantino::Definition();
167 const G4ParticleDefinition* def =
definition();
170 return def->GetParticleName();
173 TDatabasePDG* db = TDatabasePDG::Instance();
175 if ( pdef )
return pdef->GetName();
184 const G4ParticleDefinition* def =
definition();
187 return def->GetParticleType();
190 TDatabasePDG* db = TDatabasePDG::Instance();
192 if ( pdef )
return pdef->ParticleClass();
213 return G4VProcess::GetProcessTypeName(
particle->
process->GetProcessType());
226 for(std::set<int>::iterator i=temp.begin(); i != temp.end(); ++i)
231 for(std::set<int>::iterator i=temp.begin(); i != temp.end(); ++i)
241 ::snprintf(text,
sizeof(text),
"/%d",*(p->
parents.begin()));
242 else if ( p->
parents.size() > 1 ) {
243 text[0]=
'/';text[1]=0;
244 for(std::set<int>::const_iterator i=p->
parents.begin(); i!=p->
parents.end(); ++i)
245 ::snprintf(text+strlen(text),
sizeof(text)-strlen(text),
"%d ",*i);
248 "+++ %s %4d def [%-11s,%8s] reason:%8d E:%+.2e %3s #Dau:%3d #Par:%3d%-5s",
263 if ( p->
parents.size() == 0 ) text[0]=0;
264 else if ( p->
parents.size() == 1 ) ::snprintf(text,
sizeof(text),
"/%d",*(p->
parents.begin()));
265 else if ( p->
parents.size() > 1 ) ::snprintf(text,
sizeof(text),
"/%d..",*(p->
parents.begin()));
267 "+++ %s %4d G4:%4d [%-12s,%8s] reason:%8d "
268 "E:%+.2e in record:%s #Par:%3d%-5s #Dau:%3d",
285 ::snprintf(text,
sizeof(text),
"/%d",*(p->
parents.begin()));
286 else if ( p->
parents.size() > 1 ) {
287 text[0]=
'/';text[1]=0;
288 for(std::set<int>::const_iterator i=p->
parents.begin(); i!=p->
parents.end(); ++i)
289 ::snprintf(text+strlen(text),
sizeof(text)-strlen(text),
"%d ",*i);
292 "+++ %s ID:%3d %-12s status:%08X PDG:%6d Vtx:(%+.2e,%+.2e,%+.2e)[mm] "
293 "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
308 ::snprintf(text,
sizeof(text),
"/%d",*(p->
parents.begin()));
309 else if ( p->
parents.size() > 1 ) {
310 text[0]=
'/';text[1]=0;
311 for(std::set<int>::const_iterator i=p->
parents.begin(); i!=p->
parents.end(); ++i)
312 ::snprintf(text+strlen(text),
sizeof(text)-strlen(text),
"%d ",*i);
315 "+++%s ID:%3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
316 "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
330 ::snprintf(text,
sizeof(text),
"/%d",*(p->
parents.begin()));
331 else if ( p->
parents.size() > 1 ) {
332 text[0]=
'/';text[1]=0;
333 for(std::set<int>::const_iterator i=p->
parents.begin(); i!=p->
parents.end(); ++i)
334 ::snprintf(text+strlen(text),
sizeof(text)-strlen(text),
"%d ",*i);
337 "+++%s %3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
338 "Vtx:(%+.2e,%+.2e,%+.2e)[mm] #Dau:%3d #Par:%1d%-6s",
358 ::snprintf(equiv,
sizeof(equiv),
"/%d",p->
g4Parent);
361 "+++ %s ID:%7d %12s %6d%-7s %7s %3s %5d %3s %+.3e %-4s %-7s %-3s %-3s %2d [%s%s%s] %c%c%c%c -- %c%c%c%c%c%c%c",
414 cout <<
"Particle map:" << endl;
415 for(Geant4ParticleMap::ParticleMap::const_iterator i=
m->particleMap.begin(); i!=
m->particleMap.end();++i) {
416 ::snprintf(text,
sizeof(text),
" [%-4d:%p]",(*i).second->id,(
void*)(*i).second);
426 cout <<
"Equivalents:" << endl;
427 for(Geant4ParticleMap::TrackEquivalents::const_iterator i=
m->equivalentTracks.begin(); i!=
m->equivalentTracks.end();++i) {
428 ::snprintf(text,
sizeof(text),
" [%-5d : %-5d]",(*i).first,(*i).second);
457 printout(
ERROR,
"Geant4ParticleMap",
"+++ No Equivalent particle for track:%d."
458 " Monte Carlo truth record looks broken!",g4_id);
const G4VProcess * process
not persisten. ROOT cannot handle
dd4hep_ptr< ParticleExtension > extension
User data extension if required.
std::map< int, Particle * > ParticleMap
void offset(int off) const
Handlers.
Data structure to store the MC particle information.
void adopt(ParticleMap &pm, TrackEquivalents &equiv)
Adopt particle maps.
void removeDaughter(int id_daughter)
Remove daughter from set.
void dumpWithVertex(int level, const std::string &src, const char *tag) const
Output type 3:+++ "tag" ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] #Par: 0 #Dau: 4.
static void decrement(T *)
Decrement count according to type information.
const char * yes_no(bool value)
Helper function to print booleans in format YES/NO.
int particleID(int track, bool throw_if_not_found=true) const
Access the equivalent track id (shortcut to the usage of TrackEquivalents)
void dump4(int level, const std::string &src, const char *tag) const
void dump2(int level, const std::string &src, const char *tag, int g4id, bool inrec) const
Output type 2:+++ "tag" 20 G4: 7 def:0xde4eaa8 [gamma , gamma] reason: 20 E:+3.304035e+01 in record:Y...
Data structure to manipulate a bitmask held by reference and represented by an integer.
Particles parents
The list of daughters of this MC particle.
Data structure to map particles produced during the generation and the simulation.
int ref
Reference counter.
const G4ParticleDefinition * definition() const
Access the Geant4 particle definition object (expensive!)
virtual ~ParticleExtension()
Default destructor.
std::string particleName() const
Access to the Geant4 particle name.
void clear()
Clear particle maps.
void releaseObjects(M &m)
std::string particleType() const
Access to the Geant4 particle type.
size_t numParent() const
Accessor to the number of particle parents.
Data structure to access derived MC particle information.
static void increment(T *)
Increment count according to type information.
double energy() const
Scalar particle energy.
void dumpWithMomentumAndVertex(int level, const std::string &src, const char *tag) const
Output type 3:+++ <tag> ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] #Par: 0 #Dau: 4.
virtual ~Geant4ParticleMap()
Default destructor.
Geant4Particle & get_data(Geant4Particle &c)
Assignment operator.
bool isValid() const
Check if the particle map was ever filled (ie. some particle handler was present) ...
virtual ~Geant4Particle()
Default destructor.
void dump1(int level, const std::string &src, const char *tag) const
Various output formats:
std::map< int, int > TrackEquivalents
std::string processName() const
Access to the creator process name.
ReferenceBitMask< int > PropertyMask
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Geant4Particle * particle
Particle pointer.
ParticleMap particleMap
Mapping of particles of this event.
bool isSet(const T &m) const
TrackEquivalents equivalentTracks
Map associating the G4Track identifiers with identifiers of existing MCParticles. ...
void dump() const
Dump content.
Geant4Particle()
Default constructor.
void dumpWithMomentum(int level, const std::string &src, const char *tag) const
Output type 3:+++ <tag> ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] #Par: 0 #Dau: 4.
std::string processTypeName() const
Access to the creator process type name.
void release()
Decrease reference count. Deletes object if NULL.