10#include <reconstruction/modules/PIDNtuple/PIDNtupleModule.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/StoreObjPtr.h>
17#include <framework/gearbox/Const.h>
18#include <framework/logging/Logger.h>
21#include <framework/dataobjects/EventMetaData.h>
22#include <mdst/dataobjects/Track.h>
23#include <mdst/dataobjects/MCParticle.h>
24#include <mdst/dataobjects/PIDLikelihood.h>
27#include <TDirectory.h>
42 m_norm(0), m_value(0), m_file(0), m_tree(0)
46 setDescription(
"Writes a flat ntuple of PIDLikelihoods with track info into a root file");
50 std::string(
"PIDNtuple.root"));
52 addParam(
"p1",
m_p1,
"parameter of momentum distribution", 0.90311E-01);
53 addParam(
"p2",
m_p2,
"parameter of momentum distribution", 0.56846);
54 addParam(
"pMax",
m_pMax,
"make distribution flat up to this momentum", 3.0);
73 tracks.optionalRelationTo(mcparticles);
76 TDirectory::TContext context;
78 m_tree =
new TTree(
"pid",
"PID tree");
97 m_tree->Branch(
"top", &
m_pid.
top,
"le/F:lmu:lpi:lk:lp:ld:flag/S:seen/S");
98 m_tree->Branch(
"arich", &
m_pid.
arich,
"le/F:lmu:lpi:lk:lp:ld:flag/S:seen/S");
99 m_tree->Branch(
"ecl", &
m_pid.
ecl,
"le/F:lmu:lpi:lk:lp:ld:flag/S:seen/S");
100 m_tree->Branch(
"klm", &
m_pid.
klm,
"le/F:lmu:lpi:lk:lp:ld:flag/S:seen/S");
116 for (
const auto& track : tracks) {
120 B2WARNING(
"No track fit result... Skipping.");
126 B2WARNING(
"No track fit result... Skipping.");
132 if (mcParticle) mother = mcParticle->
getMother();
135 m_pid.
evt = evtMetaData->getEvent();
137 ROOT::Math::XYZVector momentum = trackFit->
getMomentum();
227 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
A Class to store the Monte Carlo particle information.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
ROOT::Math::XYZVector getDecayVertex() const
Return decay vertex.
bool hasSeenInDetector(Const::DetectorSet set) const
Return if the seen-in flag for a specific subdetector is set or not.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
unsigned int getStatus(unsigned short int bitmask=USHRT_MAX) const
Return status code of particle.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
TTree * m_tree
TTree with PIDTree structure.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
bool m_makeFlat
if true, make momentum distribution flat up to m_pMax
virtual void terminate() override
Termination action.
double m_p2
parameter of momentum distribution
PID::PIDTree m_pid
PID tree structure.
PIDNtupleModule()
Constructor.
double momDistribution(double p) const
parameterized momentum distribution
double m_pMax
flatten distribution up to this momentum
double m_p1
parameter of momentum distribution
double m_value
distribution value at m_pMax
double m_norm
distribution normalization
std::string m_outputFileName
output file name
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.
Values of the result of a track fit with a given particle hypothesis.
double getPValue() const
Getter for Chi2 Probability of the track fit.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
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.
MCParticle * getMother() const
Returns a pointer to the mother particle.
Abstract base class for different kinds of events.
Float_t lk
log likelihood for kaon
Short_t flag
flag: information is available (1) or not (0)
Float_t ld
log likelihood for deuteron
Short_t seen
is seen in this component (from related MCParticle)
Float_t le
log likelihood for electron
Float_t lp
log likelihood for proton
Float_t lpi
log likelihood for pion
Float_t lmu
log likelihood for muon
Float_t zDec
decay vertex (cylindrical coordinate z) of MCParticle
Float_t p
momentum magnitude of Track
LogLikelihoods top
log likelihoods from TOP
LogLikelihoods cdcdedx
log likelihoods from CDC dE/dx
Float_t rhoDec
decay vertex (cylindrical coordinate r) of MCParticle
LogLikelihoods ecl
log likelihoods from ECL
Short_t primary
is a primary particle (from related MCParticle)
Float_t phi
azimuthal angle of Track
LogLikelihoods svddedx
log likelihoods from SVD dE/dx
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
LogLikelihoods klm
log likelihoods from KLM
Int_t PDG
PDG code of related MCParticle.
LogLikelihoods arich
log likelihoods from ARICH
Float_t pValue
p-value of Track fit
Float_t zProd
production vertex (cylindrical coordinate z) of MCParticle