26 using namespace DD4hep::Simulation;
30 Geant4EventReader::Geant4EventReader(
const std::string& nam)
31 : m_name(nam), m_directAccess(false), m_currEvent(0)
45 std::vector<Particle*> particles;
49 for_each(particles.begin(),particles.end(),deleteObject<Particle>);
56 if ( event_number >= INT_MIN ) {
98 str <<
"Geant4InputAction[" <<
name() <<
"]: Event " << i <<
" ";
105 std::vector<Particle*>& particles)
110 except(
"InputAction: No input file declared!");
115 m_reader = PluginService::Create<Geant4EventReader*>(tn.first,tn.second);
118 m_reader = PluginService::Create<Geant4EventReader*>(tn.first,tn.second);
120 "Failed to create file reader of type %s. Cannot open dataset %s",
121 tn.first.c_str(),tn.second.c_str());
125 catch(
const exception&
e) {
128 if ( !err.empty() ) {
135 string msg =
issue(evid)+
"Error when moving to event - may be end of file.";
146 string msg =
issue(evid)+
"Error when moving to event - may be end of file.";
159 vector<Particle*> primaries;
181 if ( primaries.empty() )
return;
183 print(
"+++ Particle interaction with %d generator particles ++++++++++++++++++++++++",
184 int(primaries.size()));
188 for(
size_t i=0; i<primaries.size(); ++i ) {
192 p->
psx = mom_scale*p->
psx;
193 p->
psy = mom_scale*p->
psy;
194 p->
psz = mom_scale*p->
psz;
196 if ( p->
parents.size() == 0 ) {
198 vtx->
in.insert(p->
id);
200 vtx->
out.insert(p->
id);
PrintLevel outputLevel() const
Access the output level.
VertexMap vertices
The map of primary vertices for the particles.
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
User event context for DDG4.
bool hasDirectAccess() const
Flag if direct event access (by event sequence number) is supported (Default: false) ...
Helper class to handle strings of the format "type/name".
Particles out
The list of outgoing particles.
Class modelling a single interaction with multiple primary vertices and particles.
Particles in
The list of incoming particles.
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
void error(const char *fmt,...) const
Support of error messages.
Data structure to manipulate a bitmask held by reference and represented by an integer.
Geant4Context * context() const
Access the context.
Class modelling a complete primary event with multiple interactions.
Data structure to store the MC vertex information.
const std::string & name() const
Access name of the action.
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
virtual ~Geant4EventReader()
Default destructor.
Geant4Vertex * vertex(EventStream &info, int i)
Particles parents
The list of daughters of this MC particle.
Helper to debug plugin manager calls.
ParticleMap particles
The map of particles participating in this primary interaction.
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.
T * extension(bool alert=true)
Access to type safe extension object. Exception is thrown if the object is invalid.
Concrete implementation of the Geant4 generator action base class.
virtual EventReaderStatus moveToEvent(int event_number)
Move to the indicated event number.
UriReader * m_reader
Pointer to URI reader.
bool m_needsControl
Default property: Flag to create control instance.
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.
Data structure to access derived MC particle information.
static TypeName split(const std::string &type_name)
Split string pair according to default delimiter ('/')
void dumpWithMomentumAndVertex(int level, const std::string &src, const char *tag) const
Output type 3:+++ <tag> ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] #Par: 0 #Dau: 4.
Generic context to extend user, run and event information.
void abortRun(const std::string &exception, const char *fmt,...) const
Abort Geant4 Run by throwing a G4Exception with type RunMustBeAborted.
void add(int id, Geant4PrimaryInteraction *interaction)
Add a new interaction object to the event.
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
bool isSet(const T &m) const