DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4Particle.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DD4hep/InstanceCount.h>
16 #include <DD4hep/Primitives.h>
17 #include <DD4hep/Printout.h>
18 #include <DDG4/Geant4Particle.h>
19 
20 #include <G4ChargedGeantino.hh>
21 #include <G4Geantino.hh>
22 #include <G4IonTable.hh>
23 #include <G4ParticleDefinition.hh>
24 #include <G4ParticleTable.hh>
25 #include <G4VProcess.hh>
26 
27 #include <TDatabasePDG.h>
28 #include <TParticlePDG.h>
29 
30 // C/C++ include files
31 #include <sstream>
32 #include <iostream>
33 #include <regex.h>
34 
35 using namespace dd4hep::sim;
36 
39 }
40 
43 {
45 }
46 
48 Geant4Particle::Geant4Particle(int part_id) : ref(1), id(part_id), originalG4ID(part_id)
49 {
51 }
52 
56  //::printf("************ Delete Geant4Particle[%p]: ID:%d pdgID %d ref:%d\n",(void*)this,id,pdgID,ref);
57 }
58 
60  //::printf("************ Release Geant4Particle[%p]: ID:%d pdgID %d ref:%d\n",(void*)this,id,pdgID,ref-1);
61  if ( --ref <= 0 ) {
62  delete this;
63  }
64 }
65 
68  if ( this != &c ) {
69  id = c.id;
71  g4Parent = c.g4Parent;
72  reason = c.reason;
73  mask = c.mask;
74  status = c.status;
75  genStatus = c.genStatus;
76  charge = c.charge;
77  steps = c.steps;
79  pdgID = c.pdgID;
80  vsx = c.vsx;
81  vsy = c.vsy;
82  vsz = c.vsz;
83  vex = c.vex;
84  vey = c.vey;
85  vez = c.vez;
86  psx = c.psx;
87  psy = c.psy;
88  psz = c.psz;
89  pex = c.pex;
90  pey = c.pey;
91  pez = c.pez;
92  mass = c.mass;
93  time = c.time;
95  process = c.process;
96  //definition = c.definition;
97  daughters = c.daughters;
98  parents = c.parents;
99 #if __cplusplus >= 201103L
100  extension.swap(c.extension);
101 #else
102  extension = c.extension;
103 #endif
104  //DD4hep_ptr<ParticleExtension>(c.extension.release());
105  }
106  return *this;
107 }
108 
110 void Geant4Particle::removeDaughter(int id_daughter) {
111  if ( std::set<int>::iterator j = daughters.find(id_daughter); j != daughters.end() )
112  daughters.erase(j);
113 }
114 
116 const G4ParticleDefinition* Geant4ParticleHandle::definition() const {
117  G4ParticleTable* tab = G4ParticleTable::GetParticleTable();
118  G4ParticleDefinition* def = tab->FindParticle(particle->pdgID);
119  if( 1000000000 < particle->pdgID) {
120  // creating ions here
121  // ion encoding is 10 L ZZZ AAA I
122  int id = particle->pdgID - 1000000000; // leading 10 is just identifier
123  const int L = id / 10000000; id %= 10000000; // strange-quark content
124  const int Z = id / 10000; id %= 10000;
125  const int A = id / 10; id %= 10;
126  const int lvl = id;
127  G4IonTable* tab_ion = G4IonTable::GetIonTable();
128  // Have to look for existing Ions, excited or not
129  G4ParticleDefinition* def_ion = tab_ion->FindIon(Z, A, L, lvl);
130  if(def_ion) {
131  //We found an existing Ion, we are good to go
132  printout(VERBOSE,"Geant4Particle","+++ Returning ion with PDG %10d", def_ion->GetPDGEncoding());
133  return def_ion;
134  } else if(lvl == 0) {
135  // GetIon creates the Ion if it does not exist, if this does not work something is seriously wrong
136  printout(VERBOSE,"Geant4Particle","+++ Creating ion with PDG %10d", particle->pdgID);
137  return tab_ion->GetIon(Z, A, L, 0.0);
138  }
139  //Cannot use GetIon with lvl > 0, must give energy, but we don't know where to get energy from
140  printout(WARNING,"Geant4Particle","+++ Cannot find excited ion with PDG %10d, setting excitation level to zero",
141  particle->pdgID);
142  return tab_ion->GetIon(Z, A, L, /* E= */ 0.0);
143  } // finished with ions
144 
145  if ( 0 == def && 0 == particle->pdgID ) {
146  if ( 0 == particle->charge )
147  return G4Geantino::Definition();
148  return G4ChargedGeantino::Definition();
149  }
150  return def;
151 }
152 
155  if ( const G4ParticleDefinition* def = definition() )
156  return def->GetParticleName();
157 #if 0
158  TDatabasePDG* db = TDatabasePDG::Instance();
159  TParticlePDG* pdef = db->GetParticle(particle->pdgID);
160  if ( pdef ) return pdef->GetName();
161 #endif
162  char text[32];
163  ::snprintf(text,sizeof(text),"PDG:%d",particle->pdgID);
164  return text;
165 }
166 
169  if ( const G4ParticleDefinition* def = definition() )
170  return def->GetParticleType();
171 #if 0
172  TDatabasePDG* db = TDatabasePDG::Instance();
173  TParticlePDG* pdef = db->GetParticle(particle->pdgID);
174  if ( pdef ) return pdef->ParticleClass();
175 #endif
176  char text[32];
177  ::snprintf(text,sizeof(text),"PDG:%d",particle->pdgID);
178  return text;
179 }
180 
182 std::vector<G4ParticleDefinition*> Geant4ParticleHandle::g4DefinitionsRegEx(const std::string& expression) {
183  std::vector<G4ParticleDefinition*> results;
184  std::string exp = expression; //'^'+expression+"$";
185  G4ParticleTable* pt = G4ParticleTable::GetParticleTable();
186  G4ParticleTable::G4PTblDicIterator* iter = pt->GetIterator();
187 
188  iter->reset();
189  if ( expression == "*" || expression == ".(*)" ) {
190  while ((*iter)()) {
191  G4ParticleDefinition* p = iter->value();
192  results.emplace_back(p);
193  }
194  }
195  else {
196  regex_t reg;
197  int ret = ::regcomp(&reg, exp.c_str(), 0);
198  if (ret) {
199  throw std::runtime_error(format("Geant4ParticleHandle", "REGEX: Failed to compile particle name %s", exp.c_str()));
200  }
201  while ((*iter)()) {
202  G4ParticleDefinition* p = iter->value();
203  ret = ::regexec(&reg, p->GetParticleName().c_str(), 0, NULL, 0);
204  if (!ret)
205  results.emplace_back(p);
206  else if (ret == REG_NOMATCH)
207  continue;
208  else {
209  char msgbuf[128];
210  ::regerror(ret, &reg, msgbuf, sizeof(msgbuf));
211  ::regfree(&reg);
212  throw std::runtime_error(format("Geant4ParticleHandle", "REGEX: Failed to match particle name %s err=%s", exp.c_str(), msgbuf));
213  }
214  }
215  ::regfree(&reg);
216  }
217  return results;
218 }
219 
221 G4ParticleDefinition* Geant4ParticleHandle::g4DefinitionsExact(const std::string& expression) {
222  G4ParticleTable* tab = G4ParticleTable::GetParticleTable();
223  G4ParticleDefinition* def = tab->FindParticle(expression);
224  return def;
225 }
226 
229  if ( particle->process ) return particle->process->GetProcessName();
230  else if ( particle->reason&G4PARTICLE_PRIMARY ) return "Primary";
231  else if ( particle->status&G4PARTICLE_GEN_EMPTY ) return "Gen.Empty";
232  else if ( particle->status&G4PARTICLE_GEN_STABLE ) return "Gen.Stable";
233  else if ( particle->status&G4PARTICLE_GEN_DECAYED ) return "Gen.Decay";
234  else if ( particle->status&G4PARTICLE_GEN_DOCUMENTATION ) return "Gen.DOC";
235  else if ( particle->status&G4PARTICLE_GEN_BEAM ) return "Gen.Beam";
236  else if ( particle->status&G4PARTICLE_GEN_OTHER ) return "Gen.Other";
237  return "???";
238 }
239 
242  if ( particle->process ) {
243  return G4VProcess::GetProcessTypeName(particle->process->GetProcessType());
244  }
245  return "";
246 }
247 
249 void Geant4ParticleHandle::offset(int off) const {
250  std::set<int> temp;
252  p->id += off;
253 
254  temp = p->daughters;
255  p->daughters.clear();
256  for(auto i : temp) p->daughters.insert(i+off);
257 
258  temp = p->parents;
259  p->parents.clear();
260  for(auto i : temp ) p->parents.insert(i+off);
261 }
262 
264 void Geant4ParticleHandle::dump1(int level, const std::string& src, const char* tag) const {
265  char text[256];
266  Geant4ParticleHandle p(*this);
267  text[0]=0;
268  if ( p->parents.size() == 1 )
269  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
270  else if ( p->parents.size() > 1 ) {
271  text[0]='/';text[1]=0;
272  for(int i : p->parents )
273  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
274  }
275  printout((dd4hep::PrintLevel)level,src,
276  "+++ %s %4d def [%-11s,%8s] reason:%8d E:%+.2e %3s #Dau:%3d #Par:%3d%-5s",
277  tag, p->id,
278  p.particleName().c_str(),
279  p.particleType().c_str(),
280  p->reason,
281  p.energy(),
282  p->g4Parent>0 ? "Sim" : "Gen",
283  int(p->daughters.size()),
284  int(p->parents.size()),text);
285 }
286 
288 void Geant4ParticleHandle::dump2(int level, const std::string& src, const char* tag, int g4id, bool inrec) const {
289  char text[32];
290  Geant4ParticleHandle p(*this);
291  if ( p->parents.size() == 0 ) text[0]=0;
292  else if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
293  else if ( p->parents.size() > 1 ) ::snprintf(text,sizeof(text),"/%d..",*(p->parents.begin()));
294  printout((dd4hep::PrintLevel)level,src,
295  "+++ %s %4d G4:%4d [%-12s,%8s] reason:%8d "
296  "E:%+.2e in record:%s #Par:%3d%-5s #Dau:%3d",
297  tag, p->id, g4id,
298  p.particleName().c_str(),
299  p.particleType().c_str(),
300  p->reason,
301  p.energy(),
302  yes_no(inrec),
303  int(p->parents.size()),text,
304  int(p->daughters.size()));
305 }
306 
308 void Geant4ParticleHandle::dumpWithVertex(int level, const std::string& src, const char* tag) const {
309  char text[256];
310  Geant4ParticleHandle p(*this);
311  text[0]=0;
312  if ( p->parents.size() == 1 )
313  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
314  else if ( p->parents.size() > 1 ) {
315  text[0]='/';text[1]=0;
316  for(int i : p->parents )
317  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
318  }
319  printout((dd4hep::PrintLevel)level,src,
320  "+++ %s ID:%3d %-12s status:%08X PDG:%6d Vtx:(%+.2e,%+.2e,%+.2e)[mm] "
321  "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
322  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
323  p->vsx/CLHEP::mm,p->vsy/CLHEP::mm,p->vsz/CLHEP::mm,p->time/CLHEP::ns,
324  p->daughters.size(),
325  p->parents.size(),
326  text);
327 }
328 
329 
331 void Geant4ParticleHandle::dumpWithMomentum(int level, const std::string& src, const char* tag) const {
332  char text[256];
333  Geant4ParticleHandle p(*this);
334  text[0]=0;
335  if ( p->parents.size() == 1 )
336  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
337  else if ( p->parents.size() > 1 ) {
338  text[0]='/';text[1]=0;
339  for(int i : p->parents )
340  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
341  }
342  printout((dd4hep::PrintLevel)level,src,
343  "+++%s ID:%3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
344  "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
345  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
346  p->psx/CLHEP::MeV,p->psy/CLHEP::MeV,p->psz/CLHEP::MeV,p->time/CLHEP::ns,
347  int(p->daughters.size()),
348  int(p->parents.size()),
349  text);
350 }
351 
353 void Geant4ParticleHandle::dumpWithMomentumAndVertex(int level, const std::string& src, const char* tag) const {
354  char text[256];
355  Geant4ParticleHandle p(*this);
356  text[0]=0;
357  if ( p->parents.size() == 1 )
358  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
359  else if ( p->parents.size() > 1 ) {
360  text[0]='/';text[1]=0;
361  for(int i : p->parents )
362  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
363  }
364  printout((dd4hep::PrintLevel)level,src,
365  "+++%s %3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
366  "Vtx:(%+.2e,%+.2e,%+.2e)[mm] #Dau:%3d #Par:%1d%-6s",
367  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
368  p->psx/CLHEP::MeV,p->psy/CLHEP::MeV,p->psz/CLHEP::MeV,
369  p->vsx/CLHEP::mm,p->vsy/CLHEP::mm,p->vsz/CLHEP::mm,
370  int(p->daughters.size()),
371  int(p->parents.size()),
372  text);
373 }
374 
375 void Geant4ParticleHandle::header4(int level, const std::string& src, const char* tag) {
376  printout((dd4hep::PrintLevel)level,src,
377  "+++ %s %10s/%-7s %12s/%-10s %6s/%-6s %4s %4s "
378  "%-4s %-3s %-3s %-10s "
379  "%-5s %-6s %-3s %-3s %-20s %s",
380  tag,"ID", "G4-ID", "Part-Name","PDG", "Parent","G4-ID", "#Par","#Dau",
381  "Prim","Sec",">E","Energy",
382  "EMPTY","STAB","DEC","DOC",
383  "Process", "Processing Flags");
384 }
385 
386 void Geant4ParticleHandle::dump4(int level, const std::string& src, const char* tag) const {
387  using PropertyMask = dd4hep::detail::ReferenceBitMask<int>;
388  Geant4ParticleHandle p(*this);
389  //char equiv[32];
390  PropertyMask mask(p->reason);
391  PropertyMask status(p->status);
392  std::string proc_name = p.processName();
393  std::string proc_type = p.processTypeName();
394  std::string proc = '['+proc_name+(p->process ? "/" : "")+proc_type+']';
395  int parent_id = p->parents.empty() ? -1 : *(p->parents.begin());
396 
397  //equiv[0] = 0;
398  //if ( p->parents.end() == p->parents.find(p->g4Parent) ) {
399  // ::snprintf(equiv,sizeof(equiv),"/%d",p->g4Parent);
400  //}
401  std::stringstream str;
402  str << "Parents: ";
403  for( const auto i : p->parents )
404  str << i << " ";
405  str << " Daughters: ";
406  for( const auto i : p->daughters )
407  str << i << " ";
408  printout((dd4hep::PrintLevel)level,src,
409  "+++ %s ID:%7d/%-7d %12s/%-10d %6d/%-6d %4d %4d %-4s %-3s %-3s %+.3e "
410  "%-5s %-4s %-3s %-3s %-20s %c%c%c%c -- %c%c%c%c%c%c%c%c%c %s",
411  tag,
412  p->id,p->originalG4ID,
413  p.particleName().c_str(),
414  p->pdgID,
415  parent_id,p->g4Parent,
416  p.numParent(),
417  int(p->daughters.size()),
418  yes_no(mask.isSet(G4PARTICLE_PRIMARY)),
419  yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)),
420  yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)),
421  p.energy(),
422  //
423  yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)),
424  yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)),
425  yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)),
426  mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "",
427  proc.c_str(),
428  // 13 flags in total
429  status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', // 1
430  status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.',
431  status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.',
432  status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.',
433  status.isSet(G4PARTICLE_GEN_BEAM) ? 'B' : '.', // 5
434  status.isSet(G4PARTICLE_GEN_OTHER) ? 'o' : '.',
435  status.isSet(G4PARTICLE_SIM_CREATED) ? 's' : '.',
436  status.isSet(G4PARTICLE_SIM_BACKSCATTER) ? 'b' : '.',
437  status.isSet(G4PARTICLE_SIM_PARENT_RADIATED) ? 'v' : '.',
438  status.isSet(G4PARTICLE_SIM_DECAY_TRACKER) ? 't' : '.', // 10
439  status.isSet(G4PARTICLE_SIM_DECAY_CALO) ? 'c' : '.',
440  status.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) ? 'l' : '.',
441  status.isSet(G4PARTICLE_SIM_STOPPED) ? 's' : '.',
442  str.str().c_str()
443  );
444 #if 0
445  printout((dd4hep::PrintLevel)level,src,
446  "+++ %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",
447  tag,
448  p->id,
449  p.particleName().c_str(),
450  parent_id,equiv,
451  yes_no(mask.isSet(G4PARTICLE_PRIMARY)),
452  yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)),
453  int(p->daughters.size()),
454  yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)),
455  p.energy(),
456  yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)),
457  yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)),
458  yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)),
459  mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "",
460  p.numParent(),
461  proc_name.c_str(),
462  p->process ? "/" : "",
463  proc_type.c_str(),
464  status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.',
465  status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.',
466  status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.',
467  status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.',
468  status.isSet(G4PARTICLE_GEN_BEAM) ? 'B' : '.',
469  status.isSet(G4PARTICLE_GEN_OTHER) ? 'o' : '.',
470 
471  status.isSet(G4PARTICLE_SIM_CREATED) ? 's' : '.',
472  status.isSet(G4PARTICLE_SIM_BACKSCATTER) ? 'b' : '.',
473  status.isSet(G4PARTICLE_SIM_PARENT_RADIATED) ? 'v' : '.',
474  status.isSet(G4PARTICLE_SIM_DECAY_TRACKER) ? 't' : '.',
475  status.isSet(G4PARTICLE_SIM_DECAY_CALO) ? 'c' : '.',
476  status.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) ? 'l' : '.',
477  status.isSet(G4PARTICLE_SIM_STOPPED) ? 's' : '.'
478  );
479 #endif
480 }
481 
484  clear();
485 }
486 
489  detail::releaseObjects(particleMap);
490  particleMap.clear();
491  equivalentTracks.clear();
492 }
493 
496  int cnt;
497  char text[64];
498  const Geant4ParticleMap* m = this;
499 
500  cnt = 0;
501  std::cout << "Particle map:" << std::endl;
502  for( const auto& p : m->particleMap ) {
503  std::snprintf(text,sizeof(text)," [%-4d:%p]",p.second->id,(void*)p.second);
504  std::cout << text;
505  if ( ++cnt == 8 ) {
506  std::cout << std::endl;
507  cnt = 0;
508  }
509  }
510  std::cout << std::endl;
511 
512  cnt = 0;
513  std::cout << "Equivalents:" << std::endl;
514  for( const auto& p : m->equivalentTracks ) {
515  std::snprintf(text,sizeof(text)," [%-5d : %-5d]",p.first,p.second);
516  std::cout << text;
517  if ( ++cnt == 8 ) {
518  std::cout << std::endl;
519  cnt = 0;
520  }
521  }
522  std::cout << std::endl;
523 }
524 
527  clear();
528  particleMap = pm;
529  equivalentTracks = equiv;
530  pm.clear();
531  equiv.clear();
532  //dump();
533 }
534 
537  return !equivalentTracks.empty();
538 }
539 
541 int Geant4ParticleMap::particleID(int g4_id, bool) const {
542  TrackEquivalents::const_iterator iequiv = equivalentTracks.find(g4_id);
543  if ( iequiv != equivalentTracks.end() ) return (*iequiv).second;
544  printout(ERROR,"Geant4ParticleMap","+++ No Equivalent particle for track:%d."
545  " Monte Carlo truth record looks broken!",g4_id);
546  dump();
547  return -1;
548 }
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:85
dd4hep::sim::G4PARTICLE_CREATED_TRACKER_HIT
@ G4PARTICLE_CREATED_TRACKER_HIT
Definition: Geant4Particle.h:64
dd4hep::sim::Geant4ParticleHandle::offset
void offset(int off) const
Handlers.
Definition: Geant4Particle.cpp:249
dd4hep::sim::G4PARTICLE_ABOVE_ENERGY_THRESHOLD
@ G4PARTICLE_ABOVE_ENERGY_THRESHOLD
Definition: Geant4Particle.h:60
dd4hep::sim::Geant4Particle::vsz
double vsz
Definition: Geant4Particle.h:124
dd4hep::sim::G4PARTICLE_KEEP_PARENT
@ G4PARTICLE_KEEP_PARENT
Definition: Geant4Particle.h:62
dd4hep::sim::Geant4Particle::reason
int reason
Definition: Geant4Particle.h:111
dd4hep::sim::Geant4ParticleHandle::dump1
void dump1(int level, const std::string &src, const char *tag) const
Various output formats:
Definition: Geant4Particle.cpp:264
dd4hep::sim::G4PARTICLE_GEN_STABLE
@ G4PARTICLE_GEN_STABLE
Definition: Geant4Particle.h:71
dd4hep::sim::G4PARTICLE_SIM_PARENT_RADIATED
@ G4PARTICLE_SIM_PARENT_RADIATED
Definition: Geant4Particle.h:91
dd4hep::sim::Geant4ParticleMap::dump
void dump() const
Dump content.
Definition: Geant4Particle.cpp:495
dd4hep::sim::Geant4Particle::mass
double mass
Particle mass.
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4Particle::vey
double vey
Definition: Geant4Particle.h:126
dd4hep::sim::Geant4ParticleHandle::particleName
std::string particleName() const
Access to the Geant4 particle name.
Definition: Geant4Particle.cpp:154
dd4hep::sim::Geant4Particle::pez
double pez
Definition: Geant4Particle.h:130
dd4hep::sim::Geant4ParticleHandle::dumpWithVertex
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,...
Definition: Geant4Particle.cpp:308
dd4hep::sim::G4PARTICLE_KEEP_PROCESS
@ G4PARTICLE_KEEP_PROCESS
Definition: Geant4Particle.h:61
dd4hep::sim::Geant4Particle::id
int id
not persistent
Definition: Geant4Particle.h:108
dd4hep::sim::Geant4ParticleHandle::g4DefinitionsRegEx
static std::vector< G4ParticleDefinition * > g4DefinitionsRegEx(const std::string &expression)
Access Geant4 particle definitions by regular expression.
Definition: Geant4Particle.cpp:182
dd4hep::sim::Geant4ParticleMap::adopt
void adopt(ParticleMap &pm, TrackEquivalents &equiv)
Adopt particle maps.
Definition: Geant4Particle.cpp:526
dd4hep::sim::Geant4ParticleHandle::processName
std::string processName() const
Access to the creator process name.
Definition: Geant4Particle.cpp:228
dd4hep::sim::Geant4Particle::pdgID
int pdgID
Definition: Geant4Particle.h:115
dd4hep::sim::Geant4Particle::g4Parent
int g4Parent
not persistent
Definition: Geant4Particle.h:110
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::sim::Geant4ParticleMap::TrackEquivalents
std::map< int, int > TrackEquivalents
Definition: Geant4Particle.h:341
dd4hep::sim::Geant4Particle::psz
double psz
Definition: Geant4Particle.h:128
dd4hep::sim::Geant4Particle::~Geant4Particle
virtual ~Geant4Particle()
Default destructor.
Definition: Geant4Particle.cpp:54
dd4hep::sim::Geant4ParticleMap::~Geant4ParticleMap
virtual ~Geant4ParticleMap()
Default destructor.
Definition: Geant4Particle.cpp:483
dd4hep::sim::Geant4Particle::secondaries
int secondaries
Definition: Geant4Particle.h:114
dd4hep::sim::G4PARTICLE_GEN_DOCUMENTATION
@ G4PARTICLE_GEN_DOCUMENTATION
Definition: Geant4Particle.h:73
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition: Geant4Particle.h:86
dd4hep::sim::Geant4ParticleHandle::dumpWithMomentumAndVertex
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,...
Definition: Geant4Particle.cpp:353
dd4hep::sim::Geant4Particle::extension
std::unique_ptr< ParticleExtension > extension
User data extension if required.
Definition: Geant4Particle.h:143
dd4hep::sim::Geant4Particle::get_data
Geant4Particle & get_data(Geant4Particle &c)
Assignment operator.
Definition: Geant4Particle.cpp:67
dd4hep::sim::Geant4ParticleMap
Data structure to map particles produced during the generation and the simulation.
Definition: Geant4Particle.h:337
dd4hep::sim::ParticleExtension::~ParticleExtension
virtual ~ParticleExtension()
Default destructor.
Definition: Geant4Particle.cpp:38
dd4hep::sim::G4PARTICLE_GEN_EMPTY
@ G4PARTICLE_GEN_EMPTY
Definition: Geant4Particle.h:70
dd4hep::sim::G4PARTICLE_SIM_STOPPED
@ G4PARTICLE_SIM_STOPPED
Definition: Geant4Particle.h:89
dd4hep::sim::Geant4ParticleHandle::particleType
std::string particleType() const
Access to the Geant4 particle type.
Definition: Geant4Particle.cpp:168
dd4hep::sim::Geant4ParticleHandle::dump2
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...
Definition: Geant4Particle.cpp:288
dd4hep::sim::Geant4Particle::vez
double vez
Definition: Geant4Particle.h:126
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition: Geant4Particle.h:87
dd4hep::sim::Geant4ParticleHandle::numParent
size_t numParent() const
Accessor to the number of particle parents.
Definition: Geant4Particle.h:282
dd4hep::sim::Geant4ParticleMap::ParticleMap
std::map< int, Particle * > ParticleMap
Definition: Geant4Particle.h:340
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4Particle::genStatus
unsigned short genStatus
Definition: Geant4Particle.h:118
dd4hep::sim::Geant4Particle::status
int status
Definition: Geant4Particle.h:116
dd4hep::sim::G4PARTICLE_GEN_DECAYED
@ G4PARTICLE_GEN_DECAYED
Definition: Geant4Particle.h:72
dd4hep::sim::Geant4Particle::originalG4ID
int originalG4ID
Definition: Geant4Particle.h:109
dd4hep::sim::Geant4ParticleHandle::dump4
void dump4(int level, const std::string &src, const char *tag) const
Definition: Geant4Particle.cpp:386
dd4hep::sim::Geant4Particle::daughters
Particles daughters
The list of daughters of this MC particle.
Definition: Geant4Particle.h:140
dd4hep::sim::G4PARTICLE_SIM_DECAY_TRACKER
@ G4PARTICLE_SIM_DECAY_TRACKER
Definition: Geant4Particle.h:88
dd4hep::sim::Geant4ParticleHandle::processTypeName
std::string processTypeName() const
Access to the creator process type name.
Definition: Geant4Particle.cpp:241
dd4hep::sim::Geant4Particle::mask
int mask
Definition: Geant4Particle.h:112
dd4hep::sim::Geant4Particle::time
double time
Particle creation time.
Definition: Geant4Particle.h:134
dd4hep::sim::Geant4Particle::steps
int steps
Definition: Geant4Particle.h:113
dd4hep::sim::Geant4Particle::process
const G4VProcess * process
Reference to the G4VProcess, which created this track.
Definition: Geant4Particle.h:145
dd4hep::sim::Geant4ParticleHandle::g4DefinitionsExact
static G4ParticleDefinition * g4DefinitionsExact(const std::string &expression)
Access Geant4 particle definitions by exact match.
Definition: Geant4Particle.cpp:221
dd4hep::sim::Geant4Particle::pex
double pex
The track momentum at the end vertex.
Definition: Geant4Particle.h:130
dd4hep::sim::Geant4ParticleMap::particleID
int particleID(int track, bool throw_if_not_found=true) const
Access the equivalent track id (shortcut to the usage of TrackEquivalents)
Definition: Geant4Particle.cpp:541
dd4hep::sim::G4PARTICLE_HAS_SECONDARIES
@ G4PARTICLE_HAS_SECONDARIES
Definition: Geant4Particle.h:59
dd4hep::sim::Geant4Particle::vex
double vex
The end vertex.
Definition: Geant4Particle.h:126
dd4hep::sim::Geant4Particle::vsx
double vsx
The starting vertex.
Definition: Geant4Particle.h:124
dd4hep::sim::Geant4ParticleMap::clear
void clear()
Clear particle maps.
Definition: Geant4Particle.cpp:488
dd4hep::sim::Geant4Particle::psx
double psx
The track momentum at the start vertex.
Definition: Geant4Particle.h:128
dd4hep::sim::G4PARTICLE_GEN_BEAM
@ G4PARTICLE_GEN_BEAM
Definition: Geant4Particle.h:74
dd4hep::sim::Geant4ParticleHandle::definition
const G4ParticleDefinition * definition() const
Access the Geant4 particle definition object (expensive!)
Definition: Geant4Particle.cpp:116
dd4hep::sim::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:130
Primitives.h
dd4hep::sim::Geant4ParticleMap::particleMap
ParticleMap particleMap
Mapping of particles of this event.
Definition: Geant4Particle.h:343
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition: Geant4Particle.h:90
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: HepMC3EventReader.cpp:37
dd4hep::sim::Geant4Particle::Geant4Particle
Geant4Particle()
not persistent
Definition: Geant4Particle.cpp:42
dd4hep::sim::Geant4ParticleHandle::particle
Geant4Particle * particle
Particle pointer.
Definition: Geant4Particle.h:187
dd4hep::sim::Geant4ParticleHandle
Data structure to access derived MC particle information.
Definition: Geant4Particle.h:181
dd4hep::sim::Geant4ParticleHandle::dumpWithMomentum
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,...
Definition: Geant4Particle.cpp:331
dd4hep::sim::Geant4Particle::parents
Particles parents
The list of parents of this MC particle.
Definition: Geant4Particle.h:138
dd4hep::sim::Geant4ParticleMap::equivalentTracks
TrackEquivalents equivalentTracks
Map associating the G4Track identifiers with identifiers of existing MCParticles.
Definition: Geant4Particle.h:345
Geant4Particle.h
dd4hep::sim::Geant4Particle::vsy
double vsy
Definition: Geant4Particle.h:124
dd4hep::sim::G4PARTICLE_CREATED_CALORIMETER_HIT
@ G4PARTICLE_CREATED_CALORIMETER_HIT
Definition: Geant4Particle.h:63
dd4hep::sim::G4PARTICLE_PRIMARY
@ G4PARTICLE_PRIMARY
Definition: Geant4Particle.h:58
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:103
dd4hep::sim::Geant4Particle::charge
char charge
Definition: Geant4Particle.h:119
InstanceCount.h
dd4hep::sim::Geant4ParticleHandle::energy
double energy() const
Scalar particle energy.
Definition: Geant4Particle.h:308
dd4hep::sim::Geant4Particle::psy
double psy
Definition: Geant4Particle.h:128
dd4hep::sim::Geant4ParticleMap::isValid
bool isValid() const
Check if the particle map was ever filled (ie. some particle handler was present)
Definition: Geant4Particle.cpp:536
dd4hep::sim::G4PARTICLE_GEN_OTHER
@ G4PARTICLE_GEN_OTHER
Definition: Geant4Particle.h:76
Printout.h
dd4hep::sim::Geant4Particle::release
void release()
Decrease reference count. Deletes object if NULL.
Definition: Geant4Particle.cpp:59
dd4hep::sim::Geant4Particle::properTime
double properTime
Proper time.
Definition: Geant4Particle.h:136
dd4hep::sim::Geant4ParticleHandle::header4
static void header4(int level, const std::string &src, const char *tag)
Definition: Geant4Particle.cpp:375
dd4hep::sim::Geant4Particle::removeDaughter
void removeDaughter(int id_daughter)
Remove daughter from set.
Definition: Geant4Particle.cpp:110
dd4hep::sim::Geant4Particle::ref
int ref
Reference counter.
Definition: Geant4Particle.h:107