DD4hep  1.37.0
Detector Description Toolkit for High Energy Physics
Geant4Output2EDM4hep.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 : F.Gaede, DESY
11 //
12 //==========================================================================
13 #ifndef DD4HEP_DDG4_GEANT4OUTPUT2EDM4hep_H
14 #define DD4HEP_DDG4_GEANT4OUTPUT2EDM4hep_H
15 
17 #include <DD4hep/Detector.h>
18 #include <DDG4/EventParameters.h>
19 #include <DDG4/FileParameters.h>
21 #include <DDG4/RunParameters.h>
22 
24 #include <edm4hep/MCParticleCollection.h>
25 #include <edm4hep/SimTrackerHitCollection.h>
26 #include <edm4hep/CaloHitContributionCollection.h>
27 #include <edm4hep/SimCalorimeterHitCollection.h>
28 #include <edm4hep/EDM4hepVersion.h>
29 #include <edm4hep/Constants.h>
30 #if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 0)
31  using edm4hep::CellIDEncoding;
32 #else
33  using edm4hep::labels::CellIDEncoding;
34 #endif
35 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 3)
36 #include <edm4hep/GeneratorEventParametersCollection.h>
37 #endif
38 
40 #include <podio/CollectionBase.h>
41 #include <podio/podioVersion.h>
42 #include <podio/Frame.h>
43 #include <podio/FrameCategories.h>
44 #if PODIO_BUILD_VERSION >= PODIO_VERSION(1, 0, 0)
45 #include <podio/Writer.h>
46 #else
47 #if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
48 #include <podio/ROOTWriter.h>
49 #else
50 #include <podio/ROOTFrameWriter.h>
51 namespace podio {
52  using ROOTWriter = podio::ROOTFrameWriter;
53 }
54 #endif
55 #endif
56 
57 #include <atomic>
58 
60 namespace dd4hep {
61 
62  class ComponentCast;
63 
65  namespace sim {
66 
67  class Geant4ParticleMap;
68 
70 
76  protected:
77 #if PODIO_BUILD_VERSION >= PODIO_VERSION(1, 0, 0)
78  using writer_t = podio::Writer;
79 #else
80  using writer_t = podio::ROOTWriter;
81 #endif
82  using floatmap_t = std::map< std::string, float >;
83  using intmap_t = std::map< std::string, int >;
84  using stringmap_t = std::map< std::string, std::string >;
85  using trackermap_t = std::map< std::string, edm4hep::SimTrackerHitCollection >;
86  using calorimeterpair_t = std::pair< edm4hep::SimCalorimeterHitCollection, edm4hep::CaloHitContributionCollection >;
87  using calorimetermap_t = std::map< std::string, calorimeterpair_t >;
88  std::unique_ptr<writer_t> m_file { };
89  std::atomic_size_t m_fileUseCount { 0 };
90  podio::Frame m_frame { };
91  edm4hep::MCParticleCollection m_particles { };
102  std::string m_section_name { podio::Category::Event };
103  int m_runNo { 0 };
104  int m_runNumberOffset { 0 };
105  int m_eventNo { 0 };
107  bool m_filesByRun { false };
108  bool m_rntuple { false };
109 
111  void saveParticles(Geant4ParticleMap* particles);
113  void saveFileMetaData();
114  public:
116  Geant4Output2EDM4hep(Geant4Context* ctxt, const std::string& nam);
118  virtual ~Geant4Output2EDM4hep();
120  virtual void beginRun(const G4Run* run);
122  virtual void endRun(const G4Run* run);
123 
125  virtual void saveRun(const G4Run* run);
127  virtual void saveEvent( OutputContext<G4Event>& ctxt);
129  virtual void saveCollection( OutputContext<G4Event>& ctxt, G4VHitsCollection* collection);
131  virtual void commit( OutputContext<G4Event>& ctxt);
132 
134  virtual void begin(const G4Event* event);
135  protected:
137  template <typename T>
138  void saveEventParameters(const std::map<std::string, T >& parameters) {
139  for(const auto& p : parameters) {
140  std::stringstream output;
141  output << "Saving event parameter: "
142  << std::setw(32) << p.first
143  << std::setw(20) << p.second;
144  info(output.str().c_str());
145  m_frame.putParameter(p.first, p.second);
146  }
147  }
148  };
149 
150  template <> void EventParameters::extractParameters(podio::Frame& frame) {
151  for(auto const& p: this->intParameters()) {
152  printout(DEBUG, "Geant4OutputEDM4hep", "Saving event parameter: %s", p.first.c_str());
153  frame.putParameter(p.first, p.second);
154  }
155  for(auto const& p: this->fltParameters()) {
156  printout(DEBUG, "Geant4OutputEDM4hep", "Saving event parameter: %s", p.first.c_str());
157  frame.putParameter(p.first, p.second);
158  }
159  for(auto const& p: this->strParameters()) {
160  printout(DEBUG, "Geant4OutputEDM4hep", "Saving event parameter: %s", p.first.c_str());
161  frame.putParameter(p.first, p.second);
162  }
163  // This functionality is only present in podio > 0.16.2
164  for (auto const& p: this->dblParameters()) {
165  printout(DEBUG, "Geant4OutputEDM4hep", "Saving event parameter: %s", p.first.c_str());
166  frame.putParameter(p.first, p.second);
167  }
168  }
169 
170  template <> void RunParameters::extractParameters(podio::Frame& frame) {
171  for(auto const& p: this->intParameters()) {
172  printout(DEBUG, "Geant4OutputEDM4hep", "Saving run parameter: %s", p.first.c_str());
173  frame.putParameter(p.first, p.second);
174  }
175  for(auto const& p: this->fltParameters()) {
176  printout(DEBUG, "Geant4OutputEDM4hep", "Saving run parameter: %s", p.first.c_str());
177  frame.putParameter(p.first, p.second);
178  }
179  for(auto const& p: this->strParameters()) {
180  printout(DEBUG, "Geant4OutputEDM4hep", "Saving run parameter: %s", p.first.c_str());
181  frame.putParameter(p.first, p.second);
182  }
183  // This functionality is only present in podio > 0.16.2
184  for (auto const& p: this->dblParameters()) {
185  printout(DEBUG, "Geant4OutputEDM4hep", "Saving run parameter: %s", p.first.c_str());
186  frame.putParameter(p.first, p.second);
187  }
188  }
189  template <> void FileParameters::extractParameters(podio::Frame& frame) {
190  for(auto const& p: this->intParameters()) {
191  printout(DEBUG, "Geant4OutputEDM4hep", "Saving meta parameter: %s", p.first.c_str());
192  frame.putParameter(p.first, p.second);
193  }
194  for(auto const& p: this->fltParameters()) {
195  printout(DEBUG, "Geant4OutputEDM4hep", "Saving meta parameter: %s", p.first.c_str());
196  frame.putParameter(p.first, p.second);
197  }
198  for(auto const& p: this->strParameters()) {
199  printout(DEBUG, "Geant4OutputEDM4hep", "Saving meta parameter: %s", p.first.c_str());
200  frame.putParameter(p.first, p.second);
201  }
202  // This functionality is only present in podio > 0.16.2
203  for (auto const& p: this->dblParameters()) {
204  printout(DEBUG, "Geant4OutputEDM4hep", "Saving meta parameter: %s", p.first.c_str());
205  frame.putParameter(p.first, p.second);
206  }
207  }
208 
209  } // End namespace sim
210 } // End namespace dd4hep
211 #endif // DD4HEP_DDG4_GEANT4OUTPUT2EDM4hep_H
212 
213 //==========================================================================
214 // AIDA Detector description implementation
215 //--------------------------------------------------------------------------
216 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
217 // All rights reserved.
218 //
219 // For the licensing terms see $DD4hepINSTALL/LICENSE.
220 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
221 //
222 // Author : F.Gaede, DESY
223 //
224 //==========================================================================
225 
227 #include <DD4hep/InstanceCount.h>
228 #include <DD4hep/VolumeManager.h>
229 
233 #include <DDG4/Geant4Context.h>
234 #include <DDG4/Geant4Particle.h>
235 #include <DDG4/Geant4Data.h>
236 
239 #include <G4Threading.hh>
240 #include <G4AutoLock.hh>
241 #include <G4Version.hh>
242 #include <G4ParticleDefinition.hh>
243 #include <G4VProcess.hh>
244 #include <G4Event.hh>
245 #include <G4Run.hh>
247 #include <CLHEP/Units/SystemOfUnits.h>
248 
250 #include <edm4hep/EventHeaderCollection.h>
251 
252 using namespace dd4hep::sim;
253 using namespace dd4hep;
254 
255 namespace {
256  G4Mutex action_mutex = G4MUTEX_INITIALIZER;
257 }
258 
259 #include <DDG4/Factories.h>
261 
262 Geant4Output2EDM4hep::Geant4Output2EDM4hep(Geant4Context* ctxt, const std::string& nam)
264 : Geant4OutputAction(ctxt,nam), m_runNo(0), m_runNumberOffset(0), m_eventNumberOffset(0)
265 {
266  declareProperty("RunHeader", m_runHeader);
267  declareProperty("EventParametersInt", m_eventParametersInt);
268  declareProperty("EventParametersFloat", m_eventParametersFloat);
269  declareProperty("EventParametersString", m_eventParametersString);
270  declareProperty("RunParametersInt", m_runParametersInt);
271  declareProperty("RunParametersFloat", m_runParametersFloat);
272  declareProperty("RunParametersString", m_runParametersString);
273  declareProperty("RunNumberOffset", m_runNumberOffset);
274  declareProperty("EventNumberOffset", m_eventNumberOffset);
275  declareProperty("SectionName", m_section_name);
276  declareProperty("FilesByRun", m_filesByRun);
277  declareProperty("RNTuple", m_rntuple);
278 
279  info("Writer is now instantiated ..." );
281 }
282 
285  G4AutoLock protection_lock(&action_mutex);
287 }
288 
289 // Callback to store the Geant4 run information
290 void Geant4Output2EDM4hep::beginRun(const G4Run* run) {
291  G4AutoLock protection_lock(&action_mutex);
292  std::string fname = m_output;
293  m_runNo = run->GetRunID();
294  if ( m_filesByRun ) {
295  std::size_t idx = m_output.rfind(".");
296  if ( idx != std::string::npos ) {
297  fname = m_output.substr(0, idx) + _toString(m_runNo, ".run%08d") + m_output.substr(idx);
298  }
299  }
300  // Create the file only when it has not yet beeen created in another thread
301  if ( !fname.empty() && !m_file ) {
302 #if PODIO_BUILD_VERSION >= PODIO_VERSION(1, 0, 0)
303  m_file = std::make_unique<podio::Writer>(podio::makeWriter(fname, m_rntuple ? "rntuple" : "default"));
304 #else
305  m_file = std::make_unique<podio::ROOTWriter>(fname);
306 #endif
307  if ( !m_file ) {
308  fatal("+++ Failed to open output file: %s", fname.c_str());
309  }
310  printout( INFO, "Geant4Output2EDM4hep" ,"Opened %s for output", fname.c_str() ) ;
311  }
312  m_fileUseCount++;
313 }
314 
316 void Geant4Output2EDM4hep::endRun(const G4Run* run) {
317  saveRun(run);
319 
320  // Close the file only when this is the last thread using it.
321  // Note: Although the use count is atomic, the file pointer is not,
322  // and testing it requires locking.
323  G4AutoLock protection_lock(&action_mutex);
324  if ( m_file && m_fileUseCount == 1 ) {
325  m_file->finish();
326  m_file.reset();
327  }
328  m_fileUseCount--;
329 }
330 
332  podio::Frame metaFrame{};
333  for (const auto& [name, encodingStr] : m_cellIDEncodingStrings) {
334  metaFrame.putParameter(podio::collMetadataParamName(name, CellIDEncoding), encodingStr);
335  }
336  if (context()->runPtr() != nullptr) {
337  FileParameters* parameters = context()->run().extension<FileParameters>(false);
338  if ( parameters ) {
339  parameters->extractParameters(metaFrame);
340  }
341  }
342  G4AutoLock protection_lock(&action_mutex);
343  m_file->writeFrame(metaFrame, podio::Category::Metadata);
344 }
345 
348  if ( m_file ) {
349  G4AutoLock protection_lock(&action_mutex);
350  m_frame.put( std::move(m_particles), "MCParticles");
351  for (auto it = m_trackerHits.begin(); it != m_trackerHits.end(); ++it) {
352  m_frame.put( std::move(it->second), it->first);
353  }
354  for (auto& [colName, calorimeterHits] : m_calorimeterHits) {
355  m_frame.put( std::move(calorimeterHits.first), colName);
356  m_frame.put( std::move(calorimeterHits.second), colName + "Contributions");
357  }
358  m_file->writeFrame(m_frame, m_section_name);
359  m_particles = { };
360  m_trackerHits.clear();
361  m_calorimeterHits.clear();
362  m_frame = {};
363  return;
364  }
365  except("+++ Failed to write output file. [Stream is not open]");
366 }
367 
369 void Geant4Output2EDM4hep::saveRun(const G4Run* run) {
370  G4AutoLock protection_lock(&action_mutex);
371  // --- write an edm4hep::RunHeader ---------
372  // Runs are just Frames with different contents in EDM4hep / podio. We simply
373  // store everything as parameters for now
374  podio::Frame runHeader {};
375  for (const auto& [key, value] : m_runHeader)
376  runHeader.putParameter(key, value);
377 
378  for (const auto& [key, value] : m_runParametersInt)
379  runHeader.putParameter(key, value);
380 
381  for (const auto& [key, value] : m_runParametersFloat)
382  runHeader.putParameter(key, value);
383 
384  for (const auto& [key, value] : m_runParametersString)
385  runHeader.putParameter(key, value);
386 
387  m_runNo = m_runNumberOffset > 0 ? m_runNumberOffset + run->GetRunID() : run->GetRunID();
388  runHeader.putParameter("runNumber", m_runNo);
389  runHeader.putParameter("GEANT4Version", G4Version);
390  runHeader.putParameter("DD4hepVersion", versionString());
391  runHeader.putParameter("detectorName", context()->detectorDescription().header().name());
392  {
393  // In multithreaded running, the run is present in only one of the contexts
394  if (context()->runPtr() != nullptr) {
395  RunParameters* parameters = context()->run().extension<RunParameters>(false);
396  if ( parameters ) {
397  parameters->extractParameters(runHeader);
398  }
399  m_file->writeFrame(runHeader, podio::Category::Run);
400  }
401  }
402 }
403 
404 void Geant4Output2EDM4hep::begin(const G4Event* event) {
406  m_eventNo = event->GetEventID();
407  m_frame = {};
408  m_particles = {};
409  m_trackerHits.clear();
410  m_calorimeterHits.clear();
411 }
412 
415  typedef detail::ReferenceBitMask<const int> PropertyMask;
416  typedef Geant4ParticleMap::ParticleMap ParticleMap;
417  const ParticleMap& pm = particles->particleMap;
418 
419  m_particles.clear();
420  if ( pm.size() > 0 ) {
421  size_t cnt = 0;
422  // Mapping of ids in the ParticleMap to indices in the MCParticle collection
423  std::map<int,int> p_ids;
424  std::vector<const Geant4Particle*> p_part;
425  p_part.reserve(pm.size());
426  // First create the particles
427  for (const auto& iParticle : pm) {
428  int id = iParticle.first;
429  const Geant4ParticleHandle p = iParticle.second;
430  PropertyMask mask(p->status);
431  // std::cout << " ********** mcp status : 0x" << std::hex << p->status << ", mask.isSet(G4PARTICLE_GEN_STABLE) x" << std::dec << mask.isSet(G4PARTICLE_GEN_STABLE) <<std::endl ;
432  const G4ParticleDefinition* def = p.definition();
433  auto mcp = m_particles.create();
434  mcp.setPDG(p->pdgID);
435  // Because EDM4hep is switching between vector3f[loat] and vector3d[ouble]
436  using MT = decltype(std::declval<edm4hep::MCParticle>().getMomentum().x);
437  mcp.setMomentum( {MT(p->psx/CLHEP::GeV),MT(p->psy/CLHEP::GeV),MT(p->psz/CLHEP::GeV)} );
438  mcp.setMomentumAtEndpoint( {MT(p->pex/CLHEP::GeV),MT(p->pey/CLHEP::GeV),MT(p->pez/CLHEP::GeV)} );
439 
440  double vs_fa[3] = { p->vsx/CLHEP::mm, p->vsy/CLHEP::mm, p->vsz/CLHEP::mm } ;
441  mcp.setVertex( vs_fa );
442 
443  double ve_fa[3] = { p->vex/CLHEP::mm, p->vey/CLHEP::mm, p->vez/CLHEP::mm } ;
444  mcp.setEndpoint( ve_fa );
445 
446  mcp.setTime(p->time/CLHEP::ns);
447  mcp.setMass(p->mass/CLHEP::GeV);
448  mcp.setCharge(def ? def->GetPDGCharge() : 0); // Charge(e+) = 1 !
449 
450  // Set generator status
451  mcp.setGeneratorStatus(0);
452  if( p->genStatus ) {
453  mcp.setGeneratorStatus( p->genStatus ) ;
454  } else {
455  if ( mask.isSet(G4PARTICLE_GEN_STABLE) ) mcp.setGeneratorStatus(1);
456  else if ( mask.isSet(G4PARTICLE_GEN_DECAYED) ) mcp.setGeneratorStatus(2);
457  else if ( mask.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) mcp.setGeneratorStatus(3);
458  else if ( mask.isSet(G4PARTICLE_GEN_BEAM) ) mcp.setGeneratorStatus(4);
459  else if ( mask.isSet(G4PARTICLE_GEN_OTHER) ) mcp.setGeneratorStatus(9);
460  }
461 
462  // Set simulation status
463  mcp.setCreatedInSimulation( mask.isSet(G4PARTICLE_SIM_CREATED) );
464  mcp.setBackscatter( mask.isSet(G4PARTICLE_SIM_BACKSCATTER) );
465  mcp.setVertexIsNotEndpointOfParent( mask.isSet(G4PARTICLE_SIM_PARENT_RADIATED) );
466  mcp.setDecayedInTracker( mask.isSet(G4PARTICLE_SIM_DECAY_TRACKER) );
467  mcp.setDecayedInCalorimeter( mask.isSet(G4PARTICLE_SIM_DECAY_CALO) );
468  mcp.setHasLeftDetector( mask.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) );
469  mcp.setStopped( mask.isSet(G4PARTICLE_SIM_STOPPED) );
470  mcp.setOverlay( false );
471 
472  //fg: if simstatus !=0 we have to set the generator status to 0:
473  if( mcp.isCreatedInSimulation() )
474  mcp.setGeneratorStatus( 0 ) ;
475 
476 #if EDM4HEP_MCPARTICLE_HAS_HELICITY
477  mcp.setHelicity(p->spin[2]);
478 #else
479  mcp.setSpin(p->spin);
480 #endif
481 
482  p_ids[id] = cnt++;
483  p_part.push_back(p);
484  }
485 
486  // Now establish parent-daughter relationships
487  for(size_t i=0; i < p_ids.size(); ++i) {
488  const Geant4Particle* p = p_part[i];
489  auto q = m_particles[i];
490 
491  for (const auto& idau : p->daughters) {
492  const auto k = p_ids.find(idau);
493  if (k == p_ids.end()) {
494  fatal("+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau);
495  continue;
496  }
497  int iqdau = (*k).second;
498  auto qdau = m_particles[iqdau];
499  q.addToDaughters(qdau);
500  }
501 
502  for (const auto& ipar : p->parents) {
503  if (ipar >= 0) { // A parent ID of -1 means NO parent, because a base of 0 is perfectly legal
504  const auto k = p_ids.find(ipar);
505  if (k == p_ids.end()) {
506  fatal("+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar);
507  continue;
508  }
509  int iqpar = (*k).second;
510  auto qpar = m_particles[iqpar];
511  q.addToParents(qpar);
512  }
513  }
514  }
515  }
516 }
517 
520  EventParameters* parameters = context()->event().extension<EventParameters>(false);
521  int runNumber(0), eventNumber(0);
522  const int eventNumberOffset(m_eventNumberOffset > 0 ? m_eventNumberOffset : 0);
523  const int runNumberOffset(m_runNumberOffset > 0 ? m_runNumberOffset : 0);
524  double eventWeight{0};
525  // Get event number, run number and parameters from extension ...
526  if ( parameters ) {
527  runNumber = parameters->runNumber() + runNumberOffset;
528  eventNumber = parameters->eventNumber() + eventNumberOffset;
529  parameters->extractParameters(m_frame);
530 #if PODIO_BUILD_VERSION > PODIO_VERSION(0, 99, 0)
531  eventWeight = m_frame.getParameter<double>("EventWeights").value_or(0.0);
532 #else
533  eventWeight = m_frame.getParameter<double>("EventWeights");
534 #endif
535  } else { // ... or from DD4hep framework
536  runNumber = m_runNo + runNumberOffset;
537  eventNumber = ctxt.context->GetEventID() + eventNumberOffset;
538  }
539  printout(INFO,"Geant4Output2EDM4hep","+++ Saving EDM4hep event %d run %d.", eventNumber, runNumber);
540 
541  // this does not compile as create() is we only get a const ref - need to review PODIO EventStore API
542  edm4hep::EventHeaderCollection header_collection;
543 
544  auto header = header_collection.create();
545  header.setRunNumber(runNumber);
546  header.setEventNumber(eventNumber);
547  header.setWeight(eventWeight);
548  //not implemented in EDM4hep ? header.setDetectorName(context()->detectorDescription().header().name());
549  header.setTimeStamp(std::time(nullptr));
550 
551  // extract event header, in case we come from edm4hep input
552  auto* meh = context()->event().extension<edm4hep::MutableEventHeader>(false);
553  if(meh) {
554  header.setTimeStamp(meh->getTimeStamp());
555 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0)
556  for (auto const& weight: meh->getWeights()) {
557  header.addToWeights(weight);
558  }
559 #endif
560  }
561 
562  m_frame.put(std::move(header_collection), "EventHeader");
563 
564 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 3)
565  // Attach the generator event parameters again if they are available
566  auto* genEvtParams = context()->event().extension<edm4hep::MutableGeneratorEventParameters>(false);
567  if (genEvtParams) {
568  edm4hep::GeneratorEventParametersCollection genEvtParamsColl{};
569  genEvtParamsColl.push_back(*genEvtParams);
570  m_frame.put(std::move(genEvtParamsColl), edm4hep::labels::GeneratorEventParameters);
571  }
572 #endif
573 
574  saveEventParameters<int>(m_eventParametersInt);
575  saveEventParameters<float>(m_eventParametersFloat);
576  saveEventParameters<std::string>(m_eventParametersString);
577 
578  Geant4ParticleMap* part_map = context()->event().extension<Geant4ParticleMap>(false);
579  if ( part_map ) {
580  print("+++ Saving %d EDM4hep particles....",int(part_map->particleMap.size()));
581  if ( part_map->particleMap.size() > 0 ) {
582  saveParticles(part_map);
583  }
584  }
585 }
586 
597  operator std::string() const {
598  const auto* sd = m_coll->sensitive();
599  return dd4hep::sim::Geant4ConversionHelper::encoding(sd->sensitiveDetector());
600  }
601 private:
602  Geant4HitCollection* m_coll{nullptr};
603 };
604 
605 
608  Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(collection);
609  std::string colName = collection->GetName();
610  if( coll == nullptr ){
611  error(" no Geant4HitCollection: %s ", colName.c_str());
612  return ;
613  }
614  size_t nhits = collection->GetSize();
616  debug("+++ Saving EDM4hep collection %s with %d entries.", colName.c_str(), int(nhits));
617 
618  // Using try_emplace here to only fill this the first time we come across
619  m_cellIDEncodingStrings.try_emplace(colName, LazyEncodingExtraction{coll});
620 
621  //-------------------------------------------------------------------
622  if( typeid( Geant4Tracker::Hit ) == coll->type().type() ){
623  // Create the hit container even if there are no entries!
624  auto& hits = m_trackerHits[colName];
625  for(unsigned i=0 ; i < nhits ; ++i){
626  auto sth = hits.create();
627  const Geant4Tracker::Hit* hit = coll->hit(i);
628  const Geant4Tracker::Hit::Contribution& t = hit->truth;
629  int trackID = pm->particleID(t.trackID);
630  auto mcp = m_particles.at(trackID);
631  const auto& mom = hit->momentum;
632  const auto& pos = hit->position;
633  edm4hep::Vector3f();
634  sth.setCellID( hit->cellID ) ;
635  sth.setEDep(hit->energyDeposit/CLHEP::GeV);
636  sth.setPathLength(hit->length/CLHEP::mm);
637  sth.setTime(hit->truth.time/CLHEP::ns);
638 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 10, 99)
639  sth.setParticle(mcp);
640 #else
641  sth.setMCParticle(mcp);
642 #endif
643  sth.setPosition( {pos.x()/CLHEP::mm, pos.y()/CLHEP::mm, pos.z()/CLHEP::mm} );
644  sth.setMomentum( {float(mom.x()/CLHEP::GeV),float(mom.y()/CLHEP::GeV),float(mom.z()/CLHEP::GeV)} );
645  auto particleIt = pm->particles().find(trackID);
646  if( ( particleIt != pm->particles().end()) ){
647  // if the original track ID of the particle is not the same as the
648  // original track ID of the hit it was produced by an MCParticle that
649  // is no longer stored
650  sth.setProducedBySecondary( (particleIt->second->originalG4ID != t.trackID) );
651  }
652  }
653  //-------------------------------------------------------------------
654  }
655  else if( typeid( Geant4Calorimeter::Hit ) == coll->type().type() ){
656  Geant4Sensitive* sd = coll->sensitive();
657  int hit_creation_mode = sd->hitCreationMode();
658  // Create the hit container even if there are no entries!
659  auto& hits = m_calorimeterHits[colName];
660  for(unsigned i=0 ; i < nhits ; ++i){
661  auto sch = hits.first.create();
662  const Geant4Calorimeter::Hit* hit = coll->hit(i);
663  const auto& pos = hit->position;
664  sch.setCellID( hit->cellID );
665  sch.setPosition({float(pos.x()/CLHEP::mm), float(pos.y()/CLHEP::mm), float(pos.z()/CLHEP::mm)});
666  sch.setEnergy( hit->energyDeposit/CLHEP::GeV );
667 
668 
669  // now add the individual step contributions
670  for(auto ci=hit->truth.begin(); ci != hit->truth.end(); ++ci){
671 
672  auto sCaloHitCont = hits.second.create();
673  sch.addToContributions( sCaloHitCont );
674 
675  const Geant4HitData::Contribution& c = *ci;
676  int trackID = pm->particleID(c.trackID);
677  auto mcp = m_particles.at(trackID);
678  sCaloHitCont.setEnergy( c.deposit/CLHEP::GeV );
679  sCaloHitCont.setTime( c.time/CLHEP::ns );
680  sCaloHitCont.setParticle( mcp );
681 
682 #if EDM4HEP_BUILD_VERSION > EDM4HEP_VERSION(1, 0, 0)
683  // In case this contribution has been created via a fast simulation
684  // method, the step length has been set to -1 at its creation. All
685  // contributions that have gone through "normal" simulation will have a
686  // step length >= 0 by definition.
687  if (c.length < 0) {
688  mcp.setHandledByFastSim(true);
689  }
690 #endif
691  if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) {
692  edm4hep::Vector3f p(c.x/CLHEP::mm, c.y/CLHEP::mm, c.z/CLHEP::mm);
693  sCaloHitCont.setPDG( c.pdgID );
694  sCaloHitCont.setStepPosition( p );
695 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 3)
696  sCaloHitCont.setStepLength(c.length / CLHEP::mm);
697 #endif
698  }
699  }
700  }
701  //-------------------------------------------------------------------
702  } else {
703  error("+++ unknown type in Geant4HitCollection %s ", coll->type().type().name());
704  }
705 }
Geant4DataConversion.h
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:87
dd4hep::sim::Geant4Tracker::Hit::momentum
Direction momentum
Hit direction.
Definition: Geant4Data.h:270
dd4hep::sim::Geant4Output2EDM4hep::beginRun
virtual void beginRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2EDM4hep.cpp:290
dd4hep::sim::Geant4Output2EDM4hep::intmap_t
std::map< std::string, int > intmap_t
Definition: Geant4Output2EDM4hep.cpp:83
dd4hep::sim::Geant4Tracker::Hit::position
Position position
Hit position.
Definition: Geant4Data.h:268
dd4hep::sim::Geant4Output2EDM4hep::m_runParametersFloat
floatmap_t m_runParametersFloat
Definition: Geant4Output2EDM4hep.cpp:99
dd4hep::sim::Geant4Output2EDM4hep::m_eventParametersString
stringmap_t m_eventParametersString
Definition: Geant4Output2EDM4hep.cpp:97
Geant4HitCollection.h
dd4hep::sim::Geant4Output2EDM4hep::m_eventNo
int m_eventNo
Definition: Geant4Output2EDM4hep.cpp:105
dd4hep::sim::Geant4Particle::vsz
double vsz
Definition: Geant4Particle.h:126
dd4hep::sim::ExtensionParameters::dblParameters
auto const & dblParameters() const
Get the double parameters.
Definition: ExtensionParameters.h:46
dd4hep::sim::Geant4Output2EDM4hep::m_runHeader
stringmap_t m_runHeader
Definition: Geant4Output2EDM4hep.cpp:94
dd4hep::sim::Geant4HitData::MonteCarloContrib::pdgID
int pdgID
Particle ID from the PDG table.
Definition: Geant4Data.h:143
dd4hep::sim::Geant4Output2EDM4hep::saveRun
virtual void saveRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2EDM4hep.cpp:369
dd4hep::sim::G4PARTICLE_GEN_STABLE
@ G4PARTICLE_GEN_STABLE
Definition: Geant4Particle.h:73
dd4hep::sim::Geant4Output2EDM4hep::commit
virtual void commit(OutputContext< G4Event > &ctxt)
Commit data at end of filling procedure.
Definition: Geant4Output2EDM4hep.cpp:347
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
dd4hep::sim::Geant4HitData::MonteCarloContrib::y
float y
Definition: Geant4Data.h:151
Detector.h
dd4hep::sim::Geant4Output2EDM4hep::endRun
virtual void endRun(const G4Run *run)
Callback to store the Geant4 run information.
Definition: Geant4Output2EDM4hep.cpp:316
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
dd4hep::sim::Geant4Particle::pez
double pez
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4HitData::MonteCarloContrib::length
double length
Length of this step.
Definition: Geant4Data.h:149
dd4hep::sim::Geant4ParticleMap::particles
const ParticleMap & particles() const
Access the particle map.
Definition: Geant4Particle.h:363
dd4hep::sim::Geant4Output2EDM4hep::saveCollection
virtual void saveCollection(OutputContext< G4Event > &ctxt, G4VHitsCollection *collection)
Callback to store each Geant4 hit collection.
Definition: Geant4Output2EDM4hep.cpp:607
dd4hep::sim::Geant4Context::run
Geant4Run & run() const
Access the geant4 run – valid only between BeginRun() and EndRun()!
Definition: Geant4Context.cpp:72
dd4hep::sim::Geant4Output2EDM4hep::m_runNo
int m_runNo
Definition: Geant4Output2EDM4hep.cpp:103
dd4hep::sim::Geant4Particle::id
int id
not persistent
Definition: Geant4Particle.h:110
Geant4SensDetAction.h
dd4hep::sim::Geant4HitCollection
Generic hit container class using Geant4HitWrapper objects.
Definition: Geant4HitCollection.h:201
dd4hep::sim::Geant4Output2EDM4hep::m_eventParametersFloat
floatmap_t m_eventParametersFloat
Definition: Geant4Output2EDM4hep.cpp:96
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
dd4hep::sim::Geant4HitCollection::hit
Geant4HitWrapper & hit(size_t which)
Access the hit wrapper.
Definition: Geant4HitCollection.h:325
dd4hep::sim::Geant4Output2EDM4hep::saveEventParameters
void saveEventParameters(const std::map< std::string, T > &parameters)
Fill event parameters in EDM4hep event.
Definition: Geant4Output2EDM4hep.cpp:138
dd4hep::_toString
std::string _toString(bool value)
String conversions: boolean value to string.
Definition: Handle.cpp:332
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
LazyEncodingExtraction
Definition: Geant4Output2EDM4hep.cpp:591
Geant4Data.h
dd4hep::sim::Geant4Context::event
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition: Geant4Context.cpp:84
dd4hep::sim::Geant4Output2EDM4hep::saveEvent
virtual void saveEvent(OutputContext< G4Event > &ctxt)
Callback to store the Geant4 event.
Definition: Geant4Output2EDM4hep.cpp:519
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4HitData::cellID
long long int cellID
cellID
Definition: Geant4Data.h:124
dd4hep::sim::Geant4Output2EDM4hep::m_runParametersString
stringmap_t m_runParametersString
Definition: Geant4Output2EDM4hep.cpp:100
dd4hep::sim::Geant4Output2EDM4hep::saveParticles
void saveParticles(Geant4ParticleMap *particles)
Data conversion interface for MC particles to EDM4hep format.
Definition: Geant4Output2EDM4hep.cpp:414
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::Geant4Action::fatal
void fatal(const char *fmt,...) const
Support of fatal messages. Throws exception.
Definition: Geant4Action.cpp:248
dd4hep::sim::Geant4Output2EDM4hep::m_frame
podio::Frame m_frame
Definition: Geant4Output2EDM4hep.cpp:90
RunParameters.h
dd4hep::sim::Geant4Output2EDM4hep
Base class to output Geant4 event data to EDM4hep.
Definition: Geant4Output2EDM4hep.cpp:75
dd4hep::sim::RunParameters
Extension to pass input run data to output run data.
Definition: RunParameters.h:28
dd4hep::sim::Geant4Output2EDM4hep::calorimetermap_t
std::map< std::string, calorimeterpair_t > calorimetermap_t
Definition: Geant4Output2EDM4hep.cpp:87
dd4hep::sim::Geant4Sensitive::DETAILED_MODE
@ DETAILED_MODE
Definition: Geant4SensDetAction.h:128
VolumeManager.h
dd4hep::sim::Geant4OutputAction::OutputContext
Helper class for thread savety.
Definition: Geant4OutputAction.h:43
dd4hep::sim::Geant4Output2EDM4hep::m_eventParametersInt
intmap_t m_eventParametersInt
Definition: Geant4Output2EDM4hep.cpp:95
dd4hep::sim::Geant4ParticleMap
Data structure to map particles produced during the generation and the simulation.
Definition: Geant4Particle.h:339
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::Geant4Output2EDM4hep::writer_t
podio::Writer writer_t
Definition: Geant4Output2EDM4hep.cpp:78
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
FileParameters.h
dd4hep::sim::G4PARTICLE_SIM_STOPPED
@ G4PARTICLE_SIM_STOPPED
Definition: Geant4Particle.h:91
Geant4OutputAction.h
dd4hep::sim::Geant4Output2EDM4hep::stringmap_t
std::map< std::string, std::string > stringmap_t
Definition: Geant4Output2EDM4hep.cpp:84
EventParameters.h
dd4hep::sim::Geant4HitCollection::sensitive
Geant4Sensitive * sensitive() const
Access the sensitive detector.
Definition: Geant4HitCollection.h:313
dd4hep::sim::Geant4Output2EDM4hep::m_section_name
std::string m_section_name
Definition: Geant4Output2EDM4hep.cpp:102
dd4hep::sim::EventParameters::extractParameters
void extractParameters(T &destination)
Put parameters into destination.
Definition: Geant4Output2LCIO.cpp:46
dd4hep::sim::Geant4Action::error
void error(const char *fmt,...) const
Support of error messages.
Definition: Geant4Action.cpp:231
dd4hep::sim::Geant4Output2EDM4hep::m_trackerHits
trackermap_t m_trackerHits
Definition: Geant4Output2EDM4hep.cpp:92
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::Geant4Tracker::Hit
DDG4 tracker hit class used by the generic DDG4 tracker sensitive detector.
Definition: Geant4Data.h:263
dd4hep::sim::Geant4Tracker::Hit::length
double length
Length of the track segment contributing to this hit.
Definition: Geant4Data.h:272
dd4hep::sim::Geant4ParticleMap::ParticleMap
std::map< int, Particle * > ParticleMap
Definition: Geant4Particle.h:342
dd4hep::sim::Geant4Output2EDM4hep::calorimeterpair_t
std::pair< edm4hep::SimCalorimeterHitCollection, edm4hep::CaloHitContributionCollection > calorimeterpair_t
Definition: Geant4Output2EDM4hep.cpp:86
dd4hep::sim::Geant4Output2EDM4hep::m_calorimeterHits
calorimetermap_t m_calorimeterHits
Definition: Geant4Output2EDM4hep.cpp:93
dd4hep::sim::Geant4HitData::MonteCarloContrib::deposit
double deposit
Total energy deposit in this hit.
Definition: Geant4Data.h:145
dd4hep::sim::Geant4Particle::spin
float spin[3]
Definition: Geant4Particle.h:123
dd4hep::sim::ExtensionParameters::fltParameters
auto const & fltParameters() const
Get the float parameters.
Definition: ExtensionParameters.h:42
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4Particle::genStatus
unsigned short genStatus
Definition: Geant4Particle.h: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::Geant4Output2EDM4hep::~Geant4Output2EDM4hep
virtual ~Geant4Output2EDM4hep()
Default destructor.
Definition: Geant4Output2EDM4hep.cpp:284
dd4hep::sim::FileParameters
Extension to pass input run data to output run data.
Definition: FileParameters.h:28
dd4hep::sim::Geant4Tracker::Hit::truth
Contribution truth
Monte Carlo / Geant4 information.
Definition: Geant4Data.h:276
LazyEncodingExtraction::LazyEncodingExtraction
LazyEncodingExtraction(Geant4HitCollection *coll)
Definition: Geant4Output2EDM4hep.cpp:594
dd4hep::sim::Geant4Output2EDM4hep::m_cellIDEncodingStrings
stringmap_t m_cellIDEncodingStrings
Definition: Geant4Output2EDM4hep.cpp:101
dd4hep::sim::Geant4Output2EDM4hep::m_rntuple
bool m_rntuple
Definition: Geant4Output2EDM4hep.cpp:108
dd4hep::sim::Geant4Output2EDM4hep::saveFileMetaData
void saveFileMetaData()
Store the metadata frame with e.g. the cellID encoding strings.
Definition: Geant4Output2EDM4hep.cpp:331
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4Output2EDM4hep::m_file
std::unique_ptr< writer_t > m_file
Definition: Geant4Output2EDM4hep.cpp:88
dd4hep::sim::Geant4Particle::time
double time
Particle creation time.
Definition: Geant4Particle.h:136
dd4hep::sim::Geant4Calorimeter::Hit::energyDeposit
double energyDeposit
Total energy deposit.
Definition: Geant4Data.h:332
dd4hep::sim::Geant4Calorimeter::Hit
DDG4 calorimeter hit class used by the generic DDG4 calorimeter sensitive detector.
Definition: Geant4Data.h:323
dd4hep::sim::FileParameters::extractParameters
void extractParameters(T &destination)
Put parameters into destination.
dd4hep::sim::Geant4Particle::pex
double pex
The track momentum at the end vertex.
Definition: Geant4Particle.h:132
dd4hep::sim::Geant4Output2EDM4hep::m_runNumberOffset
int m_runNumberOffset
Definition: Geant4Output2EDM4hep.cpp:104
dd4hep::sim::Geant4HitCollection::type
const ComponentCast & type() const
Type information of the object stored.
Definition: Geant4HitCollection.cpp:87
dd4hep::sim::Geant4ParticleMap::particleID
int particleID(int track, bool throw_if_not_found=true) const
Access the equivalent track id (shortcut to the usage of TrackEquivalents)
Definition: Geant4Particle.cpp:537
dd4hep::sim::Geant4Action::print
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
Definition: Geant4Action.cpp:144
dd4hep::sim::Geant4HitData::MonteCarloContrib::trackID
int trackID
Geant 4 Track identifier.
Definition: Geant4Data.h:141
dd4hep::sim::Geant4Output2EDM4hep::floatmap_t
std::map< std::string, float > floatmap_t
Definition: Geant4Output2EDM4hep.cpp:82
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::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::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:132
dd4hep::sim::ExtensionParameters::intParameters
auto const & intParameters() const
Get the int parameters.
Definition: ExtensionParameters.h:40
dd4hep::sim::Geant4Output2EDM4hep::m_filesByRun
bool m_filesByRun
Definition: Geant4Output2EDM4hep.cpp:107
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
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
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::Geant4Output2EDM4hep::m_particles
edm4hep::MCParticleCollection m_particles
Definition: Geant4Output2EDM4hep.cpp:91
dd4hep::sim::Geant4HitData::MonteCarloContrib::x
float x
Proper position of the hit contribution.
Definition: Geant4Data.h:151
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::sim::Geant4Calorimeter::Hit::truth
Contributions truth
Hit contributions by individual particles.
Definition: Geant4Data.h:330
dd4hep::sim::Geant4Sensitive::hitCreationMode
int hitCreationMode() const
Property access to the hit creation mode.
Definition: Geant4SensDetAction.h:188
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::Geant4Output2EDM4hep::m_eventNumberOffset
int m_eventNumberOffset
Definition: Geant4Output2EDM4hep.cpp:106
dd4hep::sim::Geant4Particle::parents
Particles parents
The list of parents of this MC particle.
Definition: Geant4Particle.h:140
dd4hep::sim::Geant4Output2EDM4hep::Geant4Output2EDM4hep
Geant4Output2EDM4hep(Geant4Context *ctxt, const std::string &nam)
Standard constructor.
Definition: Geant4Output2EDM4hep.cpp:263
Geant4Particle.h
dd4hep::sim::Geant4Particle::vsy
double vsy
Definition: Geant4Particle.h:126
dd4hep::sim::Geant4Action::debug
void debug(const char *fmt,...) const
Support of debug messages.
Definition: Geant4Action.cpp:207
dd4hep::sim::Geant4Output2EDM4hep::trackermap_t
std::map< std::string, edm4hep::SimTrackerHitCollection > trackermap_t
Definition: Geant4Output2EDM4hep.cpp:85
dd4hep::sim::Geant4Output2EDM4hep::begin
virtual void begin(const G4Event *event)
begin-of-event callback - creates EDM4hep event and adds it to the event context
Definition: Geant4Output2EDM4hep.cpp:404
dd4hep::sim::Geant4HitData::MonteCarloContrib
Utility class describing the monte carlo contribution of a given particle to a hit.
Definition: Geant4Data.h:138
dd4hep::sim::Geant4Sensitive
The base class for Geant4 sensitive detector actions implemented by users.
Definition: Geant4SensDetAction.h:123
dd4hep::sim::Geant4Tracker::Hit::energyDeposit
double energyDeposit
Energy deposit in the tracker hit.
Definition: Geant4Data.h:274
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:105
dd4hep::sim::Geant4Output2EDM4hep::m_runParametersInt
intmap_t m_runParametersInt
Definition: Geant4Output2EDM4hep.cpp:98
dd4hep::sim::Geant4Output2EDM4hep::m_fileUseCount
std::atomic_size_t m_fileUseCount
Definition: Geant4Output2EDM4hep.cpp:89
PropertyMask
dd4hep::detail::ReferenceBitMask< int > PropertyMask
Definition: EDM4hepFileReader.cpp:43
dd4hep::sim::ExtensionParameters::strParameters
auto const & strParameters() const
Get the string parameters.
Definition: ExtensionParameters.h:44
InstanceCount.h
dd4hep::sim::Geant4ConversionHelper::encoding
static std::string encoding(VolumeManager vm, VolumeID vid)
Access to the data encoding using the volume manager and a specified volume id.
Definition: Geant4DataConversion.cpp:28
dd4hep::sim::Geant4Particle::psy
double psy
Definition: Geant4Particle.h:130
dd4hep::sim::Geant4HitData::MonteCarloContrib::z
float z
Definition: Geant4Data.h:151
dd4hep::sim::EventParameters::eventNumber
int eventNumber() const
Get the event number.
Definition: EventParameters.h:40
dd4hep::sim::G4PARTICLE_GEN_OTHER
@ G4PARTICLE_GEN_OTHER
Definition: Geant4Particle.h:78
Geant4Context.h
dd4hep::sim::Geant4HitData::MonteCarloContrib::time
double time
Timestamp when this energy was deposited.
Definition: Geant4Data.h:147
dd4hep::sim::EventParameters::runNumber
int runNumber() const
Get the run number.
Definition: EventParameters.h:38
dd4hep::sim::Geant4Calorimeter::Hit::position
Position position
Hit position.
Definition: Geant4Data.h:328
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