9#include <tracking/modules/trackingPerformanceEvaluation/FillTrackFitNtupleModule.h>
11#include <mdst/dataobjects/HitPatternCDC.h>
12#include <mdst/dataobjects/HitPatternVXD.h>
27 setDescription(
"This module fills a ntuple with tracking variables under different hypotheses");
30 std::string(
"TrackingPerformanceEvaluation_output.root"));
47 TString var_list(
"evt:run:exp:prod:nhits:ncdc:npxd:nsvd:seed_x:");
48 var_list += (
"seed_y:seed_z:seed_px:seed_py:seed_pz:seed_p:seed_pt:seed_theta:seed_phi:seed_charge:");
49 var_list += (
"nhits_pi:ncdc_pi:npxd_pi:nsvd_pi:nhits_k:ncdc_k:npxd_k:nsvd_k:nhits_p:ncdc_p:npxd_p:nsvd_p:nhits_d:ncdc_d:npxd_d:nsvd_d:");
50 var_list += (
"flag_pi:flag_k:flag_p:flag_d:");
51 var_list += (
"trk_x_pi:trk_y_pi:trk_z_pi:trk_px_pi:trk_py_pi:trk_pz_pi:trk_p_pi:trk_pt_pi:trk_theta_pi:trk_phi_pi:");
52 var_list += (
"trk_charge_pi:trk_chi2_pi:trk_ndf_pi:trk_pvalue_pi:nfailed_pi:");
53 var_list += (
"trk_x_k:trk_y_k:trk_z_k:trk_px_k:trk_py_k:trk_pz_k:trk_p_k:trk_pt_k:trk_theta_k:trk_phi_k:");
54 var_list += (
"trk_charge_k:trk_chi2_k:trk_ndf_k:trk_pvalue_k:nfailed_k:");
55 var_list += (
"trk_x_p:trk_y_p:trk_z_p:trk_px_p:trk_py_p:trk_pz_p:trk_p_p:trk_pt_p:trk_theta_p:trk_phi_p:");
56 var_list += (
"trk_charge_p:trk_chi2_p:trk_ndf_p:trk_pvalue_p:nfailed_p:");
57 var_list += (
"trk_x_d:trk_y_d:trk_z_d:trk_px_d:trk_py_d:trk_pz_d:trk_p_d:trk_pt_d:trk_theta_d:trk_phi_d:");
58 var_list += (
"trk_charge_d:trk_chi2_d:trk_ndf_d:trk_pvalue_d:nfailed_d:");
59 var_list += (
"cdcf_pi:cdcl_pi:svdf_pi:svdl_pi:");
60 var_list += (
"cdcf_k:cdcl_k:svdf_k:svdl_k:");
61 var_list += (
"cdcf_p:cdcl_p:svdf_p:svdl_p:");
62 var_list += (
"cdcf_d:cdcl_d:svdf_d:svdl_d");
63 m_n_MultiParticle =
new TNtuple(
"nMultiParticle",
"ntuple for multi hyp particle", var_list);
70 Float_t event_num = eventMetaData->getEvent();
71 Float_t event_run = eventMetaData->getRun();
72 Float_t event_exp = eventMetaData->getExperiment();
73 Float_t event_prod = eventMetaData->getProduction();
75 B2DEBUG(29,
"+++++ Loop on Tracks");
78 for (
Track& track : tracks) {
81 if (recoTrack ==
nullptr) {
83 B2WARNING(
" the RecoTrack associated to Track is nullptr!");
94 std::map <Const::ChargedStable, Float_t> flag;
95 std::map <Const::ChargedStable, Float_t> trk_x, trk_y, trk_z, trk_px, trk_py, trk_pz, trk_p, trk_pt, trk_theta, trk_phi;
96 std::map <Const::ChargedStable, Float_t> trk_charge, trk_chi2, trk_ndf, trk_pvalue, trk_nfailed;
97 std::map <Const::ChargedStable, Float_t> nhits_pid, ncdc_pid, nsvd_pid, npxd_pid;
98 std::map <Const::ChargedStable, Float_t> first_cdc, last_cdc, first_svd, last_svd;
101 trk_x[pdgIter] = 0.; trk_y[pdgIter] = 0.; trk_z[pdgIter] = 0.;
102 trk_px[pdgIter] = 0.; trk_py[pdgIter] = 0.; trk_pz[pdgIter] = 0.;
103 trk_p[pdgIter] = 0.; trk_pt[pdgIter] = 0.; trk_theta[pdgIter] = 0.; trk_phi[pdgIter] = 0.;
104 trk_charge[pdgIter] = 0.;
105 trk_chi2[pdgIter] = 0.; trk_ndf[pdgIter] = 0.; trk_pvalue[pdgIter] = 0.; trk_nfailed[pdgIter] = 0.;
106 nhits_pid[pdgIter] = 0.; ncdc_pid[pdgIter] = 0.; nsvd_pid[pdgIter] = 0.; npxd_pid[pdgIter] = 0.;
107 first_cdc[pdgIter] = -100.; last_cdc [pdgIter] = -100.;
108 first_svd[pdgIter] = -100.; last_svd [pdgIter] = -100.;
110 const TrackFitResult* fitResult = track.getTrackFitResult(pdgIter);
111 if ((fitResult !=
nullptr) && (fitResult->
getParticleType() == pdgIter)) {
112 flag[pdgIter] = kTRUE;
114 flag[pdgIter] = kFALSE;
126 trk_theta[pdgIter] = fitResult->
getMomentum().Theta() * TMath::RadToDeg();
127 trk_phi[pdgIter] = fitResult->
getMomentum().Phi() * TMath::RadToDeg();
130 if (isnan(chi2)) chi2 = -10;
131 if (isinf(chi2)) chi2 = -20;
132 trk_chi2[pdgIter] = chi2;
133 trk_ndf[pdgIter] = fitResult->
getNDF();
134 trk_pvalue[pdgIter] = fitResult->
getPValue();
136 pdgIter.getPDGCode()))->getNFailedPoints();
140 nhits_pid[pdgIter] = ncdc_pid[pdgIter] + npxd_pid[pdgIter] + nsvd_pid[pdgIter];
147 Float_t buffer[] = {event_num, event_run, event_exp, event_prod,
148 nhits, ncdc, npxd, nsvd,
Provides a type-safe way to pass members of the chargedStableSet set.
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable deuteron
deuteron particle
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
int m_ParticleHypothesis
Particle Hypothesis for the track fit (default: 211)
std::string m_TracksName
Track StoreArray name.
void initialize() override
Require the store arrays and create the output root file.
void event() override
Loop over Track objects and fill ntuples with tracking parameters.
void terminate() override
Save output root file with ntuple.
TNtuple * m_n_MultiParticle
Multi particle ntuple.
std::string m_RecoTracksName
RecoTrack StoreArray name.
FillTrackFitNtupleModule()
Default Empty Constructor.
StoreArray< RecoTrack > m_RecoTracks
RecoTrack StoreArray.
StoreArray< Track > m_Tracks
Track StoreArray.
short getLastLayer() const
Returns the index of the last layer with a hit.
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
short getFirstLayer() const
Returns the index of the first layer with a hit.
short getLastSVDLayer() const
Get the last activated SVD layer index.
short getFirstSVDLayer() const
Get the first activated SVD layer index.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
unsigned short getNSVDHits() const
Get total number of hits in the SVD.
void setDescription(const std::string &description)
Sets the description of the module.
This is the Reconstruction Event-Data Model Track.
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
unsigned int getNumberOfTrackingHits() const
Return the number of cdc + svd + pxd hits.
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
genfit::AbsTrackRep * getTrackRepresentationForPDG(int pdgCode) const
Return an already created track representation of the given reco track for the PDG.
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.
float getNDF() const
Getter for number of degrees of freedom of the track fit.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
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.