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/HitPatternCDC.h>
19#include <mdst/dataobjects/HitPatternVXD.h>
21#include <pxd/reconstruction/PXDRecoHit.h>
22#include <svd/reconstruction/SVDRecoHit.h>
23#include <svd/reconstruction/SVDRecoHit2D.h>
24#include <cdc/dataobjects/CDCRecoHit.h>
26#include <pxd/dataobjects/PXDTrueHit.h>
27#include <pxd/dataobjects/PXDCluster.h>
28#include <svd/dataobjects/SVDCluster.h>
29#include <cdc/dataobjects/CDCHit.h>
31#include <genfit/KalmanFitterInfo.h>
33#include <root/TObject.h>
46 setDescription(
"This module evaluates the tracking package performance");
49 std::string(
"TrackingPerformanceEvaluation_output.root"));
165 2000, -10, 10,
"x (cm)",
166 2000, -10, 10,
"y (cm)",
170 2000, -30, 40,
"z (cm)",
171 2000, 0, 15,
"r_{t} (cm)",
175 "#sigma_{z0}/#sigma_{cot#theta} projected on x,y",
180 100, 0, 3,
"p_{t} (GeV/c)",
181 1000, 0, 0.2,
"#sigma_{#omega}/#omega",
186 100, 0, 3,
"p_{t} (GeV/c)",
187 100, 0, 0.1,
"#sigma_{z0} (cm)",
205 100, 0, 3,
"p_{t} (GeV/c)",
206 100, 0, 0.1,
"#sigma_{d0} (cm)",
222 50, 0, 2.5,
"p_{t} (GeV/c)",
241 "number of VXD hits used in the fit per Layer, weighted",
246 2000, -15, 15,
"x (cm)",
247 2000, -15, 15,
"y (cm)",
251 2000, -30, 40,
"z (cm)",
252 2000, 0, 15,
"r_{t} (cm)",
258 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};
259 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()};
260 Double_t bins_phi[14 + 1];
261 Double_t width_phi = 2 * TMath::Pi() / 14;
262 for (
int bin = 0; bin < 14 + 1; bin++)
263 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
267 10, bins_pt,
"p_{t} (GeV/c)",
268 10, bins_theta,
"#theta",
269 14, bins_phi,
"#phi" );
272 "entry per Track connected to a MCParticle",
276 "entry per Track with PXD hits connected to a MCParticle",
280 "entry per RecoTrack with PXD hits connected to a MCParticle",
284 "entry per RecoTrack with PXD hits connected to a MCParticle with PXD hits",
288 "entry per MCParticle with PXD hits",
292 "entry per MCRecoTrack connected to the MCParticle",
296 "entry per Track connected to an MCRecoTrack",
303 "entry per Track connected to a positive MCParticle",
307 "entry per MCRecoTrack connected to the positive MCParticle",
311 "entry per Track connected to a positive MCRecoTrack",
320 "entry per Track connected to a negative MCParticle",
324 "entry per MCRecoTrack connected to the negative MCParticle",
328 "entry per Track connected to a negative MCRecoTrack",
344 "entry per MCParticle connected to a Track",
357 bool hasTrack =
false;
358 B2DEBUG(29,
"+++++ 1. loop on MCParticles");
365 int pdgCode = mcParticle.getPDG();
366 B2DEBUG(29,
"MCParticle has PDG code " << pdgCode);
368 int nFittedTracksMCRT = 0;
369 int nFittedTracks = 0;
384 if (mcParticle.hasSeenInDetector(Const::PXD))
393 if (MCRecoTracks_fromMCParticle.
size() > 0)
394 if (MCRecoTracks_fromMCParticle[0]->hasPXDHits()) {
396 if (mcParticle.hasSeenInDetector(Const::PXD))
406 if (MCRecoTracks_fromMCParticle.
size() > 0) {
421 B2DEBUG(29, Tracks_fromMCParticle.
size() <<
" Tracks related to this MCParticle");
423 for (
int trk = 0; trk < (int)Tracks_fromMCParticle.
size(); trk++) {
428 B2WARNING(
" the TrackFitResult is not found!");
450 if (MCRecoTracks_fromMCParticle.
size() > 0) {
471 if (MCRecoTracks_fromMCParticle.
size() > 0)
477 B2DEBUG(29,
"+++++ 2. loop on Tracks");
484 int nMCParticles = 0;
494 ROOT::Math::XYZVector momentum = fitResult->
getMomentum();
495 m_h3_Tracks->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
501 for (
int layer = 0; layer < 56; layer++) {
505 for (
int layer = 1; layer <= 2; layer++) {
509 for (
int layer = 3; layer <= 6; layer++) {
514 for (
int i = 0; i < N; i++)
521 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++)
533 B2DEBUG(29,
"+++++ 3. loop on MCRecoTracks");
540 B2DEBUG(29,
"~ " << RecoTracks_fromMCRecoTrack.
size() <<
" RecoTracks related to this MCRecoTrack");
546 B2DEBUG(29,
"~~~ " << MCParticles_fromMCRecoTrack.
size() <<
" MCParticles related to this MCRecoTrack");
547 for (
int mcp = 0; mcp < (int)MCParticles_fromMCRecoTrack.
size(); mcp++) {
551 (MCParticles_fromMCRecoTrack[mcp]);
553 B2DEBUG(29,
"~~~~~ " << RecoTracks_fromMCParticle.
size() <<
" RecoTracks related to this MCParticle");
559 B2DEBUG(29,
"+++++ 4. loop on RecoTracks");
605 double efficiency = num / den ;
606 double efficiencyErr =
sqrt(efficiency * (1 - efficiency)) /
sqrt(den);
608 double nFittedTracksMCRT = 0;
614 double nRecoTrack = 0;
620 double nMCRecoTrack = 0;
626 double nMCParticles = 0;
633 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
634 B2INFO(
"~ Tracking Performance Evaluation ~ SHORT SUMMARY ~");
636 B2INFO(
" + overall:");
637 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
638 B2INFO(
" purity = " << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
640 B2INFO(
" + factorizing geometrical acceptance:");
641 B2INFO(
" efficiency = " << efficiencyMCRT * 100 <<
" +/- " << efficiencyMCRTErr * 100 <<
")% ");
643 B2INFO(
" + pattern recognition:");
644 B2INFO(
" efficiency = " << efficiencyPR * 100 <<
" +/- " << efficiencyPRErr * 100 <<
")% ");
645 B2INFO(
" purity = " << purityPR * 100 <<
" +/- " << purityPRErr * 100 <<
")% ");
647 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
662 TDirectory* oldDir = gDirectory;
664 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
665 dir_multiplicity->cd();
668 while ((obj = nextH_multiplicity()))
671 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
672 dir_efficiency->cd();
674 while ((obj = nextH_efficiency()))
677 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
678 dir_trkQuality->cd();
680 while ((obj = nextH_trkQuality()))
683 TDirectory* dir_firstHit = oldDir->mkdir(
"firstHit");
686 while ((obj = nextH_firstHit()))
710 double d0_res = fitResult->
getD0() - mcParticleInfo.
getD0();
711 double phi_res = TMath::ASin(TMath::Sin(fitResult->
getPhi() - mcParticleInfo.
getPhi()));
713 double z0_res = fitResult->
getZ0() - mcParticleInfo.
getZ0();
728 mcParticleInfo.
getY());
730 mcParticleInfo.
getY() + mcParticleInfo.
getZ() * mcParticleInfo.
getZ());
779 ROOT::Math::XYZVector momentum = fitResult->
getMomentum();
781 double px = momentum.x();
782 double py = momentum.y();
783 double pz = momentum.z();
784 double pt = momentum.Rho();
785 double p = momentum.R();
787 double beta = p /
sqrt(p * p + mass * mass);
788 double sinTheta = TMath::Sin(momentum.Theta());
791 d0_err / phi_err * py / pt);
793 z0_err / cotTheta_err * py / pt);
801 m_h2_d0errMSVSpt->Fill(pt, d0_err * beta * p * pow(sinTheta, 3 / 2) / 0.0136);
814 bool hasPXDhit =
false;
815 bool isTrueHit =
false;
817 double d0_err = -999;
818 double z0_err = -999;
827 const bool hasCDChit[56] = {
false };
831 for (
int tc = 0; tc < (int)RecoTracks_fromTrack.
size(); tc++) {
833 const std::vector< genfit::TrackPoint* >& tp_vector = RecoTracks_fromTrack[tc]->getHitPointsWithMeasurement();
834 for (
int i = 0; i < (int) tp_vector.size(); i++) {
835 const genfit::TrackPoint* tp = tp_vector[i];
837 int nMea = tp->getNumRawMeasurements();
838 for (
int mea = 0; mea < nMea; mea++) {
840 genfit::AbsMeasurement* absMeas = tp->getRawMeasurement(mea);
843 std::vector<double> weights;
844 const genfit::KalmanFitterInfo* kalmanInfo = tp->getKalmanFitterInfo();
846 weights = kalmanInfo->getWeights();
848 B2WARNING(
" No KalmanFitterInfo associated to the TrackPoint!");
851 ROOT::Math::XYZVector globalHit(-999, -999, -999);
863 weight = weights.at(mea);
866 double uCoor = pxdHit->
getU();
867 double vCoor = pxdHit->
getV();
876 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
882 if ((
int)pxdth_fromcl.
size() != 0) {
888 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++) {
890 for (
int th = 0; th < (int)trueHit_fromMCParticles.
size(); th++) {
891 if (trueHit_fromMCParticles[th]->getArrayIndex() == trueHitIndex)
898 }
else if (svdHit2D) {
901 weight = weights.at(mea);
904 double uCoor = svdHit2D->
getU();
905 double vCoor = svdHit2D->
getV();
915 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
920 weight = weights.at(mea);
937 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
941 weight = weights.at(mea);
991 histoList->Add(h_ineff_pt);
993 TH1F* h_ineff_theta =
createHistogramsRatio(
"hinefftheta",
"inefficiency VS #theta, normalized to MCParticles",
995 histoList->Add(h_ineff_theta);
999 histoList->Add(h_ineff_phi);
1002 TH1F* h_ineffMCRT_pt =
createHistogramsRatio(
"hineffMCRTpt",
"inefficiency VS pt, normalized to MCRecoTrack",
1004 histoList->Add(h_ineffMCRT_pt);
1006 TH1F* h_ineffMCRT_theta =
createHistogramsRatio(
"hineffMCRTtheta",
"inefficiency VS #theta, normalized to MCRecoTrack",
1008 histoList->Add(h_ineffMCRT_theta);
1010 TH1F* h_ineffMCRT_phi =
createHistogramsRatio(
"hineffMCRTphi",
"inefficiency VS #phi, normalized to MCRecoTrack",
1012 histoList->Add(h_ineffMCRT_phi);
1020 TH1F* h_MCPwPXDhits_pt =
createHistogramsRatio(
"hMCPwPXDhits",
"fraction of MCParticles with PXD hits VS pt",
1023 histoList->Add(h_MCPwPXDhits_pt);
1026 "fraction of MCParticles with PXD Hits with RecoTracks with PXD hits VS pt",
1029 histoList->Add(h_RTwPXDhitsMCPwPXDHits_pt);
1031 TH1F* h_wPXDhits_pt =
createHistogramsRatio(
"hTrkswPXDhits",
"fraction of tracks with PXD hits VS pt",
1034 histoList->Add(h_wPXDhits_pt);
1039 histoList->Add(h_eff_pt);
1044 histoList->Add(h_eff_theta);
1048 histoList->Add(h_eff_phi);
1053 histoList->Add(h_effMCRT_pt);
1055 TH1F* h_effMCRT_theta =
createHistogramsRatio(
"heffMCRTtheta",
"efficiency VS #theta, normalized to MCRecoTrack",
1057 histoList->Add(h_effMCRT_theta);
1059 TH1F* h_effMCRT_phi =
createHistogramsRatio(
"heffMCRTphi",
"efficiency VS #phi, normalized to MCRecoTrack",
1061 histoList->Add(h_effMCRT_phi);
1066 TH1F* h_eff_pt_plus =
createHistogramsRatio(
"heffpt_plus",
"efficiency VS pt, normalized to positive MCParticles",
1068 histoList->Add(h_eff_pt_plus);
1071 TH1F* h_eff_theta_plus =
createHistogramsRatio(
"hefftheta_plus",
"efficiency VS #theta, normalized to positive MCParticles",
1073 histoList->Add(h_eff_theta_plus);
1075 TH1F* h_eff_phi_plus =
createHistogramsRatio(
"heffphi_plus",
"efficiency VS #phi, normalized to positive MCParticles",
1077 histoList->Add(h_eff_phi_plus);
1080 TH1F* h_effMCRT_pt_plus =
createHistogramsRatio(
"heffMCRTpt_plus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1082 histoList->Add(h_effMCRT_pt_plus);
1084 TH1F* h_effMCRT_theta_plus =
createHistogramsRatio(
"heffMCRTtheta_plus",
"efficiency VS #theta, normalized to positive MCRecoTrack",
1086 histoList->Add(h_effMCRT_theta_plus);
1088 TH1F* h_effMCRT_phi_plus =
createHistogramsRatio(
"heffMCRTphi_plus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1090 histoList->Add(h_effMCRT_phi_plus);
1095 TH1F* h_eff_pt_minus =
createHistogramsRatio(
"heffpt_minus",
"efficiency VS pt, normalized to positive MCParticles",
1097 histoList->Add(h_eff_pt_minus);
1100 TH1F* h_eff_theta_minus =
createHistogramsRatio(
"hefftheta_minus",
"efficiency VS #theta, normalized to positive MCParticles",
1102 histoList->Add(h_eff_theta_minus);
1104 TH1F* h_eff_phi_minus =
createHistogramsRatio(
"heffphi_minus",
"efficiency VS #phi, normalized to positive MCParticles",
1106 histoList->Add(h_eff_phi_minus);
1109 TH1F* h_effMCRT_pt_minus =
createHistogramsRatio(
"heffMCRTpt_minus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1111 histoList->Add(h_effMCRT_pt_minus);
1115 histoList->Add(h_effMCRT_theta_minus);
1117 TH1F* h_effMCRT_phi_minus =
createHistogramsRatio(
"heffMCRTphi_minus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1119 histoList->Add(h_effMCRT_phi_minus);
1122 TH1F* h_effPR =
createHistogramsRatio(
"heffPR",
"PR efficiency VS VXD Layer, normalized to MCRecoTrack",
1124 histoList->Add(h_effPR);
1129 histoList->Add(h_effVXDHitFit);
1133 histoList->Add(h_effCDCHitFit);
1147 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.
double getMass() const
Particle mass.
static const ParticleSet chargedStableSet
set of charged stable particles
static const ParticleType invalidParticle
Invalid particle, used internally.
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
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 hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
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.
Accessor to arrays stored in the data store.
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.
double getD0() const
Getter for d0.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
double getZ0() const
Getter for z0.
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.
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Default Access to TrackFitResults.
static const double T
[tesla]
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference 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.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &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.
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.
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.