9 #include <tracking/modules/trackingPerformanceEvaluation/TrackingPerformanceEvaluationModule.h>
11 #include <framework/datastore/StoreArray.h>
12 #include <framework/datastore/RelationVector.h>
14 #include <framework/geometry/BFieldManager.h>
16 #include <vxd/geometry/GeoCache.h>
18 #include <mdst/dataobjects/MCParticle.h>
19 #include <mdst/dataobjects/Track.h>
20 #include <mdst/dataobjects/HitPatternCDC.h>
21 #include <mdst/dataobjects/HitPatternVXD.h>
23 #include <pxd/reconstruction/PXDRecoHit.h>
24 #include <svd/reconstruction/SVDRecoHit.h>
25 #include <svd/reconstruction/SVDRecoHit2D.h>
26 #include <cdc/dataobjects/CDCRecoHit.h>
28 #include <tracking/dataobjects/RecoTrack.h>
30 #include <pxd/dataobjects/PXDTrueHit.h>
31 #include <pxd/dataobjects/PXDCluster.h>
32 #include <svd/dataobjects/SVDCluster.h>
33 #include <cdc/dataobjects/CDCHit.h>
35 #include <genfit/KalmanFitterInfo.h>
37 #include <root/TObject.h>
39 #include <boost/foreach.hpp>
52 setDescription(
"This module evaluates the tracking package performance");
54 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.",
55 std::string(
"TrackingPerformanceEvaluation_output.root"));
56 addParam(
"MCParticlesName", m_MCParticlesName,
"Name of MC Particle collection.", std::string(
""));
57 addParam(
"TracksName", m_TracksName,
"Name of Track collection.", std::string(
""));
58 addParam(
"RecoTracksName", m_RecoTracksName,
"Name of RecoTrack collection.", std::string(
"RecoTracks"));
59 addParam(
"MCRecoTracksName", m_MCRecoTracksName,
"Name of MCRecoTrack collection.", std::string(
"MCRecoTracks"));
60 addParam(
"ParticleHypothesis", m_ParticleHypothesis,
"Particle Hypothesis used in the track fit.",
int(211));
177 2000, -10, 10,
"x (cm)",
178 2000, -10, 10,
"y (cm)",
182 2000, -30, 40,
"z (cm)",
183 2000, 0, 15,
"r_{t} (cm)",
191 100, 0, 3,
"p_{t} (GeV/c)",
192 1000, 0, 0.2,
"#sigma_{#omega}/#omega",
197 100, 0, 3,
"p_{t} (GeV/c)",
198 100, 0, 0.1,
"#sigma_{z0} (cm)",
213 100, 0, 3,
"p_{t} (GeV/c)",
214 100, 0, 0.1,
"#sigma_{d0} (cm)",
227 50, 0, 2.5,
"p_{t} (GeV/c)",
250 2000, -15, 15,
"x (cm)",
251 2000, -15, 15,
"y (cm)",
255 2000, -30, 40,
"z (cm)",
256 2000, 0, 15,
"r_{t} (cm)",
262 Double_t bins_pt[10 + 1] = {0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.5, 1, 1.5, 2, 3.5};
263 Double_t bins_theta[10 + 1] = {0, 0.25, 0.5, 0.75, 0.75 + 0.32, 0.75 + 2 * 0.32, 0.75 + 3 * 0.32, 0.75 + 4 * 0.32, 0.75 + 5 * 0.32, 2.65, TMath::Pi()};
264 Double_t bins_phi[14 + 1];
265 Double_t width_phi = 2 * TMath::Pi() / 14;
266 for (
int bin = 0; bin < 14 + 1; bin++)
267 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
271 10, bins_pt,
"p_{t} (GeV/c)",
272 10, bins_theta,
"#theta",
273 14, bins_phi,
"#phi" );
276 "entry per Track connected to a MCParticle",
280 "entry per Track with PXD hits connected to a MCParticle",
284 "entry per RecoTrack with PXD hits connected to a MCParticle",
288 "entry per RecoTrack with PXD hits connected to a MCParticle with PXD hits",
292 "entry per MCParticle with PXD hits",
296 "entry per MCRecoTrack connected to the MCParticle",
300 "entry per Track connected to an MCRecoTrack",
307 "entry per Track connected to a positive MCParticle",
311 "entry per MCRecoTrack connected to the positive MCParticle",
315 "entry per Track connected to a positive MCRecoTrack",
324 "entry per Track connected to a negative MCParticle",
328 "entry per MCRecoTrack connected to the negative MCParticle",
332 "entry per Track connected to a negative MCRecoTrack",
348 "entry per MCParticle connected to a Track",
364 bool hasTrack =
false;
365 B2DEBUG(99,
"+++++ 1. loop on MCParticles");
366 BOOST_FOREACH(
MCParticle & mcParticle, mcParticles) {
371 int pdgCode = mcParticle.
getPDG();
372 B2DEBUG(99,
"MCParticle has PDG code " << pdgCode);
374 int nFittedTracksMCRT = 0;
375 int nFittedTracks = 0;
376 int nFittedTrackswPXDHits = 0;
400 if (MCRecoTracks_fromMCParticle.
size() > 0)
401 if (MCRecoTracks_fromMCParticle[0]->hasPXDHits()) {
413 if (MCRecoTracks_fromMCParticle.
size() > 0) {
428 B2DEBUG(99, Tracks_fromMCParticle.
size() <<
" Tracks related to this MCParticle");
430 for (
int trk = 0; trk < (int)Tracks_fromMCParticle.
size(); trk++) {
435 B2WARNING(
" the TrackFitResult is not found!");
447 nFittedTrackswPXDHits++;
458 if (MCRecoTracks_fromMCParticle.
size() > 0) {
479 if (MCRecoTracks_fromMCParticle.
size() > 0)
485 B2DEBUG(99,
"+++++ 2. loop on Tracks");
490 BOOST_FOREACH(
Track & track, tracks) {
492 int nMCParticles = 0;
503 m_h3_Tracks->Fill(momentum.Pt(), momentum.Theta(), momentum.Phi());
509 for (
int layer = 0; layer < 56; layer++) {
513 for (
int layer = 1; layer <= 2; layer++) {
517 for (
int layer = 3; layer <= 6; layer++) {
522 for (
int i = 0; i < N; i++)
529 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++)
541 B2DEBUG(99,
"+++++ 3. loop on MCRecoTracks");
550 BOOST_FOREACH(
RecoTrack & mcRecoTrack, mcRecoTracks) {
553 bool hasRecoTrack =
false;
557 B2DEBUG(99,
"~ " << RecoTracks_fromMCRecoTrack.
size() <<
" RecoTracks related to this MCRecoTrack");
563 B2DEBUG(99,
"~~~ " << MCParticles_fromMCRecoTrack.
size() <<
" MCParticles related to this MCRecoTrack");
564 for (
int mcp = 0; mcp < (int)MCParticles_fromMCRecoTrack.
size(); mcp++) {
568 (MCParticles_fromMCRecoTrack[mcp]);
570 B2DEBUG(99,
"~~~~~ " << RecoTracks_fromMCParticle.
size() <<
" RecoTracks related to this MCParticle");
571 for (
int tc = 0; tc < (int)RecoTracks_fromMCParticle.
size(); tc++)
582 B2DEBUG(99,
"+++++ 4. loop on RecoTracks");
587 BOOST_FOREACH(
RecoTrack & recoTrack, RecoTracks) {
629 double efficiency = num / den ;
630 double efficiencyErr = sqrt(efficiency * (1 - efficiency)) / sqrt(den);
632 double nFittedTracksMCRT = 0;
638 double nRecoTrack = 0;
644 double nMCRecoTrack = 0;
650 double nMCParticles = 0;
657 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
658 B2INFO(
"~ Tracking Performance Evaluation ~ SHORT SUMMARY ~");
660 B2INFO(
" + overall:");
661 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
662 B2INFO(
" purity = " << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
664 B2INFO(
" + factorizing geometrical acceptance:");
665 B2INFO(
" efficiency = " << efficiencyMCRT * 100 <<
" +/- " << efficiencyMCRTErr * 100 <<
")% ");
667 B2INFO(
" + pattern recognition:");
668 B2INFO(
" efficiency = " << efficiencyPR * 100 <<
" +/- " << efficiencyPRErr * 100 <<
")% ");
669 B2INFO(
" purity = " << purityPR * 100 <<
" +/- " << purityPRErr * 100 <<
")% ");
671 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
686 TDirectory* oldDir = gDirectory;
688 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
689 dir_multiplicity->cd();
692 while ((obj = nextH_multiplicity()))
695 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
696 dir_efficiency->cd();
698 while ((obj = nextH_efficiency()))
701 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
702 dir_trkQuality->cd();
704 while ((obj = nextH_trkQuality()))
707 TDirectory* dir_firstHit = oldDir->mkdir(
"firstHit");
710 while ((obj = nextH_firstHit()))
734 double d0_res = fitResult->
getD0() - mcParticleInfo.
getD0();
735 double phi_res = TMath::ASin(TMath::Sin(fitResult->
getPhi() - mcParticleInfo.
getPhi()));
737 double z0_res = fitResult->
getZ0() - mcParticleInfo.
getZ0();
744 double p_res = (fitResult->
getMomentum().Mag() - mcParticleInfo.
getP()) / mcParticleInfo.
getP();
751 double r_res = fitResult->
getPosition().Perp() - sqrt(mcParticleInfo.
getX() * mcParticleInfo.
getX() + mcParticleInfo.
getY() *
752 mcParticleInfo.
getY());
753 double rtot_res = fitResult->
getPosition().Mag() - sqrt(mcParticleInfo.
getX() * mcParticleInfo.
getX() + mcParticleInfo.
getY() *
754 mcParticleInfo.
getY() + mcParticleInfo.
getZ() * mcParticleInfo.
getZ());
805 double px = momentum.Px();
806 double py = momentum.Py();
807 double pz = momentum.Pz();
808 double pt = momentum.Pt();
809 double p = momentum.Mag();
811 double beta = p / sqrt(p * p + mass * mass);
812 double sinTheta = TMath::Sin(momentum.Theta());
815 d0_err / phi_err * py / pt);
817 z0_err / cotTheta_err * py / pt);
825 m_h2_d0errMSVSpt->Fill(pt, d0_err * beta * p * pow(sinTheta, 3 / 2) / 0.0136);
838 bool hasPXDhit =
false;
839 bool isTrueHit =
false;
841 double d0_err = -999;
842 double z0_err = -999;
851 bool hasCDChit[56] = {
false };
855 for (
int tc = 0; tc < (int)RecoTracks_fromTrack.
size(); tc++) {
857 const std::vector< genfit::TrackPoint* >& tp_vector = RecoTracks_fromTrack[tc]->getHitPointsWithMeasurement();
858 for (
int i = 0; i < (int) tp_vector.size(); i++) {
861 int nMea = tp->getNumRawMeasurements();
862 for (
int mea = 0; mea < nMea; mea++) {
867 std::vector<double> weights;
872 B2WARNING(
" No KalmanFitterInfo associated to the TrackPoint!");
875 TVector3 globalHit(-999, -999, -999);
887 weight = weights.at(mea);
890 double uCoor = pxdHit->
getU();
891 double vCoor = pxdHit->
getV();
900 globalHit = aSensorInfo.
pointToGlobal(TVector3(uCoor, vCoor, 0),
true);
906 if ((
int)pxdth_fromcl.
size() != 0) {
912 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++) {
914 for (
int th = 0; th < (int)trueHit_fromMCParticles.
size(); th++) {
915 if (trueHit_fromMCParticles[th]->getArrayIndex() == trueHitIndex)
922 }
else if (svdHit2D) {
925 weight = weights.at(mea);
928 double uCoor = svdHit2D->
getU();
929 double vCoor = svdHit2D->
getV();
939 globalHit = aSensorInfo.
pointToGlobal(TVector3(uCoor, vCoor, 0),
true);
944 weight = weights.at(mea);
961 globalHit = aSensorInfo.
pointToGlobal(TVector3(uCoor, vCoor, 0),
true);
965 weight = weights.at(mea);
1015 histoList->Add(h_ineff_pt);
1017 TH1F* h_ineff_theta =
createHistogramsRatio(
"hinefftheta",
"inefficiency VS #theta, normalized to MCParticles",
1019 histoList->Add(h_ineff_theta);
1023 histoList->Add(h_ineff_phi);
1026 TH1F* h_ineffMCRT_pt =
createHistogramsRatio(
"hineffMCRTpt",
"inefficiency VS pt, normalized to MCRecoTrack",
1028 histoList->Add(h_ineffMCRT_pt);
1030 TH1F* h_ineffMCRT_theta =
createHistogramsRatio(
"hineffMCRTtheta",
"inefficiency VS #theta, normalized to MCRecoTrack",
1032 histoList->Add(h_ineffMCRT_theta);
1034 TH1F* h_ineffMCRT_phi =
createHistogramsRatio(
"hineffMCRTphi",
"inefficiency VS #phi, normalized to MCRecoTrack",
1036 histoList->Add(h_ineffMCRT_phi);
1044 TH1F* h_MCPwPXDhits_pt =
createHistogramsRatio(
"hMCPwPXDhits",
"fraction of MCParticles with PXD hits VS pt",
1047 histoList->Add(h_MCPwPXDhits_pt);
1050 "fraction of MCParticles with PXD Hits with RecoTracks with PXD hits VS pt",
1053 histoList->Add(h_RTwPXDhitsMCPwPXDHits_pt);
1055 TH1F* h_wPXDhits_pt =
createHistogramsRatio(
"hTrkswPXDhits",
"fraction of tracks with PXD hits VS pt",
1058 histoList->Add(h_wPXDhits_pt);
1063 histoList->Add(h_eff_pt);
1068 histoList->Add(h_eff_theta);
1072 histoList->Add(h_eff_phi);
1077 histoList->Add(h_effMCRT_pt);
1079 TH1F* h_effMCRT_theta =
createHistogramsRatio(
"heffMCRTtheta",
"efficiency VS #theta, normalized to MCRecoTrack",
1081 histoList->Add(h_effMCRT_theta);
1083 TH1F* h_effMCRT_phi =
createHistogramsRatio(
"heffMCRTphi",
"efficiency VS #phi, normalized to MCRecoTrack",
1085 histoList->Add(h_effMCRT_phi);
1090 TH1F* h_eff_pt_plus =
createHistogramsRatio(
"heffpt_plus",
"efficiency VS pt, normalized to positive MCParticles",
1092 histoList->Add(h_eff_pt_plus);
1095 TH1F* h_eff_theta_plus =
createHistogramsRatio(
"hefftheta_plus",
"efficiency VS #theta, normalized to positive MCParticles",
1097 histoList->Add(h_eff_theta_plus);
1099 TH1F* h_eff_phi_plus =
createHistogramsRatio(
"heffphi_plus",
"efficiency VS #phi, normalized to positive MCParticles",
1101 histoList->Add(h_eff_phi_plus);
1104 TH1F* h_effMCRT_pt_plus =
createHistogramsRatio(
"heffMCRTpt_plus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1106 histoList->Add(h_effMCRT_pt_plus);
1108 TH1F* h_effMCRT_theta_plus =
createHistogramsRatio(
"heffMCRTtheta_plus",
"efficiency VS #theta, normalized to positive MCRecoTrack",
1110 histoList->Add(h_effMCRT_theta_plus);
1112 TH1F* h_effMCRT_phi_plus =
createHistogramsRatio(
"heffMCRTphi_plus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1114 histoList->Add(h_effMCRT_phi_plus);
1119 TH1F* h_eff_pt_minus =
createHistogramsRatio(
"heffpt_minus",
"efficiency VS pt, normalized to positive MCParticles",
1121 histoList->Add(h_eff_pt_minus);
1124 TH1F* h_eff_theta_minus =
createHistogramsRatio(
"hefftheta_minus",
"efficiency VS #theta, normalized to positive MCParticles",
1126 histoList->Add(h_eff_theta_minus);
1128 TH1F* h_eff_phi_minus =
createHistogramsRatio(
"heffphi_minus",
"efficiency VS #phi, normalized to positive MCParticles",
1130 histoList->Add(h_eff_phi_minus);
1133 TH1F* h_effMCRT_pt_minus =
createHistogramsRatio(
"heffMCRTpt_minus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1135 histoList->Add(h_effMCRT_pt_minus);
1139 histoList->Add(h_effMCRT_theta_minus);
1141 TH1F* h_effMCRT_phi_minus =
createHistogramsRatio(
"heffMCRTphi_minus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1143 histoList->Add(h_effMCRT_phi_minus);
1146 TH1F* h_effPR =
createHistogramsRatio(
"heffPR",
"PR efficiency VS VXD Layer, normalized to MCRecoTrack",
1148 histoList->Add(h_effPR);
1153 histoList->Add(h_effVXDHitFit);
1157 histoList->Add(h_effCDCHitFit);
1171 return (isPrimary && isChargedStable);
This class is used to transfer CDC information to the track fit.
WireID getWireID() const
Getter for WireID object.
Provides a type-safe way to pass members of the chargedStableSet set.
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
double getMass() const
Particle mass.
static const ParticleSet chargedStableSet
set of charged stable particles
static const ParticleType invalidParticle
Invalid particle, used internally.
bool hasLayer(const unsigned short layer) const
Getter for single layer.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
std::pair< const unsigned short, const unsigned short > getSVDLayer(const unsigned short layerId) const
Get the number of hits in a specific layer of the SVD.
This struct is used by the TrackingPerformanceEvaluation Module to save information of reconstructed ...
double getPx()
Getter for x component of momentum.
double getZ()
Getter for z component of vertex.
double getPt()
Getter for transverse momentum.
double getY()
Getter for y component of vertex.
double getCharge()
Getter for electric charge of particle.
double getPtheta()
Getter for theta of momentum vector.
double getZ0()
Getter for Z0.
double getX()
Getter for x component of vertex.
double getPy()
Getter for y component of momentum.
double getCotTheta()
Getter for Theta.
double getPhi()
Getter for Phi.
double getPz()
Getter for z component of momentum.
double getOmega()
Getter for Omega.
double getPphi()
Getter for phi of momentum vector.
double getD0()
Getter for D0.
double getP()
Getter for magnitut of momentum.
A Class to store the Monte Carlo particle information.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
bool hasSeenInDetector(Const::DetectorSet set) const
Return if the seen-in flag for a specific subdetector is set or not.
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
int getPDG() const
Return PDG code of particle.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
PXDRecoHit - an extended form of PXDCluster containing geometry information.
float getV() const
Get v coordinate.
const PXDCluster * getCluster() const
Get pointer to the Cluster used when creating this RecoHit, can be NULL if created from something els...
VxdID getSensorID() const
Get the compact ID.
float getU() const
Get u coordinate.
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
This is the Reconstruction Event-Data Model Track.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
SVDRecoHit - an extended form of SVDHit containing geometry information.
float getV() const
Get v coordinate.
VxdID getSensorID() const
Get the compact ID.
float getU() const
Get u coordinate.
SVDRecoHit - an extended form of SVDHit containing geometry information.
bool isU() const
Is the coordinate u or v?
float getPosition() const
Get coordinate.
VxdID getSensorID() const
Get the compact ID.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Values of the result of a track fit with a given particle hypothesis.
TMatrixDSym getCovariance5() const
Getter for covariance matrix of perigee parameters in matrix form.
double getPhi() const
Getter for phi0 with CDF naming convention.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
double getOmega() const
Getter for omega.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
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.
double getZ0() const
Getter for z0.
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.
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Access to TrackFitResults.
static const double T
[tesla]
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Base class to provide Sensor Information for PXD and SVD.
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Class to identify a wire inside the CDC.
unsigned short getICLayer() const
Getter for continuous layer numbering.
Contains the measurement and covariance in raw detector coordinates.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
std::vector< double > getWeights() const
Get weights of measurements.
Object containing AbsMeasurement and AbsFitterInfo objects.
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Abstract base class for different kinds of events.