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");
29 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.",
30 std::string(
"TrackingPerformanceEvaluation_output.root"));
31 addParam(
"TracksName", m_TracksName,
"Name of Track collection.", std::string(
""));
32 addParam(
"RecoTracksName", m_RecoTracksName,
"Name of RecoTrack collection.", std::string(
"RecoTracks"));
33 addParam(
"ParticleHypothesis", m_ParticleHypothesis,
"Particle Hypothesis used in the track fit.",
int(211));
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;
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...
This module takes the Tracks and the RecoTrack input and produce a root file containing an nutple sho...
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.
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.
This is the Reconstruction Event-Data Model Track.
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...
genfit::AbsTrackRep * getTrackRepresentationForPDG(int pdgCode)
Return an already created track representation of the given reco track for the PDG.
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.
TVector3 getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
TVector3 getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
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.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
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.
double getChi2() const
Get chi^2 of the fit.
double getNdf() const
Get the degrees of freedom of the fit.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.