3434#include < TProfile2D.h>
3535#include < TString.h>
3636
37+ #include < algorithm>
3738#include < map>
3839#include < memory>
3940#include < string>
4041#include < vector>
4142
4243using namespace o2 ;
4344using namespace o2 ::framework;
44- std::shared_ptr<TH1 > particlePdgCodes;
45- std::map<int , std::shared_ptr<TH1 >> particlePtDistribution;
46- std::map<int , std::shared_ptr<TH1 >> particleEtaDistribution;
47- std::map<int , std::shared_ptr<TH1 >> ptDistribution;
48- std::map<int , std::shared_ptr<TH2 >> ptResolutionVsPt;
49- std::map<int , std::shared_ptr<TProfile2D>> ptResolutionVsEta;
50- std::map<int , std::shared_ptr<TH2 >> invPtResolutionVsPt;
51- std::map<int , std::shared_ptr<TProfile2D>> invPtResolutionVsEta;
52- std::map<int , std::shared_ptr<TH2 >> dcaXyResolutionVsPt;
53- std::map<int , std::shared_ptr<TH2 >> dcaZResolutionVsPt;
54- std::map<int , std::shared_ptr<TH2 >> covariancePtPtVsPt;
55- std::map<int , std::shared_ptr<TH2 >> covarianceDcaXyDcaXyVsPt;
56- std::map<int , std::shared_ptr<TH2 >> covarianceDcaZDcaZVsPt;
5745
5846struct Alice3TrackingPerformance {
59- Configurable<std::vector<int >> pdgCodes{" pdgCodes" , {0 , 211 }, " List of PDG codes to consider for efficiency calculation. (0 means all) " };
47+ Configurable<std::vector<int >> pdgCodes{" pdgCodes" , {211 }, " List of signed PDG codes to consider for performance evaluation " };
6048 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
6149 ConfigurableAxis ptAxis{" ptAxis" , {500 , 0 , 100 }, " #it{p}_{T} (GeV/#it{c})" };
6250 ConfigurableAxis etaAxis{" etaAxis" , {100 , -5 .f , 5 .f }, " #eta" };
6351 ConfigurableAxis invPtDeltaAxis{" invPtDeltaAxis" , {1000 , -0 .1f , 0 .1f }, " 1./#it{p}_{T}^{gen} - 1./#it{p}_{T}^{reco} (GeV/#it{c})^{-1}" };
6452
53+ // Histograms
54+ std::shared_ptr<TH1 > particlePdgCodes;
55+ std::map<int , std::shared_ptr<TH1 >> particlePtDistribution;
56+ std::map<int , std::shared_ptr<TH1 >> particleEtaDistribution;
57+ std::map<int , std::shared_ptr<TH1 >> ptDistribution;
58+ std::map<int , std::shared_ptr<TH2 >> ptResolutionVsPt;
59+ std::map<int , std::shared_ptr<TProfile2D>> ptResolutionVsEta;
60+ std::map<int , std::shared_ptr<TH2 >> invPtResolutionVsPt;
61+ std::map<int , std::shared_ptr<TProfile2D>> invPtResolutionVsEta;
62+ std::map<int , std::shared_ptr<TH2 >> dcaXyResolutionVsPt;
63+ std::map<int , std::shared_ptr<TH2 >> dcaZResolutionVsPt;
64+ std::map<int , std::shared_ptr<TH2 >> covariancePtPtVsPt;
65+ std::map<int , std::shared_ptr<TH2 >> covarianceDcaXyDcaXyVsPt;
66+ std::map<int , std::shared_ptr<TH2 >> covarianceDcaZDcaZVsPt;
67+
6568 void init (o2::framework::InitContext&)
6669 {
70+ // Check if pdgCodes has duplicates and remove them
71+ std::sort (pdgCodes.value .begin (), pdgCodes.value .end ());
72+ pdgCodes.value .erase (std::unique (pdgCodes.value .begin (), pdgCodes.value .end ()), pdgCodes.value .end ());
73+ // Add 0 to the list of pdgCodes if it is not already present
74+ if (std::find (pdgCodes.value .begin (), pdgCodes.value .end (), 0 ) == pdgCodes.value .end ()) {
75+ pdgCodes.value .push_back (0 );
76+ }
6777 const AxisSpec axisPtDelta{100 , -1 , 1 , " (#it{p}_{T}^{reco} - #it{p}_{T}^{gen}) / #it{p}_{T}^{gen}" };
6878 const AxisSpec axisDcaXy{100 , -1 , 1 , " DCA_{xy} (cm)" };
6979 const AxisSpec axisDcaZ{100 , -1 , 1 , " DCA_{z} (cm)" };
7080 const AxisSpec axisCovariancePtPt{100 , 0 , 10 , " cov(#it{p}_{T}, #it{p}_{T}) ((GeV/#it{c})^{2})" };
7181 const AxisSpec axisCovarianceDcaXyDcaXy{100 , 0 , 1 , " cov(DCA_{xy}, DCA_{xy}) (cm^{2})" };
7282 const AxisSpec axisCovarianceDcaZDcaZ{100 , 0 , 1 , " cov(DCA_{z}, DCA_{z}) (cm^{2})" };
73- particlePdgCodes = histos.add <TH1 >(" particlePdgCodes" , " " , kTH1D , {AxisSpec{100 , -0.5 , 99.5 , " PDG Code" }});
83+ const int nBinsPdgCodes = static_cast <int >(pdgCodes.value .size ());
84+ particlePdgCodes = histos.add <TH1 >(" particlePdgCodes" , " " , kTH1D , {AxisSpec{nBinsPdgCodes, -0.5 , -0.5 + nBinsPdgCodes, " PDG Code" }});
7485 for (const int & pdg : pdgCodes.value ) {
7586 std::string prefix = Form (" %i" , pdg);
7687 if (pdg < 0 ) {
@@ -80,6 +91,7 @@ struct Alice3TrackingPerformance {
8091 prefix += " /" ;
8192 auto histoName = [&](const std::string& name) { return Form (" %s%s%s" , prefix.c_str (), name.c_str (), tag.c_str ()); };
8293 particlePtDistribution[pdg] = histos.add <TH1 >(histoName (" particlePtDistribution" ), " " , kTH1D , {ptAxis});
94+ LOG (info) << " Added histogram: " << histoName (" particlePtDistribution" );
8395 particleEtaDistribution[pdg] = histos.add <TH1 >(histoName (" particleEtaDistribution" ), " " , kTH1D , {etaAxis});
8496
8597 ptDistribution[pdg] = histos.add <TH1 >(histoName (" ptDistribution" ), " " , kTH1D , {ptAxis});
@@ -125,7 +137,7 @@ struct Alice3TrackingPerformance {
125137 }
126138 const auto & mcParticle = track.mcParticle ();
127139 const float ptResolution = (track.pt () - mcParticle.pt ()) / mcParticle.pt ();
128- const float invptResolution = 1 .f / track.pt () - 1 .f / mcParticle.pt ();
140+ const float invptResolution = (track. pt () > 0 . f ? 1 .f / track.pt () : 0 . f ) - (mcParticle. pt () > 0 . f ? 1 .f / mcParticle.pt () : 0 . f );
129141 const float covariancePtPt = track.sigma1Pt () * track.sigma1Pt () * track.pt () * track.pt () * track.pt () * track.pt ();
130142
131143 auto fillResolutionHistograms = [&](const int p) {
@@ -137,8 +149,8 @@ struct Alice3TrackingPerformance {
137149 dcaXyResolutionVsPt[p]->Fill (mcParticle.pt (), track.dcaXY ());
138150 dcaZResolutionVsPt[p]->Fill (mcParticle.pt (), track.dcaZ ());
139151 covariancePtPtVsPt[p]->Fill (mcParticle.pt (), covariancePtPt);
140- covarianceDcaXyDcaXyVsPt[p]->Fill (mcParticle.pt (), track.sigmaDcaXY2 ());
141- covarianceDcaZDcaZVsPt[p]->Fill (mcParticle.pt (), track.sigmaDcaZ2 ());
152+ // covarianceDcaXyDcaXyVsPt[p]->Fill(mcParticle.pt(), track.sigmaDcaXY2());
153+ // covarianceDcaZDcaZVsPt[p]->Fill(mcParticle.pt(), track.sigmaDcaZ2());
142154 };
143155
144156 fillResolutionHistograms (0 );
0 commit comments