3030using namespace o2 ;
3131using namespace o2 ::framework;
3232std::map<int , TEfficiency*> effVsPt;
33+ std::map<int , TEfficiency*> effVsEta;
3334
3435struct alice3Efficiency {
3536 Configurable<std::vector<int >> pdgCodes{" pdgCodes" , {211 }, " List of PDG codes to consider for efficiency calculation" };
3637 OutputObj<THashList> outList{" output" };
3738 void init (o2::framework::InitContext&)
3839 {
3940 outList.setObject (new THashList);
41+ auto createEff = [&](const char * baseName, const char * axisTitle, int pdg, int nBins, double min, double max) {
42+ auto eff = new TEfficiency (Form (" %s_pdg%d" , baseName, pdg),
43+ Form (" Efficiency for PDG %d; %s; Efficiency" , pdg, axisTitle),
44+ nBins, min, max);
45+ outList->Add (eff);
46+ return eff;
47+ };
4048 for (auto pdg : pdgCodes.value ) {
41- effVsPt[pdg] = new TEfficiency (Form (" efficiency_pdg%d" , pdg),
42- Form (" Efficiency for PDG %d; p_{T} (GeV/c); Efficiency" , pdg),
43- 100 , 0 , 10 );
44- outList->Add (effVsPt[pdg]);
49+ effVsPt[pdg] = createEff (" efficiency" , " p_{T} (GeV/c)" , pdg, 100 , 0 , 10 );
50+ effVsEta[pdg] = createEff (" efficiency_eta" , " #eta" , pdg, 100 , -5 , 5 );
4551 }
4652 }
4753
@@ -67,9 +73,9 @@ struct alice3Efficiency {
6773
6874 std::vector<int64_t >& indices = pdgIndices[mcParticle.pdgCode ()];
6975 // Fill efficiency histogram
70- auto & eff = effVsPt[mcParticle.pdgCode ()];
7176 const bool found = std::find (indices.begin (), indices.end (), track.globalIndex ()) != indices.end ();
72- eff->Fill (track.pt (), found);
77+ effVsPt[mcParticle.pdgCode ()]->Fill (found, track.pt ());
78+ effVsEta[mcParticle.pdgCode ()]->Fill (found, track.eta ());
7379 }
7480 }
7581};
0 commit comments