DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  extension.swap(c.extension);
100  //DD4hep_ptr<ParticleExtension>(c.extension.release());
101  }
102  return *this;
103 }
104 
106 void Geant4Particle::removeDaughter(int id_daughter) {
107  if ( std::set<int>::iterator j = daughters.find(id_daughter); j != daughters.end() )
108  daughters.erase(j);
109 }
110 
112 const G4ParticleDefinition* Geant4ParticleHandle::definition() const {
113  G4ParticleTable* tab = G4ParticleTable::GetParticleTable();
114  G4ParticleDefinition* def = tab->FindParticle(particle->pdgID);
115  if( 1000000000 < particle->pdgID) {
116  // creating ions here
117  // ion encoding is 10 L ZZZ AAA I
118  int id = particle->pdgID - 1000000000; // leading 10 is just identifier
119  const int L = id / 10000000; id %= 10000000; // strange-quark content
120  const int Z = id / 10000; id %= 10000;
121  const int A = id / 10; id %= 10;
122  const int lvl = id;
123  G4IonTable* tab_ion = G4IonTable::GetIonTable();
124  // Have to look for existing Ions, excited or not
125  G4ParticleDefinition* def_ion = tab_ion->FindIon(Z, A, L, lvl);
126  if(def_ion) {
127  //We found an existing Ion, we are good to go
128  printout(VERBOSE,"Geant4Particle","+++ Returning ion with PDG %10d", def_ion->GetPDGEncoding());
129  return def_ion;
130  } else if(lvl == 0) {
131  // GetIon creates the Ion if it does not exist, if this does not work something is seriously wrong
132  printout(VERBOSE,"Geant4Particle","+++ Creating ion with PDG %10d", particle->pdgID);
133  return tab_ion->GetIon(Z, A, L, 0.0);
134  }
135  //Cannot use GetIon with lvl > 0, must give energy, but we don't know where to get energy from
136  printout(WARNING,"Geant4Particle","+++ Cannot find excited ion with PDG %10d, setting excitation level to zero",
137  particle->pdgID);
138  return tab_ion->GetIon(Z, A, L, /* E= */ 0.0);
139  } // finished with ions
140 
141  if ( 0 == def && 0 == particle->pdgID ) {
142  if ( 0 == particle->charge )
143  return G4Geantino::Definition();
144  return G4ChargedGeantino::Definition();
145  }
146  return def;
147 }
148 
151  if ( const G4ParticleDefinition* def = definition() )
152  return def->GetParticleName();
153 #if 0
154  TDatabasePDG* db = TDatabasePDG::Instance();
155  TParticlePDG* pdef = db->GetParticle(particle->pdgID);
156  if ( pdef ) return pdef->GetName();
157 #endif
158  char text[32];
159  ::snprintf(text,sizeof(text),"PDG:%d",particle->pdgID);
160  return text;
161 }
162 
165  if ( const G4ParticleDefinition* def = definition() )
166  return def->GetParticleType();
167 #if 0
168  TDatabasePDG* db = TDatabasePDG::Instance();
169  TParticlePDG* pdef = db->GetParticle(particle->pdgID);
170  if ( pdef ) return pdef->ParticleClass();
171 #endif
172  char text[32];
173  ::snprintf(text,sizeof(text),"PDG:%d",particle->pdgID);
174  return text;
175 }
176 
178 std::vector<G4ParticleDefinition*> Geant4ParticleHandle::g4DefinitionsRegEx(const std::string& expression) {
179  std::vector<G4ParticleDefinition*> results;
180  std::string exp = expression; //'^'+expression+"$";
181  G4ParticleTable* pt = G4ParticleTable::GetParticleTable();
182  G4ParticleTable::G4PTblDicIterator* iter = pt->GetIterator();
183 
184  iter->reset();
185  if ( expression == "*" || expression == ".(*)" ) {
186  while ((*iter)()) {
187  G4ParticleDefinition* p = iter->value();
188  results.emplace_back(p);
189  }
190  }
191  else {
192  regex_t reg;
193  int ret = ::regcomp(&reg, exp.c_str(), 0);
194  if (ret) {
195  throw std::runtime_error(format("Geant4ParticleHandle", "REGEX: Failed to compile particle name %s", exp.c_str()));
196  }
197  while ((*iter)()) {
198  G4ParticleDefinition* p = iter->value();
199  ret = ::regexec(&reg, p->GetParticleName().c_str(), 0, NULL, 0);
200  if (!ret)
201  results.emplace_back(p);
202  else if (ret == REG_NOMATCH)
203  continue;
204  else {
205  char msgbuf[128];
206  ::regerror(ret, &reg, msgbuf, sizeof(msgbuf));
207  ::regfree(&reg);
208  throw std::runtime_error(format("Geant4ParticleHandle", "REGEX: Failed to match particle name %s err=%s", exp.c_str(), msgbuf));
209  }
210  }
211  ::regfree(&reg);
212  }
213  return results;
214 }
215 
217 G4ParticleDefinition* Geant4ParticleHandle::g4DefinitionsExact(const std::string& expression) {
218  G4ParticleTable* tab = G4ParticleTable::GetParticleTable();
219  G4ParticleDefinition* def = tab->FindParticle(expression);
220  return def;
221 }
222 
225  if ( particle->process ) return particle->process->GetProcessName();
226  else if ( particle->reason&G4PARTICLE_PRIMARY ) return "Primary";
227  else if ( particle->status&G4PARTICLE_GEN_EMPTY ) return "Gen.Empty";
228  else if ( particle->status&G4PARTICLE_GEN_STABLE ) return "Gen.Stable";
229  else if ( particle->status&G4PARTICLE_GEN_DECAYED ) return "Gen.Decay";
230  else if ( particle->status&G4PARTICLE_GEN_DOCUMENTATION ) return "Gen.DOC";
231  else if ( particle->status&G4PARTICLE_GEN_BEAM ) return "Gen.Beam";
232  else if ( particle->status&G4PARTICLE_GEN_OTHER ) return "Gen.Other";
233  return "???";
234 }
235 
238  if ( particle->process ) {
239  return G4VProcess::GetProcessTypeName(particle->process->GetProcessType());
240  }
241  return "";
242 }
243 
245 void Geant4ParticleHandle::offset(int off) const {
246  std::set<int> temp;
248  p->id += off;
249 
250  temp = p->daughters;
251  p->daughters.clear();
252  for(auto i : temp) p->daughters.insert(i+off);
253 
254  temp = p->parents;
255  p->parents.clear();
256  for(auto i : temp ) p->parents.insert(i+off);
257 }
258 
260 void Geant4ParticleHandle::dump1(int level, const std::string& src, const char* tag) const {
261  char text[256];
262  Geant4ParticleHandle p(*this);
263  text[0]=0;
264  if ( p->parents.size() == 1 )
265  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
266  else if ( p->parents.size() > 1 ) {
267  text[0]='/';text[1]=0;
268  for(int i : p->parents )
269  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
270  }
271  printout((dd4hep::PrintLevel)level,src,
272  "+++ %s %4d def [%-11s,%8s] reason:%8d E:%+.2e %3s #Dau:%3d #Par:%3d%-5s",
273  tag, p->id,
274  p.particleName().c_str(),
275  p.particleType().c_str(),
276  p->reason,
277  p.energy(),
278  p->g4Parent>0 ? "Sim" : "Gen",
279  int(p->daughters.size()),
280  int(p->parents.size()),text);
281 }
282 
284 void Geant4ParticleHandle::dump2(int level, const std::string& src, const char* tag, int g4id, bool inrec) const {
285  char text[32];
286  Geant4ParticleHandle p(*this);
287  if ( p->parents.size() == 0 ) text[0]=0;
288  else if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
289  else if ( p->parents.size() > 1 ) ::snprintf(text,sizeof(text),"/%d..",*(p->parents.begin()));
290  printout((dd4hep::PrintLevel)level,src,
291  "+++ %s %4d G4:%4d [%-12s,%8s] reason:%8d "
292  "E:%+.2e in record:%s #Par:%3d%-5s #Dau:%3d",
293  tag, p->id, g4id,
294  p.particleName().c_str(),
295  p.particleType().c_str(),
296  p->reason,
297  p.energy(),
298  yes_no(inrec),
299  int(p->parents.size()),text,
300  int(p->daughters.size()));
301 }
302 
304 void Geant4ParticleHandle::dumpWithVertex(int level, const std::string& src, const char* tag) const {
305  char text[256];
306  Geant4ParticleHandle p(*this);
307  text[0]=0;
308  if ( p->parents.size() == 1 )
309  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
310  else if ( p->parents.size() > 1 ) {
311  text[0]='/';text[1]=0;
312  for(int i : p->parents )
313  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
314  }
315  printout((dd4hep::PrintLevel)level,src,
316  "+++ %s ID:%3d %-12s status:%08X PDG:%6d Vtx:(%+.2e,%+.2e,%+.2e)[mm] "
317  "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
318  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
319  p->vsx/CLHEP::mm,p->vsy/CLHEP::mm,p->vsz/CLHEP::mm,p->time/CLHEP::ns,
320  p->daughters.size(),
321  p->parents.size(),
322  text);
323 }
324 
325 
327 void Geant4ParticleHandle::dumpWithMomentum(int level, const std::string& src, const char* tag) const {
328  char text[256];
329  Geant4ParticleHandle p(*this);
330  text[0]=0;
331  if ( p->parents.size() == 1 )
332  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
333  else if ( p->parents.size() > 1 ) {
334  text[0]='/';text[1]=0;
335  for(int i : p->parents )
336  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
337  }
338  printout((dd4hep::PrintLevel)level,src,
339  "+++%s ID:%3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
340  "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s",
341  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
342  p->psx/CLHEP::MeV,p->psy/CLHEP::MeV,p->psz/CLHEP::MeV,p->time/CLHEP::ns,
343  int(p->daughters.size()),
344  int(p->parents.size()),
345  text);
346 }
347 
349 void Geant4ParticleHandle::dumpWithMomentumAndVertex(int level, const std::string& src, const char* tag) const {
350  char text[256];
351  Geant4ParticleHandle p(*this);
352  text[0]=0;
353  if ( p->parents.size() == 1 )
354  ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin()));
355  else if ( p->parents.size() > 1 ) {
356  text[0]='/';text[1]=0;
357  for(int i : p->parents )
358  ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",i);
359  }
360  printout((dd4hep::PrintLevel)level,src,
361  "+++%s %3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] "
362  "Vtx:(%+.2e,%+.2e,%+.2e)[mm] #Dau:%3d #Par:%1d%-6s",
363  tag,p->id,p.particleName().c_str(),p->status,p->pdgID,
364  p->psx/CLHEP::MeV,p->psy/CLHEP::MeV,p->psz/CLHEP::MeV,
365  p->vsx/CLHEP::mm,p->vsy/CLHEP::mm,p->vsz/CLHEP::mm,
366  int(p->daughters.size()),
367  int(p->parents.size()),
368  text);
369 }
370 
371 void Geant4ParticleHandle::header4(int level, const std::string& src, const char* tag) {
372  printout((dd4hep::PrintLevel)level,src,
373  "+++ %s %10s/%-7s %12s/%-10s %6s/%-6s %4s %4s "
374  "%-4s %-3s %-3s %-10s "
375  "%-5s %-6s %-3s %-3s %-20s %s",
376  tag,"ID", "G4-ID", "Part-Name","PDG", "Parent","G4-ID", "#Par","#Dau",
377  "Prim","Sec",">E","Energy",
378  "EMPTY","STAB","DEC","DOC",
379  "Process", "Processing Flags");
380 }
381 
382 void Geant4ParticleHandle::dump4(int level, const std::string& src, const char* tag) const {
383  using PropertyMask = dd4hep::detail::ReferenceBitMask<int>;
384  Geant4ParticleHandle p(*this);
385  //char equiv[32];
386  PropertyMask mask(p->reason);
387  PropertyMask status(p->status);
388  std::string proc_name = p.processName();
389  std::string proc_type = p.processTypeName();
390  std::string proc = '['+proc_name+(p->process ? "/" : "")+proc_type+']';
391  int parent_id = p->parents.empty() ? -1 : *(p->parents.begin());
392 
393  //equiv[0] = 0;
394  //if ( p->parents.end() == p->parents.find(p->g4Parent) ) {
395  // ::snprintf(equiv,sizeof(equiv),"/%d",p->g4Parent);
396  //}
397  std::stringstream str;
398  str << "Parents: ";
399  for( const auto i : p->parents )
400  str << i << " ";
401  str << " Daughters: ";
402  for( const auto i : p->daughters )
403  str << i << " ";
404  printout((dd4hep::PrintLevel)level,src,
405  "+++ %s ID:%7d/%-7d %12s/%-10d %6d/%-6d %4d %4d %-4s %-3s %-3s %+.3e "
406  "%-5s %-4s %-3s %-3s %-20s %c%c%c%c -- %c%c%c%c%c%c%c%c%c %s",
407  tag,
408  p->id,p->originalG4ID,
409  p.particleName().c_str(),
410  p->pdgID,
411  parent_id,p->g4Parent,
412  p.numParent(),
413  int(p->daughters.size()),
414  yes_no(mask.isSet(G4PARTICLE_PRIMARY)),
415  yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)),
416  yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)),
417  p.energy(),
418  //
419  yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)),
420  yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)),
421  yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)),
422  mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "",
423  proc.c_str(),
424  // 13 flags in total
425  status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', // 1
426  status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.',
427  status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.',
428  status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.',
429  status.isSet(G4PARTICLE_GEN_BEAM) ? 'B' : '.', // 5
430  status.isSet(G4PARTICLE_GEN_OTHER) ? 'o' : '.',
431  status.isSet(G4PARTICLE_SIM_CREATED) ? 's' : '.',
432  status.isSet(G4PARTICLE_SIM_BACKSCATTER) ? 'b' : '.',
433  status.isSet(G4PARTICLE_SIM_PARENT_RADIATED) ? 'v' : '.',
434  status.isSet(G4PARTICLE_SIM_DECAY_TRACKER) ? 't' : '.', // 10
435  status.isSet(G4PARTICLE_SIM_DECAY_CALO) ? 'c' : '.',
436  status.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) ? 'l' : '.',
437  status.isSet(G4PARTICLE_SIM_STOPPED) ? 's' : '.',
438  str.str().c_str()
439  );
440 #if 0
441  printout((dd4hep::PrintLevel)level,src,
442  "+++ %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",
443  tag,
444  p->id,
445  p.particleName().c_str(),
446  parent_id,equiv,
447  yes_no(mask.isSet(G4PARTICLE_PRIMARY)),
448  yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)),
449  int(p->daughters.size()),
450  yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)),
451  p.energy(),
452  yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)),
453  yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)),
454  yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)),
455  mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "",
456  p.numParent(),
457  proc_name.c_str(),
458  p->process ? "/" : "",
459  proc_type.c_str(),
460  status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.',
461  status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.',
462  status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.',
463  status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.',
464  status.isSet(G4PARTICLE_GEN_BEAM) ? 'B' : '.',
465  status.isSet(G4PARTICLE_GEN_OTHER) ? 'o' : '.',
466 
467  status.isSet(G4PARTICLE_SIM_CREATED) ? 's' : '.',
468  status.isSet(G4PARTICLE_SIM_BACKSCATTER) ? 'b' : '.',
469  status.isSet(G4PARTICLE_SIM_PARENT_RADIATED) ? 'v' : '.',
470  status.isSet(G4PARTICLE_SIM_DECAY_TRACKER) ? 't' : '.',
471  status.isSet(G4PARTICLE_SIM_DECAY_CALO) ? 'c' : '.',
472  status.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) ? 'l' : '.',
473  status.isSet(G4PARTICLE_SIM_STOPPED) ? 's' : '.'
474  );
475 #endif
476 }
477 
480  clear();
481 }
482 
485  detail::releaseObjects(particleMap);
486  particleMap.clear();
487  equivalentTracks.clear();
488 }
489 
492  int cnt;
493  char text[64];
494  const Geant4ParticleMap* m = this;
495 
496  cnt = 0;
497  std::cout << "Particle map:" << std::endl;
498  for( const auto& p : m->particleMap ) {
499  std::snprintf(text,sizeof(text)," [%-4d:%p]",p.second->id,(void*)p.second);
500  std::cout << text;
501  if ( ++cnt == 8 ) {
502  std::cout << std::endl;
503  cnt = 0;
504  }
505  }
506  std::cout << std::endl;
507 
508  cnt = 0;
509  std::cout << "Equivalents:" << std::endl;
510  for( const auto& p : m->equivalentTracks ) {
511  std::snprintf(text,sizeof(text)," [%-5d : %-5d]",p.first,p.second);
512  std::cout << text;
513  if ( ++cnt == 8 ) {
514  std::cout << std::endl;
515  cnt = 0;
516  }
517  }
518  std::cout << std::endl;
519 }
520 
523  clear();
524  particleMap = pm;
525  equivalentTracks = equiv;
526  pm.clear();
527  equiv.clear();
528  //dump();
529 }
530 
533  return !equivalentTracks.empty();
534 }
535 
537 int Geant4ParticleMap::particleID(int g4_id, bool) const {
538  TrackEquivalents::const_iterator iequiv = equivalentTracks.find(g4_id);
539  if ( iequiv != equivalentTracks.end() ) return (*iequiv).second;
540  printout(ERROR,"Geant4ParticleMap","+++ No Equivalent particle for track:%d."
541  " Monte Carlo truth record looks broken!",g4_id);
542  dump();
543  return -1;
544 }
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:245
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:260
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:491
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:150
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:304
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:178
dd4hep::sim::Geant4ParticleMap::adopt
void adopt(ParticleMap &pm, TrackEquivalents &equiv)
Adopt particle maps.
Definition: Geant4Particle.cpp:522
dd4hep::sim::Geant4ParticleHandle::processName
std::string processName() const
Access to the creator process name.
Definition: Geant4Particle.cpp:224
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:479
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:349
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:164
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:284
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:382
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:237
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:217
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:537
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:484
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:112
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: EDM4hepFileReader.cpp:41
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:327
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
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: EDM4hepFileReader.cpp:38
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:532
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:371
dd4hep::sim::Geant4Particle::removeDaughter
void removeDaughter(int id_daughter)
Remove daughter from set.
Definition: Geant4Particle.cpp:106
dd4hep::sim::Geant4Particle::ref
int ref
Reference counter.
Definition: Geant4Particle.h:107