Skip to content

Commit c6500fd

Browse files
authored
[PWGLF] Change histo filling in MC process (#16301)
1 parent f2e941b commit c6500fd

1 file changed

Lines changed: 54 additions & 72 deletions

File tree

PWGLF/Tasks/GlobalEventProperties/flattenictyPikp.cxx

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ using namespace o2::constants::math;
8484
using namespace o2::aod::rctsel;
8585

8686
auto static constexpr CminCharge = 3.f;
87-
static constexpr float CnullInt = 0;
87+
static constexpr int CnullInt = 0;
8888
static constexpr float Cnull = 0.0f;
89-
static constexpr float ConeInt = 1;
89+
static constexpr int ConeInt = 1;
90+
static constexpr int CtwoInt = 2;
9091
static constexpr float Cone = 1.0f;
9192

9293
// FV0 specific constants
@@ -756,26 +757,11 @@ struct FlattenictyPikp {
756757
registryMC.add({"Events/ResponseGen", ";N_{ch,FV0};1-#rho_{FV0};", {kTHnSparseF, {multAxis, flatAxis}}});
757758
registryMC.add("Events/h1flatencityFV0MCGen", "", {kTH1F, {flatAxis}});
758759
registryMC.add("Events/hFlatMCGen", "Events/hFlatMCGen", {kTH1F, {flatAxis}});
759-
registryMC.add("Events/hFlatMCRec", "Events/hFlatMCRec", {kTH1F, {flatAxis}});
760-
// Event counter
761-
auto h = registryMC.add<TH1>("Events/hEvtGenRec", "Generated and Reconstructed MC Collisions", kTH1F, {{3, 0.5, 3.5}});
762-
h->GetXaxis()->SetBinLabel(1, "Gen coll");
763-
h->GetXaxis()->SetBinLabel(2, "Rec coll");
764-
h->GetXaxis()->SetBinLabel(3, "INEL>0");
765760
registryMC.add("Events/hEvtMcGen", "Events/hEvtMcGen", {kTH1F, {{4, 0.f, 4.f}}});
766761
registryMC.get<TH1>(HIST("Events/hEvtMcGen"))->GetXaxis()->SetBinLabel(1, "all");
767762
registryMC.get<TH1>(HIST("Events/hEvtMcGen"))->GetXaxis()->SetBinLabel(2, "z-vtx");
768763
registryMC.get<TH1>(HIST("Events/hEvtMcGen"))->GetXaxis()->SetBinLabel(3, "INELgt0");
769764
registryMC.get<TH1>(HIST("Events/hEvtMcGen"))->GetXaxis()->SetBinLabel(4, "INELgt0TVX");
770-
registryMC.add("Events/hEvtMCRec", "Events/hEvtMCRec", {kTH1F, {{3, 0.f, 3.f}}});
771-
registryMC.get<TH1>(HIST("Events/hEvtMCRec"))->GetXaxis()->SetBinLabel(1, "all");
772-
registryMC.get<TH1>(HIST("Events/hEvtMCRec"))->GetXaxis()->SetBinLabel(2, "evt sel");
773-
registryMC.get<TH1>(HIST("Events/hEvtMCRec"))->GetXaxis()->SetBinLabel(3, "INELgt0");
774-
registryMC.add("Events/hEvtMcGenColls", "Number of events; Cut; #Events Passed Cut", {kTH1F, {{4, 0.5, 4.5}}});
775-
registryMC.get<TH1>(HIST("Events/hEvtMcGenColls"))->GetXaxis()->SetBinLabel(1, "Gen. coll");
776-
registryMC.get<TH1>(HIST("Events/hEvtMcGenColls"))->GetXaxis()->SetBinLabel(2, "At least 1 reco");
777-
registryMC.get<TH1>(HIST("Events/hEvtMcGenColls"))->GetXaxis()->SetBinLabel(3, "Reco. coll.");
778-
registryMC.get<TH1>(HIST("Events/hEvtMcGenColls"))->GetXaxis()->SetBinLabel(4, "Reco. good coll.");
779765
//
780766
registryMC.add("Events/hNchGenVsCent", "Gen Nch vs Cent; mult; Gen Nch (|#eta|<0.8)", {kTH2F, {nChAxis, multAxis}});
781767
registryMC.add("Events/hVtxZRec", "MC Rec vertex z position", kTH1F, {vtxzAxis});
@@ -2357,7 +2343,7 @@ struct FlattenictyPikp {
23572343
{
23582344
LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(), collisions.size());
23592345
auto multMC = -1.;
2360-
if (evtSelOpt.useMultMCmidrap || multEst == 2) { // use generated Nch in ∣eta∣ < 0.8
2346+
if (evtSelOpt.useMultMCmidrap || multEst == CtwoInt) { // use generated Nch in ∣eta∣ < 0.8
23612347
multMC = countPart(particles);
23622348
} else {
23632349
multMC = getMultMC(mcCollision); // using McCentFT0Ms
@@ -2366,45 +2352,66 @@ struct FlattenictyPikp {
23662352
registryMC.fill(HIST("Events/hFlatMCGen"), flatMC);
23672353

23682354
// Loop on rec collisions
2369-
// Obtain here: Denominator of tracking efficiency; Numerator event and signal loss
2370-
//
2371-
bool gtZeroColl = false;
2372-
auto multRecGt1 = -999;
2373-
auto flatRec = -999;
2355+
// Obtain here: Numerator of tracking efficiency; Secondary contamination correction
23742356
for (const auto& collision : collisions) {
2375-
if (!isGoodEvent<false>(collision)) {
2376-
continue;
2357+
if (trkSelOpt.cfgRejectTrkAtTPCSector || applyCalibGain || applyCalibVtx) {
2358+
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
2359+
int currentRun = bc.runNumber();
2360+
if (runNumber != currentRun) {
2361+
initCCDB(bc);
2362+
runNumber = currentRun;
2363+
}
23772364
}
2378-
registryMC.fill(HIST("Events/hCentVsFlatRecINELgt0"), multRecGt1, flatRec); // Evt split den
2365+
registryMC.fill(HIST("Events/hCentVsFlatRecINELgt0"), getMult(collision), fillFlat<false>(collision)); // Evt split den
23792366
if (evtSelOpt.cfgRemoveSplitVertex && collision.globalIndex() != mcCollision.bestCollisionIndex()) {
23802367
continue;
23812368
}
2382-
registryMC.fill(HIST("Events/hCentVsFlatRecINELgt0wRecEvt"), multRecGt1, flatRec); // Evt split num, w/ Nrec > 0
2383-
gtZeroColl = true;
2384-
multRecGt1 = getMult(collision);
2385-
flatRec = fillFlat<true>(collision);
2386-
}
2369+
registryMC.fill(HIST("Events/hCentVsFlatRecINELgt0wRecEvt"), getMult(collision), fillFlat<false>(collision)); // Evt split num, w/ Nrec > 0
2370+
2371+
for (const auto& particle : particles) {
2372+
if (!isChrgParticle(particle.pdgCode())) {
2373+
continue;
2374+
}
2375+
if (!particle.isPhysicalPrimary()) {
2376+
continue;
2377+
}
2378+
if (std::abs(particle.eta()) > trkSelOpt.cfgTrkEtaMax) {
2379+
continue;
2380+
}
2381+
if (particle.pt() < trkSelOpt.cfgTrkPtMin) {
2382+
continue;
2383+
}
2384+
static_for<0, 1>([&](auto pidSgn) {
2385+
fillMCGenRecEvt<pidSgn, o2::track::PID::Pion>(particle, multMC, flatMC);
2386+
fillMCGenRecEvt<pidSgn, o2::track::PID::Kaon>(particle, multMC, flatMC);
2387+
fillMCGenRecEvt<pidSgn, o2::track::PID::Proton>(particle, multMC, flatMC);
2388+
});
2389+
}
2390+
if (!isGoodEvent<false>(collision)) {
2391+
continue;
2392+
}
2393+
const float multRecGt1 = getMult(collision);
2394+
const float flatRec = fillFlat<true>(collision);
23872395

2388-
if (gtZeroColl) {
2396+
registryMC.fill(HIST("Events/hVtxZRec"), collision.posZ());
23892397
registryMC.fill(HIST("Events/hCentVsFlatRecINELgt0wRecEvtSel"), multRecGt1, flatRec); // Evt split num, w/ Nrec > 0 + Evt. sel
23902398
registryMC.fill(HIST("Events/hNchGenVsCent"), multMC, multRecGt1);
23912399
registryMC.fill(HIST("Events/hNchVsFlatGenINELgt0wRecEvtSel"), multMC, flatMC); // Evt loss num, w/ Nrec > 0 + Evt. sel
2392-
}
23932400

2394-
for (const auto& particle : particles) {
2395-
if (!isChrgParticle(particle.pdgCode())) {
2396-
continue;
2397-
}
2398-
if (!particle.isPhysicalPrimary()) {
2399-
continue;
2400-
}
2401-
if (std::abs(particle.eta()) > trkSelOpt.cfgTrkEtaMax) {
2402-
continue;
2403-
}
2404-
if (particle.pt() < trkSelOpt.cfgTrkPtMin) {
2405-
continue;
2406-
}
2407-
if (gtZeroColl) {
2401+
// Obtain here: Denominator of tracking efficiency; Numerator event and signal loss
2402+
for (const auto& particle : particles) {
2403+
if (!isChrgParticle(particle.pdgCode())) {
2404+
continue;
2405+
}
2406+
if (!particle.isPhysicalPrimary()) {
2407+
continue;
2408+
}
2409+
if (std::abs(particle.eta()) > trkSelOpt.cfgTrkEtaMax) {
2410+
continue;
2411+
}
2412+
if (particle.pt() < trkSelOpt.cfgTrkPtMin) {
2413+
continue;
2414+
}
24082415
static_for<0, 1>([&](auto pidSgn) {
24092416
fillMCGenRecEvt<pidSgn, o2::track::PID::Pion, true>(particle, multMC, flatMC);
24102417
fillMCGenRecEvt<pidSgn, o2::track::PID::Kaon, true>(particle, multMC, flatMC);
@@ -2417,33 +2424,8 @@ struct FlattenictyPikp {
24172424
registryMC.fill(HIST(Cprefix) + HIST(CspeciesAll[Cidx]) + HIST(CpTeffGenPrimRecEvt), multRecGt1, flatRec, particle.pt()); // Tracking eff. den
24182425
}
24192426
});
2420-
} else {
2421-
static_for<0, 1>([&](auto pidSgn) {
2422-
fillMCGenRecEvt<pidSgn, o2::track::PID::Pion>(particle, multMC, flatMC);
2423-
fillMCGenRecEvt<pidSgn, o2::track::PID::Kaon>(particle, multMC, flatMC);
2424-
fillMCGenRecEvt<pidSgn, o2::track::PID::Proton>(particle, multMC, flatMC);
2425-
});
24262427
}
2427-
}
24282428

2429-
// Loop on rec collisions
2430-
// Obtain here: Numerator of tracking efficiency; Secondary contamination correction
2431-
for (const auto& collision : collisions) {
2432-
if (trkSelOpt.cfgRejectTrkAtTPCSector || applyCalibGain || applyCalibVtx) {
2433-
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
2434-
int currentRun = bc.runNumber();
2435-
if (runNumber != currentRun) {
2436-
initCCDB(bc);
2437-
runNumber = currentRun;
2438-
}
2439-
}
2440-
if (!isGoodEvent<false>(collision)) {
2441-
continue;
2442-
}
2443-
registryMC.fill(HIST("Events/hVtxZRec"), collision.posZ());
2444-
if (evtSelOpt.cfgRemoveSplitVertex && collision.globalIndex() != mcCollision.bestCollisionIndex()) {
2445-
continue;
2446-
}
24472429
// Rec tracks; track selection w/ DCA open (for secondaries), w/ DCA close (for efficiency)
24482430
// Obtain here: DCAxy for sec contamination, MC closure
24492431
const auto& groupedTrks = tracks.sliceBy(perCollTrk, collision.globalIndex());

0 commit comments

Comments
 (0)