10#include <ecl/modules/eclChargedPIDDataAnalysisExpert/ECLChargedPIDDataAnalysisModule.h>
11#include <framework/datastore/RelationVector.h>
12#include <framework/logging/Logger.h>
13#include <framework/gearbox/Const.h>
15#include <mdst/dataobjects/MCParticle.h>
16#include <mdst/dataobjects/Track.h>
17#include <ecl/dataobjects/ECLShower.h>
36 m_eclShowers(eclShowerArrayName()),
45 n1_eclShowerMultip(0),
46 n1_eclShowerEnergy(0),
50 n1_eclShowerHypothesisId(0),
51 n1_eclShowerAbsZernike40(0),
52 n1_eclShowerAbsZernike51(0),
80 n2_eclShowerMultip(0),
81 n2_eclShowerEnergy(0),
85 n2_eclShowerHypothesisId(0),
86 n2_eclShowerAbsZernike40(0),
87 n2_eclShowerAbsZernike51(0),
109 setDescription(
"This module produces an ntuple with ECL-related quantities starting from mdst");
111 "set true if you want to save the information in a root file named by parameter 'rootFileName'",
114 "fileName used for root file where info are saved. Will be ignored if parameter 'writeToRoot' is false (standard)",
115 string(
"eclChargedPID"));
124 B2INFO(
"[ECLChargedPIDDataAnalysis Module]: Starting initialization of ECLChargedPIDDataAnalysis Module.");
132 n1_tree =
new TTree(
"n1_tree",
"ECL Charged PID tree: N1 Hypothesis");
168 n2_tree =
new TTree(
"n2_tree",
"ECL Charged PID tree: N2 Hypothesis");
203 B2INFO(
"[ECLChargedPIDDataAnalysis Module]: Initialization of ECLChargedPIDDataAnalysis Module completed.");
213 B2DEBUG(1,
" ++++++++++++++ ECLChargedPIDDataAnalysisModule");
299 n1_mcPdg->push_back(imcpart.getPDG());
300 if (imcpart.getMother() !=
nullptr)
n1_mcMothPdg->push_back(imcpart.getMother()->getPDG());
303 n1_mcP->push_back(imcpart.getMomentum().R());
304 n1_mcTheta->push_back(imcpart.getMomentum().Theta());
305 n1_mcPhi->push_back(imcpart.getMomentum().Phi());
307 n2_mcPdg->push_back(imcpart.getPDG());
308 if (imcpart.getMother() !=
nullptr)
n2_mcMothPdg->push_back(imcpart.getMother()->getPDG());
311 n2_mcP->push_back(imcpart.getMomentum().R());
312 n2_mcTheta->push_back(imcpart.getMomentum().Theta());
313 n2_mcPhi->push_back(imcpart.getMomentum().Phi());
317 int index_max_mom = -1;
319 for (
const auto& itrk : imcpart.getRelationsFrom<
Track>()) {
322 if (atrkF ==
nullptr)
continue;
325 index_max_mom = index;
329 if (index_max_mom == -1)
continue;
332 const auto itrack = imcpart.getRelationsFrom<
Track>()[index_max_mom];
340 n1_trkPdg->push_back(atrkF->getParticleType().getPDGCode());
342 n1_trkP->push_back(atrkF->getMomentum().R());
343 n1_trkTheta->push_back(atrkF->getMomentum().Theta());
344 n1_trkPhi->push_back(atrkF->getMomentum().Phi());
346 n2_trkPdg->push_back(atrkF->getParticleType().getPDGCode());
348 n2_trkP->push_back(atrkF->getMomentum().R());
349 n2_trkTheta->push_back(atrkF->getMomentum().Theta());
350 n2_trkPhi->push_back(atrkF->getMomentum().Phi());
354 int jndex1_max_e = -1;
356 for (
const auto& i1sh : itrack->getRelationsTo<
ECLShower>()) {
359 if (i1sh.getHypothesisId() != 5)
continue;
361 if (abs(i1sh.getTime()) > i1sh.getDeltaTime99())
continue;
362 if (i1sh.getEnergy() > max_e1) {
363 max_e1 = i1sh.getEnergy();
364 jndex1_max_e = jndex1;
368 int jndex2_max_e = -1;
370 for (
const auto& i2sh : itrack->getRelationsTo<
ECLShower>()) {
373 if (i2sh.getHypothesisId() != 6)
continue;
375 if (abs(i2sh.getTime()) > i2sh.getDeltaTime99())
continue;
376 if (i2sh.getEnergy() > max_e2) {
377 max_e2 = i2sh.getEnergy();
378 jndex2_max_e = jndex2;
383 if (jndex1_max_e != -1) {
384 const auto i1shower = itrack->getRelationsTo<
ECLShower>()[jndex1_max_e];
395 n1_eclEoP->push_back((i1shower->getEnergy()) / (atrkF->getMomentum().R()));
398 if (jndex2_max_e != -1) {
399 const auto i2shower = itrack->getRelationsTo<
ECLShower>()[jndex2_max_e];
410 n2_eclEoP->push_back((i2shower->getEnergy()) / (atrkF->getMomentum().R()));
static const ChargedStable pion
charged pion particle
std::string m_rootFileName
name of the root file
std::vector< int > * n1_trkPdg
Track PDG code.
std::vector< double > * n1_trkPhi
Track azimuthal direction.
bool m_writeToRoot
if true, a rootFile named by m_rootFileName will be filled with info
int n1_iExperiment
Experiment number.
std::vector< double > * n2_eclShowerAbsZernike40
Shower Zernike40 Moment.
virtual void initialize() override
Initializes the Module.
int n2_iEvent
Event number.
int n1_eclShowerMultip
Number of ECLShowers per event.
virtual void event() override
Called once for each event.
std::vector< int > * n2_mcMothPdg
MCParticle mother particle PDG code.
std::vector< int > * n2_trkCharge
Track charge.
std::vector< double > * n2_mcP
MCParticle momentum.
std::vector< double > * n2_eclShowerEnergy
Shower Energy.
TTree * n2_tree
Root tree and file for saving the output.
virtual void endRun() override
Called once when a run ends.
std::vector< int > * n1_eclShowerHypothesisId
Shower Particle Hypothesis ID.
int n2_mcMultip
Multiplicity of MCParticles.
int n2_eclShowerMultip
Number of ECLShowers per event.
std::vector< double > * n1_mcP
MCParticle momentum.
std::vector< double > * n2_eclShowerR
Shower R.
virtual void terminate() override
Termination action.
std::vector< double > * n2_mcTheta
MCParticle Theta.
TTree * n1_tree
Root tree and file for saving the output.
int n2_iExperiment
Experiment number.
ECLChargedPIDDataAnalysisModule()
Constructor of the module.
std::vector< double > * n1_eclShowerEnergy
Shower Energy.
int n1_mcMultip
Multiplicity of MCParticles.
std::vector< double > * n1_mcPhi
MCParticle Phi.
std::vector< double > * n1_eclShowerAbsZernike51
Shower Zernike51 Moment.
std::vector< int > * n1_mcMothPdg
MCParticle mother particle PDG code.
std::vector< double > * n1_eclShowerR
Shower R.
virtual void beginRun() override
Called once before a new run begins.
std::vector< double > * n2_eclEoP
ECL Shower Energy on Track Momentum.
std::vector< double > * n2_trkPhi
Track azimuthal direction.
std::vector< double > * n1_trkTheta
Track polar direction.
std::vector< double > * n1_mcEnergy
MCParticle energyx.
std::vector< int > * n2_mcPdg
MCParticle PDG code.
std::vector< double > * n1_eclShowerAbsZernike40
Shower Zernike40 Moment.
std::vector< double > * n1_eclEoP
ECL Shower Energy on Track Momentum.
std::vector< int > * n1_mcPdg
MCParticle PDG code.
std::vector< int > * n1_trkCharge
Track charge.
int n2_trkMultip
Track Multiplicity.
std::vector< double > * n2_eclShowerTheta
Shower Theta.
std::vector< double > * n2_eclShowerPhi
Shower Phi.
StoreArray< MCParticle > m_mcParticles
MCParticles StoreArray.
std::vector< double > * n2_trkTheta
Track polar direction.
std::vector< double > * n2_mcPhi
MCParticle Phi.
std::vector< double > * n1_eclShowerTheta
Shower Theta.
virtual ~ECLChargedPIDDataAnalysisModule()
Destructor of the module.
std::vector< double > * n2_trkP
Track momentum.
std::vector< double > * n1_trkP
Track momentum.
std::vector< int > * n2_trkPdg
Track PDG code.
std::vector< double > * n2_eclShowerAbsZernike51
Shower Zernike51 Moment.
TFile * m_rootFilePtr
members of ECLReconstructor Module
int n1_trkMultip
Track Multiplicity.
std::vector< double > * n2_mcEnergy
MCParticle energyx.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
std::vector< int > * n2_eclShowerHypothesisId
Shower Particle Hypothesis ID.
std::vector< double > * n1_mcTheta
MCParticle Theta.
std::vector< double > * n1_eclShowerPhi
Shower Phi.
int n1_iEvent
Event number.
Class to store ECL Showers.
A Class to store the Monte Carlo particle information.
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
@ c_PrimaryParticle
bit 0: Particle is primary particle.
@ c_IsVirtual
bit 4: Particle is virtual and not going to Geant4.
void setDescription(const std::string &description)
Sets the description of the module.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
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.
Abstract base class for different kinds of events.