From eb0f8729a978fe991c7f6f8ae229a941565eda82 Mon Sep 17 00:00:00 2001 From: Navneet Date: Wed, 2 Sep 2026 20:58:20 +0530 Subject: [PATCH] To fix the empty histograms --- .../Tasks/Resonances/chargedkstaranalysis.cxx | 209 +++++++++--------- 1 file changed, 100 insertions(+), 109 deletions(-) diff --git a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx index 0b384e52179..2020bacdaa4 100644 --- a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx +++ b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx @@ -585,9 +585,9 @@ struct Chargedkstaranalysis { histosMc.add("h3ChaKstarInvMassDSMcGen", "h3ChaKstarInvMassDSMcGen", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); histosMc.add("h3ChaKstarInvMassDSMcRec", "h3ChaKstarInvMassDSMcRec", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); histosMc.add("h3ChaKstarInvMassDSMcRecClosure", "h3ChaKstarInvMassDSMcRecClosure", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); + histosMc.add("sigLoss_den_pri_threeD", "sigLoss_den_pri_threeD", kTHnSparseF, {centAxis, ptAxis, thnAxisPOL}, true); if (mcCfgs.doBkgMc) { - histosMc.add("h3ChaKstarInvMassRotMcGen", "h3ChaKstarInvMassRotMcGen", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); histosMc.add("h3ChaKstarInvMassRotMcRec", "h3ChaKstarInvMassRotMcRec", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); histosMc.add("h3ChaKstarInvMassRotMcRecClosure", "h3ChaKstarInvMassRotMcRecClosure", kTHnSparseF, {centAxis, ptAxis, invMassAxisReso, thnAxisPOL}, true); } @@ -604,8 +604,6 @@ struct Chargedkstaranalysis { histos.add("Correction/sigLoss_num_pri", "Gen primary Kstar (|y|<0.5, selected events) in reco class", HistType::kTH2F, {ptAxis, centAxis}); histos.add("Correction/EF_den", "Gen events (truth class)", HistType::kTH1F, {centAxis}); histos.add("Correction/EF_num", "Reco events (selected events)", HistType::kTH1F, {centAxis}); - histos.add("sigLoss_den_pri_threeD", "sigLoss_den_pri_threeD", kTHnSparseF, {centAxis, ptAxis, thnAxisPOL}, true); - histos.add("sigLoss_den_pri_threeD_rot", "sigLoss_den_pri_threeD_rot", kTHnSparseF, {centAxis, ptAxis, thnAxisPOL}, true); histos.add("Correction/hNEventsMCTruth", "hNEventsMCTruth", HistType::kTH1F, {AxisSpec{nSteps, 0.5, nSteps + 0.5, ""}}); auto hstep = histos.get(HIST("Correction/hNEventsMCTruth")); hstep->GetXaxis()->SetBinLabel(1, "All"); @@ -849,18 +847,10 @@ struct Chargedkstaranalysis { if (currentIsGen) { if (sigLossDen) { // Fill ONLY the Signal Loss Denominator 3D Histograms - if (isRot) { - histos.fill(HIST("sigLoss_den_pri_threeD_rot"), multiplicity, mother.Pt(), cosTheta); - } else { - histos.fill(HIST("sigLoss_den_pri_threeD"), multiplicity, mother.Pt(), cosTheta); - } + histosMc.fill(HIST("sigLoss_den_pri_threeD"), multiplicity, mother.Pt(), cosTheta); } else { // Fill standard 4D MC Gen Histograms - if (isRot) { - histosMc.fill(HIST("h3ChaKstarInvMassRotMcGen"), multiplicity, mother.Pt(), mother.M(), cosTheta); - } else { - histosMc.fill(HIST("h3ChaKstarInvMassDSMcGen"), multiplicity, mother.Pt(), mother.M(), cosTheta); - } + histosMc.fill(HIST("h3ChaKstarInvMassDSMcGen"), multiplicity, mother.Pt(), mother.M(), cosTheta); } return; } @@ -926,7 +916,7 @@ struct Chargedkstaranalysis { auto phiCS = std::atan2(yAxisCS.Dot(v1CM), xAxisCS.Dot(v1CM)); phiCS = RecoDecay::constrainAngle(phiCS, 0.0); - bool doRotation = !doprocessMC || mcCfgs.doBkgMc; + bool doRotation = !doprocessMC || (!currentIsGen && mcCfgs.doBkgMc); // if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { if (helicityCfgs.activateHelicityFrame) { // helicityVec = mother.Vect(); // 3 vector of mother in COM frame @@ -1465,10 +1455,10 @@ struct Chargedkstaranalysis { const float lCentrality = getCentrality(coll); refCentByMcId.emplace(mcid, lCentrality); } - + currentIsGen = true; + sigLossDen = false; // Calculating the generated Kstar for (const auto& part : mcParticles) { - currentIsGen = true; if (!part.has_mcCollision()) { continue; } @@ -1559,9 +1549,102 @@ struct Chargedkstaranalysis { } } } + sigLossDen = true; + // To calculate the denominator -> To check the all the events have chk892 + for (auto const& part : mcParticles) { + if (!part.has_mcCollision()) { + continue; + } + if (std::abs(part.pdgCode()) != kKstarPlus) { + continue; + } + if (std::abs(part.y()) > kstarCutCfgs.cKstarMaxRap) { + continue; + } + + const auto mcid = part.mcCollisionId(); + if (!refClassIds.contains(mcid)) { + continue; + } + + auto iter = refCentByMcId.find(mcid); + if (iter == refCentByMcId.end()) { + continue; + } + + const float lCentrality = iter->second; + + histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); + if (part.vt() == 0) { + histos.fill(HIST("Correction/sigLoss_den_pri"), part.pt(), lCentrality); + } + LorentzVectorSetXYZM lResoSecondary, lDecayDaughter_bach, lResoKstar, lDaughterRot; + lResoKstar = LorentzVectorSetXYZM(part.px(), part.py(), part.pz(), MassKPlusStar892); + const int pionWanted = (part.pdgCode() > 0) ? +kPiPlus : -kPiPlus; + bool hasRightPion = false; + bool hasK0sToPipi = false; + for (const auto& d1 : part.template daughters_as()) { + const int pdg1 = d1.pdgCode(); + if (pdg1 == pionWanted) { + lDecayDaughter_bach = LorentzVectorSetXYZM(d1.px(), d1.py(), d1.pz(), MassPionCharged); + if (helicityCfgs.genKinematicsChecks) { + if (lDecayDaughter_bach.pt() <= trackCutCfgs.cMinPtcut || std::abs(lDecayDaughter_bach.eta()) >= trackCutCfgs.cMaxEtacut) { + continue; + } + } + hasRightPion = true; + } else if (std::abs(pdg1) == kPDGK0) { + for (const auto& d2 : d1.template daughters_as()) { + if (std::abs(d2.pdgCode()) == kPDGK0s) { + if (helicityCfgs.genKinematicsChecks) { + if (d2.pt() <= secondaryCutsCfgs.cSecondaryPtMin || std::abs(d2.eta()) >= secondaryCutsCfgs.cSecondaryRapidityMax) { + continue; + } + } + bool seenPip = false, seenPim = false; + for (const auto& d3 : d2.template daughters_as()) { + if (d3.pdgCode() == +kPiPlus) { + if (helicityCfgs.genKinematicsChecks) { + if (d3.pt() <= trackCutCfgs.cMinPtcut || std::abs(d3.eta()) >= trackCutCfgs.cMaxEtacut) { + continue; + } + } + seenPip = true; + } else if (d3.pdgCode() == -kPiPlus) { + if (helicityCfgs.genKinematicsChecks) { + if (d3.pt() <= trackCutCfgs.cMinPtcut || std::abs(d3.eta()) >= trackCutCfgs.cMaxEtacut) { + continue; + } + } + seenPim = true; + } + } + if (seenPip && seenPim) { + lResoSecondary = LorentzVectorSetXYZM(d2.px(), d2.py(), d2.pz(), MassK0Short); + hasK0sToPipi = true; + break; + } + } + } + } + if (hasRightPion && hasK0sToPipi) { + break; + } + } + + if (!(hasRightPion && hasK0sToPipi)) { + continue; + } + if (helicityCfgs.cCosWithKShot) { + fillInvMass(lResoKstar, lCentrality, lResoSecondary, lDecayDaughter_bach, eventCutCfgs.confIsMix); + } else { + fillInvMass(lResoKstar, lCentrality, lDecayDaughter_bach, lResoSecondary, eventCutCfgs.confIsMix); + } + } + + currentIsGen = false; // To store the recoKstar for (const auto& v0 : v0s) { - currentIsGen = false; auto coll = v0.template collision_as(); if (!coll.has_mcCollision()) { @@ -1703,98 +1786,6 @@ struct Chargedkstaranalysis { histos.fill(HIST("Correction/sigLoss_num_pri"), part.pt(), lCentrality); } } - sigLossDen = true; - // To calculate the denominator -> To check the all the events have chk892 - for (auto const& part : mcParticles) { - if (!part.has_mcCollision()) { - continue; - } - if (std::abs(part.pdgCode()) != kKstarPlus) { - continue; - } - if (std::abs(part.y()) > kstarCutCfgs.cKstarMaxRap) { - continue; - } - - const auto mcid = part.mcCollisionId(); - if (!refClassIds.contains(mcid)) { - continue; - } - - auto iter = refCentByMcId.find(mcid); - if (iter == refCentByMcId.end()) { - continue; - } - - const float lCentrality = iter->second; - - histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); - if (part.vt() == 0) { - histos.fill(HIST("Correction/sigLoss_den_pri"), part.pt(), lCentrality); - } - LorentzVectorSetXYZM lResoSecondary, lDecayDaughter_bach, lResoKstar, lDaughterRot; - lResoKstar = LorentzVectorSetXYZM(part.px(), part.py(), part.pz(), MassKPlusStar892); - const int pionWanted = (part.pdgCode() > 0) ? +kPiPlus : -kPiPlus; - bool hasRightPion = false; - bool hasK0sToPipi = false; - for (const auto& d1 : part.template daughters_as()) { - const int pdg1 = d1.pdgCode(); - if (pdg1 == pionWanted) { - lDecayDaughter_bach = LorentzVectorSetXYZM(d1.px(), d1.py(), d1.pz(), MassPionCharged); - if (helicityCfgs.genKinematicsChecks) { - if (lDecayDaughter_bach.pt() <= trackCutCfgs.cMinPtcut || std::abs(lDecayDaughter_bach.eta()) >= trackCutCfgs.cMaxEtacut) { - continue; - } - } - hasRightPion = true; - } else if (std::abs(pdg1) == kPDGK0) { - for (const auto& d2 : d1.template daughters_as()) { - if (std::abs(d2.pdgCode()) == kPDGK0s) { - if (helicityCfgs.genKinematicsChecks) { - if (d2.pt() <= secondaryCutsCfgs.cSecondaryPtMin || std::abs(d2.eta()) >= secondaryCutsCfgs.cSecondaryRapidityMax) { - continue; - } - } - bool seenPip = false, seenPim = false; - for (const auto& d3 : d2.template daughters_as()) { - if (d3.pdgCode() == +kPiPlus) { - if (helicityCfgs.genKinematicsChecks) { - if (d3.pt() <= trackCutCfgs.cMinPtcut || std::abs(d3.eta()) >= trackCutCfgs.cMaxEtacut) { - continue; - } - } - seenPip = true; - } else if (d3.pdgCode() == -kPiPlus) { - if (helicityCfgs.genKinematicsChecks) { - if (d3.pt() <= trackCutCfgs.cMinPtcut || std::abs(d3.eta()) >= trackCutCfgs.cMaxEtacut) { - continue; - } - } - seenPim = true; - } - } - if (seenPip && seenPim) { - lResoSecondary = LorentzVectorSetXYZM(d2.px(), d2.py(), d2.pz(), MassK0Short); - hasK0sToPipi = true; - break; - } - } - } - } - if (hasRightPion && hasK0sToPipi) { - break; - } - } - - if (!(hasRightPion && hasK0sToPipi)) { - continue; - } - if (helicityCfgs.cCosWithKShot) { - fillInvMass(lResoKstar, lCentrality, lResoSecondary, lDecayDaughter_bach, eventCutCfgs.confIsMix); - } else { - fillInvMass(lResoKstar, lCentrality, lDecayDaughter_bach, lResoSecondary, eventCutCfgs.confIsMix); - } - } // To calculate the event fraction correction for (const auto& mcid : refClassIds) { histos.fill(HIST("Correction/EF_den"), refCentByMcId[mcid]);