10 #include <top/modules/TOPNtuple/TOPNtupleModule.h>
13 #include <top/geometry/TOPGeometryPar.h>
16 #include <framework/datastore/StoreArray.h>
17 #include <framework/datastore/StoreObjPtr.h>
20 #include <framework/gearbox/Const.h>
21 #include <framework/logging/Logger.h>
24 #include <framework/dataobjects/EventMetaData.h>
25 #include <framework/dataobjects/MCInitialParticles.h>
26 #include <mdst/dataobjects/Track.h>
27 #include <mdst/dataobjects/MCParticle.h>
28 #include <top/dataobjects/TOPLikelihood.h>
29 #include <top/dataobjects/TOPBarHit.h>
30 #include <tracking/dataobjects/ExtHit.h>
33 #include <TDirectory.h>
55 TOPNtupleModule::TOPNtupleModule() :
Module()
58 setDescription(
"Writes ntuple of TOPLikelihoods with tracking info into a root file");
62 string(
"TOPNtuple.root"));
72 TDirectory::TContext context;
79 m_tree =
new TTree(
"top",
"TOP validation ntuple");
105 m_tree->Branch(
"extHit", &
m_top.
extHit,
"moduleID/I:PDG:x/F:y:z:p:theta:phi:time");
106 m_tree->Branch(
"barHit", &
m_top.
barHit,
"moduleID/I:PDG:x/F:y:z:p:theta:phi:time");
132 double trueEventT0 = 0;
133 if (mcInitialParticles.
isValid()) trueEventT0 = mcInitialParticles->getTime();
137 for (
const auto& track : tracks) {
138 const auto* trackFit = track.getTrackFitResultWithClosestMass(
Const::pion);
139 if (!trackFit)
continue;
142 if (top->getFlag() != 1)
continue;
149 mother = mcParticle->getMother();
151 const auto barHits = mcParticle->getRelationsWith<
TOPBarHit>();
152 for (
const auto& bHit : barHits) {
153 if (bHit.getModuleID() == extHit->
getCopyID()) barHit = &bHit;
160 m_top.
evt = evtMetaData->getEvent();
163 ROOT::Math::XYZVector mom = trackFit->getMomentum();
173 m_top.
seen = mcParticle->hasSeenInDetector(Const::TOP);
174 ROOT::Math::XYZVector prodVertex = mcParticle->getProductionVertex();
178 ROOT::Math::XYZVector decVertex = mcParticle->getDecayVertex();
202 auto position =
static_cast<ROOT::Math::XYZPoint
>(extHit->
getPosition());
204 if (geo->isModuleIDValid(moduleID)) {
205 const auto& module = geo->getModule(moduleID);
206 position = module.pointToLocal(position);
207 momentum = module.momentumToLocal(momentum);
221 int moduleID = barHit->getModuleID();
222 auto position = barHit->getPosition();
223 auto momentum = barHit->getMomentum();
224 if (geo->isModuleIDValid(moduleID)) {
225 const auto& module = geo->getModule(moduleID);
226 position = module.pointToLocal(position);
227 momentum = module.momentumToLocal(momentum);
252 TDirectory::TContext context;
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
Store one Ext hit as a ROOT object.
int getPdgCode() const
Get PDG code of this extrapolation's hypothesis.
int getCopyID() const
Get detector-element ID of sensitive element within detector.
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
double getTOF() const
Get time of flight from the point of closest approach near the origin to this hit.
A Class to store the Monte Carlo particle information.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
void setDescription(const std::string &description)
Sets the description of the module.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
Class to store TOP log likelihoods (output of TOPReconstructor).
TTree * m_tree
TTree with TOPTree structure.
TOP::TOPTree m_top
ntuple structure
std::string m_outputFileName
output file name (root file)
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual ~TOPNtupleModule()
Destructor.
virtual void beginRun() override
Called when entering a new run.
Abstract base class for different kinds of events.
Float_t zDec
decay vertex (cylindrical coordinate z) of MCParticle
Float_t p
momentum magnitude of Track
Likelihoods logL
log likelihoods
Float_t rhoDec
decay vertex (cylindrical coordinate r) of MCParticle
Int_t numPhot
number of detected photons
Short_t primary
is a primary particle (from related MCParticle)
Float_t phi
azimuthal angle of Track
Float_t numBkg
number of expected background photons
Short_t seen
is seen in TOP (from related MCParticle)
TrackHit extHit
extrapolated Track hit (in local module frame)
Int_t motherPDG
PDG code of related mother MCParticle.
Float_t phiProd
production vertex (cylindrical coordinate phi) of MCParticle
Float_t cth
cosine of polar angle of Track
Float_t rhoProd
production vertex (cylindrical coordinate r) of MCParticle
void clear()
Clear the structure: set elements to zero.
Float_t phiDec
decay vertex (cylindrical coordinate phi) of MCParticle
Int_t PDG
PDG code of related MCParticle.
Float_t pValue
p-value of Track fit
Likelihoods phot
number of expected photons (signal + bkg)
Float_t zProd
production vertex (cylindrical coordinate z) of MCParticle
TrackHit barHit
related MC particle hit (in local module frame)
Float_t p
momentum magnitude
Float_t z
impact point, z component
Float_t theta
momentum polar angle
Float_t phi
momentum azimuthal angle
Float_t x
impact point, x component
Float_t y
impact point, y component