DD4hep  1.30.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 
21 #include <DDG4/EventParameters.h>
22 #include <DDG4/RunParameters.h>
23 // Geant4 headers
24 #include <G4Threading.hh>
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 namespace {
202  G4Mutex action_mutex=G4MUTEX_INITIALIZER;
203 }
204 
205 #include <DDG4/Factories.h>
207 
208 Geant4Output2LCIO::Geant4Output2LCIO(Geant4Context* ctxt, const string& nam)
210 : Geant4OutputAction(ctxt,nam), m_file(0), m_runNo(0), m_runNumberOffset(0), m_eventNumberOffset(0)
211 {
212  declareProperty("RunHeader", m_runHeader);
213  declareProperty("EventParametersInt", m_eventParametersInt);
214  declareProperty("EventParametersFloat", m_eventParametersFloat);
215  declareProperty("EventParametersString", m_eventParametersString);
216  declareProperty("RunNumberOffset", m_runNumberOffset);
217  declareProperty("EventNumberOffset", m_eventNumberOffset);
219 }
220 
223  G4AutoLock protection_lock(&action_mutex);
224  if ( m_file ) {
225  m_file->close();
226  detail::deletePtr(m_file);
227  }
229 }
230 
231 // Callback to store the Geant4 run information
232 void Geant4Output2LCIO::beginRun(const G4Run* run) {
233  if ( 0 == m_file && !m_output.empty() ) {
234  G4AutoLock protection_lock(&action_mutex);
235  m_file = lcio::LCFactory::getInstance()->createLCWriter();
236  m_file->open(m_output,lcio::LCIO::WRITE_NEW);
237  }
238 
239  saveRun(run);
240 }
241 
243 void Geant4Output2LCIO::endRun(const G4Run* /*run*/) {
244  // saveRun(run);
245 }
246 
249  lcio::LCEventImpl* e = context()->event().extension<lcio::LCEventImpl>();
250  if ( m_file ) {
251  G4AutoLock protection_lock(&action_mutex);
252  m_file->writeEvent(e);
253  return;
254  }
255  except("+++ Failed to write output file. [Stream is not open]");
256 }
257 
259 void Geant4Output2LCIO::saveRun(const G4Run* run) {
260  G4AutoLock protection_lock(&action_mutex);
261  // --- write an lcio::RunHeader ---------
262  lcio::LCRunHeaderImpl* rh = new lcio::LCRunHeaderImpl;
263  for (std::map< std::string, std::string >::iterator it = m_runHeader.begin(); it != m_runHeader.end(); ++it) {
264  rh->parameters().setValue( it->first, it->second );
265  }
266  m_runNo = m_runNumberOffset > 0 ? m_runNumberOffset + run->GetRunID() : run->GetRunID();
267  rh->parameters().setValue("GEANT4Version", G4Version);
268  rh->parameters().setValue("DD4HEPVersion", versionString());
269  rh->setRunNumber(m_runNo);
270  rh->setDetectorName(context()->detectorDescription().header().name());
271  auto* parameters = context()->run().extension<RunParameters>(false);
272  if (parameters) {
273  parameters->extractParameters(*rh);
274  }
275  m_file->writeRunHeader(rh);
276 }
277 
278 void Geant4Output2LCIO::begin(const G4Event* /* event */) {
279  lcio::LCEventImpl* e = new lcio::LCEventImpl;
280  //fg: here the event context takes ownership and
281  // deletes the event in the end
282  context()->event().addExtension<lcio::LCEventImpl>( e );
283 }
284 
286 lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* particles) {
287  typedef detail::ReferenceBitMask<const int> PropertyMask;
288  typedef Geant4ParticleMap::ParticleMap ParticleMap;
289  const ParticleMap& pm = particles->particleMap;
290  size_t nparts = pm.size();
291  lcio::LCCollectionVec* lc_coll = new lcio::LCCollectionVec(lcio::LCIO::MCPARTICLE);
292  lc_coll->reserve(nparts);
293  if ( nparts > 0 ) {
294  size_t cnt = 0;
295  map<int,int> p_ids;
296  vector<const Geant4Particle*> p_part(pm.size(),0);
297  vector<MCParticleImpl*> p_lcio(pm.size(),0);
298  // First create the particles
299  for(ParticleMap::const_iterator i=pm.begin(); i!=pm.end();++i, ++cnt) {
300  int id = (*i).first;
301  const Geant4ParticleHandle p = (*i).second;
302  PropertyMask mask(p->status);
303  // std::cout << " ********** mcp status : 0x" << std::hex << p->status << ", mask.isSet(G4PARTICLE_GEN_STABLE) x" << std::dec << mask.isSet(G4PARTICLE_GEN_STABLE) <<std::endl ;
304  const G4ParticleDefinition* def = p.definition();
305  MCParticleImpl* q = new lcio::MCParticleImpl();
306  q->setPDG(p->pdgID);
307 
308  float ps_fa[3] = {float(p->psx/CLHEP::GeV),float(p->psy/CLHEP::GeV),float(p->psz/CLHEP::GeV)};
309  q->setMomentum( ps_fa );
310 
311 #if LCIO_VERSION_GE(2,7)
312  float pe_fa[3] = {float(p->pex/CLHEP::GeV),float(p->pey/CLHEP::GeV),float(p->pez/CLHEP::GeV)};
313  q->setMomentumAtEndpoint( pe_fa );
314 #endif
315  double vs_fa[3] = { p->vsx/CLHEP::mm, p->vsy/CLHEP::mm, p->vsz/CLHEP::mm } ;
316  q->setVertex( vs_fa );
317 
318  double ve_fa[3] = { p->vex/CLHEP::mm, p->vey/CLHEP::mm, p->vez/CLHEP::mm } ;
319  q->setEndpoint( ve_fa );
320 
321  q->setTime(p->time/CLHEP::ns);
322  q->setMass(p->mass/CLHEP::GeV);
323  q->setCharge(def ? def->GetPDGCharge() : 0); // Charge(e+) = 1 !
324 
325  // Set generator status
326  q->setGeneratorStatus(0);
327  if( p->genStatus ) {
328  q->setGeneratorStatus( p->genStatus ) ;
329  } else {
330 
331  if ( mask.isSet(G4PARTICLE_GEN_STABLE) ) q->setGeneratorStatus(1);
332  else if ( mask.isSet(G4PARTICLE_GEN_DECAYED) ) q->setGeneratorStatus(2);
333  else if ( mask.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) q->setGeneratorStatus(3);
334  else if ( mask.isSet(G4PARTICLE_GEN_BEAM) ) q->setGeneratorStatus(4);
335  else if ( mask.isSet(G4PARTICLE_GEN_OTHER) ) q->setGeneratorStatus(9);
336  }
337 // std::cout << " ********** mcp genstatus : " << q->getGeneratorStatus() << std::endl ;
338 
339  // Set simulation status
340  q->setCreatedInSimulation( mask.isSet(G4PARTICLE_SIM_CREATED) );
341  q->setBackscatter( mask.isSet(G4PARTICLE_SIM_BACKSCATTER) );
342  q->setVertexIsNotEndpointOfParent( mask.isSet(G4PARTICLE_SIM_PARENT_RADIATED) );
343  q->setDecayedInTracker( mask.isSet(G4PARTICLE_SIM_DECAY_TRACKER) );
344  q->setDecayedInCalorimeter( mask.isSet(G4PARTICLE_SIM_DECAY_CALO) );
345  q->setHasLeftDetector( mask.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) );
346  q->setStopped( mask.isSet(G4PARTICLE_SIM_STOPPED) );
347  q->setOverlay( false );
348 
349  //fg: if simstatus !=0 we have to set the generator status to 0:
350  if( q->isCreatedInSimulation() )
351  q->setGeneratorStatus( 0 ) ;
352 
353  q->setSpin(p->spin);
354  q->setColorFlow(p->colorFlow);
355 
356  lc_coll->addElement(q);
357  p_ids[id] = cnt;
358  p_part[cnt] = p;
359  p_lcio[cnt] = q;
360  }
361 
362  // Now establish parent-daughter relationships
363  for(size_t i=0, n=p_ids.size(); i<n; ++i) {
364  map<int,int>::iterator k;
365  const Geant4Particle* p = p_part[i];
366  MCParticleImpl* q = p_lcio[i];
367  const Geant4Particle::Particles& dau = p->daughters;
368  for( Geant4Particle::Particles::const_iterator j=dau.begin(); j != dau.end(); ++j ) {
369  int idau = *j;
370  if ( (k=p_ids.find(idau)) == p_ids.end() ) { // Error!!!
371  printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau);
372  continue;
373  }
374  int iqdau = (*k).second;
375  MCParticleImpl* qdau = p_lcio[iqdau];
376  qdau->addParent(q);
377  }
378  const Geant4Particle::Particles& par = p->parents;
379  for( Geant4Particle::Particles::const_iterator j=par.begin(); j != par.end(); ++j ) {
380  int ipar = *j; // A parent ID iof -1 means NO parent, because a base of 0 is perfectly leagal!
381  if ( ipar >= 0 ) {
382  if( (k=p_ids.find(ipar)) == p_ids.end() ) { // Error!!!
383  printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar);
384  continue;
385  }
386  int iqpar = (*k).second;
387  MCParticleImpl* qpar = p_lcio[iqpar];
388  q->addParent(qpar);
389  }
390  }
391  }
392  }
393  return lc_coll;
394 }
395 
398  lcio::LCEventImpl* e = context()->event().extension<lcio::LCEventImpl>();
399  EventParameters* parameters = context()->event().extension<EventParameters>(false);
400  int runNumber(0), eventNumber(0);
401  const int eventNumberOffset(m_eventNumberOffset > 0 ? m_eventNumberOffset : 0);
402  const int runNumberOffset(m_runNumberOffset > 0 ? m_runNumberOffset : 0);
403  double eventWeight{0};
404  // Get event number, run number and parameters from extension ...
405  if (parameters) {
406  runNumber = parameters->runNumber() + runNumberOffset;
407  eventNumber = parameters->eventNumber() + eventNumberOffset;
408  parameters->extractParameters(*e);
409 #if LCIO_VERSION_GE(2, 17)
410  eventWeight = e->getParameters().getDoubleVal("EventWeights");
411 #endif
412  } else { // ... or from DD4hep framework
413  runNumber = m_runNo + runNumberOffset;
414  eventNumber = ctxt.context->GetEventID() + eventNumberOffset;
415  }
416  print("+++ Saving LCIO event %d run %d ....", eventNumber, runNumber);
417  e->setRunNumber(runNumber);
418  e->setEventNumber(eventNumber);
419  e->setWeight(eventWeight);
420  e->setDetectorName(context()->detectorDescription().header().name());
421  saveEventParameters<int>(e, m_eventParametersInt);
422  saveEventParameters<float>(e, m_eventParametersFloat);
423  saveEventParameters<std::string>(e, m_eventParametersString);
424  lcio::LCEventImpl* evt = context()->event().extension<lcio::LCEventImpl>();
425  Geant4ParticleMap* part_map = context()->event().extension<Geant4ParticleMap>(false);
426  if ( part_map ) {
427  print("+++ Saving %d LCIO particles....",int(part_map->particleMap.size()));
428  if ( part_map->particleMap.size() > 0 ) {
429  lcio::LCCollectionVec* col = saveParticles(part_map);
430  evt->addCollection(col,lcio::LCIO::MCPARTICLE);
431  }
432  }
433 }
434 
437  size_t nhits = collection->GetSize();
438  std::string hc_nam = collection->GetName();
439  print("+++ Saving LCIO collection %s with %d entries....",hc_nam.c_str(),int(nhits));
440  typedef pair<const Geant4Context*,G4VHitsCollection*> _Args;
442  const _C& cnv = _C::converter(typeid(Geant4HitCollection));
443  cnv(_Args(context(),collection));
444 }
445 
Geant4DataConversion.h
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:85
dd4hep::sim::Geant4Output2LCIO::m_runNo
int m_runNo
Definition: Geant4Output2LCIO.cpp:96
Geant4HitCollection.h
dd4hep::sim::Geant4Particle::vsz
double vsz
Definition: Geant4Particle.h:124
dd4hep::sim::G4PARTICLE_GEN_STABLE
@ G4PARTICLE_GEN_STABLE
Definition: Geant4Particle.h:71
dd4hep::sim::Geant4Conversion
Data conversion class.
Definition: Geant4DataConversion.h:54
dd4hep::sim::G4PARTICLE_SIM_PARENT_RADIATED
@ G4PARTICLE_SIM_PARENT_RADIATED
Definition: Geant4Particle.h:91
dd4hep::sim::Geant4Particle::mass
double mass
Particle mass.
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4Particle::vey
double vey
Definition: Geant4Particle.h:126
Detector.h
_C
DetElement::Children _C
Definition: GeometryWalk.cpp:64
dd4hep::sim::Geant4Particle::pez
double pez
Definition: Geant4Particle.h:130
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:108
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:278
dd4hep::versionString
std::string versionString()
return a string with the current dd4hep version in the form vXX-YY.
Definition: DetectorImp.cpp:139
dd4hep::sim::Geant4Particle::pdgID
int pdgID
Definition: Geant4Particle.h:115
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:128
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:248
dd4hep::sim::G4PARTICLE_GEN_DOCUMENTATION
@ G4PARTICLE_GEN_DOCUMENTATION
Definition: Geant4Particle.h:73
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition: Geant4Particle.h:86
RunParameters.h
dd4hep::sim::RunParameters
Extension to pass input run data to output run data.
Definition: RunParameters.h:31
dd4hep::sim::Geant4Output2LCIO::saveEvent
virtual void saveEvent(OutputContext< G4Event > &ctxt)
Callback to store the Geant4 event.
Definition: Geant4Output2LCIO.cpp:397
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:337
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:243
dd4hep::sim::G4PARTICLE_SIM_STOPPED
@ G4PARTICLE_SIM_STOPPED
Definition: Geant4Particle.h:89
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:105
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::Geant4Output2LCIO::saveCollection
virtual void saveCollection(OutputContext< G4Event > &ctxt, G4VHitsCollection *collection)
Callback to store each Geant4 hit collection.
Definition: Geant4Output2LCIO.cpp:436
dd4hep::sim::Geant4ParticleMap::ParticleMap
std::map< int, Particle * > ParticleMap
Definition: Geant4Particle.h:340
dd4hep::sim::Geant4Particle::colorFlow
int colorFlow[2]
Definition: Geant4Particle.h:117
dd4hep::sim::Geant4Particle::spin
float spin[3]
Definition: Geant4Particle.h:121
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:259
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::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::Geant4Output2LCIO::saveParticles
lcio::LCCollectionVec * saveParticles(Geant4ParticleMap *particles)
Data conversion interface for MC particles to LCIO format.
Definition: Geant4Output2LCIO.cpp:286
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:134
dd4hep::sim::Geant4Particle::pex
double pex
The track momentum at the end vertex.
Definition: Geant4Particle.h:130
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:126
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:124
dd4hep::sim::Geant4Particle::psx
double psx
The track momentum at the start vertex.
Definition: Geant4Particle.h:128
dd4hep::sim::G4PARTICLE_GEN_BEAM
@ G4PARTICLE_GEN_BEAM
Definition: Geant4Particle.h:74
dd4hep::sim::Geant4ParticleHandle::definition
const G4ParticleDefinition * definition() const
Access the Geant4 particle definition object (expensive!)
Definition: Geant4Particle.cpp:116
dd4hep::sim::Geant4Output2LCIO::beginRun
virtual void beginRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2LCIO.cpp:232
dd4hep::sim::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:130
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:343
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition: Geant4Particle.h:90
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: HepMC3EventReader.cpp:37
dd4hep::sim::RunParameters::extractParameters
void extractParameters(T &destination)
Put parameters into destination.
Definition: Geant4Output2LCIO.cpp:66
std
Definition: Plugins.h:30
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:31
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:181
dd4hep::sim::Geant4Particle::parents
Particles parents
The list of parents of this MC particle.
Definition: Geant4Particle.h:138
Geant4Particle.h
dd4hep::sim::Geant4Particle::vsy
double vsy
Definition: Geant4Particle.h:124
dd4hep::sim::Geant4Output2LCIO::m_eventNumberOffset
int m_eventNumberOffset
Definition: Geant4Output2LCIO.cpp:98
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:103
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:128
dd4hep::sim::G4PARTICLE_GEN_OTHER
@ G4PARTICLE_GEN_OTHER
Definition: Geant4Particle.h:76
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:222
dd4hep::sim::Geant4Output2LCIO::m_eventParametersInt
std::map< std::string, std::string > m_eventParametersInt
Definition: Geant4Output2LCIO.cpp:100