30 using namespace DD4hep;
31 using namespace DD4hep::Simulation;
36 Geant4ParticlePrint::Geant4ParticlePrint(
Geant4Context* ctxt,
const std::string& nam)
57 print(
"+++ ******** MC Particle Printout for event ID:%d ********",e->GetEventID());
62 except(
"No Geant4MonteCarloTruth object present in the event structure to access the particle information!",
c_name());
90 ::snprintf(equiv,
sizeof(equiv),
"/%d",p->
g4Parent);
92 print(
"+++ %s ID:%7d %12s %6d%-7s %7s %3s %5d %3s %+.3e %-4s %-7s %-3s %-3s %2d [%s%s%s] %c%c%c%c",
117 G4HCofThisEvent* hc = e->GetHCofThisEvent();
118 for (
int ihc=0, nhc=hc->GetNumberOfCollections(); ihc<nhc; ++ihc) {
121 size_t nhits = coll->
GetSize();
122 for(
size_t i=0; i<nhits; ++i) {
125 if ( 0 != trk_hit ) {
129 if ( trueID == p->
id ) {
130 print(
"+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]",
"",c->GetName().c_str(),i,
135 if ( 0 != cal_hit ) {
137 for(Geant4HitData::Contributions::iterator j=contrib.begin(); j!=contrib.end(); ++j) {
141 if ( trueID == p->
id ) {
142 print(
"+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]",
"",c->GetName().c_str(),i,
158 int num_secondaries = 0;
159 int num_calo_hits = 0;
160 int num_tracker_hits = 0;
162 print(
"+++ MC Particles #Tracks:%7d ParticleType Parent/Geant4 "
163 "Primary Secondary Energy in [MeV] Calo Tracker Process/Par Details",
164 int(particles.size()));
165 for(ParticleMap::const_iterator i=particles.begin(); i!=particles.end(); ++i) {
169 num_secondaries += int(p->
daughters.size());
177 print(
"+++ MC Particles #Tracks:%7d ParticleType Parent/Geant4 "
178 "Primary Secondary Energy Calo Tracker Process/Par",
179 int(particles.size()));
180 print(
"+++ MC Particle Summary: %7d %10d %7d %7d %9d %5d %6d",
181 num_primary, num_secondaries, num_energy,
182 num_calo_hits,num_tracker_hits,num_process,num_parent);
187 size_t len =
sizeof(txt)-1;
189 if ( level>
int(len)-3 ) level=len-3;
191 ::snprintf(txt,
sizeof(txt),
"%5d ",level);
192 ::memset(txt+6,
' ',len-6);
196 ::memset(txt+level+6+1,
'-',len-level-3-6);
199 const set<int>& daughters = p->
daughters;
201 for(set<int>::const_iterator
id=daughters.begin();
id!=daughters.end(); ++id) {
210 print(
"+++ MC Particle Parent daughter relationships. [%d particles]",
int(particles.size()));
211 print(
"+++ MC Particles %12s #Tracks:%7d %-12s Parent%-7s "
212 "Primary Secondary Energy %-8s Calo Tracker Process/Par Details",
213 "",
int(particles.size()),
"ParticleType",
"",
"in [MeV]");
214 for(ParticleMap::const_iterator i=particles.begin(); i!=particles.end(); ++i) {
DDG4 tracker hit class used by the generic DDG4 tracker sensitive detector.
void makePrintout(const G4Event *e) const
Print particle table.
void printParticle(const std::string &prefix, const G4Event *e, Geant4ParticleHandle p) const
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
const G4VProcess * process
not persisten. ROOT cannot handle
void printParticleTree(const G4Event *e, const ParticleMap &particles, int level, Geant4ParticleHandle p) const
Print tree of kept particles.
void printParticles(const G4Event *e, const ParticleMap &particles) const
Print record of kept particles.
std::vector< MonteCarloContrib > Contributions
static void decrement(T *)
Decrement count according to type information.
DDG4 calorimeter hit class used by the generic DDG4 calorimeter sensitive detector.
bool m_printGeneration
Property: Flag to indicate output type as part of the generator action.
const char * yes_no(bool value)
Helper function to print booleans in format YES/NO.
Geant4HitWrapper & hit(size_t which)
Access the hit wrapper.
int particleID(int track, bool throw_if_not_found=true) const
Access the equivalent track id (shortcut to the usage of TrackEquivalents)
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
const ParticleMap & particles() const
Access the particle map.
Position position
Hit position.
Concrete basic implementation of the Geant4 event action.
Data structure to manipulate a bitmask held by reference and represented by an integer.
const char * c_name() const
Access name of the action.
Geant4Context * context() const
Access the context.
Contribution truth
Monte Carlo / Geant4 information.
Contributions truth
Hit contributions by individual particles.
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.
Geant4ParticleMap::ParticleMap ParticleMap
int m_outputType
Property: Flag to indicate output type: 1: TABLE, 2:TREE, 3:BOTH (default)
not persisten. ROOT cannot handle
virtual void begin(const G4Event *event)
Pre-event action callback.
Particles parents
The list of daughters of this MC particle.
Position position
Hit position.
Data structure to map particles produced during the generation and the simulation.
virtual void end(const G4Event *event)
Post-event action callback.
std::string particleName() const
Access to the Geant4 particle name.
T * extension(bool alert=true)
Access to type safe extension object. Exception is thrown if the object is invalid.
Generic hit container class using Geant4HitWrapper objects.
size_t numParent() const
Accessor to the number of particle parents.
virtual void operator()(G4Event *event)
Generation action callback.
Data structure to access derived MC particle information.
static void increment(T *)
Increment count according to type information.
bool m_printBegin
Property: Flag to indicate output type at begin of event.
double energy() const
Scalar particle energy.
ReferenceBitMask< const int > PropertyMask
bool m_printHits
Property: Flag to indicate output of hit data in tree.
Generic context to extend user, run and event information.
static const double second
bool m_printEnd
Property: Flag to indicate output type at end of event.
virtual size_t GetSize() const
Access the collection size.
std::string processName() const
Access to the creator process name.
int trackID
Geant 4 Track identifier.
virtual ~Geant4ParticlePrint()
Default destructor.
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
bool isSet(const T &m) const
Base class for geant4 hit structures used by the default DDG4 sensitive detector implementations.
std::string processTypeName() const
Access to the creator process type name.