DD4hep  1.37.0
Detector Description Toolkit for High Energy Physics
Geant4Output2LCIO.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 #ifndef DD4HEP_DDG4_GEANT4OUTPUT2LCIO_H
15 #define DD4HEP_DDG4_GEANT4OUTPUT2LCIO_H
16 
17 // Framework include files
18 #include <DD4hep/VolumeManager.h>
20 #include <DDG4/Geant4Kernel.h>
21 
22 #include <DDG4/EventParameters.h>
23 #include <DDG4/RunParameters.h>
24 // Geant4 headers
25 #include <G4AutoLock.hh>
26 
27 #include <DD4hep/Detector.h>
28 #include <G4Version.hh>
29 
30 // lcio include files
31 #include <lcio.h>
32 #include <IO/LCWriter.h>
33 #include <IMPL/LCEventImpl.h>
34 #include <IMPL/LCCollectionVec.h>
35 #include <EVENT/LCParameters.h>
36 
37 using namespace lcio ;
38 
40 namespace dd4hep {
41 
42  class ComponentCast;
43 
45  namespace sim {
46  template <class T=lcio::LCEventImpl> void EventParameters::extractParameters(T& event){
47  auto& lcparameters = event.parameters();
48  event.setRunNumber(this->runNumber());
49  event.setEventNumber(this->eventNumber());
50  for(auto const& ival: this->intParameters()) {
51  lcparameters.setValues(ival.first, ival.second);
52  }
53  for(auto const& ival: this->fltParameters()) {
54  lcparameters.setValues(ival.first, ival.second);
55  }
56  for(auto const& ival: this->strParameters()) {
57  lcparameters.setValues(ival.first, ival.second);
58  }
59 #if LCIO_VERSION_GE(2, 17)
60  for(auto const& ival: this->dblParameters()) {
61  lcparameters.setValues(ival.first, ival.second);
62  }
63 #endif
64  }
65 
66  template <class T=lcio::LCRunHeaderImpl> void RunParameters::extractParameters(T& runHeader){
67  auto& lcparameters = runHeader.parameters();
68  for(auto const& ival: this->intParameters()) {
69  lcparameters.setValues(ival.first, ival.second);
70  }
71  for(auto const& ival: this->fltParameters()) {
72  lcparameters.setValues(ival.first, ival.second);
73  }
74  for(auto const& ival: this->strParameters()) {
75  lcparameters.setValues(ival.first, ival.second);
76  }
77 #if LCIO_VERSION_GE(2, 17)
78  for(auto const& ival: this->dblParameters()) {
79  lcparameters.setValues(ival.first, ival.second);
80  }
81 #endif
82  }
83 
84  class Geant4ParticleMap;
85 
87 
94  protected:
95  lcio::LCWriter* m_file;
96  int m_runNo;
99  std::map< std::string, std::string > m_runHeader;
100  std::map< std::string, std::string > m_eventParametersInt;
101  std::map< std::string, std::string > m_eventParametersFloat;
102  std::map< std::string, std::string > m_eventParametersString;
103 
105  lcio::LCCollectionVec* saveParticles(Geant4ParticleMap* particles);
106  public:
108  Geant4Output2LCIO(Geant4Context* ctxt, const std::string& nam);
110  virtual ~Geant4Output2LCIO();
112  virtual void beginRun(const G4Run* run);
114  virtual void endRun(const G4Run* run);
115 
117  virtual void saveRun(const G4Run* run);
119  virtual void saveEvent( OutputContext<G4Event>& ctxt);
121  virtual void saveCollection( OutputContext<G4Event>& ctxt, G4VHitsCollection* collection);
123  virtual void commit( OutputContext<G4Event>& ctxt);
124 
126  virtual void begin(const G4Event* event);
127  protected:
129  template <typename T>
130  void saveEventParameters(lcio::LCEventImpl* event, const std::map<std::string, std::string >& parameters);
131  };
132 
134  template <typename T>
135  inline void Geant4Output2LCIO::saveEventParameters(lcio::LCEventImpl* event, const std::map<std::string, std::string >& parameters) {
136  for(std::map<std::string, std::string >::const_iterator iter = parameters.begin(), endIter = parameters.end() ; iter != endIter ; ++iter) {
137  T parameter;
138  std::istringstream iss(iter->second);
139  if ( (iss >> parameter).fail() ) {
140  printout(FATAL,"saveEventParameters","+++ Event parameter %s: FAILED to convert to type :%s",iter->first.c_str(),typeid(T).name());
141  continue;
142  }
143  event->parameters().setValue(iter->first,parameter);
144  }
145  }
146 
148  template <>
149  inline void Geant4Output2LCIO::saveEventParameters<std::string>(lcio::LCEventImpl* event, const std::map<std::string, std::string >& parameters) {
150  for(std::map<std::string, std::string >::const_iterator iter = parameters.begin(), endIter = parameters.end() ; iter != endIter ; ++iter) {
151  event->parameters().setValue(iter->first,iter->second);
152  }
153  }
154 
155  } // End namespace sim
156 } // End namespace dd4hep
157 #endif // DD4HEP_DDG4_GEANT4OUTPUT2LCIO_H
158 
159 //==========================================================================
160 // AIDA Detector description implementation
161 //--------------------------------------------------------------------------
162 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
163 // All rights reserved.
164 //
165 // For the licensing terms see $DD4hepINSTALL/LICENSE.
166 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
167 //
168 // Author : M.Frank
169 //
170 //==========================================================================
171 
172 // Framework include files
173 #include <DD4hep/InstanceCount.h>
174 #include <DD4hep/Detector.h>
177 #include <DDG4/Geant4Context.h>
178 #include <DDG4/Geant4Particle.h>
179 #include <DDG4/Geant4Data.h>
180 #include <DDG4/Geant4Action.h>
181 
182 //#include <DDG4/Geant4Output2LCIO.h>
183 #include <G4ParticleDefinition.hh>
184 #include <G4VProcess.hh>
185 #include <G4Event.hh>
186 #include <G4Run.hh>
187 
188 // LCIO include files
189 #include <IMPL/LCEventImpl.h>
190 #include <IMPL/LCRunHeaderImpl.h>
191 #include <IMPL/LCCollectionVec.h>
192 #include <IMPL/ClusterImpl.h>
193 #include <IMPL/SimTrackerHitImpl.h>
194 #include <IMPL/SimCalorimeterHitImpl.h>
195 #include <IMPL/MCParticleImpl.h>
196 #include <UTIL/ILDConf.h>
197 
198 using namespace dd4hep::sim;
199 using namespace dd4hep;
200 using namespace std;
201 
202 #include <DDG4/Factories.h>
204 
205 Geant4Output2LCIO::Geant4Output2LCIO(Geant4Context* ctxt, const string& nam)
207 : Geant4OutputAction(ctxt,nam), m_file(0), m_runNo(0), m_runNumberOffset(0), m_eventNumberOffset(0)
208 {
209  declareProperty("RunHeader", m_runHeader);
210  declareProperty("EventParametersInt", m_eventParametersInt);
211  declareProperty("EventParametersFloat", m_eventParametersFloat);
212  declareProperty("EventParametersString", m_eventParametersString);
213  declareProperty("RunNumberOffset", m_runNumberOffset);
214  declareProperty("EventNumberOffset", m_eventNumberOffset);
216 }
217 
220  G4AutoLock protection_lock(mutex());
221  if ( m_file ) {
222  m_file->close();
223  detail::deletePtr(m_file);
224  }
226 }
227 
228 // Callback to store the Geant4 run information
229 void Geant4Output2LCIO::beginRun(const G4Run* run) {
230  if ( 0 == m_file && !m_output.empty() ) {
231  G4AutoLock protection_lock(mutex());
232  m_file = lcio::LCFactory::getInstance()->createLCWriter();
233  m_file->open(m_output,lcio::LCIO::WRITE_NEW);
234  }
235 
236  saveRun(run);
237 }
238 
240 void Geant4Output2LCIO::endRun(const G4Run* /*run*/) {
241  // saveRun(run);
242 }
243 
246  lcio::LCEventImpl* e = context()->event().extension<lcio::LCEventImpl>();
247  if ( m_file ) {
248  m_file->writeEvent(e);
249  return;
250  }
251  except("+++ Failed to write output file. [Stream is not open]");
252 }
253 
255 void Geant4Output2LCIO::saveRun(const G4Run* run) {
256  G4AutoLock protection_lock(mutex());
257  // --- write an lcio::RunHeader ---------
258  lcio::LCRunHeaderImpl* rh = new lcio::LCRunHeaderImpl;
259  for (std::map< std::string, std::string >::iterator it = m_runHeader.begin(); it != m_runHeader.end(); ++it) {
260  rh->parameters().setValue( it->first, it->second );
261  }
262  m_runNo = m_runNumberOffset > 0 ? m_runNumberOffset + run->GetRunID() : run->GetRunID();
263  rh->parameters().setValue("GEANT4Version", G4Version);
264  rh->parameters().setValue("DD4HEPVersion", versionString());
265  rh->setRunNumber(m_runNo);
266  rh->setDetectorName(context()->detectorDescription().header().name());
268  auto* parameters = workerCtx->run().extension<RunParameters>(false);
269  if (parameters) {
270  parameters->extractParameters(*rh);
271  }
272  m_file->writeRunHeader(rh);
273 }
274 
275 void Geant4Output2LCIO::begin(const G4Event* /* event */) {
276  lcio::LCEventImpl* e = new lcio::LCEventImpl;
277  //fg: here the event context takes ownership and
278  // deletes the event in the end
279  context()->event().addExtension<lcio::LCEventImpl>( e );
280 }
281 
283 lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* particles) {
284  typedef detail::ReferenceBitMask<const int> PropertyMask;
285  typedef Geant4ParticleMap::ParticleMap ParticleMap;
286  const ParticleMap& pm = particles->particleMap;
287  size_t nparts = pm.size();
288  lcio::LCCollectionVec* lc_coll = new lcio::LCCollectionVec(lcio::LCIO::MCPARTICLE);
289  lc_coll->reserve(nparts);
290  if ( nparts > 0 ) {
291  size_t cnt = 0;
292  map<int,int> p_ids;
293  vector<const Geant4Particle*> p_part(pm.size(),0);
294  vector<MCParticleImpl*> p_lcio(pm.size(),0);
295  // First create the particles
296  for(ParticleMap::const_iterator i=pm.begin(); i!=pm.end();++i, ++cnt) {
297  int id = (*i).first;
298  const Geant4ParticleHandle p = (*i).second;
299  PropertyMask mask(p->status);
300  // std::cout << " ********** mcp status : 0x" << std::hex << p->status << ", mask.isSet(G4PARTICLE_GEN_STABLE) x" << std::dec << mask.isSet(G4PARTICLE_GEN_STABLE) <<std::endl ;
301  const G4ParticleDefinition* def = p.definition();
302  MCParticleImpl* q = new lcio::MCParticleImpl();
303  q->setPDG(p->pdgID);
304 
305  float ps_fa[3] = {float(p->psx/CLHEP::GeV),float(p->psy/CLHEP::GeV),float(p->psz/CLHEP::GeV)};
306  q->setMomentum( ps_fa );
307 
308 #if LCIO_VERSION_GE(2,7)
309  float pe_fa[3] = {float(p->pex/CLHEP::GeV),float(p->pey/CLHEP::GeV),float(p->pez/CLHEP::GeV)};
310  q->setMomentumAtEndpoint( pe_fa );
311 #endif
312  double vs_fa[3] = { p->vsx/CLHEP::mm, p->vsy/CLHEP::mm, p->vsz/CLHEP::mm } ;
313  q->setVertex( vs_fa );
314 
315  double ve_fa[3] = { p->vex/CLHEP::mm, p->vey/CLHEP::mm, p->vez/CLHEP::mm } ;
316  q->setEndpoint( ve_fa );
317 
318  q->setTime(p->time/CLHEP::ns);
319  q->setMass(p->mass/CLHEP::GeV);
320  q->setCharge(def ? def->GetPDGCharge() : 0); // Charge(e+) = 1 !
321 
322  // Set generator status
323  q->setGeneratorStatus(0);
324  if( p->genStatus ) {
325  q->setGeneratorStatus( p->genStatus ) ;
326  } else {
327 
328  if ( mask.isSet(G4PARTICLE_GEN_STABLE) ) q->setGeneratorStatus(1);
329  else if ( mask.isSet(G4PARTICLE_GEN_DECAYED) ) q->setGeneratorStatus(2);
330  else if ( mask.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) q->setGeneratorStatus(3);
331  else if ( mask.isSet(G4PARTICLE_GEN_BEAM) ) q->setGeneratorStatus(4);
332  else if ( mask.isSet(G4PARTICLE_GEN_OTHER) ) q->setGeneratorStatus(9);
333  }
334 // std::cout << " ********** mcp genstatus : " << q->getGeneratorStatus() << std::endl ;
335 
336  // Set simulation status
337  q->setCreatedInSimulation( mask.isSet(G4PARTICLE_SIM_CREATED) );
338  q->setBackscatter( mask.isSet(G4PARTICLE_SIM_BACKSCATTER) );
339  q->setVertexIsNotEndpointOfParent( mask.isSet(G4PARTICLE_SIM_PARENT_RADIATED) );
340  q->setDecayedInTracker( mask.isSet(G4PARTICLE_SIM_DECAY_TRACKER) );
341  q->setDecayedInCalorimeter( mask.isSet(G4PARTICLE_SIM_DECAY_CALO) );
342  q->setHasLeftDetector( mask.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) );
343  q->setStopped( mask.isSet(G4PARTICLE_SIM_STOPPED) );
344  q->setOverlay( false );
345 
346  //fg: if simstatus !=0 we have to set the generator status to 0:
347  if( q->isCreatedInSimulation() )
348  q->setGeneratorStatus( 0 ) ;
349 
350  q->setSpin(p->spin);
351  q->setColorFlow(p->colorFlow);
352 
353  lc_coll->addElement(q);
354  p_ids[id] = cnt;
355  p_part[cnt] = p;
356  p_lcio[cnt] = q;
357  }
358 
359  // Now establish parent-daughter relationships
360  for(size_t i=0, n=p_ids.size(); i<n; ++i) {
361  map<int,int>::iterator k;
362  const Geant4Particle* p = p_part[i];
363  MCParticleImpl* q = p_lcio[i];
364  const Geant4Particle::Particles& dau = p->daughters;
365  for( Geant4Particle::Particles::const_iterator j=dau.begin(); j != dau.end(); ++j ) {
366  int idau = *j;
367  if ( (k=p_ids.find(idau)) == p_ids.end() ) { // Error!!!
368  printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau);
369  continue;
370  }
371  int iqdau = (*k).second;
372  MCParticleImpl* qdau = p_lcio[iqdau];
373  qdau->addParent(q);
374  }
375  const Geant4Particle::Particles& par = p->parents;
376  for( Geant4Particle::Particles::const_iterator j=par.begin(); j != par.end(); ++j ) {
377  int ipar = *j; // A parent ID iof -1 means NO parent, because a base of 0 is perfectly leagal!
378  if ( ipar >= 0 ) {
379  if( (k=p_ids.find(ipar)) == p_ids.end() ) { // Error!!!
380  printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar);
381  continue;
382  }
383  int iqpar = (*k).second;
384  MCParticleImpl* qpar = p_lcio[iqpar];
385  q->addParent(qpar);
386  }
387  }
388  }
389  }
390  return lc_coll;
391 }
392 
395  lcio::LCEventImpl* e = context()->event().extension<lcio::LCEventImpl>();
396  EventParameters* parameters = context()->event().extension<EventParameters>(false);
397  int runNumber(0), eventNumber(0);
398  const int eventNumberOffset(m_eventNumberOffset > 0 ? m_eventNumberOffset : 0);
399  const int runNumberOffset(m_runNumberOffset > 0 ? m_runNumberOffset : 0);
400  double eventWeight{0};
401  // Get event number, run number and parameters from extension ...
402  if (parameters) {
403  runNumber = parameters->runNumber() + runNumberOffset;
404  eventNumber = parameters->eventNumber() + eventNumberOffset;
405  parameters->extractParameters(*e);
406 #if LCIO_VERSION_GE(2, 17)
407  eventWeight = e->getParameters().getDoubleVal("EventWeights");
408 #endif
409  } else { // ... or from DD4hep framework
410  runNumber = m_runNo + runNumberOffset;
411  eventNumber = ctxt.context->GetEventID() + eventNumberOffset;
412  }
413  print("+++ Saving LCIO event %d run %d ....", eventNumber, runNumber);
414  e->setRunNumber(runNumber);
415  e->setEventNumber(eventNumber);
416  e->setWeight(eventWeight);
417  e->setDetectorName(context()->detectorDescription().header().name());
418  saveEventParameters<int>(e, m_eventParametersInt);
419  saveEventParameters<float>(e, m_eventParametersFloat);
420  saveEventParameters<std::string>(e, m_eventParametersString);
421  lcio::LCEventImpl* evt = context()->event().extension<lcio::LCEventImpl>();
422  Geant4ParticleMap* part_map = context()->event().extension<Geant4ParticleMap>(false);
423  if ( part_map ) {
424  print("+++ Saving %d LCIO particles....",int(part_map->particleMap.size()));
425  if ( part_map->particleMap.size() > 0 ) {
426  lcio::LCCollectionVec* col = saveParticles(part_map);
427  evt->addCollection(col,lcio::LCIO::MCPARTICLE);
428  }
429  }
430 }
431 
434  size_t nhits = collection->GetSize();
435  std::string hc_nam = collection->GetName();
436  print("+++ Saving LCIO collection %s with %d entries....",hc_nam.c_str(),int(nhits));
437  typedef pair<const Geant4Context*,G4VHitsCollection*> _Args;
439  const _C& cnv = _C::converter(typeid(Geant4HitCollection));
440  cnv(_Args(context(),collection));
441 }
442 
Geant4DataConversion.h
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:87
dd4hep::sim::Geant4Output2LCIO::m_runNo
int m_runNo
Definition: Geant4Output2LCIO.cpp:96
Geant4HitCollection.h
dd4hep::sim::Geant4Particle::vsz
double vsz
Definition: Geant4Particle.h:126
dd4hep::sim::G4PARTICLE_GEN_STABLE
@ G4PARTICLE_GEN_STABLE
Definition: Geant4Particle.h:73
dd4hep::sim::Geant4Conversion
Data conversion class.
Definition: Geant4DataConversion.h:54
dd4hep::sim::G4PARTICLE_SIM_PARENT_RADIATED
@ G4PARTICLE_SIM_PARENT_RADIATED
Definition: Geant4Particle.h:93
dd4hep::sim::Geant4Particle::mass
double mass
Particle mass.
Definition: Geant4Particle.h:134
dd4hep::sim::Geant4Particle::vey
double vey
Definition: Geant4Particle.h:128
Detector.h
_C
DetElement::Children _C
Definition: GeometryWalk.cpp:64
dd4hep::sim::Geant4Particle::pez
double pez
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4Context::run
Geant4Run & run() const
Access the geant4 run – valid only between BeginRun() and EndRun()!
Definition: Geant4Context.cpp:72
dd4hep::sim::Geant4Particle::id
int id
not persistent
Definition: Geant4Particle.h:110
dd4hep::sim::Geant4HitCollection
Generic hit container class using Geant4HitWrapper objects.
Definition: Geant4HitCollection.h:201
dd4hep::sim::Geant4Output2LCIO::begin
virtual void begin(const G4Event *event)
begin-of-event callback - creates LCIO event and adds it to the event context
Definition: Geant4Output2LCIO.cpp:275
dd4hep::versionString
std::string versionString()
return a string with the current dd4hep version in the form vXX-YY.
Definition: DetectorImp.cpp:122
dd4hep::sim::Geant4Particle::pdgID
int pdgID
Definition: Geant4Particle.h:117
G4VHitsCollection
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:47
dd4hep::sim::Geant4OutputAction
Base class to output Geant4 event data to persistent media.
Definition: Geant4OutputAction.h:40
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::sim::Geant4Particle::psz
double psz
Definition: Geant4Particle.h:130
Geant4Data.h
dd4hep::sim::Geant4Context::event
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition: Geant4Context.cpp:84
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4Output2LCIO::commit
virtual void commit(OutputContext< G4Event > &ctxt)
Commit data at end of filling procedure.
Definition: Geant4Output2LCIO.cpp:245
dd4hep::sim::G4PARTICLE_GEN_DOCUMENTATION
@ G4PARTICLE_GEN_DOCUMENTATION
Definition: Geant4Particle.h:75
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition: Geant4Particle.h:88
dd4hep::sim::Geant4ActionContainer::workerContext
Geant4Context * workerContext()
Thread's Geant4 execution context.
Definition: Geant4ActionContainer.cpp:65
RunParameters.h
dd4hep::sim::Geant4EventAction::mutex
G4Mutex & mutex() const
access to mutex for this action
Definition: Geant4EventAction.h:77
dd4hep::sim::Geant4Kernel::worker
Geant4Kernel & worker(unsigned long thread_identifier, bool create_if=false)
Access worker instance by its identifier.
Definition: Geant4Kernel.cpp:230
dd4hep::sim::RunParameters
Extension to pass input run data to output run data.
Definition: RunParameters.h:28
dd4hep::sim::Geant4Output2LCIO::saveEvent
virtual void saveEvent(OutputContext< G4Event > &ctxt)
Callback to store the Geant4 event.
Definition: Geant4Output2LCIO.cpp:394
VolumeManager.h
dd4hep::sim::Geant4Output2LCIO::m_runNumberOffset
int m_runNumberOffset
Definition: Geant4Output2LCIO.cpp:97
dd4hep::sim::Geant4OutputAction::OutputContext
Helper class for thread savety.
Definition: Geant4OutputAction.h:43
dd4hep::sim::Geant4ParticleMap
Data structure to map particles produced during the generation and the simulation.
Definition: Geant4Particle.h:339
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::Geant4Output2LCIO::endRun
virtual void endRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2LCIO.cpp:240
dd4hep::sim::G4PARTICLE_SIM_STOPPED
@ G4PARTICLE_SIM_STOPPED
Definition: Geant4Particle.h:91
dd4hep::sim::Geant4Output2LCIO::m_runHeader
std::map< std::string, std::string > m_runHeader
Definition: Geant4Output2LCIO.cpp:99
Geant4OutputAction.h
EventParameters.h
dd4hep::sim::Geant4Particle::Particles
std::set< int > Particles
Definition: Geant4Particle.h:107
dd4hep::sim::Geant4Particle::vez
double vez
Definition: Geant4Particle.h:128
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition: Geant4Particle.h:89
dd4hep::sim::Geant4Output2LCIO::saveCollection
virtual void saveCollection(OutputContext< G4Event > &ctxt, G4VHitsCollection *collection)
Callback to store each Geant4 hit collection.
Definition: Geant4Output2LCIO.cpp:433
dd4hep::sim::Geant4ParticleMap::ParticleMap
std::map< int, Particle * > ParticleMap
Definition: Geant4Particle.h:342
dd4hep::sim::Geant4Particle::colorFlow
int colorFlow[2]
Definition: Geant4Particle.h:119
dd4hep::sim::Geant4Particle::spin
float spin[3]
Definition: Geant4Particle.h:123
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4Output2LCIO::saveRun
virtual void saveRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2LCIO.cpp:255
dd4hep::sim::Geant4Particle::genStatus
unsigned short genStatus
Definition: Geant4Particle.h:120
dd4hep::sim::Geant4Particle::status
int status
Definition: Geant4Particle.h:118
dd4hep::sim::G4PARTICLE_GEN_DECAYED
@ G4PARTICLE_GEN_DECAYED
Definition: Geant4Particle.h:74
dd4hep::sim::Geant4Particle::daughters
Particles daughters
The list of daughters of this MC particle.
Definition: Geant4Particle.h:142
dd4hep::sim::G4PARTICLE_SIM_DECAY_TRACKER
@ G4PARTICLE_SIM_DECAY_TRACKER
Definition: Geant4Particle.h:90
dd4hep::sim::Geant4Kernel::thread_self
static unsigned long int thread_self()
Access thread identifier.
Definition: Geant4Kernel.cpp:211
dd4hep::sim::Geant4Output2LCIO::saveParticles
lcio::LCCollectionVec * saveParticles(Geant4ParticleMap *particles)
Data conversion interface for MC particles to LCIO format.
Definition: Geant4Output2LCIO.cpp:283
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4Particle::time
double time
Particle creation time.
Definition: Geant4Particle.h:136
dd4hep::sim::Geant4Particle::pex
double pex
The track momentum at the end vertex.
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4Action::print
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
Definition: Geant4Action.cpp:144
dd4hep::sim::Geant4Output2LCIO::m_eventParametersString
std::map< std::string, std::string > m_eventParametersString
Definition: Geant4Output2LCIO.cpp:102
dd4hep::sim::Geant4Particle::vex
double vex
The end vertex.
Definition: Geant4Particle.h:128
dd4hep::sim::Geant4Run::extension
T * extension(bool alert=true)
Access to type safe extension object. Exception is thrown if the object is invalid.
Definition: Geant4Context.h:95
dd4hep::sim::Geant4Output2LCIO::m_file
lcio::LCWriter * m_file
Definition: Geant4Output2LCIO.cpp:95
dd4hep::sim::Geant4Particle::vsx
double vsx
The starting vertex.
Definition: Geant4Particle.h:126
dd4hep::sim::Geant4Particle::psx
double psx
The track momentum at the start vertex.
Definition: Geant4Particle.h:130
dd4hep::sim::G4PARTICLE_GEN_BEAM
@ G4PARTICLE_GEN_BEAM
Definition: Geant4Particle.h:76
dd4hep::sim::Geant4ParticleHandle::definition
const G4ParticleDefinition * definition() const
Access the Geant4 particle definition object (expensive!)
Definition: Geant4Particle.cpp:112
dd4hep::sim::Geant4Output2LCIO::beginRun
virtual void beginRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2LCIO.cpp:229
dd4hep::sim::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:132
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
Factories.h
dd4hep::sim::Geant4OutputAction::m_output
std::string m_output
Property: "Output" output destination.
Definition: Geant4OutputAction.h:56
dd4hep::sim::Geant4ParticleMap::particleMap
ParticleMap particleMap
Mapping of particles of this event.
Definition: Geant4Particle.h:345
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition: Geant4Particle.h:92
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: EDM4hepFileReader.cpp:46
dd4hep::sim::RunParameters::extractParameters
void extractParameters(T &destination)
Put parameters into destination.
Definition: Geant4Output2LCIO.cpp:66
dd4hep::sim::Geant4Context::kernel
Geant4Kernel & kernel() const
Access to the kernel object.
Definition: Geant4Context.h:233
dd4hep::sim::Geant4OutputAction::OutputContext::context
const T * context
Definition: Geant4OutputAction.h:45
dd4hep::sim::EventParameters
Event extension to pass input event data to output event.
Definition: EventParameters.h:28
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4ParticleHandle
Data structure to access derived MC particle information.
Definition: Geant4Particle.h:183
dd4hep::sim::Geant4Particle::parents
Particles parents
The list of parents of this MC particle.
Definition: Geant4Particle.h:140
Geant4Particle.h
dd4hep::sim::Geant4Particle::vsy
double vsy
Definition: Geant4Particle.h:126
dd4hep::sim::Geant4Output2LCIO::m_eventNumberOffset
int m_eventNumberOffset
Definition: Geant4Output2LCIO.cpp:98
Geant4Kernel.h
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:105
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: EDM4hepFileReader.cpp:43
InstanceCount.h
dd4hep::sim::Geant4Output2LCIO
Base class to output Geant4 event data to media.
Definition: Geant4Output2LCIO.cpp:93
dd4hep::sim::Geant4Particle::psy
double psy
Definition: Geant4Particle.h:130
dd4hep::sim::G4PARTICLE_GEN_OTHER
@ G4PARTICLE_GEN_OTHER
Definition: Geant4Particle.h:78
Geant4Context.h
Geant4Action.h
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
dd4hep::sim::Geant4Output2LCIO::m_eventParametersFloat
std::map< std::string, std::string > m_eventParametersFloat
Definition: Geant4Output2LCIO.cpp:101
dd4hep::sim::Geant4Output2LCIO::~Geant4Output2LCIO
virtual ~Geant4Output2LCIO()
Default destructor.
Definition: Geant4Output2LCIO.cpp:219
dd4hep::sim::Geant4Output2LCIO::m_eventParametersInt
std::map< std::string, std::string > m_eventParametersInt
Definition: Geant4Output2LCIO.cpp:100