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)",
179 100, 0, 3,
"p_{t} (GeV/c)",
180 1000, 0, 0.2,
"#sigma_{#omega}/#omega",
185 100, 0, 3,
"p_{t} (GeV/c)",
186 100, 0, 0.1,
"#sigma_{z0} (cm)",
201 100, 0, 3,
"p_{t} (GeV/c)",
202 100, 0, 0.1,
"#sigma_{d0} (cm)",
215 50, 0, 2.5,
"p_{t} (GeV/c)",
238 2000, -15, 15,
"x (cm)",
239 2000, -15, 15,
"y (cm)",
243 2000, -30, 40,
"z (cm)",
244 2000, 0, 15,
"r_{t} (cm)",
250 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};
251 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()};
252 Double_t bins_phi[14 + 1];
253 Double_t width_phi = 2 * TMath::Pi() / 14;
254 for (
int bin = 0; bin < 14 + 1; bin++)
255 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
259 10, bins_pt,
"p_{t} (GeV/c)",
260 10, bins_theta,
"#theta",
261 14, bins_phi,
"#phi" );
264 "entry per Track connected to a MCParticle",
268 "entry per Track with PXD hits connected to a MCParticle",
272 "entry per RecoTrack with PXD hits connected to a MCParticle",
276 "entry per RecoTrack with PXD hits connected to a MCParticle with PXD hits",
280 "entry per MCParticle with PXD hits",
284 "entry per MCRecoTrack connected to the MCParticle",
288 "entry per Track connected to an MCRecoTrack",
295 "entry per Track connected to a positive MCParticle",
299 "entry per MCRecoTrack connected to the positive MCParticle",
303 "entry per Track connected to a positive MCRecoTrack",
312 "entry per Track connected to a negative MCParticle",
316 "entry per MCRecoTrack connected to the negative MCParticle",
320 "entry per Track connected to a negative MCRecoTrack",
336 "entry per MCParticle connected to a Track",
349 bool hasTrack =
false;
350 B2DEBUG(29,
"+++++ 1. loop on MCParticles");
356 int pdgCode = mcParticle.getPDG();
357 B2DEBUG(29,
"MCParticle has PDG code " << pdgCode);
359 int nFittedTracksMCRT = 0;
360 int nFittedTracks = 0;
375 if (mcParticle.hasSeenInDetector(Const::PXD))
384 if (MCRecoTracks_fromMCParticle.
size() > 0)
385 if (MCRecoTracks_fromMCParticle[0]->hasPXDHits()) {
387 if (mcParticle.hasSeenInDetector(Const::PXD))
397 if (MCRecoTracks_fromMCParticle.
size() > 0) {
412 B2DEBUG(29, Tracks_fromMCParticle.
size() <<
" Tracks related to this MCParticle");
414 for (
int trk = 0; trk < (int)Tracks_fromMCParticle.
size(); trk++) {
419 B2WARNING(
" the TrackFitResult is not found!");
441 if (MCRecoTracks_fromMCParticle.
size() > 0) {
462 if (MCRecoTracks_fromMCParticle.
size() > 0)
468 B2DEBUG(29,
"+++++ 2. loop on Tracks");
475 int nMCParticles = 0;
485 ROOT::Math::XYZVector momentum = fitResult->
getMomentum();
486 m_h3_Tracks->Fill(momentum.Rho(), momentum.Theta(), momentum.Phi());
492 for (
int layer = 0; layer < 56; layer++) {
496 for (
int layer = 1; layer <= 2; layer++) {
500 for (
int layer = 3; layer <= 6; layer++) {
505 for (
int i = 0; i < N; i++)
512 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++)
524 B2DEBUG(29,
"+++++ 3. loop on MCRecoTracks");
528 bool hasRecoTrack =
false;
532 B2DEBUG(29,
"~ " << RecoTracks_fromMCRecoTrack.
size() <<
" RecoTracks related to this MCRecoTrack");
538 B2DEBUG(29,
"~~~ " << MCParticles_fromMCRecoTrack.
size() <<
" MCParticles related to this MCRecoTrack");
539 for (
int mcp = 0; mcp < (int)MCParticles_fromMCRecoTrack.
size(); mcp++) {
543 (MCParticles_fromMCRecoTrack[mcp]);
545 B2DEBUG(29,
"~~~~~ " << RecoTracks_fromMCParticle.
size() <<
" RecoTracks related to this MCParticle");
546 for (
int tc = 0; tc < (int)RecoTracks_fromMCParticle.
size(); tc++)
556 B2DEBUG(29,
"+++++ 4. loop on RecoTracks");
602 double efficiency = num / den ;
603 double efficiencyErr =
sqrt(efficiency * (1 - efficiency)) /
sqrt(den);
605 double nFittedTracksMCRT = 0;
611 double nRecoTrack = 0;
617 double nMCRecoTrack = 0;
623 double nMCParticles = 0;
630 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
631 B2INFO(
"~ Tracking Performance Evaluation ~ SHORT SUMMARY ~");
633 B2INFO(
" + overall:");
634 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
635 B2INFO(
" purity = " << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
637 B2INFO(
" + factorizing geometrical acceptance:");
638 B2INFO(
" efficiency = " << efficiencyMCRT * 100 <<
" +/- " << efficiencyMCRTErr * 100 <<
")% ");
640 B2INFO(
" + pattern recognition:");
641 B2INFO(
" efficiency = " << efficiencyPR * 100 <<
" +/- " << efficiencyPRErr * 100 <<
")% ");
642 B2INFO(
" purity = " << purityPR * 100 <<
" +/- " << purityPRErr * 100 <<
")% ");
644 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
659 TDirectory* oldDir = gDirectory;
661 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
662 dir_multiplicity->cd();
665 while ((obj = nextH_multiplicity()))
668 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
669 dir_efficiency->cd();
671 while ((obj = nextH_efficiency()))
674 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
675 dir_trkQuality->cd();
677 while ((obj = nextH_trkQuality()))
680 TDirectory* dir_firstHit = oldDir->mkdir(
"firstHit");
683 while ((obj = nextH_firstHit()))
707 double d0_res = fitResult->
getD0() - mcParticleInfo.
getD0();
708 double phi_res = TMath::ASin(TMath::Sin(fitResult->
getPhi() - mcParticleInfo.
getPhi()));
710 double z0_res = fitResult->
getZ0() - mcParticleInfo.
getZ0();
717 double p_res = (fitResult->
getMomentum().R() - mcParticleInfo.
getP()) / mcParticleInfo.
getP();
725 mcParticleInfo.
getY());
727 mcParticleInfo.
getY() + mcParticleInfo.
getZ() * mcParticleInfo.
getZ());
776 ROOT::Math::XYZVector momentum = fitResult->
getMomentum();
778 double px = momentum.x();
779 double py = momentum.y();
780 double pz = momentum.z();
781 double pt = momentum.Rho();
782 double p = momentum.R();
784 double beta = p /
sqrt(p * p + mass * mass);
785 double sinTheta = TMath::Sin(momentum.Theta());
788 d0_err / phi_err * py / pt);
790 z0_err / cotTheta_err * py / pt);
798 m_h2_d0errMSVSpt->Fill(pt, d0_err * beta * p * pow(sinTheta, 3 / 2) / 0.0136);
811 bool hasPXDhit =
false;
812 bool isTrueHit =
false;
814 double d0_err = -999;
815 double z0_err = -999;
824 const bool hasCDChit[56] = {
false };
828 for (
int tc = 0; tc < (int)RecoTracks_fromTrack.
size(); tc++) {
830 const std::vector< genfit::TrackPoint* >& tp_vector = RecoTracks_fromTrack[tc]->getHitPointsWithMeasurement();
831 for (
int i = 0; i < (int) tp_vector.size(); i++) {
832 genfit::TrackPoint* tp = tp_vector[i];
834 int nMea = tp->getNumRawMeasurements();
835 for (
int mea = 0; mea < nMea; mea++) {
837 genfit::AbsMeasurement* absMeas = tp->getRawMeasurement(mea);
840 std::vector<double> weights;
841 genfit::KalmanFitterInfo* kalmanInfo = tp->getKalmanFitterInfo();
843 weights = kalmanInfo->getWeights();
845 B2WARNING(
" No KalmanFitterInfo associated to the TrackPoint!");
848 ROOT::Math::XYZVector globalHit(-999, -999, -999);
860 weight = weights.at(mea);
863 double uCoor = pxdHit->
getU();
864 double vCoor = pxdHit->
getV();
873 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
879 if ((
int)pxdth_fromcl.
size() != 0) {
885 for (
int mcp = 0; mcp < (int)MCParticles_fromTrack.
size(); mcp++) {
887 for (
int th = 0; th < (int)trueHit_fromMCParticles.
size(); th++) {
888 if (trueHit_fromMCParticles[th]->getArrayIndex() == trueHitIndex)
895 }
else if (svdHit2D) {
898 weight = weights.at(mea);
901 double uCoor = svdHit2D->
getU();
902 double vCoor = svdHit2D->
getV();
912 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
917 weight = weights.at(mea);
934 globalHit = aSensorInfo.
pointToGlobal(ROOT::Math::XYZVector(uCoor, vCoor, 0),
true);
938 weight = weights.at(mea);
988 histoList->Add(h_ineff_pt);
990 TH1F* h_ineff_theta =
createHistogramsRatio(
"hinefftheta",
"inefficiency VS #theta, normalized to MCParticles",
992 histoList->Add(h_ineff_theta);
996 histoList->Add(h_ineff_phi);
999 TH1F* h_ineffMCRT_pt =
createHistogramsRatio(
"hineffMCRTpt",
"inefficiency VS pt, normalized to MCRecoTrack",
1001 histoList->Add(h_ineffMCRT_pt);
1003 TH1F* h_ineffMCRT_theta =
createHistogramsRatio(
"hineffMCRTtheta",
"inefficiency VS #theta, normalized to MCRecoTrack",
1005 histoList->Add(h_ineffMCRT_theta);
1007 TH1F* h_ineffMCRT_phi =
createHistogramsRatio(
"hineffMCRTphi",
"inefficiency VS #phi, normalized to MCRecoTrack",
1009 histoList->Add(h_ineffMCRT_phi);
1017 TH1F* h_MCPwPXDhits_pt =
createHistogramsRatio(
"hMCPwPXDhits",
"fraction of MCParticles with PXD hits VS pt",
1020 histoList->Add(h_MCPwPXDhits_pt);
1023 "fraction of MCParticles with PXD Hits with RecoTracks with PXD hits VS pt",
1026 histoList->Add(h_RTwPXDhitsMCPwPXDHits_pt);
1028 TH1F* h_wPXDhits_pt =
createHistogramsRatio(
"hTrkswPXDhits",
"fraction of tracks with PXD hits VS pt",
1031 histoList->Add(h_wPXDhits_pt);
1036 histoList->Add(h_eff_pt);
1041 histoList->Add(h_eff_theta);
1045 histoList->Add(h_eff_phi);
1050 histoList->Add(h_effMCRT_pt);
1052 TH1F* h_effMCRT_theta =
createHistogramsRatio(
"heffMCRTtheta",
"efficiency VS #theta, normalized to MCRecoTrack",
1054 histoList->Add(h_effMCRT_theta);
1056 TH1F* h_effMCRT_phi =
createHistogramsRatio(
"heffMCRTphi",
"efficiency VS #phi, normalized to MCRecoTrack",
1058 histoList->Add(h_effMCRT_phi);
1063 TH1F* h_eff_pt_plus =
createHistogramsRatio(
"heffpt_plus",
"efficiency VS pt, normalized to positive MCParticles",
1065 histoList->Add(h_eff_pt_plus);
1068 TH1F* h_eff_theta_plus =
createHistogramsRatio(
"hefftheta_plus",
"efficiency VS #theta, normalized to positive MCParticles",
1070 histoList->Add(h_eff_theta_plus);
1072 TH1F* h_eff_phi_plus =
createHistogramsRatio(
"heffphi_plus",
"efficiency VS #phi, normalized to positive MCParticles",
1074 histoList->Add(h_eff_phi_plus);
1077 TH1F* h_effMCRT_pt_plus =
createHistogramsRatio(
"heffMCRTpt_plus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1079 histoList->Add(h_effMCRT_pt_plus);
1081 TH1F* h_effMCRT_theta_plus =
createHistogramsRatio(
"heffMCRTtheta_plus",
"efficiency VS #theta, normalized to positive MCRecoTrack",
1083 histoList->Add(h_effMCRT_theta_plus);
1085 TH1F* h_effMCRT_phi_plus =
createHistogramsRatio(
"heffMCRTphi_plus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1087 histoList->Add(h_effMCRT_phi_plus);
1092 TH1F* h_eff_pt_minus =
createHistogramsRatio(
"heffpt_minus",
"efficiency VS pt, normalized to positive MCParticles",
1094 histoList->Add(h_eff_pt_minus);
1097 TH1F* h_eff_theta_minus =
createHistogramsRatio(
"hefftheta_minus",
"efficiency VS #theta, normalized to positive MCParticles",
1099 histoList->Add(h_eff_theta_minus);
1101 TH1F* h_eff_phi_minus =
createHistogramsRatio(
"heffphi_minus",
"efficiency VS #phi, normalized to positive MCParticles",
1103 histoList->Add(h_eff_phi_minus);
1106 TH1F* h_effMCRT_pt_minus =
createHistogramsRatio(
"heffMCRTpt_minus",
"efficiency VS pt, normalized to positive MCRecoTrack",
1108 histoList->Add(h_effMCRT_pt_minus);
1112 histoList->Add(h_effMCRT_theta_minus);
1114 TH1F* h_effMCRT_phi_minus =
createHistogramsRatio(
"heffMCRTphi_minus",
"efficiency VS #phi, normalized to positive MCRecoTrack",
1116 histoList->Add(h_effMCRT_phi_minus);
1119 TH1F* h_effPR =
createHistogramsRatio(
"heffPR",
"PR efficiency VS VXD Layer, normalized to MCRecoTrack",
1121 histoList->Add(h_effPR);
1126 histoList->Add(h_effVXDHitFit);
1130 histoList->Add(h_effCDCHitFit);
1144 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 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.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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 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.
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.