DD4hep  1.36.0
Detector Description Toolkit for High Energy Physics
Geant4ParticleHandler.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/Primitives.h>
16 #include <DD4hep/InstanceCount.h>
17 #include <DDG4/Geant4StepHandler.h>
19 #include <DDG4/Geant4EventAction.h>
26 
27 // Geant4 include files
28 #include <G4Step.hh>
29 #include <G4Track.hh>
30 #include <G4Event.hh>
31 #include <G4TrackStatus.hh>
32 #include <G4PrimaryVertex.hh>
33 #include <G4PrimaryParticle.hh>
34 #include <G4TrackingManager.hh>
35 #include <G4ParticleDefinition.hh>
36 #include <CLHEP/Units/SystemOfUnits.h>
37 
38 // C/C++ include files
39 #include <set>
40 #include <algorithm>
41 
42 using namespace dd4hep::sim;
43 using PropertyMask = dd4hep::detail::ReferenceBitMask<int>;
44 using PropertyMaskView = dd4hep::detail::ReferenceBitMask<const int>;
45 
49 {
50  InstanceCount::increment(this);
51  //generatorAction().adopt(this);
52  eventAction().callAtBegin(this, &Geant4ParticleHandler::beginEvent);
53  eventAction().callAtEnd(this, &Geant4ParticleHandler::endEvent);
54  trackingAction().callAtFinal(this, &Geant4ParticleHandler::end,CallbackSequence::FRONT);
55  trackingAction().callUpFront(this, &Geant4ParticleHandler::begin,CallbackSequence::FRONT);
56  steppingAction().call(this, &Geant4ParticleHandler::step);
57  m_globalParticleID = 0;
58  declareProperty("PrintEndTracking", m_printEndTracking = false);
59  declareProperty("PrintStartTracking", m_printStartTracking = false);
60  declareProperty("KeepAllParticles", m_keepAll = false);
61  declareProperty("SaveProcesses", m_processNames);
62  declareProperty("MinimalKineticEnergy", m_kinEnergyCut = 100e0*CLHEP::MeV);
63  declareProperty("MinDistToParentVertex", m_minDistToParentVertex = 2.2e-14*CLHEP::mm);//default tolerance for g4ThreeVector isNear
64  m_needsControl = true;
65 }
66 
68 Geant4ParticleHandler::Geant4ParticleHandler()
70 {
71  m_globalParticleID = 0;
72  declareProperty("PrintEndTracking", m_printEndTracking = false);
73  declareProperty("PrintStartTracking", m_printStartTracking = false);
74  declareProperty("KeepAllParticles", m_keepAll = false);
75  declareProperty("SaveProcesses", m_processNames);
76  declareProperty("MinimalKineticEnergy", m_kinEnergyCut = 100e0*CLHEP::MeV);
77  declareProperty("MinDistToParentVertex", m_minDistToParentVertex = 2.2e-14*CLHEP::mm);//default tolerance for g4ThreeVector isNear
78  m_needsControl = true;
79 }
80 
82 Geant4ParticleHandler::~Geant4ParticleHandler() {
83  clear();
84  for( auto* h : this->m_userHandlers )
85  detail::releasePtr(h);
86  this->m_userHandlers.clear();
88 }
89 
92  return *this;
93 }
94 
97  if ( action ) {
98  if ( Geant4UserParticleHandler* h = dynamic_cast<Geant4UserParticleHandler*>(action) ) {
99  this->m_userHandlers.push_back(h);
100  h->addRef();
101  return true;
102  }
103  except("Cannot add an user particle handler object [Object-exists].");
104  }
105  except("Cannot add an invalid user particle handler object [NULL-object].");
106  return false;
107 }
108 
111  detail::releaseObjects(m_particleMap);
112  m_particleMap.clear();
113  // m_suspendedPM should already be empty and cleared...
114  assert(m_suspendedPM.empty() && "There was something wrong with the particle record treatment, please open a bug report!");
115  m_equivalentTracks.clear();
116 }
117 
119 void Geant4ParticleHandler::mark(const G4Track* track, int reason) {
120  if ( track ) {
121  if ( reason != 0 ) {
122  PropertyMask(m_currTrack.reason).set(reason);
123  return;
124  }
125  }
126  except("Cannot mark the G4Track if the pointer is invalid!");
127 }
128 
130 void Geant4ParticleHandler::mark(const G4Step* step_value, int reason) {
131  if ( step_value ) {
132  mark(step_value->GetTrack(),reason);
133  return;
134  }
135  except("Cannot mark the G4Track if the step-pointer is invalid!");
136 }
137 
139 void Geant4ParticleHandler::mark(const G4Step* step_value) {
140  if ( step_value ) {
141  this->mark(step_value->GetTrack());
142  return;
143  }
144  except("Cannot mark the G4Track if the step-pointer is invalid!");
145 }
146 
148 void Geant4ParticleHandler::mark(const G4Track* track) {
150  mask.set(G4PARTICLE_CREATED_HIT);
152  // If yes, flag it, because it is a candidate for removal.
153  G4LogicalVolume* vol = track->GetVolume()->GetLogicalVolume();
154  // Volume is never null since track is always within the world volume
155  G4VSensitiveDetector* g4 = vol->GetSensitiveDetector();
156  Geant4ActionSD* sd = dynamic_cast<Geant4ActionSD*>(g4);
157  if( sd ) {
158  std::string typ = sd->sensitiveType();
159 
160  if ( typ == "calorimeter" ) {
162  }
163  else if ( typ == "tracker" ) {
164  mask.set( G4PARTICLE_CREATED_TRACKER_HIT );
165  }
166  else { // Assume by default "tracker"
167  mask.set( G4PARTICLE_CREATED_TRACKER_HIT );
168  }
169  }
170  if( !this->m_userHandlers.empty() ) {
171  for( auto* h : this->m_userHandlers )
172  h->mark_track( track, &m_currTrack );
173  }
174 }
175 
176 
177 
178 
180 void Geant4ParticleHandler::operator()(G4Event* event) {
181  typedef Geant4MonteCarloTruth _MC;
182  debug("+++ Event:%d Add EVENT extension of type Geant4ParticleHandler.....",event->GetEventID());
183  context()->event().addExtension((_MC*)this, false);
184  clear();
186  for( auto* h : this->m_userHandlers )
187  h->generate(event, this);
188 }
189 
191 void Geant4ParticleHandler::step(const G4Step* step_value, G4SteppingManager* mgr) {
192  typedef std::vector<const G4Track*> _Sec;
193  ++m_currTrack.steps;
195  //
196  // Tracks below the energy threshold are NOT stored.
197  // If these tracks produce hits or are selected due to another signature,
198  // this criterium will anyhow take precedence.
199  //
200  const _Sec* sec=step_value->GetSecondaryInCurrentStep();
201  if ( not sec->empty() ) {
203  }
204  }
206  for( auto* h : this->m_userHandlers )
207  h->step(step_value, mgr, m_currTrack);
208 }
209 
211 void Geant4ParticleHandler::begin(const G4Track* track) {
212  Geant4TrackHandler h(track);
213  double kine = h.kineticEnergy();
214  G4ThreeVector mom = h.momentum();
215  const G4ThreeVector& v = h.vertex();
216  int reason = (kine > m_kinEnergyCut) ? G4PARTICLE_ABOVE_ENERGY_THRESHOLD : 0;
217  const G4PrimaryParticle* prim = h.primary();
218  Particle* prim_part = 0;
219 
220  // if particles are not tracked to the end, we pick up where we stopped previously
221  if ( m_haveSuspended ) {
222  // primary particles are already in the particle map, we don't have to store them in another map
223  auto existingParticle = m_particleMap.find(h.id());
224  if ( existingParticle != m_particleMap.end() ) {
225  m_currTrack.get_data(*(existingParticle->second));
226  return;
227  }
228  //other particles might not be in the particleMap yet, so we take them from here
229  existingParticle = m_suspendedPM.find(h.id());
230  if ( existingParticle != m_suspendedPM.end() ) {
231  m_currTrack.get_data(*(existingParticle->second));
232  // make sure we delete a suspended particle in the map, fill it back later...
233  delete (*existingParticle).second;
234  m_suspendedPM.erase(existingParticle);
235  return;
236  }
237  }
238 
239  if ( prim ) {
240  prim_part = m_primaryMap->get(prim);
241  if ( !prim_part ) {
242  except("+++ Tracking preaction: Primary particle without generator particle!");
243  }
245  m_particleMap[h.id()] = prim_part->addRef();
246  }
247 
248  if ( prim_part ) {
249  m_currTrack.id = prim_part->id;
250  m_currTrack.reason = prim_part->reason|reason;
251  m_currTrack.mask = prim_part->mask;
252  m_currTrack.status = prim_part->status;
253  m_currTrack.genStatus = prim_part->genStatus;
254  m_currTrack.spin[0] = prim_part->spin[0];
255  m_currTrack.spin[1] = prim_part->spin[1];
256  m_currTrack.spin[2] = prim_part->spin[2];
257  m_currTrack.colorFlow[0] = prim_part->colorFlow[0];
258  m_currTrack.colorFlow[1] = prim_part->colorFlow[1];
259  m_currTrack.parents = prim_part->parents;
260  m_currTrack.daughters = prim_part->daughters;
261  m_currTrack.pdgID = prim_part->pdgID;
262  m_currTrack.mass = prim_part->mass;
263  m_currTrack.charge = int(3.0 * h.charge());
264  }
265  else {
267  m_currTrack.reason = reason;
268  m_currTrack.mask = 0;
271  m_currTrack.spin[0] = 0;
272  m_currTrack.spin[1] = 0;
273  m_currTrack.spin[2] = 0;
274  m_currTrack.colorFlow[0] = 0;
275  m_currTrack.colorFlow[1] = 0;
276  m_currTrack.parents.clear();
277  m_currTrack.daughters.clear();
278  m_currTrack.pdgID = h.pdgID();
279  m_currTrack.mass = h.mass();
280  m_currTrack.charge = int(3.0 * h.charge());
282  }
283  m_currTrack.steps = 0;
285  m_currTrack.g4Parent = h.parent();
286  m_currTrack.originalG4ID= h.id();
287  m_currTrack.process = h.creatorProcess();
288  m_currTrack.time = h.globalTime();
289  m_currTrack.vsx = v.x();
290  m_currTrack.vsy = v.y();
291  m_currTrack.vsz = v.z();
292  m_currTrack.vex = 0.0;
293  m_currTrack.vey = 0.0;
294  m_currTrack.vez = 0.0;
295  m_currTrack.psx = mom.x();
296  m_currTrack.psy = mom.y();
297  m_currTrack.psz = mom.z();
298  m_currTrack.pex = 0.0;
299  m_currTrack.pey = 0.0;
300  m_currTrack.pez = 0.0;
301 
303  // If the creator process of the track is in the list of process products to be kept, set the proper flag
304  if ( m_currTrack.process ) {
305  Processes::iterator i=find(m_processNames.begin(),m_processNames.end(),m_currTrack.process->GetProcessName());
306  if ( i != m_processNames.end() ) {
307  mask.set(G4PARTICLE_KEEP_PROCESS);
308  }
309  }
310  if ( m_keepAll ) {
311  mask.set(G4PARTICLE_KEEP_ALWAYS);
312  }
313 
314  G4LogicalVolume* vol = track->GetVolume()->GetLogicalVolume();
315  // Volume is never null since track is always within the world volume
316  G4VSensitiveDetector* g4 = vol->GetSensitiveDetector();
317  if( Geant4ActionSD* sd = dynamic_cast<Geant4ActionSD*>(g4) ) {
318  std::string typ = sd->sensitiveType();
319  if( typ == "calorimeter" ) {
321  }
322  }
323 
325  for( auto* handler : this->m_userHandlers )
326  handler->begin(track, m_currTrack);
327 }
328 
330 void Geant4ParticleHandler::end(const G4Track* track) {
331  Geant4TrackHandler h(track);
333  const int g4_id = h.id();
334 
335  int32_t track_reason = m_currTrack.reason;
337  // Update vertex end point and final momentum
338  G4ThreeVector mom = track->GetMomentum();
339  const G4ThreeVector& pos = track->GetPosition();
340  ph->pex = mom.x();
341  ph->pey = mom.y();
342  ph->pez = mom.z();
343  ph->vex = pos.x();
344  ph->vey = pos.y();
345  ph->vez = pos.z();
346 
347  // Set the simulator status bits
348  PropertyMask simStatus(m_currTrack.status);
349 
350  // check if the last step ended on the worldVolume boundary
351  const G4Step* theLastStep = track->GetStep();
352  G4StepPoint* theLastPostStepPoint = NULL;
353  if( theLastStep ) theLastPostStepPoint = theLastStep->GetPostStepPoint();
354  if( theLastPostStepPoint &&
355  ( theLastPostStepPoint->GetStepStatus() == fWorldBoundary //particle left world volume
356  //|| theLastPostStepPoint->GetStepStatus() == fGeomBoundary
357  )
358  ) {
359  simStatus.set(G4PARTICLE_SIM_LEFT_DETECTOR);
360  }
361 
362  if( track->GetKineticEnergy() <= 0. ) {
363  simStatus.set(G4PARTICLE_SIM_STOPPED);
364  }
365 
366  PropertyMask reason_mask(track_reason);
367  if( reason_mask.isSet( G4PARTICLE_STARTED_IN_CALORIMETER ) ) {
368  std::string end_volume_type;
369  bool calo_hits = reason_mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT);
370  bool tracker_hits = reason_mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT);
371  G4LogicalVolume* vol = track->GetVolume()->GetLogicalVolume();
372  // Volume is never null since track is always within the world volume
373  G4VSensitiveDetector* g4 = vol->GetSensitiveDetector();
374  if( Geant4ActionSD* sd = dynamic_cast<Geant4ActionSD*>(g4) ) {
375  end_volume_type = sd->sensitiveType();
376  }
377  if( tracker_hits || end_volume_type == "tracker" ) {
378  reason_mask.set(G4PARTICLE_SIM_BACKSCATTER);
379  debug("+++ Track: %6d back-scattered to tracking volume. Origin: calorimeter End: %s "
380  "CALO-hits:%s TRACKER-hits:%s --> keep particle in MC history",
381  g4_id, end_volume_type.c_str(), yes_no(calo_hits), yes_no(tracker_hits));
382  }
383  }
384 
386  for( auto* handler : this->m_userHandlers )
387  handler->end(track, m_currTrack);
388 
389  //
390  // These are candidate tracks with a probability to be stored due to their properties:
391  // - primary particle
392  // - hits created
393  // - secondaries
394  // - above energy threshold
395  // - to be kept due to creator process
396  // - to be kept due to user information of type 'Geant4ParticleInformation' stored in the G4Track
397  //
398  Geant4ParticleInformation* track_info =
399  dynamic_cast<Geant4ParticleInformation*>(track->GetUserInformation());
400  if( !mask.isNull() || track_info || reason_mask.isSet(G4PARTICLE_SIM_BACKSCATTER) ) {
401  m_equivalentTracks[g4_id] = g4_id;
402  ParticleMap::iterator ip = m_particleMap.find(g4_id);
403  if( mask.isSet(G4PARTICLE_PRIMARY) ) {
404  ph.dump2(outputLevel()-1,name(),"Add Primary", h.id(), ip != m_particleMap.end());
405  }
406  if( reason_mask.isSet(G4PARTICLE_SIM_BACKSCATTER) ) {
407  mask.set(G4PARTICLE_KEEP_ALWAYS);
408  info("+++ Track: %6d Particle back-scattering to tracker --> keep particle in MC history.", g4_id);
409  }
410  // Create a new MC particle from the current track information saved in the pre-tracking action
411  Particle* part = 0;
412  if( ip==m_particleMap.end() ) part = m_particleMap[g4_id] = new Particle();
413  else part = (*ip).second;
414  if( track_info ) {
415  mask.set(G4PARTICLE_KEEP_USER);
416  part->extension.reset(track_info->release());
417  }
418  part->get_data(m_currTrack);
419  }
420  else {
421  // These are tracks without any special properties.
422  //
423  // We will not store them on the record, but have to memorise the
424  // track identifier in order to restore the history for the created hits.
425  int pid = m_currTrack.g4Parent;
426  m_equivalentTracks[g4_id] = pid;
427  // Need to find the last stored particle and OR this particle's mask
428  // with the mask of the last stored particle
429  auto iend = m_equivalentTracks.end(), iequiv=m_equivalentTracks.end();
430  ParticleMap::iterator ip;
431  for(ip=m_particleMap.find(pid); ip == m_particleMap.end(); ip=m_particleMap.find(pid)) {
432  if (iequiv=m_equivalentTracks.find(pid); iequiv == iend) break; // ERROR
433  pid = (*iequiv).second;
434  }
435  if ( ip != m_particleMap.end() )
436  (*ip).second->reason |= track_reason;
437  else
438  ph.dumpWithVertex(outputLevel()+3,name(),"FATAL: No real particle parent present");
439  }
440 
441  if( track->GetTrackStatus() == fSuspend ) {
442  m_haveSuspended = true;
443  //track is already in particle map, we pick it up from there in begin again
444  if(m_particleMap.find(g4_id) != m_particleMap.end()) return;
445  //track is not already stored, keep it in special map
446  auto iPart = m_suspendedPM.emplace(g4_id, new Particle());
447  (iPart.first->second)->get_data(m_currTrack);
448  return; // we trust that we eventually return to this function with another status and go on then
449  }
450 
451 }
452 
454 void Geant4ParticleHandler::beginEvent(const G4Event* event) {
456  info("+++ Event %d Begin event action. Access event related information.",event->GetEventID());
458  m_globalParticleID = interaction->nextPID();
459  m_particleMap.clear();
460  m_equivalentTracks.clear();
462  for( auto* h : this->m_userHandlers )
463  h->begin(event);
464 }
465 
467 void Geant4ParticleHandler::dumpMap(const char* tag) const {
468  const std::string& n = name();
469  Geant4ParticleHandle::header4(INFO,n,tag);
470  for(ParticleMap::const_iterator iend=m_particleMap.end(), i=m_particleMap.begin(); i!=iend; ++i) {
471  Geant4ParticleHandle((*i).second).dump4(INFO,n,tag);
472  }
473 }
474 
476 void Geant4ParticleHandler::endEvent(const G4Event* event) {
477  int count = 0;
478  int level = outputLevel();
479  do {
480  if ( level <= VERBOSE ) dumpMap("Particle ");
481  debug("+++ Iteration:%d Tracks:%d Equivalents:%d",++count,m_particleMap.size(),m_equivalentTracks.size());
482  } while( recombineParents() > 0 );
483 
484  if ( level <= VERBOSE ) dumpMap( "Recombined");
485  // Rebase the simulated tracks, so that they fit to the generator particles
487  if ( level <= VERBOSE ) dumpMap( "Rebased ");
488  // Consistency check....
491  for( auto* h : this->m_userHandlers )
492  h->end(event);
494 
495  // Now export the data to the final record.
498  m_primaryMap = 0;
499  clear();
500 }
501 
505  TrackEquivalents equivalents, orgParticles;
506  ParticleMap finalParticles;
507  ParticleMap::const_iterator ipar, iend, i;
508  int count;
509 
511  ParticleMap& pm = interaction->particles;
512 
513  // (1.0) Copy the pre-defined particle mapping for the simulated tracks
514  // It is assumed the mapping is ZERO based without holes.
515  for(count = 0, iend=pm.end(), i=pm.begin(); i!=iend; ++i) {
516  Particle* p = (*i).second;
517  orgParticles[p->id] = p->id;
518  finalParticles[p->id] = p;
519  if ( p->id > count ) count = p->id;
520  if ( (p->reason&G4PARTICLE_PRIMARY) != G4PARTICLE_PRIMARY ) {
521  p->addRef();
522  }
523  }
524  // (1.1) Define the new particle mapping for the simulated tracks
525  for(++count, iend=m_particleMap.end(), i=m_particleMap.begin(); i!=iend; ++i) {
526  Particle* p = (*i).second;
527  if ( (p->reason&G4PARTICLE_PRIMARY) != G4PARTICLE_PRIMARY ) {
528  //if ( orgParticles.find(p->id) == orgParticles.end() ) {
529  orgParticles[p->id] = count;
530  finalParticles[count] = p;
531  p->id = count;
532  ++count;
533  }
534  }
535  // (2) Re-evaluate the corresponding geant4 track equivalents using the new mapping
536  for(TrackEquivalents::iterator ie=m_equivalentTracks.begin(),ie_end=m_equivalentTracks.end(); ie!=ie_end; ++ie) {
537  int g4_equiv = (*ie).first;
538  while( (ipar=m_particleMap.find(g4_equiv)) == m_particleMap.end() ) {
539  TrackEquivalents::const_iterator iequiv = m_equivalentTracks.find(g4_equiv);
540  if ( iequiv == ie_end ) {
541  break; // ERROR !! Will be handled by printout below because ipar==end()
542  }
543  g4_equiv = (*iequiv).second;
544  }
545  TrackEquivalents::mapped_type equiv = (*ie).second;
546  if ( ipar != m_particleMap.end() ) {
547  Geant4ParticleHandle p = (*ipar).second;
548  equivalents[(*ie).first] = p->id; // requires (1) to be filled properly!
549  const G4ParticleDefinition* def = p.definition();
550  int pdg = int(std::abs(def->GetPDGEncoding())+0.1);
551  if ( pdg != 0 && pdg<36 && !(pdg > 10 && pdg < 17) && pdg != 22 ) {
552  error("+++ ERROR: Geant4 particle for track:%d last known is:%d -- is gluon or quark!",equiv,g4_equiv);
553  }
554  pdg = int(std::abs(p->pdgID)+0.1);
555  if ( pdg != 0 && pdg<36 && !(pdg > 10 && pdg < 17) && pdg != 22 ) {
556  error("+++ ERROR(2): Geant4 particle for track:%d last known is:%d -- is gluon or quark!",equiv,g4_equiv);
557  }
558  }
559  else {
560  error("+++ No Equivalent particle for track:%d last known is:%d",equiv,g4_equiv);
561  }
562  }
563 
564  // (3) Compute the particle's parents and daughters.
565  // Replace the original Geant4 track with the
566  // equivalent particle still present in the record.
567  // Note:
568  // We rely here on the ordering of the particles accoding to their
569  // Processing by Geant4 to establish mother daughter relationships.
570  // == > use finalParticles map and NOT m_particleMap.
571  int equiv_id = -1;
572  for( auto& part : finalParticles ) {
573  auto& p = part.second;
574  if ( p->g4Parent > 0 ) {
575  TrackEquivalents::iterator iequ = equivalents.find(p->g4Parent);
576  if ( iequ != equivalents.end() ) {
577  equiv_id = (*iequ).second;//equivalents[p->g4Parent];
578  if ( (ipar=finalParticles.find(equiv_id)) != finalParticles.end() ) {
579  Particle* q = (*ipar).second;
580  bool prim = (p->reason&G4PARTICLE_PRIMARY) == G4PARTICLE_PRIMARY;
581  // We assume that the mother daughter relationship
582  // is filled by the event readers!
583  if ( !prim ) {
584  p->parents.insert(q->id);
585  }
586  if ( !p->parents.empty() ) {
587  int parent_id = (*p->parents.begin());
588  if ( parent_id == q->id )
589  q->daughters.insert(p->id);
590  else if ( !prim )
591  error("+++ Inconsistency in equivalent record! Parent: %d Daughter:%d",q->id, p->id);
592  }
593  else {
594  error("+++ Inconsistency in parent relashionship: %d NO parent!", p->id);
595  }
596  continue;
597  }
598  }
599  error("+++ Inconsistency in particle record: Geant4 parent %d "
600  "of particle %d not in record of final particles!",
601  p->g4Parent,p->id);
602  }
603  }
604 #if 0
605  for(iend=finalParticles.end(), i=finalParticles.begin(); i!=iend; ++i) {
606  Particle* p = (*i).second;
607  if ( p->g4Parent > 0 ) {
608  int parent_id = (*p->parents.begin());
609  if ( (ipar=finalParticles.find(parent_id)) != finalParticles.end() ) {
610  Particle* q = (*ipar).second;
611  // Generator particles have a proper history.
612  // We only deal with particles, which are not of MC origin.
613  //p->parents.insert(q->id);
614  if ( parent_id == q->id )
615  q->daughters.insert(p->id);
616  else
617  error("+++ Inconsistency in equivalent record! Parent: %d Daughter:%d",q->id, p->id);
618  continue;
619  }
620  error("+++ Inconsistency in particle record: Geant4 parent %d "
621  "of particle %d not in record of final particles!",
622  p->g4Parent,p->id);
623  }
624  }
625 #endif
626  m_equivalentTracks = std::move(equivalents);
627  m_particleMap = std::move(finalParticles);
628 }
629 
631 bool Geant4ParticleHandler::defaultDropParticle(const Particle& particle) {
632  PropertyMaskView mask(particle.reason);
633  bool backscatter = mask.isSet(G4PARTICLE_SIM_BACKSCATTER);
634  bool secondaries = mask.isSet(G4PARTICLE_HAS_SECONDARIES);
635  bool tracker_track = mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT);
636  bool calo_track = mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT);
637  bool hits_produced = mask.isSet(G4PARTICLE_CREATED_HIT);
638  bool low_energy = !mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD);
639 
641  if ( backscatter ) {
642  return false;
643  }
645  else if ( mask.isNull() || (secondaries && low_energy && !hits_produced) ) {
646  return true;
647  }
649  else if ( !hits_produced && low_energy ) {
650  return true;
651  }
653  else if ( !tracker_track && calo_track && low_energy ) {
654  return true;
655  }
656  else {
657  // printout(INFO,name(),"+++ Track: %d should be kept for no obvious reason....",id);
658  }
659  return false;
660 }
661 
665  std::set<int> remove;
666 
668  for(ParticleMap::reverse_iterator i=m_particleMap.rbegin(); i!=m_particleMap.rend(); ++i) {
669  Particle* p = (*i).second;
670  PropertyMask mask(p->reason);
671  // Allow the user to force the particle handling either by
672  // or the reason mask with G4PARTICLE_KEEP_USER or
673  // to set the reason mask to NULL in order to drop it.
674  //
675  // If the mask entry is set to G4PARTICLE_FORCE_KILL
676  // or is set to NULL, the particle is ALWAYS removed
677  //
678  // Note: This may override all other decisions!
679  bool remove_me = false;
680  if ( !this->m_userHandlers.empty() ) {
681  for( auto* h : this->m_userHandlers )
682  remove_me |= h->dropParticle(*p);
683  } else {
684  remove_me = defaultDropParticle(*p);
685  }
686 
687  // Now look at the property mask of the particle
688  if ( mask.isNull() || mask.isSet(G4PARTICLE_FORCE_KILL) ) {
689  remove_me = true;
690  }
691  else if ( mask.isSet(G4PARTICLE_KEEP_USER) ) {
693  mask.set(G4PARTICLE_KEEP_USER);
694  continue;
695  }
696  else if ( mask.isSet(G4PARTICLE_PRIMARY) ) {
698  continue;
699  }
700  else if ( mask.isSet(G4PARTICLE_KEEP_ALWAYS) ) {
701  continue;
702  }
703  else if ( mask.isSet(G4PARTICLE_KEEP_PARENT) ) {
704  //continue;
705  }
706  else if ( mask.isSet(G4PARTICLE_KEEP_PROCESS) ) {
707  if(ParticleMap::iterator ip = m_particleMap.find(p->g4Parent); ip != m_particleMap.end() ) {
708  Particle* parent_part = (*ip).second;
709  PropertyMask parent_mask(parent_part->reason);
710  if ( parent_mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) {
711  parent_mask.set(G4PARTICLE_KEEP_PARENT);
712  continue;
713  }
714  }
715  // Low energy stuff. Remove it. Reassign to parent.
716  //remove_me = true;
717  }
718 
720  if ( remove_me ) {
721  int g4_id = (*i).first;
722  remove.insert(g4_id);
723  m_equivalentTracks[g4_id] = p->g4Parent;
724  if(ParticleMap::iterator ip = m_particleMap.find(p->g4Parent); ip != m_particleMap.end() ) {
725  Particle* parent_part = (*ip).second;
726  PropertyMask(parent_part->reason).set(mask.value());
727  parent_part->steps += p->steps;
728  parent_part->secondaries += p->secondaries;
730  for( auto* h : this->m_userHandlers )
731  h->combine(*p, *parent_part);
732  }
733  }
734  }
735  for( int r : remove ) {
736  if( auto ir = m_particleMap.find(r); ir != m_particleMap.end() ) {
737  (*ir).second->release();
738  m_particleMap.erase(ir);
739  }
740  }
741  return int(remove.size());
742 }
743 
746  int num_errors = 0;
747 
749  for(const auto& part : m_particleMap ) {
750  Geant4Particle* particle = part.second;
751  Geant4ParticleHandle p(particle);
752  PropertyMask mask(p->reason);
753  PropertyMask status(p->status);
754  std::set<int>& daughters = p->daughters;
755  ParticleMap::const_iterator j;
756  // For all particles, the set of daughters must be contained in the record.
757  for( int id_dau : daughters ) {
758  if ( j=m_particleMap.find(id_dau); j == m_particleMap.end() ) {
759  ++num_errors;
760  error("+++ Particle:%d Daughter %d is not in particle map!",p->id,id_dau);
761  }
762  }
763  // We assume that particles from the generator have consistent parents
764  // For all other particles except the primaries, the parent must be contained in the record.
765  if ( !mask.isSet(G4PARTICLE_PRIMARY) && !status.anySet(G4PARTICLE_GEN_STATUS) ) {
766  bool in_map = false, in_parent_list = false;
767  int parent_id = -1;
768  if( auto eq_it=m_equivalentTracks.find(p->g4Parent); eq_it != m_equivalentTracks.end() ) {
769  parent_id = (*eq_it).second;
770  in_map = (j=m_particleMap.find(parent_id)) != m_particleMap.end();
771  in_parent_list = p->parents.find(parent_id) != p->parents.end();
772  }
773  if ( !in_map || !in_parent_list ) {
774  char parent_list[1024];
775  parent_list[0] = 0;
776  ++num_errors;
777  p.dumpWithMomentum(ERROR,name(),"INCONSISTENCY");
778  for( int ip : p->parents )
779  ::snprintf(parent_list+strlen(parent_list),sizeof(parent_list)-strlen(parent_list),"%d ",ip);
780  error("+++ Particle:%d Parent %d (G4id:%d) In record:%s In parent list:%s [%s]",
781  p->id,parent_id,p->g4Parent,yes_no(in_map),yes_no(in_parent_list),parent_list);
782  }
783  }
784  }
785 
786  if ( num_errors > 0 ) {
787  except("+++ Consistency check failed. Found %d problems.",num_errors);
788  }
789 }
790 
792  for( auto& part : m_particleMap ) {
793  auto* p = part.second;
794  if( !p->parents.empty() ) {
795  PropertyMask mask(p->status);
796  //if the particle did not go to geant4 none of these flags is set
797  // we shouldn't set the vertex bit in this case.
798  if(not mask.anySet(G4PARTICLE_SIM_CREATED
804  continue;
805  }
806  Geant4Particle *parent(m_particleMap[ *p->parents.begin() ]);
807  const double X( parent->vex - p->vsx );
808  const double Y( parent->vey - p->vsy );
809  const double Z( parent->vez - p->vsz );
810  if( sqrt(X*X + Y*Y + Z*Z) > m_minDistToParentVertex ){
812  }
813  }
814  }
815 }
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:86
dd4hep::sim::G4PARTICLE_CREATED_TRACKER_HIT
@ G4PARTICLE_CREATED_TRACKER_HIT
Definition: Geant4Particle.h:64
dd4hep::sim::Geant4ParticleHandler::endEvent
virtual void endEvent(const G4Event *event)
Post-event action callback.
dd4hep::sim::Geant4ParticleHandler::m_keepAll
bool m_keepAll
Property: Flag to keep all particles generated.
Definition: Geant4ParticleHandler.h:99
dd4hep::sim::Geant4ParticleHandler::Geant4ParticleHandler
Geant4ParticleHandler()
No default constructor.
Geant4TrackHandler.h
dd4hep::sim::Geant4PrimaryMap
Data structure to map primaries to particles.
Definition: Geant4Primary.h:64
dd4hep::sim::Geant4PrimaryInteraction::nextPID
int nextPID()
Access a new particle identifier within the interaction.
Definition: Geant4Primary.cpp:65
dd4hep::sim::Geant4ParticleHandler::Particle
Geant4ParticleMap::Particle Particle
Definition: Geant4ParticleHandler.h:74
dd4hep::sim::G4PARTICLE_ABOVE_ENERGY_THRESHOLD
@ G4PARTICLE_ABOVE_ENERGY_THRESHOLD
Definition: Geant4Particle.h:60
dd4hep::sim::Geant4Particle::vsz
double vsz
Definition: Geant4Particle.h:125
dd4hep::sim::G4PARTICLE_KEEP_PARENT
@ G4PARTICLE_KEEP_PARENT
Definition: Geant4Particle.h:62
dd4hep::sim::Geant4Particle::reason
int reason
Definition: Geant4Particle.h:112
Geant4ParticleHandler
Geant4Action to collect the MC particle information.
dd4hep::sim::G4PARTICLE_SIM_PARENT_RADIATED
@ G4PARTICLE_SIM_PARENT_RADIATED
Definition: Geant4Particle.h:92
v
View * v
Definition: MultiView.cpp:28
dd4hep::sim::Geant4Particle::mass
double mass
Particle mass.
Definition: Geant4Particle.h:133
dd4hep::sim::Geant4ParticleHandler::recombineParents
int recombineParents()
Recombine particles and associate the to parents with cleanup.
dd4hep::sim::Geant4Particle::vey
double vey
Definition: Geant4Particle.h:127
dd4hep::sim::Geant4Particle::pez
double pez
Definition: Geant4Particle.h:131
dd4hep::sim::Geant4ParticleHandler::m_primaryMap
Geant4PrimaryMap * m_primaryMap
Primary map.
Definition: Geant4ParticleHandler.h:117
dd4hep::sim::Geant4ParticleInformation::release
ParticleExtension * release()
Definition: Geant4ParticleInformation.h:86
dd4hep::sim::G4PARTICLE_KEEP_USER
@ G4PARTICLE_KEEP_USER
Definition: Geant4Particle.h:65
dd4hep::sim::Geant4PrimaryInteraction
Class modelling a single interaction with multiple primary vertices and particles.
Definition: Geant4Primary.h:95
dd4hep::sim::G4PARTICLE_KEEP_PROCESS
@ G4PARTICLE_KEEP_PROCESS
Definition: Geant4Particle.h:61
dd4hep::sim::Geant4ParticleHandler::m_processNames
Processes m_processNames
Property: All the processes of which the decay products will be explicitly stored.
Definition: Geant4ParticleHandler.h:107
dd4hep::sim::Geant4Particle::id
int id
not persistent
Definition: Geant4Particle.h:109
dd4hep::sim::Geant4ParticleHandler::operator=
Geant4ParticleHandler & operator=(const Geant4ParticleHandler &c)
No assignment operator.
Geant4SensDetAction.h
Geant4TrackingAction.h
dd4hep::sim::Geant4ParticleMap::adopt
void adopt(ParticleMap &pm, TrackEquivalents &equiv)
Adopt particle maps.
Definition: Geant4Particle.cpp:522
Geant4EventAction.h
dd4hep::sim::Geant4ParticleHandler::checkConsistency
void checkConsistency() const
Check the record consistency.
dd4hep::sim::Geant4ParticleHandler::begin
virtual void begin(const G4Track *track)
Pre-track action callback.
dd4hep::sim::Geant4Particle::pdgID
int pdgID
Definition: Geant4Particle.h:116
dd4hep::sim::Geant4Particle::g4Parent
int g4Parent
not persistent
Definition: Geant4Particle.h:111
dd4hep::sim::Geant4Particle::psz
double psz
Definition: Geant4Particle.h:129
dd4hep::sim::G4PARTICLE_CREATED_HIT
@ G4PARTICLE_CREATED_HIT
Definition: Geant4Particle.h:57
dd4hep::sim::Geant4PrimaryInteraction::particles
ParticleMap particles
The map of particles participating in this primary interaction.
Definition: Geant4Primary.h:112
dd4hep::sim::Geant4ParticleHandler::step
virtual void step(const G4Step *step, G4SteppingManager *mgr)
User stepping callback.
dd4hep::sim::Geant4Context::event
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition: Geant4Context.cpp:84
Geant4StepHandler.h
dd4hep::sim::Geant4Particle::secondaries
int secondaries
Definition: Geant4Particle.h:115
Geant4UserParticleHandler.h
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition: Geant4Particle.h:87
Geant4SteppingAction.h
dd4hep::sim::Geant4ParticleHandler::m_equivalentTracks
TrackEquivalents m_equivalentTracks
Map associating the G4Track identifiers with identifiers of existing MCParticles.
Definition: Geant4ParticleHandler.h:126
dd4hep::sim::Geant4ParticleHandler::m_suspendedPM
ParticleMap m_suspendedPM
Map with stored MC Particles that were suspended by the stepping action.
Definition: Geant4ParticleHandler.h:123
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: Geant4ParticleHandler.cpp:43
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:338
dd4hep::sim::Geant4Action::info
void info(const char *fmt,...) const
Support of info messages.
Definition: Geant4Action.cpp:215
dd4hep::sim::Geant4Event::extension
T * extension(bool alert=true)
Access to type safe extension object. Exception is thrown if the object is invalid.
Definition: Geant4Context.h:151
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
dd4hep::sim::Geant4ParticleHandler::m_userHandlers
std::vector< Geant4UserParticleHandler * > m_userHandlers
User action pointer.
Definition: Geant4ParticleHandler.h:111
dd4hep::sim::G4PARTICLE_SIM_STOPPED
@ G4PARTICLE_SIM_STOPPED
Definition: Geant4Particle.h:90
dd4hep::sim::Geant4ParticleHandler::dumpMap
void dumpMap(const char *tag) const
Debugging: Dump Geant4 particle map.
Geant4UserParticleHandler
Geant4ParticleHandler user extension action called by the particle handler.
dd4hep::sim::Geant4Action::error
void error(const char *fmt,...) const
Support of error messages.
Definition: Geant4Action.cpp:231
Geant4ParticleInformation.h
dd4hep::sim::Geant4Particle::vez
double vez
Definition: Geant4Particle.h:127
Geant4ParticleHandler.h
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition: Geant4Particle.h:88
dd4hep::sim::Geant4ParticleHandler::rebaseSimulatedTracks
void rebaseSimulatedTracks(int base)
Rebase the simulated tracks, so that they fit to the generator particles.
dd4hep::sim::Geant4ParticleHandler::TrackEquivalents
Geant4ParticleMap::TrackEquivalents TrackEquivalents
Definition: Geant4ParticleHandler.h:76
G4VSensitiveDetector
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:59
dd4hep::sim::G4PARTICLE_KEEP_ALWAYS
@ G4PARTICLE_KEEP_ALWAYS
Definition: Geant4Particle.h:66
dd4hep::sim::Geant4Particle::colorFlow
int colorFlow[2]
Definition: Geant4Particle.h:118
dd4hep::sim::Geant4Particle::spin
float spin[3]
Definition: Geant4Particle.h:122
dd4hep::sim::G4PARTICLE_GEN_STATUS
@ G4PARTICLE_GEN_STATUS
Definition: Geant4Particle.h:83
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4MonteCarloTruth
Default Interface class to handle monte carlo truth records.
Definition: Geant4MonteCarloTruth.h:43
dd4hep::sim::Geant4Particle::genStatus
unsigned short genStatus
Definition: Geant4Particle.h:119
dd4hep::sim::Geant4GeneratorAction
Concrete implementation of the Geant4 generator action base class.
Definition: Geant4GeneratorAction.h:47
dd4hep::sim::Geant4ParticleHandler::m_minDistToParentVertex
double m_minDistToParentVertex
Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set.
Definition: Geant4ParticleHandler.h:105
dd4hep::sim::Geant4ParticleHandler::adopt
bool adopt(Geant4Action *action)
Adopt the user particle handler.
PropertyMaskView
dd4hep::detail::ReferenceBitMask< const int > PropertyMaskView
Definition: Geant4ParticleHandler.cpp:44
dd4hep::sim::Geant4Particle::status
int status
Definition: Geant4Particle.h:117
dd4hep::sim::Geant4TrackHandler
Helper class to ease the extraction of information from a G4Track object.
Definition: Geant4TrackHandler.h:53
dd4hep::sim::Geant4Particle::originalG4ID
int originalG4ID
Definition: Geant4Particle.h:110
dd4hep::sim::Geant4ActionSD::sensitiveType
virtual const std::string & sensitiveType() const =0
Access to the sensitive type of the detector.
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:141
dd4hep::sim::G4PARTICLE_SIM_DECAY_TRACKER
@ G4PARTICLE_SIM_DECAY_TRACKER
Definition: Geant4Particle.h:89
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::G4PARTICLE_STARTED_IN_CALORIMETER
@ G4PARTICLE_STARTED_IN_CALORIMETER
Definition: Geant4Particle.h:68
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4Particle::mask
int mask
Definition: Geant4Particle.h:113
dd4hep::sim::Geant4Particle::time
double time
Particle creation time.
Definition: Geant4Particle.h:135
dd4hep::sim::Geant4Particle::steps
int steps
Definition: Geant4Particle.h:114
dd4hep::sim::Geant4Particle::process
const G4VProcess * process
Reference to the G4VProcess, which created this track.
Definition: Geant4Particle.h:146
dd4hep::sim::Geant4ParticleHandler::defaultDropParticle
static bool defaultDropParticle(const Particle &particle)
Default callback to be answered if the particle should be dropped if NO user handler is installed.
dd4hep::sim::Geant4Particle::pex
double pex
The track momentum at the end vertex.
Definition: Geant4Particle.h:131
dd4hep::sim::Geant4ActionSD
Interface class to access properties of the underlying Geant4 sensitive detector structure.
Definition: Geant4SensDetAction.h:61
dd4hep::sim::Geant4Action::outputLevel
PrintLevel outputLevel() const
Access the output level.
Definition: Geant4Action.h:296
dd4hep::sim::G4PARTICLE_HAS_SECONDARIES
@ G4PARTICLE_HAS_SECONDARIES
Definition: Geant4Particle.h:59
dd4hep::sim::Geant4Particle::vex
double vex
The end vertex.
Definition: Geant4Particle.h:127
dd4hep::sim::Geant4ParticleHandler::m_globalParticleID
int m_globalParticleID
Global particle identifier. Obtained at the begin of the event.
Definition: Geant4ParticleHandler.h:115
dd4hep::sim::Geant4ParticleHandler::m_particleMap
ParticleMap m_particleMap
Map with stored MC Particles.
Definition: Geant4ParticleHandler.h:121
dd4hep::sim::Geant4ParticleHandler::m_haveSuspended
bool m_haveSuspended
Definition: Geant4ParticleHandler.h:124
dd4hep::sim::Geant4Particle::vsx
double vsx
The starting vertex.
Definition: Geant4Particle.h:125
dd4hep::sim::Geant4ParticleHandler::operator()
virtual void operator()(G4Event *event) override
Event generation action callback.
dd4hep::sim::Geant4Particle::psx
double psx
The track momentum at the start vertex.
Definition: Geant4Particle.h:129
dd4hep::sim::Geant4ParticleHandle::definition
const G4ParticleDefinition * definition() const
Access the Geant4 particle definition object (expensive!)
Definition: Geant4Particle.cpp:112
dd4hep::sim::Geant4ParticleHandler::setVertexEndpointBit
void setVertexEndpointBit()
set the endpointIsNotVertexOfParentFlag at the end of the event
dd4hep::sim::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:131
dd4hep::sim::Geant4ParticleHandler::mark
virtual void mark(const G4Track *track) override
Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT.
dd4hep::sim::G4PARTICLE_FORCE_KILL
@ G4PARTICLE_FORCE_KILL
Definition: Geant4Particle.h:67
dd4hep::sim::Geant4Event::addExtension
void * addExtension(unsigned long long int k, ExtensionEntry *e)
Add an extension object to the detector element.
Definition: Geant4Context.h:140
Primitives.h
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition: Geant4Particle.h:91
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: EDM4hepFileReader.cpp:46
dd4hep::sim::Geant4ParticleHandler::clear
void clear()
Clear particle maps.
dd4hep::sim::Geant4ParticleHandle
Data structure to access derived MC particle information.
Definition: Geant4Particle.h:182
dd4hep::sim::Geant4ParticleHandler::m_currTrack
Particle m_currTrack
Local buffer about the 'current' G4Track.
Definition: Geant4ParticleHandler.h:119
dd4hep::sim::Geant4ParticleInformation
Wrapper to store user information in a G4Track.
Definition: Geant4ParticleInformation.h:48
dd4hep::sim::Geant4Particle::parents
Particles parents
The list of parents of this MC particle.
Definition: Geant4Particle.h:139
dd4hep::sim::Geant4Particle::vsy
double vsy
Definition: Geant4Particle.h:125
dd4hep::sim::G4PARTICLE_CREATED_CALORIMETER_HIT
@ G4PARTICLE_CREATED_CALORIMETER_HIT
Definition: Geant4Particle.h:63
dd4hep::sim::Geant4Action::debug
void debug(const char *fmt,...) const
Support of debug messages.
Definition: Geant4Action.cpp:207
dd4hep::sim::Geant4ParticleHandler::m_kinEnergyCut
double m_kinEnergyCut
Property: Flag if the handler is executed in standalone mode and hence must manage particles.
Definition: Geant4ParticleHandler.h:103
dd4hep::sim::Geant4ParticleHandler::end
virtual void end(const G4Track *track)
Post-track action callback.
dd4hep::sim::G4PARTICLE_PRIMARY
@ G4PARTICLE_PRIMARY
Definition: Geant4Particle.h:58
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:104
dd4hep::sim::Geant4Particle::charge
char charge
Definition: Geant4Particle.h:120
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: EDM4hepFileReader.cpp:43
InstanceCount.h
dd4hep::sim::Geant4PrimaryMap::get
Geant4Particle * get(const G4PrimaryParticle *particle)
Access DDG4 particle by G4 primary particle.
Definition: Geant4Primary.cpp:44
dd4hep::sim::Geant4Particle::psy
double psy
Definition: Geant4Particle.h:129
dd4hep::sim::Geant4ParticleHandler::ParticleMap
Geant4ParticleMap::ParticleMap ParticleMap
Definition: Geant4ParticleHandler.h:75
dd4hep::sim::Geant4ParticleHandler::beginEvent
virtual void beginEvent(const G4Event *event)
Pre-event action callback.
dd4hep::sim::Geant4ParticleHandle::header4
static void header4(int level, const std::string &src, const char *tag)
Definition: Geant4Particle.cpp:371
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270