DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4InputAction.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 #ifndef DD4HEP_DDG4_GEANT4INPUTACTION_H
16 #define DD4HEP_DDG4_GEANT4INPUTACTION_H
17 
18 // Framework include files
19 #include "DDG4/Geant4Vertex.h"
20 #include "DDG4/Geant4Particle.h"
22 
23 // C/C++ include files
24 #include <vector>
25 #include <memory>
26 
27 // Forward declarations
28 class G4Event;
29 
31 namespace DD4hep {
32 
34  namespace Simulation {
35 
37 
46 
47  public:
50  typedef std::vector<Particle*> Particles;
59  };
60  protected:
62  std::string m_name;
67  public:
69  Geant4EventReader(const std::string& nam);
71  virtual ~Geant4EventReader();
73  const std::string& name() const { return m_name; }
75  bool hasDirectAccess() const { return m_directAccess; }
77  int currentEventNumber() const { return m_currEvent; }
79 
86  virtual EventReaderStatus moveToEvent(int event_number);
88  virtual EventReaderStatus skipEvent();
90 
92  virtual EventReaderStatus readParticles(int event_number,
93  Vertex& primary_vertex,
94  Particles& particles) = 0;
95  };
96 
98 
108 
109  public:
112  typedef std::vector<Particle*> Particles;
113  protected:
115  std::string m_input;
119  int m_mask;
121  double m_momScale;
127  bool m_abort;
128 
129  public:
131  int readParticles(int event_number, Vertex& primary_vertex, Particles& particles);
133  std::string issue(int i) const;
134 
136  Geant4InputAction(Geant4Context* context, const std::string& name);
138  virtual ~Geant4InputAction();
140  Particles* new_particles() const { return new Particles; }
142  virtual void operator()(G4Event* event);
143  };
144  } /* End namespace Simulation */
145 } /* End namespace DD4hep */
146 #endif /* DD4HEP_DDG4_GEANT4INPUTACTION_H */
int currentEventNumber() const
return current Event Number
Geant4DataDump::Particles Particles
Data structure to store the MC particle information.
bool hasDirectAccess() const
Flag if direct event access (by event sequence number) is supported (Default: false) ...
virtual void operator()(G4Event *event)
Callback to generate primary particles.
double m_momScale
Property: Momentum downscaler for debugging.
std::string m_input
Property: input file.
Geant4EventReader * m_reader
Event reader object.
std::vector< Particle * > Particles
Particles * new_particles() const
Create particle vector.
Generic input action capable of using the Geant4EventReader class.
Basic geant4 event reader class. This interface/base-class must be implemented by concrete readers...
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
Data structure to store the MC vertex information.
Definition: Geant4Vertex.h:46
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:271
virtual ~Geant4EventReader()
Default destructor.
virtual ~Geant4InputAction()
Default destructor.
const std::string & name() const
File name.
int m_currentEventNumber
current event number without initially skipped events
virtual EventReaderStatus skipEvent()
Skip event. To be implemented for sequential sources.
EventReaderStatus
Status codes of the event reader object. Anything with NOT low-bit set is an error.
std::string issue(int i) const
helper to report Geant4 exceptions
Geant4EventReader(const std::string &nam)
Initializing constructor.
Concrete implementation of the Geant4 generator action base class.
virtual EventReaderStatus moveToEvent(int event_number)
Move to the indicated event number.
int m_currEvent
Current event number.
virtual EventReaderStatus readParticles(int event_number, Vertex &primary_vertex, Particles &particles)=0
Read an event and fill a vector of MCParticles.
Generic context to extend user, run and event information.
bool m_directAccess
Flag if direct event access is supported. To be explicitly set by subclass constructors.
std::string m_name
File name to be opened and read.
int m_mask
Property; interaction mask.
Geant4InputAction(Geant4Context *context, const std::string &name)
Standard constructor.
bool m_abort
Flag to call abortEvent in case of failure (default: true)
int readParticles(int event_number, Vertex &primary_vertex, Particles &particles)
Read an event and return a LCCollectionVec of MCParticles.