DD4hep  1.35.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 { "events" };
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  G4AutoLock protection_lock(&action_mutex);
337  m_file->writeFrame(metaFrame, "metadata");
338 }
339 
342  if ( m_file ) {
343  G4AutoLock protection_lock(&action_mutex);
344  m_frame.put( std::move(m_particles), "MCParticles");
345  for (auto it = m_trackerHits.begin(); it != m_trackerHits.end(); ++it) {
346  m_frame.put( std::move(it->second), it->first);
347  }
348  for (auto& [colName, calorimeterHits] : m_calorimeterHits) {
349  m_frame.put( std::move(calorimeterHits.first), colName);
350  m_frame.put( std::move(calorimeterHits.second), colName + "Contributions");
351  }
352  m_file->writeFrame(m_frame, m_section_name);
353  m_particles = { };
354  m_trackerHits.clear();
355  m_calorimeterHits.clear();
356  m_frame = {};
357  return;
358  }
359  except("+++ Failed to write output file. [Stream is not open]");
360 }
361 
363 void Geant4Output2EDM4hep::saveRun(const G4Run* run) {
364  G4AutoLock protection_lock(&action_mutex);
365  // --- write an edm4hep::RunHeader ---------
366  // Runs are just Frames with different contents in EDM4hep / podio. We simply
367  // store everything as parameters for now
368  podio::Frame runHeader {};
369  for (const auto& [key, value] : m_runHeader)
370  runHeader.putParameter(key, value);
371 
372  for (const auto& [key, value] : m_runParametersInt)
373  runHeader.putParameter(key, value);
374 
375  for (const auto& [key, value] : m_runParametersFloat)
376  runHeader.putParameter(key, value);
377 
378  for (const auto& [key, value] : m_runParametersString)
379  runHeader.putParameter(key, value);
380 
381  m_runNo = m_runNumberOffset > 0 ? m_runNumberOffset + run->GetRunID() : run->GetRunID();
382  runHeader.putParameter("runNumber", m_runNo);
383  runHeader.putParameter("GEANT4Version", G4Version);
384  runHeader.putParameter("DD4hepVersion", versionString());
385  runHeader.putParameter("detectorName", context()->detectorDescription().header().name());
386  {
387  // In multithreaded running, the run is present in only one of the contexts
388  if (context()->runPtr() != nullptr) {
389  RunParameters* parameters = context()->run().extension<RunParameters>(false);
390  if ( parameters ) {
391  parameters->extractParameters(runHeader);
392  }
393  m_file->writeFrame(runHeader, "runs");
394  }
395  }
396  {
397  // In multithreaded running, the run is present in only one of the contexts
398  if (context()->runPtr() != nullptr) {
399  podio::Frame metaFrame {};
400  FileParameters* parameters = context()->run().extension<FileParameters>(false);
401  if ( parameters ) {
402  parameters->extractParameters(metaFrame);
403  }
404  m_file->writeFrame(metaFrame, "meta");
405  }
406  }
407 }
408 
409 void Geant4Output2EDM4hep::begin(const G4Event* event) {
411  m_eventNo = event->GetEventID();
412  m_frame = {};
413  m_particles = {};
414  m_trackerHits.clear();
415  m_calorimeterHits.clear();
416 }
417 
420  typedef detail::ReferenceBitMask<const int> PropertyMask;
421  typedef Geant4ParticleMap::ParticleMap ParticleMap;
422  const ParticleMap& pm = particles->particleMap;
423 
424  m_particles.clear();
425  if ( pm.size() > 0 ) {
426  size_t cnt = 0;
427  // Mapping of ids in the ParticleMap to indices in the MCParticle collection
428  std::map<int,int> p_ids;
429  std::vector<const Geant4Particle*> p_part;
430  p_part.reserve(pm.size());
431  // First create the particles
432  for (const auto& iParticle : pm) {
433  int id = iParticle.first;
434  const Geant4ParticleHandle p = iParticle.second;
435  PropertyMask mask(p->status);
436  // std::cout << " ********** mcp status : 0x" << std::hex << p->status << ", mask.isSet(G4PARTICLE_GEN_STABLE) x" << std::dec << mask.isSet(G4PARTICLE_GEN_STABLE) <<std::endl ;
437  const G4ParticleDefinition* def = p.definition();
438  auto mcp = m_particles.create();
439  mcp.setPDG(p->pdgID);
440  // Because EDM4hep is switching between vector3f[loat] and vector3d[ouble]
441  using MT = decltype(std::declval<edm4hep::MCParticle>().getMomentum().x);
442  mcp.setMomentum( {MT(p->psx/CLHEP::GeV),MT(p->psy/CLHEP::GeV),MT(p->psz/CLHEP::GeV)} );
443  mcp.setMomentumAtEndpoint( {MT(p->pex/CLHEP::GeV),MT(p->pey/CLHEP::GeV),MT(p->pez/CLHEP::GeV)} );
444 
445  double vs_fa[3] = { p->vsx/CLHEP::mm, p->vsy/CLHEP::mm, p->vsz/CLHEP::mm } ;
446  mcp.setVertex( vs_fa );
447 
448  double ve_fa[3] = { p->vex/CLHEP::mm, p->vey/CLHEP::mm, p->vez/CLHEP::mm } ;
449  mcp.setEndpoint( ve_fa );
450 
451  mcp.setTime(p->time/CLHEP::ns);
452  mcp.setMass(p->mass/CLHEP::GeV);
453  mcp.setCharge(def ? def->GetPDGCharge() : 0); // Charge(e+) = 1 !
454 
455  // Set generator status
456  mcp.setGeneratorStatus(0);
457  if( p->genStatus ) {
458  mcp.setGeneratorStatus( p->genStatus ) ;
459  } else {
460  if ( mask.isSet(G4PARTICLE_GEN_STABLE) ) mcp.setGeneratorStatus(1);
461  else if ( mask.isSet(G4PARTICLE_GEN_DECAYED) ) mcp.setGeneratorStatus(2);
462  else if ( mask.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) mcp.setGeneratorStatus(3);
463  else if ( mask.isSet(G4PARTICLE_GEN_BEAM) ) mcp.setGeneratorStatus(4);
464  else if ( mask.isSet(G4PARTICLE_GEN_OTHER) ) mcp.setGeneratorStatus(9);
465  }
466 
467  // Set simulation status
468  mcp.setCreatedInSimulation( mask.isSet(G4PARTICLE_SIM_CREATED) );
469  mcp.setBackscatter( mask.isSet(G4PARTICLE_SIM_BACKSCATTER) );
470  mcp.setVertexIsNotEndpointOfParent( mask.isSet(G4PARTICLE_SIM_PARENT_RADIATED) );
471  mcp.setDecayedInTracker( mask.isSet(G4PARTICLE_SIM_DECAY_TRACKER) );
472  mcp.setDecayedInCalorimeter( mask.isSet(G4PARTICLE_SIM_DECAY_CALO) );
473  mcp.setHasLeftDetector( mask.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) );
474  mcp.setStopped( mask.isSet(G4PARTICLE_SIM_STOPPED) );
475  mcp.setOverlay( false );
476 
477  //fg: if simstatus !=0 we have to set the generator status to 0:
478  if( mcp.isCreatedInSimulation() )
479  mcp.setGeneratorStatus( 0 ) ;
480 
481 #if EDM4HEP_MCPARTICLE_HAS_HELICITY
482  mcp.setHelicity(p->spin[2]);
483 #else
484  mcp.setSpin(p->spin);
485 #endif
486 
487  p_ids[id] = cnt++;
488  p_part.push_back(p);
489  }
490 
491  // Now establish parent-daughter relationships
492  for(size_t i=0; i < p_ids.size(); ++i) {
493  const Geant4Particle* p = p_part[i];
494  auto q = m_particles[i];
495 
496  for (const auto& idau : p->daughters) {
497  const auto k = p_ids.find(idau);
498  if (k == p_ids.end()) {
499  fatal("+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau);
500  continue;
501  }
502  int iqdau = (*k).second;
503  auto qdau = m_particles[iqdau];
504  q.addToDaughters(qdau);
505  }
506 
507  for (const auto& ipar : p->parents) {
508  if (ipar >= 0) { // A parent ID of -1 means NO parent, because a base of 0 is perfectly legal
509  const auto k = p_ids.find(ipar);
510  if (k == p_ids.end()) {
511  fatal("+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar);
512  continue;
513  }
514  int iqpar = (*k).second;
515  auto qpar = m_particles[iqpar];
516  q.addToParents(qpar);
517  }
518  }
519  }
520  }
521 }
522 
525  EventParameters* parameters = context()->event().extension<EventParameters>(false);
526  int runNumber(0), eventNumber(0);
527  const int eventNumberOffset(m_eventNumberOffset > 0 ? m_eventNumberOffset : 0);
528  const int runNumberOffset(m_runNumberOffset > 0 ? m_runNumberOffset : 0);
529  double eventWeight{0};
530  // Get event number, run number and parameters from extension ...
531  if ( parameters ) {
532  runNumber = parameters->runNumber() + runNumberOffset;
533  eventNumber = parameters->eventNumber() + eventNumberOffset;
534  parameters->extractParameters(m_frame);
535 #if PODIO_BUILD_VERSION > PODIO_VERSION(0, 99, 0)
536  eventWeight = m_frame.getParameter<double>("EventWeights").value_or(0.0);
537 #else
538  eventWeight = m_frame.getParameter<double>("EventWeights");
539 #endif
540  } else { // ... or from DD4hep framework
541  runNumber = m_runNo + runNumberOffset;
542  eventNumber = ctxt.context->GetEventID() + eventNumberOffset;
543  }
544  printout(INFO,"Geant4Output2EDM4hep","+++ Saving EDM4hep event %d run %d.", eventNumber, runNumber);
545 
546  // this does not compile as create() is we only get a const ref - need to review PODIO EventStore API
547  edm4hep::EventHeaderCollection header_collection;
548 
549  auto header = header_collection.create();
550  header.setRunNumber(runNumber);
551  header.setEventNumber(eventNumber);
552  header.setWeight(eventWeight);
553  //not implemented in EDM4hep ? header.setDetectorName(context()->detectorDescription().header().name());
554  header.setTimeStamp(std::time(nullptr));
555 
556  // extract event header, in case we come from edm4hep input
557  auto* meh = context()->event().extension<edm4hep::MutableEventHeader>(false);
558  if(meh) {
559  header.setTimeStamp(meh->getTimeStamp());
560 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0)
561  for (auto const& weight: meh->getWeights()) {
562  header.addToWeights(weight);
563  }
564 #endif
565  }
566 
567  m_frame.put(std::move(header_collection), "EventHeader");
568 
569 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 3)
570  // Attach the generator event parameters again if they are available
571  auto* genEvtParams = context()->event().extension<edm4hep::MutableGeneratorEventParameters>(false);
572  if (genEvtParams) {
573  edm4hep::GeneratorEventParametersCollection genEvtParamsColl{};
574  genEvtParamsColl.push_back(*genEvtParams);
575  m_frame.put(std::move(genEvtParamsColl), edm4hep::labels::GeneratorEventParameters);
576  }
577 #endif
578 
579  saveEventParameters<int>(m_eventParametersInt);
580  saveEventParameters<float>(m_eventParametersFloat);
581  saveEventParameters<std::string>(m_eventParametersString);
582 
583  Geant4ParticleMap* part_map = context()->event().extension<Geant4ParticleMap>(false);
584  if ( part_map ) {
585  print("+++ Saving %d EDM4hep particles....",int(part_map->particleMap.size()));
586  if ( part_map->particleMap.size() > 0 ) {
587  saveParticles(part_map);
588  }
589  }
590 }
591 
602  operator std::string() const {
603  const auto* sd = m_coll->sensitive();
604  return dd4hep::sim::Geant4ConversionHelper::encoding(sd->sensitiveDetector());
605  }
606 private:
607  Geant4HitCollection* m_coll{nullptr};
608 };
609 
610 
613  Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(collection);
614  std::string colName = collection->GetName();
615  if( coll == nullptr ){
616  error(" no Geant4HitCollection: %s ", colName.c_str());
617  return ;
618  }
619  size_t nhits = collection->GetSize();
621  debug("+++ Saving EDM4hep collection %s with %d entries.", colName.c_str(), int(nhits));
622 
623  // Using try_emplace here to only fill this the first time we come across
624  m_cellIDEncodingStrings.try_emplace(colName, LazyEncodingExtraction{coll});
625 
626  //-------------------------------------------------------------------
627  if( typeid( Geant4Tracker::Hit ) == coll->type().type() ){
628  // Create the hit container even if there are no entries!
629  auto& hits = m_trackerHits[colName];
630  for(unsigned i=0 ; i < nhits ; ++i){
631  auto sth = hits.create();
632  const Geant4Tracker::Hit* hit = coll->hit(i);
633  const Geant4Tracker::Hit::Contribution& t = hit->truth;
634  int trackID = pm->particleID(t.trackID);
635  auto mcp = m_particles.at(trackID);
636  const auto& mom = hit->momentum;
637  const auto& pos = hit->position;
638  edm4hep::Vector3f();
639  sth.setCellID( hit->cellID ) ;
640  sth.setEDep(hit->energyDeposit/CLHEP::GeV);
641  sth.setPathLength(hit->length/CLHEP::mm);
642  sth.setTime(hit->truth.time/CLHEP::ns);
643 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 10, 99)
644  sth.setParticle(mcp);
645 #else
646  sth.setMCParticle(mcp);
647 #endif
648  sth.setPosition( {pos.x()/CLHEP::mm, pos.y()/CLHEP::mm, pos.z()/CLHEP::mm} );
649  sth.setMomentum( {float(mom.x()/CLHEP::GeV),float(mom.y()/CLHEP::GeV),float(mom.z()/CLHEP::GeV)} );
650  auto particleIt = pm->particles().find(trackID);
651  if( ( particleIt != pm->particles().end()) ){
652  // if the original track ID of the particle is not the same as the
653  // original track ID of the hit it was produced by an MCParticle that
654  // is no longer stored
655  sth.setProducedBySecondary( (particleIt->second->originalG4ID != t.trackID) );
656  }
657  }
658  //-------------------------------------------------------------------
659  }
660  else if( typeid( Geant4Calorimeter::Hit ) == coll->type().type() ){
661  Geant4Sensitive* sd = coll->sensitive();
662  int hit_creation_mode = sd->hitCreationMode();
663  // Create the hit container even if there are no entries!
664  auto& hits = m_calorimeterHits[colName];
665  for(unsigned i=0 ; i < nhits ; ++i){
666  auto sch = hits.first.create();
667  const Geant4Calorimeter::Hit* hit = coll->hit(i);
668  const auto& pos = hit->position;
669  sch.setCellID( hit->cellID );
670  sch.setPosition({float(pos.x()/CLHEP::mm), float(pos.y()/CLHEP::mm), float(pos.z()/CLHEP::mm)});
671  sch.setEnergy( hit->energyDeposit/CLHEP::GeV );
672 
673 
674  // now add the individual step contributions
675  for(auto ci=hit->truth.begin(); ci != hit->truth.end(); ++ci){
676 
677  auto sCaloHitCont = hits.second.create();
678  sch.addToContributions( sCaloHitCont );
679 
680  const Geant4HitData::Contribution& c = *ci;
681  int trackID = pm->particleID(c.trackID);
682  auto mcp = m_particles.at(trackID);
683  sCaloHitCont.setEnergy( c.deposit/CLHEP::GeV );
684  sCaloHitCont.setTime( c.time/CLHEP::ns );
685  sCaloHitCont.setParticle( mcp );
686 
687  if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) {
688  edm4hep::Vector3f p(c.x/CLHEP::mm, c.y/CLHEP::mm, c.z/CLHEP::mm);
689  sCaloHitCont.setPDG( c.pdgID );
690  sCaloHitCont.setStepPosition( p );
691 #if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 3)
692  sCaloHitCont.setStepLength(c.length / CLHEP::mm);
693 #endif
694  }
695  }
696  }
697  //-------------------------------------------------------------------
698  } else {
699  error("+++ unknown type in Geant4HitCollection %s ", coll->type().type().name());
700  }
701 }
Geant4DataConversion.h
dd4hep::sim::G4PARTICLE_SIM_CREATED
@ G4PARTICLE_SIM_CREATED
Definition: Geant4Particle.h:85
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:124
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:363
dd4hep::sim::G4PARTICLE_GEN_STABLE
@ G4PARTICLE_GEN_STABLE
Definition: Geant4Particle.h:71
dd4hep::sim::Geant4Output2EDM4hep::commit
virtual void commit(OutputContext< G4Event > &ctxt)
Commit data at end of filling procedure.
Definition: Geant4Output2EDM4hep.cpp:341
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
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:130
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:361
dd4hep::sim::Geant4Output2EDM4hep::saveCollection
virtual void saveCollection(OutputContext< G4Event > &ctxt, G4VHitsCollection *collection)
Callback to store each Geant4 hit collection.
Definition: Geant4Output2EDM4hep.cpp:612
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:108
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:115
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:128
LazyEncodingExtraction
Definition: Geant4Output2EDM4hep.cpp:596
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:524
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:419
dd4hep::sim::G4PARTICLE_GEN_DOCUMENTATION
@ G4PARTICLE_GEN_DOCUMENTATION
Definition: Geant4Particle.h:73
dd4hep::sim::G4PARTICLE_SIM_BACKSCATTER
@ G4PARTICLE_SIM_BACKSCATTER
Definition: Geant4Particle.h:86
dd4hep::sim::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:337
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:89
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:126
dd4hep::sim::G4PARTICLE_SIM_DECAY_CALO
@ G4PARTICLE_SIM_DECAY_CALO
Definition: Geant4Particle.h:87
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:340
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:121
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: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::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:599
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:134
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:130
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: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::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:112
dd4hep::sim::Geant4Particle::pey
double pey
Definition: Geant4Particle.h:130
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:343
dd4hep::sim::G4PARTICLE_SIM_LEFT_DETECTOR
@ G4PARTICLE_SIM_LEFT_DETECTOR
Definition: Geant4Particle.h:90
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::sim::Geant4Context::runPtr
Geant4Run * runPtr() const
Access the geant4 run by ptr. Must be checked by clients!
Definition: Geant4Context.h:225
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:181
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:138
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:124
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:409
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:103
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:128
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:76
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