9 #include "../include/PrintTauTauMCParticlesModule.h"
10 #include <mdst/dataobjects/MCParticle.h>
12 #include <framework/datastore/StoreArray.h>
14 #include <boost/format.hpp>
15 #include <boost/foreach.hpp>
17 #include <TDatabasePDG.h>
33 B2DEBUG(100,
"PrintTauTauMCParticles called:");
35 setDescription(
"Print an MCParticle Collection");
38 addParam(
"collectionName", m_particleList,
"Collection to print",
string(
""));
39 addParam(
"onlyPrimaries", m_onlyPrimaries,
"Show only primary particles",
true);
40 addParam(
"maxLevel", m_maxLevel,
"Show only up to specified depth level, -1 means no limit", -1);
44 void PrintTauTauMCParticlesModule::event()
48 m_seen.resize(MCParticles.
getEntries() + 1,
false);
49 B2INFO(
"Content from MCParticle Collection '" + m_particleList +
"':");
50 for (
int i = 0; i < MCParticles.
getEntries(); i++) {
58 sprintf(buf,
"PMC: %3d %4u %8d %4d %4d %4d %9.4f %9.4f %9.4f %9.4f",
59 p.getIndex(), p.getStatus(), p.getPDG(), moID,
60 p.getFirstDaughter(), p.getLastDaughter(),
61 p.get4Vector().Px(), p.get4Vector().Py(),
62 p.get4Vector().Pz(), p.get4Vector().E());
66 for (
int i = 0; i < MCParticles.
getEntries(); i++) {
68 if (!(mc.getMother() != NULL && mc.getMother()->getIndex() <= 3))
continue;
74 void PrintTauTauMCParticlesModule::printTree(
const MCParticle& mc,
int level)
76 if (m_onlyPrimaries && !mc.hasStatus(MCParticle::c_PrimaryParticle))
return;
78 if (m_maxLevel >= 0 && level > m_maxLevel)
return;
81 for (
int i = 0; i < 2 * level; i++) indent +=
" ";
82 TDatabasePDG* pdb = TDatabasePDG::Instance();
83 TParticlePDG* pdef = pdb->GetParticle(mc.getPDG());
84 string name = pdef ? (string(
" (") + pdef->GetTitle() +
")") :
"";
86 if (m_seen[mc.getIndex()]) {
87 B2INFO(boost::format(
"%4d %s%10d%s*") % mc.getIndex() % indent % mc.getPDG() % name);
90 const TVector3& p = mc.getMomentum();
91 const TVector3& v = mc.getVertex();
92 B2INFO(boost::format(
"%3d %s%5d%s%20tp:(%10.3e, %10.3e, %10.3e) v:(%10.3e, %10.3e, %10.3e), t:%10.3e,%10.3e, s:%d, c:%d")
93 % mc.getIndex() % indent % mc.getPDG() % name
94 % p.X() % p.Y() % p.Z()
95 % v.X() % v.Y() % v.Z()
96 % mc.getProductionTime() % mc.getDecayTime()
97 % mc.getStatus() % mc.getCharge()
100 const vector<MCParticle*> daughters = mc.getDaughters();
101 BOOST_FOREACH(
MCParticle * daughter, daughters) {
102 printTree(*daughter, level);
104 m_seen[mc.getIndex()] =
true;
A Class to store the Monte Carlo particle information.
The PrintTauTauMCParticles module.
int getEntries() const
Get the number of objects in the array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.