From 1a0328eb115221ea42ab89ba79a63b361b67d3cf Mon Sep 17 00:00:00 2001 From: skundu692 Date: Sat, 23 Aug 2025 13:46:14 +0200 Subject: [PATCH 01/25] Improve TOF PID selection cut --- PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx index 2abaf1fff47..576fba2748f 100644 --- a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx +++ b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx @@ -213,7 +213,7 @@ struct phispectrapbpbqa { template bool selectionPIDpTdependent(const T& candidate, double nsigmaTPC, double nsigmaTOF) { - if (candidate.p() < 0.7 && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { + if(candidate.p() < 0.7 && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { return true; } if (candidate.p() > 0.7 && candidate.hasTOF() && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { From f679e1b41930d5125b0f12e3d3a9494fb17bedcc Mon Sep 17 00:00:00 2001 From: skundu692 Date: Sat, 23 Aug 2025 13:47:12 +0200 Subject: [PATCH 02/25] Improve TOF PID selection cut --- PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx index 576fba2748f..2abaf1fff47 100644 --- a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx +++ b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx @@ -213,7 +213,7 @@ struct phispectrapbpbqa { template bool selectionPIDpTdependent(const T& candidate, double nsigmaTPC, double nsigmaTOF) { - if(candidate.p() < 0.7 && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { + if (candidate.p() < 0.7 && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { return true; } if (candidate.p() > 0.7 && candidate.hasTOF() && TMath::Abs(nsigmaTPC) < nsigmaCutTPC) { From 426c6898dab37204172754efb9578428bfc69f2b Mon Sep 17 00:00:00 2001 From: skundu692 Date: Sun, 24 Aug 2025 10:15:09 +0200 Subject: [PATCH 03/25] Add RCT flag for event selection --- PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx | 29 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx index 2abaf1fff47..981365eefb1 100644 --- a/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx +++ b/PWGLF/Tasks/Resonances/phispectrapbpbqa.cxx @@ -64,6 +64,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; +using namespace o2::aod::rctsel; struct phispectrapbpbqa { double bz = 0.; @@ -75,6 +76,13 @@ struct phispectrapbpbqa { Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; } cfgCcdbParam; + + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + TH3D* hTPCCallib; TH3D* hTOFCallib; @@ -141,13 +149,13 @@ struct phispectrapbpbqa { Partition negTracks = aod::track::signed1Pt < cfgCutCharge; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - + RCTFlagsChecker rctChecker; // Event selection cuts - Alex // TF1* fMultPVCutLow = nullptr; void init(o2::framework::InitContext&) { - + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); histos.add("hphiSE", "hphiSE", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisCentrality, axisOccupancy, cnfgaxis.configThnAxisSector}, true); histos.add("hphiME", "hphiME", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisCentrality, axisOccupancy, cnfgaxis.configThnAxisSector}, true); histos.add("hphiGen", "hphiGen", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisCentrality, axisOccupancy}, true); @@ -325,6 +333,11 @@ struct phispectrapbpbqa { if (!collision.sel8() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) || !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { return; } + if (rctCut.requireRCTFlagChecker) { + if (!rctChecker(collision)) { + return; + } + } auto centrality = collision.centFT0C(); int occupancy = collision.trackOccupancyInTimeRange(); histos.fill(HIST("hCentrality"), centrality); @@ -481,6 +494,11 @@ struct phispectrapbpbqa { if (!collision2.sel8() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) || !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { continue; } + if (rctCut.requireRCTFlagChecker) { + if (!rctChecker(collision1) || !rctChecker(collision2)) { + continue; + } + } int occupancy = collision1.trackOccupancyInTimeRange(); auto centrality = collision1.centFT0C(); for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { @@ -587,8 +605,13 @@ struct phispectrapbpbqa { histos.fill(HIST("hMC"), 8); continue; } - histos.fill(HIST("hMC"), 9); + if (rctCut.requireRCTFlagChecker) { + if (!rctChecker(RecCollision)) { + continue; + } + } + histos.fill(HIST("hMC"), 10); auto centrality = RecCollision.centFT0C(); int occupancy = RecCollision.trackOccupancyInTimeRange(); histos.fill(HIST("hOccupancy"), occupancy, centrality); From 48e43e3ee57dd1dad74f26364a31436fdec0c1be Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 26 Aug 2025 20:52:12 +0200 Subject: [PATCH 04/25] Add charge information in derived data and QA histogram in analysis task --- .../Resonances/f1protonreducedtable.cxx | 9 +- .../Tasks/Resonances/f1protoncorrelation.cxx | 208 ++++++++++++++---- 2 files changed, 169 insertions(+), 48 deletions(-) diff --git a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx index 842c0e46c82..0f1ea4cdbe7 100644 --- a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx +++ b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx @@ -751,10 +751,17 @@ struct f1protonreducedtable { continue; // check if the pair is unlike or wrongsign - auto pairsign = 1; + auto pairsign = 100; if (PionCharge.at(i1) * KaonCharge.at(i2) > 0) { qaRegistry.fill(HIST("hInvMassf1Like"), F1Vector.M(), F1Vector.Pt()); pairsign = -1; + } else if (PionCharge.at(i1) * KaonCharge.at(i2) < 0) { + if (KaonCharge.at(i2) > 0) { + pairsign = 1; + } + if (KaonCharge.at(i2) < 0) { + pairsign = 2; + } } ROOT::Math::PtEtaPhiMVector temp(F1Vector.Pt(), F1Vector.Eta(), F1Vector.Phi(), F1Vector.M()); f1resonance.push_back(temp); diff --git a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx index af45b89b8da..41a21b66358 100644 --- a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx +++ b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx @@ -13,31 +13,51 @@ /// \author sourav kundu /// \since 02/11/2023 +#include "PWGLF/DataModel/ReducedF1ProtonTables.h" + +#include "Common/Core/trackUtilities.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include -#include + #include #include +#include #include + #include + #include #include #include -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/StepTHn.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/ReducedF1ProtonTables.h" -#include "CommonConstants/PhysicsConstants.h" - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; struct f1protoncorrelation { + + double bz = 0.; + double bz2 = 0.; + + // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // PID selection Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; @@ -70,6 +90,7 @@ struct f1protoncorrelation { ConfigurableAxis configThnAxisKstar{"configThnAxisKstar", {100, 0.0, 1.0}, "#it{k}^{*} (GeV/#it{c})"}; ConfigurableAxis configThnAxisPtProton{"configThnAxisPtProton", {20, 0.0, 4.}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configThnAxisNsigma{"configThnAxisNsigma", {90, -9.0, 9.0}, "NsigmaCombined"}; + ConfigurableAxis configThnAxisCharge{"configThnAxisCharge", {5, -2.5, 2.5}, "Charge"}; // mix event bining policy ColumnBinningPolicy colBinningFemto{{CfgVtxBins, CfgMultBins}, true}; @@ -83,31 +104,89 @@ struct f1protoncorrelation { const AxisSpec thnAxisPtProton{configThnAxisPtProton, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec thnAxisKstar{configThnAxisKstar, "#it{k}^{*} (GeV/#it{c})"}; const AxisSpec thnAxisNsigma{configThnAxisNsigma, "NsigmaCombined"}; + const AxisSpec thnAxisCharge{configThnAxisCharge, "Charge"}; // register histograms + histos.add("hPhaseSpaceProtonKaonSame", "hPhaseSpaceProtonKaonSame", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); + histos.add("hPhaseSpaceProtonPionSame", "hPhaseSpaceProtonPionSame", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); + histos.add("hPhaseSpaceProtonKaonMix", "hPhaseSpaceProtonKaonMix", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); + histos.add("hPhaseSpaceProtonPionMix", "hPhaseSpaceProtonPionMix", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); histos.add("hNsigmaProtonTPC", "Nsigma Proton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaKaonTPC", "Nsigma Kaon TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaPionTPC", "Nsigma Pion TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaPionKaonTPC", "Nsigma Pion Kaon TPC correlation", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); histos.add("h2SameEventPtCorrelation", "Pt correlation of F1 and proton", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {100, 0.0, 10.0}}); - histos.add("h2SameEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - histos.add("h2SameEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - histos.add("h2SameEventInvariantMassRot_mass", "Rotational Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2SameEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 same event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2SameEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 same event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2SameEventInvariantMassRot_mass", "Rotational Invariant mass of f1 same event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); - histos.add("h2MixEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - histos.add("h2MixEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - histos.add("h2MixEventInvariantMassRot_mass", "Rotational Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2MixEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 mix event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2MixEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 mix event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2MixEventInvariantMassRot_mass", "Rotational Sign Invariant mass of f1 mix event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); if (fillSparse) { - histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); - histos.add("SEMassLike", "SEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); - histos.add("SEMassRot", "SEMassRot", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); + histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + histos.add("SEMassLike", "SEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + histos.add("SEMassRot", "SEMassRot", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + + histos.add("MEMassUnlike", "MEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + histos.add("MEMassLike", "MEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + histos.add("MEMassRot", "MEMassRot", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); + } + + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + } + + int getMagneticField(uint64_t timestamp) + { + // Get the magnetic field + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("/GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %2.2f kG", timestamp, 0.1 * grpo->getNominalL3Field()); + } + return 0.1 * grpo->getNominalL3Field(); + } + + /// Magnetic field to be provided in Tesla + static constexpr float tmpRadiiTPC[9] = {85., 105., 125., 145., 165., 185., 205., 225., 245.}; + float PhiAtSpecificRadiiTPC(const TLorentzVector part1, const TLorentzVector part2, float charge1 = 0, int charge2 = 0, float magfield1 = 0.0, float magfield2 = 0.0) + { + float pt1 = part1.Pt(); + float phi1 = part1.Phi(); + float value1 = 0.0; + float count1 = 0.0; + for (size_t i = 0; i < 9; i++) { + auto arg1 = 0.3 * charge1 * magfield1 * tmpRadiiTPC[i] * 0.01 / (2. * pt1); + if (std::fabs(arg1) < 1) { + value1 = value1 + (phi1 - std::asin(arg1)); + count1 = count1 + 1.0; + } + } + value1 = value1 / count1; - histos.add("MEMassUnlike", "MEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); - histos.add("MEMassLike", "MEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); - histos.add("MEMassRot", "MEMassRot", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); + float pt2 = part2.Pt(); + float phi2 = part2.Phi(); + float value2 = 0.0; + float count2 = 0.0; + for (size_t i = 0; i < 9; i++) { + auto arg2 = 0.3 * charge2 * magfield2 * tmpRadiiTPC[i] * 0.01 / (2. * pt2); + if (std::fabs(arg2) < 1) { + value2 = value2 + (phi2 - std::asin(arg2)); + count2 = count2 + 1.0; + } } + value2 = value2 / count2; + return value1 - value2; } // get kstar @@ -136,8 +215,21 @@ struct f1protoncorrelation { TLorentzVector F1, Proton, F1ProtonPair, Pion, Kaon, Kshort; TLorentzVector F1Rot, PionRot, KaonKshortPair, KaonKshortPairRot; // Process the data in same event - void process(aod::RedF1PEvents::iterator const& /*collision*/, aod::F1Tracks const& f1tracks, aod::ProtonTracks const& protontracks) + + int currentRunNumber = -999; + int lastRunNumber = -999; + + void process(aod::RedF1PEvents::iterator const& collision, aod::F1Tracks const& f1tracks, aod::ProtonTracks const& protontracks) { + + // auto bc = collision.template bc_as(); + // currentRunNumber = collision.bc_as().runNumber(); + currentRunNumber = collision.runNumber(); + if (currentRunNumber != lastRunNumber) { + bz = getMagneticField(collision.timestamp()); + } + lastRunNumber = currentRunNumber; + for (auto f1track : f1tracks) { if (f1track.f1MassKaonKshort() > maxKKS0Mass) { continue; @@ -207,16 +299,24 @@ struct f1protoncorrelation { histos.fill(HIST("hNsigmaProtonTPC"), protontrack.protonNsigmaTPC(), Proton.Pt()); } histos.fill(HIST("h2SameEventPtCorrelation"), relative_momentum, F1.Pt(), Proton.Pt()); - if (f1track.f1SignalStat() == 1) { - histos.fill(HIST("h2SameEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M()); // F1 sign = 1 unlike, F1 sign = -1 like + if (f1track.f1SignalStat() > 0) { + int f1Charge = f1track.f1SignalStat(); + if (f1Charge == 2) { + f1Charge = -1; + } + int pionCharge = -1.0 * f1Charge; + float pairCharge = f1Charge * protontrack.protonCharge(); + histos.fill(HIST("hPhaseSpaceProtonKaonSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, protontrack.protonCharge(), f1Charge, bz, bz)); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonPionSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, protontrack.protonCharge(), pionCharge, bz, bz)); // Phase Space Proton Pion + histos.fill(HIST("h2SameEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like if (fillSparse) { - histos.fill(HIST("SEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("SEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); } } if (f1track.f1SignalStat() == -1) { - histos.fill(HIST("h2SameEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M()); + histos.fill(HIST("h2SameEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), protontrack.protonCharge()); if (fillSparse) { - histos.fill(HIST("SEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("SEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, protontrack.protonCharge()); } } if (fillRotation) { @@ -230,10 +330,10 @@ struct f1protoncorrelation { KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); F1Rot = Pion + KaonKshortPairRot; auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (f1track.f1SignalStat() == 1) { - histos.fill(HIST("h2SameEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M()); + if (f1track.f1SignalStat() > 0) { + histos.fill(HIST("h2SameEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), protontrack.protonCharge()); if (fillSparse) { - histos.fill(HIST("SEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC); + histos.fill(HIST("SEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, protontrack.protonCharge()); } } } @@ -317,16 +417,16 @@ struct f1protoncorrelation { continue; } auto relative_momentum = getkstar(F1, Proton); - if (t1.f1SignalStat() == 1) { - histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M()); // F1 sign = 1 unlike, F1 sign = -1 like + if (t1.f1SignalStat() > 0) { + histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), 1.0); // F1 sign = 1 unlike, F1 sign = -1 like if (fillSparse) { - histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, 1.0); } } if (t1.f1SignalStat() == -1) { - histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M()); + histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), 1.0); if (fillSparse) { - histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, 1.0); } } if (fillRotation) { @@ -340,10 +440,10 @@ struct f1protoncorrelation { KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); F1Rot = Pion + KaonKshortPairRot; auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (t1.f1SignalStat() == 1) { - histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M()); + if (t1.f1SignalStat() > 0) { + histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), 1.0); if (fillSparse) { - histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC); + histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, 1.0); } } } @@ -360,6 +460,12 @@ struct f1protoncorrelation { if (collision1.index() == collision2.index()) { continue; } + currentRunNumber = collision1.runNumber(); + if (currentRunNumber != lastRunNumber) { + bz = getMagneticField(collision1.timestamp()); + bz2 = getMagneticField(collision2.timestamp()); + } + lastRunNumber = currentRunNumber; auto groupF1 = f1tracks.sliceBy(tracksPerCollisionPresliceF1, collision1.globalIndex()); auto groupProton = protontracks.sliceBy(tracksPerCollisionPresliceP, collision2.globalIndex()); // auto groupF1 = f1tracks.sliceByCached(aod::f1protondaughter::redF1PEventId, collision1.globalIndex(), cache); @@ -419,16 +525,24 @@ struct f1protoncorrelation { continue; } auto relative_momentum = getkstar(F1, Proton); - if (t1.f1SignalStat() == 1) { - histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M()); // F1 sign = 1 unlike, F1 sign = -1 like + if (t1.f1SignalStat() > 0) { + int f1Charge = t1.f1SignalStat(); + if (f1Charge == 2) { + f1Charge = -1; + } + int pionCharge = -1.0 * f1Charge; + float pairCharge = f1Charge * t2.protonCharge(); + histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like + histos.fill(HIST("hPhaseSpaceProtonKaonMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, t2.protonCharge(), f1Charge, bz, bz2)); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonPionMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, t2.protonCharge(), pionCharge, bz, bz2)); // Phase Space Proton Pion if (fillSparse) { - histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); } } if (t1.f1SignalStat() == -1) { - histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M()); + histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), t2.protonCharge()); if (fillSparse) { - histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC); + histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, t2.protonCharge()); } } if (fillRotation) { @@ -442,10 +556,10 @@ struct f1protoncorrelation { KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); F1Rot = Pion + KaonKshortPairRot; auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (t1.f1SignalStat() == 1) { - histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M()); + if (t1.f1SignalStat() > 0) { + histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), t2.protonCharge()); if (fillSparse) { - histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC); + histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, t2.protonCharge()); } } } From c111df198ff30ab9e2005826a5e5493ed5fcf980 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Thu, 4 Sep 2025 20:13:52 +0200 Subject: [PATCH 05/25] Fix bug in derived data and rotational background in task --- .../Resonances/f1protonreducedtable.cxx | 2 +- .../Tasks/Resonances/f1protoncorrelation.cxx | 99 ++++++++++--------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx index 0f1ea4cdbe7..5004b2f1bd8 100644 --- a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx +++ b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx @@ -779,7 +779,7 @@ struct f1protonreducedtable { PionTPCFinal.push_back(PionTPC.at(i1)); // Pion TPC KaonTPCFinal.push_back(KaonTPC.at(i2)); // Kaon TPC KaonTPCPionHypoFinal.push_back(KaonTPCPionHypo.at(i2)); // Kaon TPC - if (pairsign == 1) { + if (pairsign > 0) { qaRegistry.fill(HIST("hInvMassf1"), F1Vector.M(), F1Vector.Pt()); numberF1 = numberF1 + 1; for (auto iproton = protons.begin(); iproton != protons.end(); ++iproton) { diff --git a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx index 41a21b66358..02395a2b1fe 100644 --- a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx +++ b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx @@ -79,6 +79,7 @@ struct f1protoncorrelation { Configurable momentumTOFProton{"momentumTOFProton", 0.7, "Proton momentum TOF"}; Configurable momentumProtonMax{"momentumProtonMax", 3.0, "Maximum proton momentum"}; Configurable lowPtF1{"lowPtF1", 1.0, "PT cut F1"}; + Configurable nRot{"nRot", 4, "Number of rotational bkg"}; // Event Mixing Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; ConfigurableAxis CfgVtxBins{"CfgVtxBins", {10, -10, 10}, "Mixing bins - z-vertex"}; @@ -213,7 +214,7 @@ struct f1protoncorrelation { } float combinedTPC; TLorentzVector F1, Proton, F1ProtonPair, Pion, Kaon, Kshort; - TLorentzVector F1Rot, PionRot, KaonKshortPair, KaonKshortPairRot; + TLorentzVector F1Rot, PionRot, KaonKshortPair; // Process the data in same event int currentRunNumber = -999; @@ -299,7 +300,9 @@ struct f1protoncorrelation { histos.fill(HIST("hNsigmaProtonTPC"), protontrack.protonNsigmaTPC(), Proton.Pt()); } histos.fill(HIST("h2SameEventPtCorrelation"), relative_momentum, F1.Pt(), Proton.Pt()); + if (f1track.f1SignalStat() > 0) { + // check charge int f1Charge = f1track.f1SignalStat(); if (f1Charge == 2) { f1Charge = -1; @@ -312,6 +315,26 @@ struct f1protoncorrelation { if (fillSparse) { histos.fill(HIST("SEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); } + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nRot; nrotbkg++) { + auto anglestart = 5.0 * TMath::Pi() / 6.0; + auto angleend = 7.0 * TMath::Pi() / 6.0; + auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); + auto rotangle = anglestart + nrotbkg * anglestep; + auto rotPionPx = Pion.Px() * std::cos(rotangle) - Pion.Py() * std::sin(rotangle); + auto rotPionPy = Pion.Px() * std::sin(rotangle) + Pion.Py() * std::cos(rotangle); + PionRot.SetXYZM(rotPionPx, rotPionPy, Pion.Pz(), Pion.M()); + F1Rot = PionRot + KaonKshortPair; + if (F1Rot.Pt() < 1.0) { + continue; + } + auto relative_momentum_rot = getkstar(F1Rot, Proton); + histos.fill(HIST("h2SameEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), pairCharge); + if (fillSparse) { + histos.fill(HIST("SEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, pairCharge); + } + } + } } if (f1track.f1SignalStat() == -1) { histos.fill(HIST("h2SameEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), protontrack.protonCharge()); @@ -319,25 +342,6 @@ struct f1protoncorrelation { histos.fill(HIST("SEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, protontrack.protonCharge()); } } - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < 9; nrotbkg++) { - auto anglestart = 5.0 * TMath::Pi() / 6.0; - auto angleend = 7.0 * TMath::Pi() / 6.0; - auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); - auto rotangle = anglestart + nrotbkg * anglestep; - auto rotKKPx = KaonKshortPair.Px() * std::cos(rotangle) - KaonKshortPair.Py() * std::sin(rotangle); - auto rotKKPy = KaonKshortPair.Px() * std::sin(rotangle) + KaonKshortPair.Py() * std::cos(rotangle); - KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); - F1Rot = Pion + KaonKshortPairRot; - auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (f1track.f1SignalStat() > 0) { - histos.fill(HIST("h2SameEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), protontrack.protonCharge()); - if (fillSparse) { - histos.fill(HIST("SEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, protontrack.protonCharge()); - } - } - } - } } } } @@ -430,15 +434,18 @@ struct f1protoncorrelation { } } if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < 9; nrotbkg++) { + for (int nrotbkg = 0; nrotbkg < nRot; nrotbkg++) { auto anglestart = 5.0 * TMath::Pi() / 6.0; auto angleend = 7.0 * TMath::Pi() / 6.0; auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); auto rotangle = anglestart + nrotbkg * anglestep; - auto rotKKPx = KaonKshortPair.Px() * std::cos(rotangle) - KaonKshortPair.Py() * std::sin(rotangle); - auto rotKKPy = KaonKshortPair.Px() * std::sin(rotangle) + KaonKshortPair.Py() * std::cos(rotangle); - KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); - F1Rot = Pion + KaonKshortPairRot; + auto rotPionPx = Pion.Px() * std::cos(rotangle) - Pion.Py() * std::sin(rotangle); + auto rotPionPy = Pion.Px() * std::sin(rotangle) + Pion.Py() * std::cos(rotangle); + PionRot.SetXYZM(rotPionPx, rotPionPy, Pion.Pz(), Pion.M()); + F1Rot = PionRot + KaonKshortPair; + if (F1Rot.Pt() < 1.0) { + continue; + } auto relative_momentum_rot = getkstar(F1Rot, Proton); if (t1.f1SignalStat() > 0) { histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), 1.0); @@ -538,6 +545,29 @@ struct f1protoncorrelation { if (fillSparse) { histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); } + + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nRot; nrotbkg++) { + auto anglestart = 5.0 * TMath::Pi() / 6.0; + auto angleend = 7.0 * TMath::Pi() / 6.0; + auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); + auto rotangle = anglestart + nrotbkg * anglestep; + auto rotPionPx = Pion.Px() * std::cos(rotangle) - Pion.Py() * std::sin(rotangle); + auto rotPionPy = Pion.Px() * std::sin(rotangle) + Pion.Py() * std::cos(rotangle); + PionRot.SetXYZM(rotPionPx, rotPionPy, Pion.Pz(), Pion.M()); + F1Rot = PionRot + KaonKshortPair; + if (F1Rot.Pt() < 1.0) { + continue; + } + auto relative_momentum_rot = getkstar(F1Rot, Proton); + if (t1.f1SignalStat() > 0) { + histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), pairCharge); + if (fillSparse) { + histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, pairCharge); + } + } + } + } } if (t1.f1SignalStat() == -1) { histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), t2.protonCharge()); @@ -545,25 +575,6 @@ struct f1protoncorrelation { histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, t2.protonCharge()); } } - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < 9; nrotbkg++) { - auto anglestart = 5.0 * TMath::Pi() / 6.0; - auto angleend = 7.0 * TMath::Pi() / 6.0; - auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); - auto rotangle = anglestart + nrotbkg * anglestep; - auto rotKKPx = KaonKshortPair.Px() * std::cos(rotangle) - KaonKshortPair.Py() * std::sin(rotangle); - auto rotKKPy = KaonKshortPair.Px() * std::sin(rotangle) + KaonKshortPair.Py() * std::cos(rotangle); - KaonKshortPairRot.SetXYZM(rotKKPx, rotKKPy, KaonKshortPair.Pz(), KaonKshortPair.M()); - F1Rot = Pion + KaonKshortPairRot; - auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (t1.f1SignalStat() > 0) { - histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), t2.protonCharge()); - if (fillSparse) { - histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, t2.protonCharge()); - } - } - } - } } } } From 5aaa41f4ea2c709e54903d1fcd57d83c34ca1cfb Mon Sep 17 00:00:00 2001 From: skundu692 Date: Fri, 5 Sep 2025 21:27:06 +0200 Subject: [PATCH 06/25] Add new histogram for spin correlation --- .../Strangeness/lambdaspincorrderived.cxx | 115 ++++++++++++------ 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 3a350f5b6d0..9bf238cec25 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -109,6 +109,8 @@ struct lambdaspincorrderived { ConfigurableAxis configThnAxisR{"configThnAxisR", {80, 0.0, 8.0}, "#it{R}"}; ConfigurableAxis configThnAxisPol{"configThnAxisPol", {80, 0.0, 8.0}, "cos#it{#theta *}"}; ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0.0, 80.0}, "Centrality"}; + ConfigurableAxis configThnAxisRapidity{"configThnAxisRapidity", {5, 0.0, 1.0}, "Rapidity"}; + ConfigurableAxis configThnAxisPhi{"configThnAxisPhi", {18, 0.0, 2.0 * TMath::Pi()}, "Phi"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) @@ -131,15 +133,35 @@ struct lambdaspincorrderived { histos.add("hLambdaMixForALL", "hLambdaMixForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hAntiLambdaMixForALAL", "hAntiLambdaMixForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseAntiLambdaLambda", "hSparseAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseAntiLambdaAntiLambda", "hSparseAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseAntiLambdaLambda", "hSparseAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseAntiLambdaAntiLambda", "hSparseAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); - histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseAntiLambdaLambdaMixed", "hSparseAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); - histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); + histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); + histos.add("hSparseAntiLambdaLambdaMixed", "hSparseAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); + histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); + + histos.add("hSparseRapLambdaLambda", "hSparseRapLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapLambdaAntiLambda", "hSparseRapLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaLambda", "hSparseRapAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaAntiLambda", "hSparseRapAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + + histos.add("hSparseRapLambdaLambdaMixed", "hSparseRapLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapLambdaAntiLambdaMixed", "hSparseRapLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + + histos.add("hSparsePhiLambdaLambda", "hSparsePhiLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiLambdaAntiLambda", "hSparsePhiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiAntiLambdaLambda", "hSparsePhiAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiAntiLambdaAntiLambda", "hSparsePhiAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + + histos.add("hSparsePhiLambdaLambdaMixed", "hSparsePhiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiLambdaAntiLambdaMixed", "hSparsePhiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiAntiLambdaLambdaMixed", "hSparsePhiAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); + histos.add("hSparsePhiAntiLambdaAntiLambdaMixed", "hSparsePhiAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); ccdb->setURL(cfgCcdbParam.cfgURL); ccdbApi.init("http://alice-ccdb.cern.ch"); @@ -147,10 +169,12 @@ struct lambdaspincorrderived { ccdb->setLocalObjectValidityChecking(); ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); LOGF(info, "Getting alignment offsets from the CCDB..."); - hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); - hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); - hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); - hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); + if (useweight) { + hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); + hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); + hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); + hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); + } } template @@ -214,7 +238,7 @@ struct lambdaspincorrderived { void fillHistograms(int tag1, int tag2, const ROOT::Math::PtEtaPhiMVector& particle1, const ROOT::Math::PtEtaPhiMVector& particle2, const ROOT::Math::PtEtaPhiMVector& daughpart1, const ROOT::Math::PtEtaPhiMVector& daughpart2, - double centrality, int datatype, float mixpairweight) + int datatype, float mixpairweight) { auto lambda1Mass = 0.0; @@ -249,24 +273,36 @@ struct lambdaspincorrderived { auto cosThetaDiff = -999.0; cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + + auto costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); + double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); double deltaEta = particle1Dummy.Eta() - particle2Dummy.Eta(); + double deltaRap = std::abs(particle1Dummy.Rapidity() - particle2Dummy.Rapidity()); double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); if (datatype == 0) { mixpairweight = 1.0; histos.fill(HIST("hPtYSame"), particle1.Pt(), particle1.Rapidity(), mixpairweight); if (tag1 == 0 && tag2 == 0) { - histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); histos.fill(HIST("hLambdaSameForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 0 && tag2 == 1) { - histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); histos.fill(HIST("hLambdaSameForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 0) { - histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); histos.fill(HIST("hLambdaSameForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 1) { - histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } } else if (datatype == 1) { @@ -282,16 +318,25 @@ struct lambdaspincorrderived { } histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity()); if (tag1 == 0 && tag2 == 0) { - histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight1); + histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight1); + histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight1); + histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight1); histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); } else if (tag1 == 0 && tag2 == 1) { - histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight2); + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight2); + histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight2); + histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight2); histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); } else if (tag1 == 1 && tag2 == 0) { - histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight3); + histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight3); + histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight3); + histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight3); + histos.fill(HIST("hLambdaMixForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); } else if (tag1 == 1 && tag2 == 1) { - histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight4); + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight4); + histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight4); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight4); histos.fill(HIST("hAntiLambdaMixForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight4); } } @@ -334,16 +379,16 @@ struct lambdaspincorrderived { lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass()); histos.fill(HIST("deltaPhiSame"), std::abs(RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(v02.lambdaPhi(), 0.0F, harmonic))); if (v0.v0Status() == 0 && v02.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 0 && v02.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 1 && v02.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 1 && v02.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 0, 1.0); } } } @@ -361,7 +406,7 @@ struct lambdaspincorrderived { std::vector t1Used; for (auto& [collision1, collision2] : selfCombinations(colBinning, nEvtMixing, -1, collisions, collisions)) { // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); - auto centrality = collision1.cent(); + // auto centrality = collision1.cent(); auto groupV01 = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); auto groupV02 = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); auto groupV03 = V0s.sliceBy(tracksPerCollisionV0, collision2.index()); @@ -406,16 +451,16 @@ struct lambdaspincorrderived { lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); histos.fill(HIST("deltaPhiMix"), std::abs(RecoDecay::constrainAngle(t3.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(t2.lambdaPhi(), 0.0F, harmonic))); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, 1.0); } } } // replacement track pair @@ -431,7 +476,7 @@ struct lambdaspincorrderived { for (auto& collision1 : collisions) { int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); - float centrality = collision1.cent(); + // float centrality = collision1.cent(); // <<< CHANGED: map old collision index → set of (t2.idx, t3.idx) we've already filled std::unordered_map>> seenMap; @@ -486,16 +531,16 @@ struct lambdaspincorrderived { histos.fill(HIST("deltaPhiMix"), dPhi, invN); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 1, invN); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 1, invN); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, centrality, 1, invN); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 1, invN); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, invN); } } } // end mixing-event loop From e17c9062a6a9e1aebecc2c9490d6b267f9a1de5e Mon Sep 17 00:00:00 2001 From: skundu692 Date: Mon, 8 Sep 2025 18:29:44 +0200 Subject: [PATCH 07/25] Add new event-mixing process function --- .../Strangeness/lambdaspincorrderived.cxx | 114 +++++++++++++++++- 1 file changed, 108 insertions(+), 6 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 9bf238cec25..c8a3b5f729a 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -138,10 +138,10 @@ struct lambdaspincorrderived { histos.add("hSparseAntiLambdaLambda", "hSparseAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseAntiLambdaAntiLambda", "hSparseAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); - histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); - histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); - histos.add("hSparseAntiLambdaLambdaMixed", "hSparseAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); - histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity, configThnAxisR}, true); + histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseAntiLambdaLambdaMixed", "hSparseAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); + histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseRapLambdaLambda", "hSparseRapLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); histos.add("hSparseRapLambdaAntiLambda", "hSparseRapLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); @@ -316,24 +316,27 @@ struct lambdaspincorrderived { weight3 = mixpairweight * hweight3->GetBinContent(hweight3->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); weight4 = mixpairweight * hweight4->GetBinContent(hweight4->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); } - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity()); + if (tag1 == 0 && tag2 == 0) { + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight1); histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight1); histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight1); histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight1); histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); } else if (tag1 == 0 && tag2 == 1) { + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight2); histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight2); histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight2); histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight2); histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); } else if (tag1 == 1 && tag2 == 0) { + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight3); histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight3); histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight3); histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight3); - histos.fill(HIST("hLambdaMixForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); } else if (tag1 == 1 && tag2 == 1) { + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight4); histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight4); histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight4); histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight4); @@ -554,6 +557,105 @@ struct lambdaspincorrderived { } // end primary-event loop } PROCESS_SWITCH(lambdaspincorrderived, processMEV2, "Process data ME", false); + + void processMEV3(EventCandidates const& collisions, AllTrackCandidates const& V0s) + { + // one pool (deque) per mixing bin; each entry holds (collision index, slice of its V0s) + auto nBins = colBinning.getAllBinsCount(); + std::vector>> eventPools(nBins); + + for (auto& collision1 : collisions) { + // select mixing bin for this event + const int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); + + // all V0s from the current event + auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + + // loop over same-event candidate pairs (t1,t2) + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) { + if (!selectionV0(t1) || !selectionV0(t2)) + continue; + if (t2.index() <= t1.index()) + continue; // unique unordered pairs + if (t1.protonIndex() == t2.protonIndex()) + continue; // no shared daughter + if (t1.pionIndex() == t2.pionIndex()) + continue; + + // --- First pass over previous events in this bin: count replacements and build a list of usable pools + int mixes = 0; + struct PoolView { + AllTrackCandidates* pool; + int nRepl; + int collIdx; + }; + std::vector usable; + int totalRepl = 0; + + for (auto it = eventPools[bin].rbegin(); + it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { + const int collision2idx = it->first; + auto& poolB = it->second; + + // (defensive; shouldn't happen because we push the current event after mixing) + if (collision2idx == collision1.index()) + continue; + + int nRepl = 0; + for (auto& t3 : poolB) { + if (selectionV0(t3) && checkKinematics(t1, t3)) + ++nRepl; + } + if (nRepl > 0) { + usable.push_back(PoolView{&poolB, nRepl, collision2idx}); + totalRepl += nRepl; + } + } + + if (totalRepl == 0) + continue; + const float w = 1.0f / static_cast(totalRepl); // global normalization: sum of weights over all replacements = 1 + + // --- Second pass: fill with normalized weight w + for (auto& pv : usable) { + auto& poolB = *pv.pool; + for (auto& t3 : poolB) { + if (!(selectionV0(t3) && checkKinematics(t1, t3))) + continue; + + // build 4-vectors for the mixed pair (t3 from prior event replaces t1; t2 stays from current event) + proton = ROOT::Math::PtEtaPhiMVector(t3.protonPt(), t3.protonEta(), t3.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(t3.lambdaPt(), t3.lambdaEta(), t3.lambdaPhi(), t3.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + + float dPhi = std::fabs( + RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - + RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, w); + + if (t3.v0Status() == 0 && t2.v0Status() == 0) { + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, w); + } else if (t3.v0Status() == 0 && t2.v0Status() == 1) { + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, w); + } else if (t3.v0Status() == 1 && t2.v0Status() == 0) { + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, w); + } else if (t3.v0Status() == 1 && t2.v0Status() == 1) { + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, w); + } + } + } + } // end same-event pair loop + + // after mixing with prior events, push current event into the pool + auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); + if (static_cast(eventPools[bin].size()) > nEvtMixing) { + eventPools[bin].pop_front(); + } + } // end primary-event loop + } + PROCESS_SWITCH(lambdaspincorrderived, processMEV3, "Process data ME", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { From a94bdfd54efed4b89c4d167d93c94a5632838898 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Thu, 11 Sep 2025 12:57:54 +0200 Subject: [PATCH 08/25] Add new process function for doublephi and modify charge pairing for f1p correlation --- PWGLF/Tasks/Resonances/doublephimeson.cxx | 228 +++++++++++++++++- .../Tasks/Resonances/f1protoncorrelation.cxx | 20 +- 2 files changed, 229 insertions(+), 19 deletions(-) diff --git a/PWGLF/Tasks/Resonances/doublephimeson.cxx b/PWGLF/Tasks/Resonances/doublephimeson.cxx index 0c8f9c2c780..4e6b9918155 100644 --- a/PWGLF/Tasks/Resonances/doublephimeson.cxx +++ b/PWGLF/Tasks/Resonances/doublephimeson.cxx @@ -13,27 +13,32 @@ /// \author sourav kundu /// \since 02/11/2023 +#include "PWGLF/DataModel/ReducedDoublePhiTables.h" + +#include "Common/Core/trackUtilities.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include -#include + #include -#include #include +#include +#include #include +#include + #include + #include #include #include #include -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/StepTHn.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/ReducedDoublePhiTables.h" -#include "CommonConstants/PhysicsConstants.h" - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -631,6 +636,207 @@ struct doublephimeson { } PROCESS_SWITCH(doublephimeson, processopti, "Process Optimized same event", false); + void processopti2(aod::RedPhiEvents::iterator const& collision, aod::PhiTracks const& phitracks) + { + if (additionalEvsel && (collision.numPos() < 2 || collision.numNeg() < 2)) { + return; + } + + // === Helpers === + // PDG phi mass (centralized constant, easy to vary for systematics) + constexpr double mPhiPDG = 1.019461; // GeV/c^2 + + // ΔR with proper Δφ wrapping (−π, π] + const auto deltaR = [](double phi1, double eta1, double phi2, double eta2) { + const double dphi = TVector2::Phi_mpi_pi(phi1 - phi2); + const double deta = eta1 - eta2; + return std::sqrt(dphi * dphi + deta * deta); + }; + + // Combined mass offset from PDG (tie-breaker metric) + const auto deltam = [=](double m1, double m2) { + return std::sqrt((m1 - mPhiPDG) * (m1 - mPhiPDG) + (m2 - mPhiPDG) * (m2 - mPhiPDG)); + }; + + // Anti-merging/duplication veto: + // Require same-sign kaons from the two φ's to be separated in (η,φ). + // This protects against split/merged tracks and near-duplicate topologies. + const auto passDaughterDR = [&](const ROOT::Math::PtEtaPhiMVector& kplusA, + const ROOT::Math::PtEtaPhiMVector& kplusB, + const ROOT::Math::PtEtaPhiMVector& kminusA, + const ROOT::Math::PtEtaPhiMVector& kminusB) { + const double dRkplus = deltaR(kplusA.Phi(), kplusA.Eta(), kplusB.Phi(), kplusB.Eta()); + const double dRkminus = deltaR(kminusA.Phi(), kminusA.Eta(), kminusB.Phi(), kminusB.Eta()); + return (dRkplus > daughterDeltaR) && (dRkminus > daughterDeltaR); + // If later needed, make pT-aware: + // const double thr = std::max(0.01, daughterDeltaR - 0.002 * std::min(10.0, exoticPt)); + // return (dRkplus > thr) && (dRkminus > thr); + }; + + // === Phi multiplicity (uses PID1 for d1, PID2 for d2) === + int phimult = 0; + for (auto const& t : phitracks) { + if (t.phiMass() < minPhiMass1 || t.phiMass() > maxPhiMass1) + continue; + const double kpluspt = std::hypot(t.phid1Px(), t.phid1Py()); + const double kminuspt = std::hypot(t.phid2Px(), t.phid2Py()); + if (kpluspt > maxKaonPt) + continue; + if (kminuspt > maxKaonPt) + continue; + if (!selectionPID(t.phid1TPC(), t.phid1TOF(), t.phid1TOFHit(), strategyPID1, kpluspt)) + continue; // d1 → PID1 + if (!selectionPID(t.phid2TPC(), t.phid2TOF(), t.phid2TOFHit(), strategyPID2, kminuspt)) + continue; // d2 → PID2 + ++phimult; + } + + // === Collect candidates first === + std::vector exoticres, phi1v, phi2v, kplus1, kplus2, kminus1, kminus2; + std::vector d1id, d2id, d3id, d4id; + + const auto n = phitracks.size(); + exoticres.reserve(n); + phi1v.reserve(n); + phi2v.reserve(n); + kplus1.reserve(n); + kplus2.reserve(n); + kminus1.reserve(n); + kminus2.reserve(n); + d1id.reserve(n); + d2id.reserve(n); + d3id.reserve(n); + d4id.reserve(n); + + for (auto const& t1 : phitracks) { + // Per-φ selection for the first φ + const double kplus1pt = std::hypot(t1.phid1Px(), t1.phid1Py()); + const double kminus1pt = std::hypot(t1.phid2Px(), t1.phid2Py()); + if (kplus1pt > maxKaonPt) + continue; + if (kminus1pt > maxKaonPt) + continue; + if (!selectionPID(t1.phid1TPC(), t1.phid1TOF(), t1.phid1TOFHit(), strategyPID1, kplus1pt)) + continue; + if (!selectionPID(t1.phid2TPC(), t1.phid2TOF(), t1.phid2TOFHit(), strategyPID2, kminus1pt)) + continue; + + // Set vectors BEFORE QA fills + Phid1.SetXYZM(t1.phiPx(), t1.phiPy(), t1.phiPz(), t1.phiMass()); + Phi1kaonplus.SetXYZM(t1.phid1Px(), t1.phid1Py(), t1.phid1Pz(), 0.493); + Phi1kaonminus.SetXYZM(t1.phid2Px(), t1.phid2Py(), t1.phid2Pz(), 0.493); + + // PID QA + histos.fill(HIST("hnsigmaTPCTOFKaon"), t1.phid1TPC(), t1.phid1TOF(), kplus1pt); + histos.fill(HIST("hnsigmaTPCKaonPlus"), t1.phid1TPC(), kplus1pt); + histos.fill(HIST("hnsigmaTPCKaonMinus"), t1.phid2TPC(), kminus1pt); + histos.fill(HIST("hPhiMass"), Phid1.M(), Phid1.Pt()); + + const auto id1 = t1.index(); + + for (auto const& t2 : phitracks) { + const auto id2 = t2.index(); + if (id2 <= id1) + continue; // unique unordered pairs + + // Per-φ selection for the second φ + const double kplus2pt = std::hypot(t2.phid1Px(), t2.phid1Py()); + const double kminus2pt = std::hypot(t2.phid2Px(), t2.phid2Py()); + if (kplus2pt > maxKaonPt) + continue; + if (kminus2pt > maxKaonPt) + continue; + if (!selectionPID(t2.phid1TPC(), t2.phid1TOF(), t2.phid1TOFHit(), strategyPID1, kplus2pt)) + continue; + if (!selectionPID(t2.phid2TPC(), t2.phid2TOF(), t2.phid2TOFHit(), strategyPID2, kminus2pt)) + continue; + + // Disallow shared same-sign daughters between the two φ's + if ((t1.phid1Index() == t2.phid1Index()) || (t1.phid2Index() == t2.phid2Index())) + continue; + + Phid2.SetXYZM(t2.phiPx(), t2.phiPy(), t2.phiPz(), t2.phiMass()); + Phi2kaonplus.SetXYZM(t2.phid1Px(), t2.phid1Py(), t2.phid1Pz(), 0.493); + Phi2kaonminus.SetXYZM(t2.phid2Px(), t2.phid2Py(), t2.phid2Pz(), 0.493); + + // Mass windows + if (t1.phiMass() < minPhiMass1 || t1.phiMass() > maxPhiMass1) + continue; + if (t2.phiMass() < minPhiMass2 || t2.phiMass() > maxPhiMass2) + continue; + + exotic = Phid1 + Phid2; + if (exotic.M() < minExoticMass || exotic.M() > maxExoticMass) + continue; + + // Store candidate and bookkeeping + exoticres.emplace_back(exotic.Pt(), exotic.Eta(), exotic.Phi(), exotic.M()); + phi1v.emplace_back(Phid1.Pt(), Phid1.Eta(), Phid1.Phi(), Phid1.M()); + phi2v.emplace_back(Phid2.Pt(), Phid2.Eta(), Phid2.Phi(), Phid2.M()); + + kplus1.emplace_back(Phi1kaonplus.Pt(), Phi1kaonplus.Eta(), Phi1kaonplus.Phi(), 0.493); + kminus1.emplace_back(Phi1kaonminus.Pt(), Phi1kaonminus.Eta(), Phi1kaonminus.Phi(), 0.493); + kplus2.emplace_back(Phi2kaonplus.Pt(), Phi2kaonplus.Eta(), Phi2kaonplus.Phi(), 0.493); + kminus2.emplace_back(Phi2kaonminus.Pt(), Phi2kaonminus.Eta(), Phi2kaonminus.Phi(), 0.493); + + d1id.push_back(t1.phid1Index()); + d2id.push_back(t2.phid1Index()); + d3id.push_back(t1.phid2Index()); + d4id.push_back(t2.phid2Index()); + } + } + + if (exoticres.empty()) + return; + + // === Special handling if exactly two candidates were built === + if (exoticres.size() == 2) { + const int i0 = 0, i1 = 1; + + const bool sameFour = + ((d1id[i0] == d1id[i1] || d1id[i0] == d2id[i1]) && + (d2id[i0] == d1id[i1] || d2id[i0] == d2id[i1]) && + (d3id[i0] == d3id[i1] || d3id[i0] == d4id[i1]) && + (d4id[i0] == d3id[i1] || d4id[i0] == d4id[i1])); + + const double deltam0 = deltam(phi1v[i0].M(), phi2v[i0].M()); + const double deltam1 = deltam(phi1v[i1].M(), phi2v[i1].M()); + const bool dr0 = passDaughterDR(kplus1[i0], kplus2[i0], kminus1[i0], kminus2[i0]); + const bool dr1 = passDaughterDR(kplus1[i1], kplus2[i1], kminus1[i1], kminus2[i1]); + + if (sameFour) { + // Choose the candidate closer to mφ (if it passes ΔR) + int keep = (deltam1 < deltam0 && dr1) ? i1 : (dr0 ? i0 : -1); + if (keep >= 0) { + const double dR = deltaR(phi1v[keep].Phi(), phi1v[keep].Eta(), phi2v[keep].Phi(), phi2v[keep].Eta()); + const double dm = (keep == i0) ? deltam0 : deltam1; + histos.fill(HIST("SEMassUnlike"), exoticres[keep].M(), exoticres[keep].Pt(), dR, dm, phimult); + } + } else { + // Independent candidates → fill both (respect ΔR) + if (dr0) { + const double dR0 = deltaR(phi1v[i0].Phi(), phi1v[i0].Eta(), phi2v[i0].Phi(), phi2v[i0].Eta()); + histos.fill(HIST("SEMassUnlike"), exoticres[i0].M(), exoticres[i0].Pt(), dR0, deltam0, phimult); + } + if (dr1) { + const double dR1 = deltaR(phi1v[i1].Phi(), phi1v[i1].Eta(), phi2v[i1].Phi(), phi2v[i1].Eta()); + histos.fill(HIST("SEMassUnlike"), exoticres[i1].M(), exoticres[i1].Pt(), dR1, deltam1, phimult); + } + } + return; + } + + // === General case: fill each candidate once (respect ΔR) === + for (size_t i = 0; i < exoticres.size(); ++i) { + if (!passDaughterDR(kplus1[i], kplus2[i], kminus1[i], kminus2[i])) + continue; + const double dR = deltaR(phi1v[i].Phi(), phi1v[i].Eta(), phi2v[i].Phi(), phi2v[i].Eta()); + const double dm = deltam(phi1v[i].M(), phi2v[i].M()); + histos.fill(HIST("SEMassUnlike"), exoticres[i].M(), exoticres[i].Pt(), dR, dm, phimult); + } + } + PROCESS_SWITCH(doublephimeson, processopti2, "Process Optimized same event", false); + SliceCache cache; using BinningTypeVertexContributor = ColumnBinningPolicy; void processMixedEvent(aod::RedPhiEvents& collisions, aod::PhiTracks& phitracks) diff --git a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx index 02395a2b1fe..177f4b6a5dd 100644 --- a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx +++ b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx @@ -303,13 +303,15 @@ struct f1protoncorrelation { if (f1track.f1SignalStat() > 0) { // check charge + float pairCharge = f1track.f1SignalStat() * protontrack.protonCharge(); int f1Charge = f1track.f1SignalStat(); + int pionCharge = -1; + int kaonCharge = 1; if (f1Charge == 2) { - f1Charge = -1; + pionCharge = 1; + kaonCharge = -1; } - int pionCharge = -1.0 * f1Charge; - float pairCharge = f1Charge * protontrack.protonCharge(); - histos.fill(HIST("hPhaseSpaceProtonKaonSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, protontrack.protonCharge(), f1Charge, bz, bz)); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonKaonSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, protontrack.protonCharge(), kaonCharge, bz, bz)); // Phase Space Proton kaon histos.fill(HIST("hPhaseSpaceProtonPionSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, protontrack.protonCharge(), pionCharge, bz, bz)); // Phase Space Proton Pion histos.fill(HIST("h2SameEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like if (fillSparse) { @@ -533,14 +535,16 @@ struct f1protoncorrelation { } auto relative_momentum = getkstar(F1, Proton); if (t1.f1SignalStat() > 0) { + float pairCharge = t1.f1SignalStat() * t2.protonCharge(); int f1Charge = t1.f1SignalStat(); + int pionCharge = -1; + int kaonCharge = 1; if (f1Charge == 2) { - f1Charge = -1; + pionCharge = 1; + kaonCharge = -1; } - int pionCharge = -1.0 * f1Charge; - float pairCharge = f1Charge * t2.protonCharge(); histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like - histos.fill(HIST("hPhaseSpaceProtonKaonMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, t2.protonCharge(), f1Charge, bz, bz2)); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonKaonMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, t2.protonCharge(), kaonCharge, bz, bz2)); // Phase Space Proton kaon histos.fill(HIST("hPhaseSpaceProtonPionMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, t2.protonCharge(), pionCharge, bz, bz2)); // Phase Space Proton Pion if (fillSparse) { histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); From b820e26bdf3aed7df85f47802572f6b043b180f1 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Fri, 19 Sep 2025 18:24:34 +0200 Subject: [PATCH 09/25] Add mixed event combinatorial background --- .../Tasks/Resonances/f1protoncorrelation.cxx | 231 +++++++++++------- 1 file changed, 143 insertions(+), 88 deletions(-) diff --git a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx index 177f4b6a5dd..035418143bf 100644 --- a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx +++ b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx @@ -82,6 +82,7 @@ struct f1protoncorrelation { Configurable nRot{"nRot", 4, "Number of rotational bkg"}; // Event Mixing Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; + Configurable nEvtMixingBkg{"nEvtMixingBkg", 5, "Number of events to mix for background reconstruction"}; ConfigurableAxis CfgVtxBins{"CfgVtxBins", {10, -10, 10}, "Mixing bins - z-vertex"}; ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0, 40.0, 80.0, 500.0}, "Mixing bins - number of contributor"}; @@ -108,10 +109,11 @@ struct f1protoncorrelation { const AxisSpec thnAxisCharge{configThnAxisCharge, "Charge"}; // register histograms - histos.add("hPhaseSpaceProtonKaonSame", "hPhaseSpaceProtonKaonSame", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); - histos.add("hPhaseSpaceProtonPionSame", "hPhaseSpaceProtonPionSame", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); - histos.add("hPhaseSpaceProtonKaonMix", "hPhaseSpaceProtonKaonMix", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); - histos.add("hPhaseSpaceProtonPionMix", "hPhaseSpaceProtonPionMix", kTH2F, {{200, -2.0f, 2.0f}, {360, -4.0 * TMath::Pi(), 4.0 * TMath::Pi()}}); + histos.add("hPhaseSpaceProtonKaonSame", "hPhaseSpaceProtonKaonSame", kTH3F, {{40, -2.0f, 2.0f}, {180, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}, {100, 0.0, 1.0}}); + histos.add("hPhaseSpaceProtonPionSame", "hPhaseSpaceProtonPionSame", kTH3F, {{40, -2.0f, 2.0f}, {180, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}, {100, 0.0, 1.0}}); + histos.add("hPhaseSpaceProtonKaonMix", "hPhaseSpaceProtonKaonMix", kTH3F, {{40, -2.0f, 2.0f}, {180, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}, {100, 0.0, 1.0}}); + histos.add("hPhaseSpaceProtonPionMix", "hPhaseSpaceProtonPionMix", kTH3F, {{40, -2.0f, 2.0f}, {180, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}, {100, 0.0, 1.0}}); + histos.add("hNsigmaProtonTPC", "Nsigma Proton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaKaonTPC", "Nsigma Kaon TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaPionTPC", "Nsigma Pion TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); @@ -126,6 +128,9 @@ struct f1protoncorrelation { histos.add("h2MixEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 mix event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); histos.add("h2MixEventInvariantMassRot_mass", "Rotational Sign Invariant mass of f1 mix event", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2MixEventInvariantMassUnlike_mass_SEFP", "Unlike-sign invariant mass of f1 mix event (SE-F1P: π mixed, p same event)", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + histos.add("h2MixEventInvariantMassUnlike_mass_DEFP", "Unlike-sign invariant mass of f1 mix event (DE-F1P: π + p mixed)", kTHnSparseF, {thnAxisKstar, thnAxisPt, thnAxisInvMass, thnAxisCharge}); + if (fillSparse) { histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); histos.add("SEMassLike", "SEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma, thnAxisCharge}); @@ -311,8 +316,8 @@ struct f1protoncorrelation { pionCharge = 1; kaonCharge = -1; } - histos.fill(HIST("hPhaseSpaceProtonKaonSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, protontrack.protonCharge(), kaonCharge, bz, bz)); // Phase Space Proton kaon - histos.fill(HIST("hPhaseSpaceProtonPionSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, protontrack.protonCharge(), pionCharge, bz, bz)); // Phase Space Proton Pion + histos.fill(HIST("hPhaseSpaceProtonKaonSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, protontrack.protonCharge(), kaonCharge, bz, bz), relative_momentum); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonPionSame"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, protontrack.protonCharge(), pionCharge, bz, bz), relative_momentum); // Phase Space Proton Pion histos.fill(HIST("h2SameEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like if (fillSparse) { histos.fill(HIST("SEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); @@ -354,113 +359,163 @@ struct f1protoncorrelation { BinningType colBinning{{CfgVtxBins, CfgMultBins}, true}; Preslice tracksPerCollisionPresliceF1 = aod::f1protondaughter::redF1PEventId; Preslice tracksPerCollisionPresliceP = aod::f1protondaughter::redF1PEventId; - void processME(aod::RedF1PEvents& collisions, aod::F1Tracks& f1tracks, aod::ProtonTracks& protontracks) + void processME(aod::RedF1PEvents& collisions, + aod::F1Tracks& f1tracks, + aod::ProtonTracks& protontracks) { - for (auto& [collision1, collision2] : selfCombinations(colBinning, nEvtMixing, -1, collisions, collisions)) { - // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); - if (collision1.index() == collision2.index()) { + for (auto const& [collision1, collision2] : + selfCombinations(colBinning, nEvtMixingBkg, -1, collisions, collisions)) { + if (collision1.index() == collision2.index()) continue; - } - if (f1tracks.size() == 0 || protontracks.size() == 0) { - continue; - } - auto groupF1 = f1tracks.sliceBy(tracksPerCollisionPresliceF1, collision1.globalIndex()); - auto groupProton = protontracks.sliceBy(tracksPerCollisionPresliceP, collision2.globalIndex()); - // auto groupF1 = f1tracks.sliceByCached(aod::f1protondaughter::redF1PEventId, collision1.globalIndex(), cache); - // auto groupProton = protontracks.sliceByCached(aod::f1protondaughter::redF1PEventId, collision2.globalIndex(), cache); - for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupF1, groupProton))) { - if (t1.f1MassKaonKshort() > maxKKS0Mass) { + + // Preslices + auto f1_c1 = f1tracks.sliceBy(tracksPerCollisionPresliceF1, collision1.globalIndex()); + auto f1_c2 = f1tracks.sliceBy(tracksPerCollisionPresliceF1, collision2.globalIndex()); + auto p_c1 = protontracks.sliceBy(tracksPerCollisionPresliceP, collision1.globalIndex()); + auto p_c2 = protontracks.sliceBy(tracksPerCollisionPresliceP, collision2.globalIndex()); + + // ------------------------------- + // CASE 1: SE-F1P (π mixed from c2, K+K0s from c1, proton from c1) + // ------------------------------- + for (auto const& t1 : f1_c1) { + if (t1.f1MassKaonKshort() > maxKKS0Mass) continue; - } - F1.SetXYZM(t1.f1Px(), t1.f1Py(), t1.f1Pz(), t1.f1Mass()); - Pion.SetXYZM(t1.f1d1Px(), t1.f1d1Py(), t1.f1d1Pz(), 0.139); + Kaon.SetXYZM(t1.f1d2Px(), t1.f1d2Py(), t1.f1d2Pz(), 0.493); Kshort.SetXYZM(t1.f1d3Px(), t1.f1d3Py(), t1.f1d3Pz(), 0.497); KaonKshortPair = Kaon + Kshort; - if (Pion.Pt() > maxMomentumPion || Kaon.Pt() > maxMomentumKaon) { + + if (Kaon.Pt() > maxMomentumKaon) continue; - } if (pdepPID) { - if (Kaon.Pt() <= 0.5 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) { + if (Kaon.Pt() <= 0.5 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) continue; - } - if (Kaon.Pt() > 0.5 && Kaon.Pt() <= 0.7 && (t1.f1d2TPC() < -1.5 || t1.f1d2TPC() > 2.5)) { + if (Kaon.Pt() > 0.5 && Kaon.Pt() <= 0.7 && (t1.f1d2TPC() < -1.5 || t1.f1d2TPC() > 2.5)) continue; - } - if (Kaon.Pt() > 0.7 && Kaon.Pt() <= 1.0 && (t1.f1d2TPC() < -1.0 || t1.f1d2TPC() > 2.5)) { + if (Kaon.Pt() > 0.7 && Kaon.Pt() <= 1.0 && (t1.f1d2TPC() < -1.0 || t1.f1d2TPC() > 2.5)) continue; - } - if (Kaon.Pt() > 1.0 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) { + if (Kaon.Pt() > 1.0 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) continue; - } - if (Pion.Pt() < 2.0 && (t1.f1d1TPC() < -2.5 || t1.f1d1TPC() > 2.5)) { + } + if (strategyPIDKaon == 1 && + Kaon.Pt() > momentumTOFKaonMin && Kaon.Pt() <= momentumTOFKaonMax && + t1.f1d2TOFHit() != 1) + continue; + + for (auto const& t2 : p_c1) { // proton from c1 + Proton.SetXYZM(t2.protonPx(), t2.protonPy(), t2.protonPz(), 0.938); + if (Proton.Pt() > momentumProtonMax) continue; - } - if (Pion.Pt() > 2.0 && (t1.f1d1TPC() < -2.5 || t1.f1d1TPC() > 2.5)) { + if (Proton.P() < momentumTOFProton && TMath::Abs(t2.protonNsigmaTPC()) > 2.5) + continue; + if (Proton.P() >= momentumTOFProton && (t2.protonTOFHit() != 1 || TMath::Abs(t2.protonNsigmaTOF()) > 2.5)) continue; + + for (auto const& t3 : f1_c2) { // pion source from c2 + Pion.SetXYZM(t3.f1d1Px(), t3.f1d1Py(), t3.f1d1Pz(), 0.139); + if (Pion.Pt() > maxMomentumPion) + continue; + if (pdepPID) { + if (Pion.Pt() < 2.0 && (t3.f1d1TPC() < -2.5 || t3.f1d1TPC() > 2.5)) + continue; + if (Pion.Pt() >= 2.0 && (t3.f1d1TPC() < -2.5 || t3.f1d1TPC() > 2.5)) + continue; + } + if (strategyPIDPion == 1 && + Pion.Pt() > momentumTOFPionMin && Pion.Pt() <= momentumTOFPionMax && + t3.f1d1TOFHit() != 1) + continue; + + // Fake f1: π(mixed) + (K+K0s from c1) + F1 = Pion + KaonKshortPair; + + // keep only unlike-sign branch + if (t1.f1SignalStat() <= 0) + continue; + + int f1Charge = t1.f1SignalStat(); + float pairQ = f1Charge * t2.protonCharge(); + + auto kstar = getkstar(F1, Proton); + + histos.fill(HIST("h2MixEventInvariantMassUnlike_mass_SEFP"), + kstar, F1.Pt(), F1.M(), pairQ); } } - if (strategyPIDPion == 1 && Pion.Pt() > momentumTOFPionMin && Pion.Pt() <= momentumTOFPionMax && t1.f1d1TOFHit() != 1) { - continue; - } - if (strategyPIDKaon == 1 && Kaon.Pt() > momentumTOFKaonMin && Kaon.Pt() <= momentumTOFKaonMax && t1.f1d2TOFHit() != 1) { - continue; - } - if (typeofCombined == 0) { - combinedTPC = TMath::Sqrt(t1.f1d1TPC() * t1.f1d1TPC() + t1.f1d2TPC() * t1.f1d2TPC()); - } - if (typeofCombined == 1) { - combinedTPC = (t1.f1d1TPC() - t1.f1d2TPC()) / (t1.f1d1TPC() + t1.f1d2TPC()); - } - Proton.SetXYZM(t2.protonPx(), t2.protonPy(), t2.protonPz(), 0.938); - if (Proton.Pt() > momentumProtonMax) { + } + + // ------------------------------- + // CASE 2: DE-F1P (π mixed from c2, K+K0s from c1, proton from c2) + // ------------------------------- + for (auto const& t1 : f1_c1) { + if (t1.f1MassKaonKshort() > maxKKS0Mass) continue; - } - if (Proton.P() < momentumTOFProton && TMath::Abs(t2.protonNsigmaTPC()) > 2.5) { + + Kaon.SetXYZM(t1.f1d2Px(), t1.f1d2Py(), t1.f1d2Pz(), 0.493); + Kshort.SetXYZM(t1.f1d3Px(), t1.f1d3Py(), t1.f1d3Pz(), 0.497); + KaonKshortPair = Kaon + Kshort; + + if (Kaon.Pt() > maxMomentumKaon) continue; + if (pdepPID) { + if (Kaon.Pt() <= 0.5 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) + continue; + if (Kaon.Pt() > 0.5 && Kaon.Pt() <= 0.7 && (t1.f1d2TPC() < -1.5 || t1.f1d2TPC() > 2.5)) + continue; + if (Kaon.Pt() > 0.7 && Kaon.Pt() <= 1.0 && (t1.f1d2TPC() < -1.0 || t1.f1d2TPC() > 2.5)) + continue; + if (Kaon.Pt() > 1.0 && (t1.f1d2TPC() < -2.5 || t1.f1d2TPC() > 2.5)) + continue; } - if (Proton.P() >= momentumTOFProton && (t2.protonTOFHit() != 1 || TMath::Abs(t2.protonNsigmaTOF()) > 2.5)) { + if (strategyPIDKaon == 1 && + Kaon.Pt() > momentumTOFKaonMin && Kaon.Pt() <= momentumTOFKaonMax && + t1.f1d2TOFHit() != 1) continue; - } - auto relative_momentum = getkstar(F1, Proton); - if (t1.f1SignalStat() > 0) { - histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), 1.0); // F1 sign = 1 unlike, F1 sign = -1 like - if (fillSparse) { - histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, 1.0); - } - } - if (t1.f1SignalStat() == -1) { - histos.fill(HIST("h2MixEventInvariantMassLike_mass"), relative_momentum, F1.Pt(), F1.M(), 1.0); - if (fillSparse) { - histos.fill(HIST("MEMassLike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, 1.0); - } - } - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < nRot; nrotbkg++) { - auto anglestart = 5.0 * TMath::Pi() / 6.0; - auto angleend = 7.0 * TMath::Pi() / 6.0; - auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); - auto rotangle = anglestart + nrotbkg * anglestep; - auto rotPionPx = Pion.Px() * std::cos(rotangle) - Pion.Py() * std::sin(rotangle); - auto rotPionPy = Pion.Px() * std::sin(rotangle) + Pion.Py() * std::cos(rotangle); - PionRot.SetXYZM(rotPionPx, rotPionPy, Pion.Pz(), Pion.M()); - F1Rot = PionRot + KaonKshortPair; - if (F1Rot.Pt() < 1.0) { + + for (auto const& t2 : p_c2) { // proton from c2 + Proton.SetXYZM(t2.protonPx(), t2.protonPy(), t2.protonPz(), 0.938); + if (Proton.Pt() > momentumProtonMax) + continue; + if (Proton.P() < momentumTOFProton && TMath::Abs(t2.protonNsigmaTPC()) > 2.5) + continue; + if (Proton.P() >= momentumTOFProton && (t2.protonTOFHit() != 1 || TMath::Abs(t2.protonNsigmaTOF()) > 2.5)) + continue; + + for (auto const& t3 : f1_c2) { // pion from c2 + Pion.SetXYZM(t3.f1d1Px(), t3.f1d1Py(), t3.f1d1Pz(), 0.139); + if (Pion.Pt() > maxMomentumPion) continue; + if (pdepPID) { + if (Pion.Pt() < 2.0 && (t3.f1d1TPC() < -2.5 || t3.f1d1TPC() > 2.5)) + continue; + if (Pion.Pt() >= 2.0 && (t3.f1d1TPC() < -2.5 || t3.f1d1TPC() > 2.5)) + continue; } - auto relative_momentum_rot = getkstar(F1Rot, Proton); - if (t1.f1SignalStat() > 0) { - histos.fill(HIST("h2MixEventInvariantMassRot_mass"), relative_momentum_rot, F1Rot.Pt(), F1Rot.M(), 1.0); - if (fillSparse) { - histos.fill(HIST("MEMassRot"), F1Rot.M(), F1Rot.Pt(), Proton.Pt(), relative_momentum_rot, combinedTPC, 1.0); - } - } + if (strategyPIDPion == 1 && + Pion.Pt() > momentumTOFPionMin && Pion.Pt() <= momentumTOFPionMax && + t3.f1d1TOFHit() != 1) + continue; + + F1 = Pion + KaonKshortPair; + + if (t1.f1SignalStat() <= 0) + continue; + + int f1Charge = t1.f1SignalStat(); + float pairQ = f1Charge * t2.protonCharge(); + + auto kstar = getkstar(F1, Proton); + + histos.fill(HIST("h2MixEventInvariantMassUnlike_mass_DEFP"), + kstar, F1.Pt(), F1.M(), pairQ); } } } } } - PROCESS_SWITCH(f1protoncorrelation, processME, "Process EventMixing for combinatorial background", false); + + PROCESS_SWITCH(f1protoncorrelation, processME, "Process EventMixing for combinatorial background (SE-F1P & DE-F1P, minimal)", false); + void processMEOpti(aod::RedF1PEvents& collisions, aod::F1Tracks& f1tracks, aod::ProtonTracks& protontracks) { // for (auto const& [collision1, collision2] : combinations(soa::CombinationsBlockFullIndexPolicy(colBinningFemto, nEvtMixing, -1, collisions, collisions))){ @@ -544,8 +599,8 @@ struct f1protoncorrelation { kaonCharge = -1; } histos.fill(HIST("h2MixEventInvariantMassUnlike_mass"), relative_momentum, F1.Pt(), F1.M(), pairCharge); // F1 sign = 1 unlike, F1 sign = -1 like - histos.fill(HIST("hPhaseSpaceProtonKaonMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, t2.protonCharge(), kaonCharge, bz, bz2)); // Phase Space Proton kaon - histos.fill(HIST("hPhaseSpaceProtonPionMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, t2.protonCharge(), pionCharge, bz, bz2)); // Phase Space Proton Pion + histos.fill(HIST("hPhaseSpaceProtonKaonMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Kaon, t2.protonCharge(), kaonCharge, bz, bz2), relative_momentum); // Phase Space Proton kaon + histos.fill(HIST("hPhaseSpaceProtonPionMix"), Proton.Eta() - Kaon.Eta(), PhiAtSpecificRadiiTPC(Proton, Pion, t2.protonCharge(), pionCharge, bz, bz2), relative_momentum); // Phase Space Proton Pion if (fillSparse) { histos.fill(HIST("MEMassUnlike"), F1.M(), F1.Pt(), Proton.Pt(), relative_momentum, combinedTPC, pairCharge); } From 594d0be6b99e702da29c2f106f37779785375c41 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 23 Sep 2025 17:41:16 +0200 Subject: [PATCH 10/25] Fix spin correlation definition --- .../Strangeness/lambdaspincorrderived.cxx | 99 ++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index c8a3b5f729a..4d207199742 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -96,6 +96,7 @@ struct lambdaspincorrderived { Configurable v0eta{"v0eta", 0.8, "Eta cut on lambda"}; // Event Mixing + Configurable cosDef{"cosDef", 1, "Defination of cos"}; Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; ConfigurableAxis CfgVtxBins{"CfgVtxBins", {10, -10, 10}, "Mixing bins - z-vertex"}; ConfigurableAxis CfgMultBins{"CfgMultBins", {8, 0.0, 80}, "Mixing bins - centrality"}; @@ -271,10 +272,102 @@ struct lambdaspincorrderived { auto proton1LambdaRF = boostLambda1ToCM(proton1pairCM); auto proton2LambdaRF = boostLambda2ToCM(proton2pairCM); - auto cosThetaDiff = -999.0; - cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + TVector3 zhat(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); + if (zhat.Mag2() == 0) + zhat = TVector3(0, 0, 1); + zhat = zhat.Unit(); + + // pick a reference not collinear with ẑ (beam z works) + TVector3 ref(0., 0., 1.); + if (std::abs(zhat.Dot(ref)) > 0.999) + ref = TVector3(1., 0., 0.); + + // build transverse axes + TVector3 xhat = (ref - (ref.Dot(zhat)) * zhat).Unit(); + TVector3 yhat = (zhat.Cross(xhat)).Unit(); + + // proton unit vectors in their Λ rest frames + TVector3 n1(proton1LambdaRF.Px(), proton1LambdaRF.Py(), proton1LambdaRF.Pz()); + n1 = n1.Unit(); + TVector3 n2(proton2LambdaRF.Px(), proton2LambdaRF.Py(), proton2LambdaRF.Pz()); + n2 = n2.Unit(); + + // cosθ* (Λ2 measured along −ẑ) + double c1 = n1.Dot(zhat); + double c2 = -n2.Dot(zhat); + + // sinθ* + double s1 = std::sqrt(std::max(0.0, 1.0 - c1 * c1)); + double s2 = std::sqrt(std::max(0.0, 1.0 - c2 * c2)); + + // φ1*, φ2* in common convention (flip axes for Λ2) + double phi1 = std::atan2(n1.Dot(yhat), n1.Dot(xhat)); + double phi2 = std::atan2(n2.Dot(-yhat), n2.Dot(-xhat)); + + // helicity spin-correlation + double cosDelta = c1 * c2 + s1 * s2 * std::cos(phi1 - phi2); + // clamp for safety + if (cosDelta > 1.0) + cosDelta = 1.0; + if (cosDelta < -1.0) + cosDelta = -1.0; + + // + // --- (B) Beam-based correlation (common z_B = beam; axes transported into each Λ rest frame) --- + // + TVector3 zB(0., 0., 1.); // beam axis in pair–CM coordinates + + // x_B: projection of Λ1 direction onto plane ⟂ z_B; y_B completes RH basis + TVector3 L1dir(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); + L1dir = L1dir.Unit(); + TVector3 xB = L1dir - (L1dir.Dot(zB)) * zB; + if (xB.Mag2() < 1e-12) + xB = TVector3(1., 0., 0.); // fallback if Λ1 ∥ beam + xB = xB.Unit(); + TVector3 yB = (zB.Cross(xB)).Unit(); + + // helper to transport an axis into a Λ rest frame (from pair–CM) + auto transport = [](const TVector3& v, const ROOT::Math::Boost& B) -> TVector3 { + ROOT::Math::PxPyPzEVector a(v.X(), v.Y(), v.Z(), 0.0); // spacelike 4-vector (t=0) + ROOT::Math::PxPyPzEVector ar = B(a); // boost into that Λ rest frame + TVector3 out(ar.Px(), ar.Py(), ar.Pz()); + if (out.Mag2() == 0) + return out; + return out.Unit(); + }; + + // transport beam triad to each Λ rest frame + TVector3 zB1 = transport(zB, boostLambda1ToCM); + TVector3 xB1 = transport(xB, boostLambda1ToCM); + TVector3 yB1 = transport(yB, boostLambda1ToCM); + + TVector3 zB2 = transport(zB, boostLambda2ToCM); + TVector3 xB2 = transport(xB, boostLambda2ToCM); + TVector3 yB2 = transport(yB, boostLambda2ToCM); + + // angles w.r.t. beam triad (same z_B convention for both Λ’s; no flips) + double c1B = n1.Dot(zB1), c2B = n2.Dot(zB2); + double s1B = std::sqrt(std::max(0.0, 1.0 - c1B * c1B)); + double s2B = std::sqrt(std::max(0.0, 1.0 - c2B * c2B)); + double phi1B = std::atan2(n1.Dot(yB1), n1.Dot(xB1)); + double phi2B = std::atan2(n2.Dot(yB2), n2.Dot(xB2)); + + // beam correlation + double cosDeltaBeam = c1B * c2B + s1B * s2B * std::cos(phi1B - phi2B); + if (cosDeltaBeam > 1.0) + cosDeltaBeam = 1.0; + if (cosDeltaBeam < -1.0) + cosDeltaBeam = -1.0; - auto costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); + auto cosThetaDiff = -999.0; + auto costhetaz1costhetaz2 = -999.0; + if (cosDef == 0) { + cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); + } else { + cosThetaDiff = cosDelta; + costhetaz1costhetaz2 = cosDeltaBeam; + } double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); double deltaEta = particle1Dummy.Eta() - particle2Dummy.Eta(); From 11ea888520628b0f304c437410ab2a3e8a11abd0 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 23 Sep 2025 17:49:02 +0200 Subject: [PATCH 11/25] Fix megalinter error --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 4d207199742..79ae6686182 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -34,7 +34,7 @@ #include #include - +#include #include // for std::fabs #include #include From 558d87b6742a60168325e7866fabea77c731cb24 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 23 Sep 2025 17:52:35 +0200 Subject: [PATCH 12/25] Fix clang format error --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 79ae6686182..7382a32c860 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -34,6 +34,7 @@ #include #include + #include #include // for std::fabs #include From f7655195576598d5c2ff65a5a1203dde969a7a00 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Thu, 25 Sep 2025 16:10:43 +0200 Subject: [PATCH 13/25] Add new definition of spin correlation same as STAR to compare --- .../Strangeness/lambdaspincorrderived.cxx | 184 ++++++++++-------- 1 file changed, 103 insertions(+), 81 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 7382a32c860..daeefca4adc 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -273,101 +273,123 @@ struct lambdaspincorrderived { auto proton1LambdaRF = boostLambda1ToCM(proton1pairCM); auto proton2LambdaRF = boostLambda2ToCM(proton2pairCM); - TVector3 zhat(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); - if (zhat.Mag2() == 0) - zhat = TVector3(0, 0, 1); - zhat = zhat.Unit(); - - // pick a reference not collinear with ẑ (beam z works) - TVector3 ref(0., 0., 1.); - if (std::abs(zhat.Dot(ref)) > 0.999) - ref = TVector3(1., 0., 0.); - - // build transverse axes - TVector3 xhat = (ref - (ref.Dot(zhat)) * zhat).Unit(); - TVector3 yhat = (zhat.Cross(xhat)).Unit(); - - // proton unit vectors in their Λ rest frames - TVector3 n1(proton1LambdaRF.Px(), proton1LambdaRF.Py(), proton1LambdaRF.Pz()); - n1 = n1.Unit(); - TVector3 n2(proton2LambdaRF.Px(), proton2LambdaRF.Py(), proton2LambdaRF.Pz()); - n2 = n2.Unit(); - - // cosθ* (Λ2 measured along −ẑ) - double c1 = n1.Dot(zhat); - double c2 = -n2.Dot(zhat); - - // sinθ* - double s1 = std::sqrt(std::max(0.0, 1.0 - c1 * c1)); - double s2 = std::sqrt(std::max(0.0, 1.0 - c2 * c2)); - - // φ1*, φ2* in common convention (flip axes for Λ2) - double phi1 = std::atan2(n1.Dot(yhat), n1.Dot(xhat)); - double phi2 = std::atan2(n2.Dot(-yhat), n2.Dot(-xhat)); - - // helicity spin-correlation - double cosDelta = c1 * c2 + s1 * s2 * std::cos(phi1 - phi2); - // clamp for safety - if (cosDelta > 1.0) - cosDelta = 1.0; - if (cosDelta < -1.0) - cosDelta = -1.0; - - // - // --- (B) Beam-based correlation (common z_B = beam; axes transported into each Λ rest frame) --- - // - TVector3 zB(0., 0., 1.); // beam axis in pair–CM coordinates - - // x_B: projection of Λ1 direction onto plane ⟂ z_B; y_B completes RH basis + // =================== Opening-angle correlator: cos(Δθ) for helicity-z and beam-z =================== + + // Proton unit directions in Λ rest frames + TVector3 k1(proton1LambdaRF.Px(), proton1LambdaRF.Py(), proton1LambdaRF.Pz()); + k1 = k1.Unit(); + TVector3 k2(proton2LambdaRF.Px(), proton2LambdaRF.Py(), proton2LambdaRF.Pz()); + k2 = k2.Unit(); + + // Helper: boost a spacelike axis (t=0) from PRF into a Λ rest frame + auto transport = [](const TVector3& v, const ROOT::Math::Boost& B) -> TVector3 { + ROOT::Math::PxPyPzEVector a(v.X(), v.Y(), v.Z(), 0.0); + auto ar = B(a); + TVector3 out(ar.Px(), ar.Py(), ar.Pz()); + return (out.Mag2() > 0) ? out.Unit() : out; + }; + + // ----------------------------- (1) Helicity-z construction ----------------------------- + // z along Λ1 in PRF + TVector3 zPRF(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); + if (zPRF.Mag2() == 0) + zPRF = TVector3(0, 0, 1); + zPRF = zPRF.Unit(); + + // transverse axes in PRF + TVector3 ref(0, 0, 1); + if (std::abs(zPRF.Dot(ref)) > 0.999) + ref = TVector3(1, 0, 0); + TVector3 xPRF = (ref - (ref.Dot(zPRF)) * zPRF).Unit(); + TVector3 yPRF = (zPRF.Cross(xPRF)).Unit(); + + // carry PRF triad to Λ rest frames (flip triad for Λ2 to keep same PRF-handedness) + TVector3 z1_h = transport(zPRF, boostLambda1ToCM); + TVector3 x1_h = transport(xPRF, boostLambda1ToCM); + TVector3 y1_h = transport(yPRF, boostLambda1ToCM); + + TVector3 z2_h = transport(-zPRF, boostLambda2ToCM); + TVector3 x2_h = transport(-xPRF, boostLambda2ToCM); + TVector3 y2_h = transport(-yPRF, boostLambda2ToCM); + + // angles and cosΔθ (helicity) + double c1_h = k1.Dot(z1_h); + double s1_h = std::sqrt(std::max(0.0, 1.0 - c1_h * c1_h)); + double phi1_h = std::atan2(k1.Dot(y1_h), k1.Dot(x1_h)); + + double c2_h = k2.Dot(z2_h); + double s2_h = std::sqrt(std::max(0.0, 1.0 - c2_h * c2_h)); + double phi2_h = std::atan2(k2.Dot(y2_h), k2.Dot(x2_h)); + + double cosDeltaTheta_hel = c1_h * c2_h + s1_h * s2_h * std::cos(phi1_h - phi2_h); + if (cosDeltaTheta_hel > 1.0) + cosDeltaTheta_hel = 1.0; + if (cosDeltaTheta_hel < -1.0) + cosDeltaTheta_hel = -1.0; + + // ------------------------------- (2) Beam-z construction ------------------------------- + // z along beam in PRF; choose x by projecting Λ1 onto the ⟂ plane to fix azimuth zero + TVector3 zB(0, 0, 1); TVector3 L1dir(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); L1dir = L1dir.Unit(); TVector3 xB = L1dir - (L1dir.Dot(zB)) * zB; if (xB.Mag2() < 1e-12) - xB = TVector3(1., 0., 0.); // fallback if Λ1 ∥ beam + xB = TVector3(1, 0, 0); xB = xB.Unit(); TVector3 yB = (zB.Cross(xB)).Unit(); - // helper to transport an axis into a Λ rest frame (from pair–CM) - auto transport = [](const TVector3& v, const ROOT::Math::Boost& B) -> TVector3 { - ROOT::Math::PxPyPzEVector a(v.X(), v.Y(), v.Z(), 0.0); // spacelike 4-vector (t=0) - ROOT::Math::PxPyPzEVector ar = B(a); // boost into that Λ rest frame - TVector3 out(ar.Px(), ar.Py(), ar.Pz()); - if (out.Mag2() == 0) - return out; - return out.Unit(); - }; + // carry beam triad to Λ rest frames (no flip for a common external axis) + TVector3 z1_b = transport(zB, boostLambda1ToCM); + TVector3 x1_b = transport(xB, boostLambda1ToCM); + TVector3 y1_b = transport(yB, boostLambda1ToCM); + + TVector3 z2_b = transport(zB, boostLambda2ToCM); + TVector3 x2_b = transport(xB, boostLambda2ToCM); + TVector3 y2_b = transport(yB, boostLambda2ToCM); + + // angles and cosΔθ (beam) + double c1_b = k1.Dot(z1_b); + double s1_b = std::sqrt(std::max(0.0, 1.0 - c1_b * c1_b)); + double phi1_b = std::atan2(k1.Dot(y1_b), k1.Dot(x1_b)); + + double c2_b = k2.Dot(z2_b); + double s2_b = std::sqrt(std::max(0.0, 1.0 - c2_b * c2_b)); + double phi2_b = std::atan2(k2.Dot(y2_b), k2.Dot(x2_b)); + + double cosDeltaTheta_beam = c1_b * c2_b + s1_b * s2_b * std::cos(phi1_b - phi2_b); + if (cosDeltaTheta_beam > 1.0) + cosDeltaTheta_beam = 1.0; + if (cosDeltaTheta_beam < -1.0) + cosDeltaTheta_beam = -1.0; + + // --- STAR-style Δθ (as written: dot product of proton directions in their own Λ RFs) --- + + // Boost each proton into its parent's rest frame + ROOT::Math::Boost boostL1_LabToRF{particle1Dummy.BoostToCM()}; // Λ1 velocity in lab + ROOT::Math::Boost boostL2_LabToRF{particle2Dummy.BoostToCM()}; // Λ2 velocity in lab + + auto p1_LRF = boostL1_LabToRF(daughpart1); + auto p2_LRF = boostL2_LabToRF(daughpart2); + + // Unit 3-vectors (in different rest frames!) + TVector3 u1 = TVector3(p1_LRF.Px(), p1_LRF.Py(), p1_LRF.Pz()).Unit(); + TVector3 u2 = TVector3(p2_LRF.Px(), p2_LRF.Py(), p2_LRF.Pz()).Unit(); - // transport beam triad to each Λ rest frame - TVector3 zB1 = transport(zB, boostLambda1ToCM); - TVector3 xB1 = transport(xB, boostLambda1ToCM); - TVector3 yB1 = transport(yB, boostLambda1ToCM); - - TVector3 zB2 = transport(zB, boostLambda2ToCM); - TVector3 xB2 = transport(xB, boostLambda2ToCM); - TVector3 yB2 = transport(yB, boostLambda2ToCM); - - // angles w.r.t. beam triad (same z_B convention for both Λ’s; no flips) - double c1B = n1.Dot(zB1), c2B = n2.Dot(zB2); - double s1B = std::sqrt(std::max(0.0, 1.0 - c1B * c1B)); - double s2B = std::sqrt(std::max(0.0, 1.0 - c2B * c2B)); - double phi1B = std::atan2(n1.Dot(yB1), n1.Dot(xB1)); - double phi2B = std::atan2(n2.Dot(yB2), n2.Dot(xB2)); - - // beam correlation - double cosDeltaBeam = c1B * c2B + s1B * s2B * std::cos(phi1B - phi2B); - if (cosDeltaBeam > 1.0) - cosDeltaBeam = 1.0; - if (cosDeltaBeam < -1.0) - cosDeltaBeam = -1.0; + // STAR-style cosΔθ definition + double cosDeltaTheta_STAR_naive = u1.Dot(u2); + if (cosDeltaTheta_STAR_naive > 1.0) + cosDeltaTheta_STAR_naive = 1.0; + if (cosDeltaTheta_STAR_naive < -1.0) + cosDeltaTheta_STAR_naive = -1.0; auto cosThetaDiff = -999.0; auto costhetaz1costhetaz2 = -999.0; if (cosDef == 0) { - cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + cosThetaDiff = cosDeltaTheta_STAR_naive; costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); } else { - cosThetaDiff = cosDelta; - costhetaz1costhetaz2 = cosDeltaBeam; + cosThetaDiff = cosDeltaTheta_hel; + costhetaz1costhetaz2 = cosDeltaTheta_beam; } double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); From aae382a73e2a8ebbeed90b064a45892814dc8d87 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Fri, 26 Sep 2025 18:04:20 +0200 Subject: [PATCH 14/25] Add switch to activate sel8 trigger for QC check --- PWGLF/Tasks/Resonances/phianalysisrun3.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PWGLF/Tasks/Resonances/phianalysisrun3.cxx b/PWGLF/Tasks/Resonances/phianalysisrun3.cxx index a865482393a..7cd608e955c 100644 --- a/PWGLF/Tasks/Resonances/phianalysisrun3.cxx +++ b/PWGLF/Tasks/Resonances/phianalysisrun3.cxx @@ -56,6 +56,7 @@ struct phianalysisrun3 { SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // events + Configurable applyEvsel{"applyEvsel", false, "applyEvsel"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; // track Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; @@ -252,7 +253,7 @@ struct phianalysisrun3 { void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { - if (!collision.sel8()) { + if (applyEvsel && !collision.sel8()) { return; } if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { @@ -309,10 +310,10 @@ struct phianalysisrun3 { BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; for (auto& [c1, tracks1, c2, tracks2] : pair) { - if (!c1.sel8()) { + if (applyEvsel && !c1.sel8()) { continue; } - if (!c2.sel8()) { + if (applyEvsel && !c2.sel8()) { continue; } if (timFrameEvsel && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { From 8a1784cdef7a44bba97934e1efaa1948c03341f3 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 30 Sep 2025 17:46:38 +0200 Subject: [PATCH 15/25] Add new weights for event mixing --- .../Strangeness/lambdaspincorrderived.cxx | 324 ++++++++++++------ 1 file changed, 225 insertions(+), 99 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index daeefca4adc..513acb7db8a 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -66,15 +67,28 @@ struct lambdaspincorrderived { // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. Service ccdb; o2::ccdb::CcdbApi ccdbApi; - TH3D* hweight1; - TH3D* hweight2; - TH3D* hweight3; - TH3D* hweight4; - - Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // TH3D* hweightNUAL; + // TH3D* hweightNUAAL; + // TH3D* hweight1; + // TH3D* hweight2; + // TH3D* hweight3; + // TH3D* hweight4; + // Configurable ConfWeightPathNUAL{"ConfWeightPathNUAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // Configurable ConfWeightPathNUAAL{"ConfWeightPathNUAAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + // Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + + Configurable ConfRPathL{"ConfRPathL", "", "CCDB path to R_L (optional)"}; + Configurable ConfRPathAL{"ConfRPathAL", "", "CCDB path to R_AL (optional)"}; + Configurable ConfEffPathL{"ConfEffPathL", "", "CCDB path to Eff (optional)"}; + Configurable ConfEffPathAL{"ConfEffPathAL", "", "CCDB path to Eff (optional)"}; + + TH3D* hR_L = nullptr; + TH3D* hR_AL = nullptr; + TH3D* hEff_L = nullptr; + TH3D* hEff_AL = nullptr; // event sel///////// Configurable centMin{"centMin", 0, "Minimum Centrality"}; @@ -82,7 +96,8 @@ struct lambdaspincorrderived { // Lambda selection //////////// Configurable harmonic{"harmonic", 1, "Harmonic delta phi"}; - Configurable useweight{"useweight", 1, "Use weight"}; + Configurable useweight{"useweight", 0, "Use weight"}; + // Configurable useNUA{"useNUA", 0, "Use NUA weight"}; Configurable usePDGM{"usePDGM", 1, "Use PDG mass"}; Configurable checkDoubleStatus{"checkDoubleStatus", 0, "Check Double status"}; Configurable cosPA{"cosPA", 0.995, "Cosine Pointing Angle"}; @@ -125,15 +140,31 @@ struct lambdaspincorrderived { histos.add("ptCent", "ptCent", HistType::kTH2D, {{100, 0.0, 10.0}, {8, 0.0, 80.0}}, true); histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); - histos.add("hLambdaSameForLL", "hLambdaSameForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hLambdaSameForLAL", "hLambdaSameForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hLambdaSameForALL", "hLambdaSameForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hAntiLambdaSameForALAL", "hAntiLambdaSameForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // --- Singles QA for data-driven MIXED reweight (one fill per candidate) --- + histos.add("hSE_L", "SE #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hSE_AL", "SE #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hME_L", "ME #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hME_AL", "ME #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + // Attempted-for-replacement (Den) and Succeeded (Num) per SE leg kinematics + histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hLambdaMixForLL", "hLambdaMixForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hLambdaMixForLAL", "hLambdaMixForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hLambdaMixForALL", "hLambdaMixForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hAntiLambdaMixForALAL", "hAntiLambdaMixForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hLambdaNUA", "hLambdaNUA", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hAntiLambdaNUA", "hAntiLambdaNUA", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + // histos.add("hLambdaSameForLL", "hLambdaSameForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hLambdaSameForLAL", "hLambdaSameForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hLambdaSameForALL", "hLambdaSameForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hAntiLambdaSameForALAL", "hAntiLambdaSameForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + // histos.add("hLambdaMixForLL", "hLambdaMixForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hLambdaMixForLAL", "hLambdaMixForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hLambdaMixForALL", "hLambdaMixForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // histos.add("hAntiLambdaMixForALAL", "hAntiLambdaMixForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); @@ -172,10 +203,14 @@ struct lambdaspincorrderived { ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); LOGF(info, "Getting alignment offsets from the CCDB..."); if (useweight) { - hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); - hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); - hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); - hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); + hR_L = ccdb->getForTimeStamp(ConfRPathL.value, cfgCcdbParam.nolaterthan.value); + hR_AL = ccdb->getForTimeStamp(ConfRPathAL.value, cfgCcdbParam.nolaterthan.value); + hEff_L = ccdb->getForTimeStamp(ConfEffPathL.value, cfgCcdbParam.nolaterthan.value); + hEff_AL = ccdb->getForTimeStamp(ConfEffPathAL.value, cfgCcdbParam.nolaterthan.value); + // hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); + // hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); + // hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); + // hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); } } @@ -240,7 +275,7 @@ struct lambdaspincorrderived { void fillHistograms(int tag1, int tag2, const ROOT::Math::PtEtaPhiMVector& particle1, const ROOT::Math::PtEtaPhiMVector& particle2, const ROOT::Math::PtEtaPhiMVector& daughpart1, const ROOT::Math::PtEtaPhiMVector& daughpart2, - int datatype, float mixpairweight) + int datatype, float mixpairweight, int replacedFlag) { auto lambda1Mass = 0.0; @@ -397,6 +432,41 @@ struct lambdaspincorrderived { double deltaRap = std::abs(particle1Dummy.Rapidity() - particle2Dummy.Rapidity()); double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); + double nuaWeightParticle1 = 1.0, epsWeightParticle1 = 1.0; + double nuaWeightParticle2 = 1.0, epsWeightParticle2 = 1.0; + + if (useweight && datatype == 1) { + // particle 1 + { + auto* hR = (tag1 == 0 ? hR_L : hR_AL); + auto* hEff = (tag1 == 0 ? hEff_L : hEff_AL); + + float pt = particle1.Pt(); + float eta = particle1.Eta(); + float phi = RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic); + + nuaWeightParticle1 = hR->GetBinContent(hR->FindBin(pt, eta, phi)); + if (replacedFlag == 1) { + epsWeightParticle1 = hEff->GetBinContent(hEff->FindBin(pt, eta, phi)); + } + } + + // particle 2 + { + auto* hR = (tag2 == 0 ? hR_L : hR_AL); + auto* hEff = (tag2 == 0 ? hEff_L : hEff_AL); + + float pt = particle2.Pt(); + float eta = particle2.Eta(); + float phi = RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic); + + nuaWeightParticle2 = hR->GetBinContent(hR->FindBin(pt, eta, phi)); + if (replacedFlag == 2) { + epsWeightParticle2 = hEff->GetBinContent(hEff->FindBin(pt, eta, phi)); + } + } + } + if (datatype == 0) { mixpairweight = 1.0; histos.fill(HIST("hPtYSame"), particle1.Pt(), particle1.Rapidity(), mixpairweight); @@ -404,59 +474,59 @@ struct lambdaspincorrderived { histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - histos.fill(HIST("hLambdaSameForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + // histos.fill(HIST("hLambdaSameForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - histos.fill(HIST("hLambdaSameForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + // histos.fill(HIST("hLambdaSameForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - histos.fill(HIST("hLambdaSameForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + // histos.fill(HIST("hLambdaSameForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + // histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } } else if (datatype == 1) { - double weight1 = mixpairweight; - double weight2 = mixpairweight; - double weight3 = mixpairweight; - double weight4 = mixpairweight; - if (useweight) { - weight1 = mixpairweight * hweight1->GetBinContent(hweight1->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - weight2 = mixpairweight * hweight2->GetBinContent(hweight2->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - weight3 = mixpairweight * hweight3->GetBinContent(hweight3->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - weight4 = mixpairweight * hweight4->GetBinContent(hweight4->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - } - + // double weight1 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; + // double weight2 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; + // double weight3 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; + // double weight4 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; + // if (useweight) { + // weight1 = mixpairweight * hweight1->GetBinContent(hweight1->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + // weight2 = mixpairweight * hweight2->GetBinContent(hweight2->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + // weight3 = mixpairweight * hweight3->GetBinContent(hweight3->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + // weight4 = mixpairweight * hweight4->GetBinContent(hweight4->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + // } + double weight = mixpairweight * (nuaWeightParticle1 / epsWeightParticle1) * (nuaWeightParticle2 / epsWeightParticle2); if (tag1 == 0 && tag2 == 0) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight1); - histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight1); - histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight1); - histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight1); - histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); + histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); + // histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); } else if (tag1 == 0 && tag2 == 1) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight2); - histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight2); - histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight2); - histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight2); - histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); + // histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); } else if (tag1 == 1 && tag2 == 0) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight3); - histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight3); - histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight3); - histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight3); - histos.fill(HIST("hLambdaMixForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); + histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); + // histos.fill(HIST("hLambdaMixForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); } else if (tag1 == 1 && tag2 == 1) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight4); - histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight4); - histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight4); - histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight4); - histos.fill(HIST("hAntiLambdaMixForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight4); + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); + // histos.fill(HIST("hAntiLambdaMixForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight4); } } } @@ -481,6 +551,14 @@ struct lambdaspincorrderived { histos.fill(HIST("etaCent"), v0.lambdaEta(), centrality); proton = ROOT::Math::PtEtaPhiMVector(v0.protonPt(), v0.protonEta(), v0.protonPhi(), o2::constants::physics::MassProton); lambda = ROOT::Math::PtEtaPhiMVector(v0.lambdaPt(), v0.lambdaEta(), v0.lambdaPhi(), v0.lambdaMass()); + + auto phiH0 = RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic); + if (v0.v0Status() == 0) { + histos.fill(HIST("hSE_L"), v0.lambdaPt(), v0.lambdaEta(), phiH0); + } else { + histos.fill(HIST("hSE_AL"), v0.lambdaPt(), v0.lambdaEta(), phiH0); + } + for (const auto& v02 : V0s) { if (v02.index() <= v0.index()) { continue; @@ -498,16 +576,16 @@ struct lambdaspincorrderived { lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass()); histos.fill(HIST("deltaPhiSame"), std::abs(RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(v02.lambdaPhi(), 0.0F, harmonic))); if (v0.v0Status() == 0 && v02.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 0, 1.0); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0); } if (v0.v0Status() == 0 && v02.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 0, 1.0); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0); } if (v0.v0Status() == 1 && v02.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 0, 1.0); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0); } if (v0.v0Status() == 1 && v02.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 0, 1.0); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0); } } } @@ -570,16 +648,16 @@ struct lambdaspincorrderived { lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); histos.fill(HIST("deltaPhiMix"), std::abs(RecoDecay::constrainAngle(t3.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(t2.lambdaPhi(), 0.0F, harmonic))); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, 1.0); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, 1.0); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, 1.0); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, 1.0); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1); } } } // replacement track pair @@ -650,16 +728,16 @@ struct lambdaspincorrderived { histos.fill(HIST("deltaPhiMix"), dPhi, invN); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, invN); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, invN, 1); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, invN); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, invN, 1); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, invN); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, invN, 1); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, invN); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, invN, 1); } } } // end mixing-event loop @@ -698,7 +776,30 @@ struct lambdaspincorrderived { if (t1.pionIndex() == t2.pionIndex()) continue; - // --- First pass over previous events in this bin: count replacements and build a list of usable pools + // --- Decide randomly which leg to replace: true=t1, false=t2 + const bool replaceFirst = (gRandom->Rndm() < 0.5); // requires or + + // Kinematics of the SE leg we attempt to replace + auto fillDen = [&](const auto& t) { + const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); + if (t.v0Status() == 0) + histos.fill(HIST("hMatchDen_L"), t.lambdaPt(), t.lambdaEta(), phiH); + else + histos.fill(HIST("hMatchDen_AL"), t.lambdaPt(), t.lambdaEta(), phiH); + }; + + auto fillNum = [&](const auto& t) { + const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); + if (t.v0Status() == 0) + histos.fill(HIST("hMatchNum_L"), t.lambdaPt(), t.lambdaEta(), phiH); + else + histos.fill(HIST("hMatchNum_AL"), t.lambdaPt(), t.lambdaEta(), phiH); + }; + + // Denominator: every SE leg we *try* to replace counts once + fillDen(replaceFirst ? t1 : t2); + + // --- First pass over previous events: count replacements for the chosen leg int mixes = 0; struct PoolView { AllTrackCandidates* pool; @@ -712,14 +813,14 @@ struct lambdaspincorrderived { it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { const int collision2idx = it->first; auto& poolB = it->second; - - // (defensive; shouldn't happen because we push the current event after mixing) if (collision2idx == collision1.index()) - continue; + continue; // safety int nRepl = 0; - for (auto& t3 : poolB) { - if (selectionV0(t3) && checkKinematics(t1, t3)) + for (auto& tX : poolB) { + if (!selectionV0(tX)) + continue; + if (replaceFirst ? checkKinematics(t1, tX) : checkKinematics(t2, tX)) ++nRepl; } if (nRepl > 0) { @@ -728,36 +829,48 @@ struct lambdaspincorrderived { } } + // Numerator: counts only if at least one replacement exists + if (totalRepl > 0) { + fillNum(replaceFirst ? t1 : t2); + } + if (totalRepl == 0) continue; - const float w = 1.0f / static_cast(totalRepl); // global normalization: sum of weights over all replacements = 1 + const float wBase = 1.0f / static_cast(totalRepl); - // --- Second pass: fill with normalized weight w + // --- Second pass: actually build mixed pairs for the chosen leg for (auto& pv : usable) { auto& poolB = *pv.pool; - for (auto& t3 : poolB) { - if (!(selectionV0(t3) && checkKinematics(t1, t3))) + for (auto& tX : poolB) { + if (!selectionV0(tX)) + continue; + if (!(replaceFirst ? checkKinematics(t1, tX) : checkKinematics(t2, tX))) continue; - // build 4-vectors for the mixed pair (t3 from prior event replaces t1; t2 stays from current event) - proton = ROOT::Math::PtEtaPhiMVector(t3.protonPt(), t3.protonEta(), t3.protonPhi(), o2::constants::physics::MassProton); - lambda = ROOT::Math::PtEtaPhiMVector(t3.lambdaPt(), t3.lambdaEta(), t3.lambdaPhi(), t3.lambdaMass()); - proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); - lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); - - float dPhi = std::fabs( - RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); - histos.fill(HIST("deltaPhiMix"), dPhi, w); - - if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, w); - } else if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, w); - } else if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, w); - } else if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, w); + if (replaceFirst) { + // Replace t1 with tX; keep t2 + proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + + const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - + RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, wBase); + + fillHistograms(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 1); + } else { + // Replace t2 with tX; keep t1 + proton = ROOT::Math::PtEtaPhiMVector(t1.protonPt(), t1.protonEta(), t1.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(t1.lambdaPt(), t1.lambdaEta(), t1.lambdaPhi(), t1.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); + + const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - + RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, wBase); + + fillHistograms(t1.v0Status(), tX.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 2); } } } @@ -765,6 +878,19 @@ struct lambdaspincorrderived { // after mixing with prior events, push current event into the pool auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + + // --- ME singles (one fill per candidate) for this event entering the pool --- + for (auto& t : sliced) { + if (!selectionV0(t)) + continue; + const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); + if (t.v0Status() == 0) { + histos.fill(HIST("hME_L"), t.lambdaPt(), t.lambdaEta(), phiH); + } else { + histos.fill(HIST("hME_AL"), t.lambdaPt(), t.lambdaEta(), phiH); + } + } + eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); if (static_cast(eventPools[bin].size()) > nEvtMixing) { eventPools[bin].pop_front(); From 51d87a4aea60d3bd345ba32966d3f949c592ba16 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Mon, 6 Oct 2025 15:17:21 +0200 Subject: [PATCH 16/25] Fix issue with efficiency weight --- .../Strangeness/lambdaspincorrderived.cxx | 107 +++++------------- 1 file changed, 29 insertions(+), 78 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 513acb7db8a..f542a8c8fc7 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -80,13 +80,9 @@ struct lambdaspincorrderived { // Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; // Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - Configurable ConfRPathL{"ConfRPathL", "", "CCDB path to R_L (optional)"}; - Configurable ConfRPathAL{"ConfRPathAL", "", "CCDB path to R_AL (optional)"}; Configurable ConfEffPathL{"ConfEffPathL", "", "CCDB path to Eff (optional)"}; Configurable ConfEffPathAL{"ConfEffPathAL", "", "CCDB path to Eff (optional)"}; - TH3D* hR_L = nullptr; - TH3D* hR_AL = nullptr; TH3D* hEff_L = nullptr; TH3D* hEff_AL = nullptr; @@ -140,12 +136,6 @@ struct lambdaspincorrderived { histos.add("ptCent", "ptCent", HistType::kTH2D, {{100, 0.0, 10.0}, {8, 0.0, 80.0}}, true); histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); - // --- Singles QA for data-driven MIXED reweight (one fill per candidate) --- - histos.add("hSE_L", "SE #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hSE_AL", "SE #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hME_L", "ME #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hME_AL", "ME #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // Attempted-for-replacement (Den) and Succeeded (Num) per SE leg kinematics histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); @@ -203,8 +193,6 @@ struct lambdaspincorrderived { ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); LOGF(info, "Getting alignment offsets from the CCDB..."); if (useweight) { - hR_L = ccdb->getForTimeStamp(ConfRPathL.value, cfgCcdbParam.nolaterthan.value); - hR_AL = ccdb->getForTimeStamp(ConfRPathAL.value, cfgCcdbParam.nolaterthan.value); hEff_L = ccdb->getForTimeStamp(ConfEffPathL.value, cfgCcdbParam.nolaterthan.value); hEff_AL = ccdb->getForTimeStamp(ConfEffPathAL.value, cfgCcdbParam.nolaterthan.value); // hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); @@ -421,7 +409,9 @@ struct lambdaspincorrderived { auto costhetaz1costhetaz2 = -999.0; if (cosDef == 0) { cosThetaDiff = cosDeltaTheta_STAR_naive; - costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); + if (proton1LambdaRF.P() * proton2LambdaRF.P() != 0.0) { + costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); + } } else { cosThetaDiff = cosDeltaTheta_hel; costhetaz1costhetaz2 = cosDeltaTheta_beam; @@ -432,38 +422,20 @@ struct lambdaspincorrderived { double deltaRap = std::abs(particle1Dummy.Rapidity() - particle2Dummy.Rapidity()); double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); - double nuaWeightParticle1 = 1.0, epsWeightParticle1 = 1.0; - double nuaWeightParticle2 = 1.0, epsWeightParticle2 = 1.0; - - if (useweight && datatype == 1) { - // particle 1 - { - auto* hR = (tag1 == 0 ? hR_L : hR_AL); - auto* hEff = (tag1 == 0 ? hEff_L : hEff_AL); + double epsWeightParticle1 = 1.0; + double epsWeightParticle2 = 1.0; - float pt = particle1.Pt(); - float eta = particle1.Eta(); - float phi = RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic); - - nuaWeightParticle1 = hR->GetBinContent(hR->FindBin(pt, eta, phi)); - if (replacedFlag == 1) { - epsWeightParticle1 = hEff->GetBinContent(hEff->FindBin(pt, eta, phi)); - } + if (useweight && datatype == 1 && replacedFlag == 1) { + if (tag1 == 0) { + epsWeightParticle1 = hEff_L->GetBinContent(hEff_L->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + } else { + epsWeightParticle1 = hEff_AL->GetBinContent(hEff_AL->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); } - - // particle 2 - { - auto* hR = (tag2 == 0 ? hR_L : hR_AL); - auto* hEff = (tag2 == 0 ? hEff_L : hEff_AL); - - float pt = particle2.Pt(); - float eta = particle2.Eta(); - float phi = RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic); - - nuaWeightParticle2 = hR->GetBinContent(hR->FindBin(pt, eta, phi)); - if (replacedFlag == 2) { - epsWeightParticle2 = hEff->GetBinContent(hEff->FindBin(pt, eta, phi)); - } + } else if (useweight && datatype == 1 && replacedFlag == 2) { + if (tag2 == 0) { + epsWeightParticle2 = hEff_L->GetBinContent(hEff_L->FindBin(particle2.Pt(), particle2.Eta(), RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic))); + } else { + epsWeightParticle2 = hEff_AL->GetBinContent(hEff_AL->FindBin(particle2.Pt(), particle2.Eta(), RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic))); } } @@ -492,17 +464,16 @@ struct lambdaspincorrderived { // histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } } else if (datatype == 1) { - // double weight1 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; - // double weight2 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; - // double weight3 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; - // double weight4 = mixpairweight*nuaWeightParticle1*nuaWeightParticle2; - // if (useweight) { - // weight1 = mixpairweight * hweight1->GetBinContent(hweight1->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - // weight2 = mixpairweight * hweight2->GetBinContent(hweight2->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - // weight3 = mixpairweight * hweight3->GetBinContent(hweight3->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - // weight4 = mixpairweight * hweight4->GetBinContent(hweight4->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - // } - double weight = mixpairweight * (nuaWeightParticle1 / epsWeightParticle1) * (nuaWeightParticle2 / epsWeightParticle2); + double weight = mixpairweight; + if (useweight && replacedFlag == 1) { + weight = mixpairweight / epsWeightParticle1; + } + if (useweight && replacedFlag == 2) { + weight = mixpairweight / epsWeightParticle2; + } + if (weight <= 0.0) { + weight = 1.0; + } if (tag1 == 0 && tag2 == 0) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); @@ -552,13 +523,6 @@ struct lambdaspincorrderived { proton = ROOT::Math::PtEtaPhiMVector(v0.protonPt(), v0.protonEta(), v0.protonPhi(), o2::constants::physics::MassProton); lambda = ROOT::Math::PtEtaPhiMVector(v0.lambdaPt(), v0.lambdaEta(), v0.lambdaPhi(), v0.lambdaMass()); - auto phiH0 = RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic); - if (v0.v0Status() == 0) { - histos.fill(HIST("hSE_L"), v0.lambdaPt(), v0.lambdaEta(), phiH0); - } else { - histos.fill(HIST("hSE_AL"), v0.lambdaPt(), v0.lambdaEta(), phiH0); - } - for (const auto& v02 : V0s) { if (v02.index() <= v0.index()) { continue; @@ -803,11 +767,11 @@ struct lambdaspincorrderived { int mixes = 0; struct PoolView { AllTrackCandidates* pool; - int nRepl; + double nRepl; int collIdx; }; std::vector usable; - int totalRepl = 0; + double totalRepl = 0; for (auto it = eventPools[bin].rbegin(); it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { @@ -816,7 +780,7 @@ struct lambdaspincorrderived { if (collision2idx == collision1.index()) continue; // safety - int nRepl = 0; + double nRepl = 0; for (auto& tX : poolB) { if (!selectionV0(tX)) continue; @@ -836,8 +800,8 @@ struct lambdaspincorrderived { if (totalRepl == 0) continue; - const float wBase = 1.0f / static_cast(totalRepl); + const float wBase = 1.0f / totalRepl; // --- Second pass: actually build mixed pairs for the chosen leg for (auto& pv : usable) { auto& poolB = *pv.pool; @@ -878,19 +842,6 @@ struct lambdaspincorrderived { // after mixing with prior events, push current event into the pool auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); - - // --- ME singles (one fill per candidate) for this event entering the pool --- - for (auto& t : sliced) { - if (!selectionV0(t)) - continue; - const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); - if (t.v0Status() == 0) { - histos.fill(HIST("hME_L"), t.lambdaPt(), t.lambdaEta(), phiH); - } else { - histos.fill(HIST("hME_AL"), t.lambdaPt(), t.lambdaEta(), phiH); - } - } - eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); if (static_cast(eventPools[bin].size()) > nEvtMixing) { eventPools[bin].pop_front(); From 864129180a82d7cefb3791c18c2926d677ed58cd Mon Sep 17 00:00:00 2001 From: skundu692 Date: Wed, 8 Oct 2025 15:18:57 +0200 Subject: [PATCH 17/25] Code clean up, fix weight calculation --- .../Strangeness/lambdaspincorrderived.cxx | 337 +++++------------- 1 file changed, 98 insertions(+), 239 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index f542a8c8fc7..aaf8ec902f5 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -137,24 +137,11 @@ struct lambdaspincorrderived { histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); // Attempted-for-replacement (Den) and Succeeded (Num) per SE leg kinematics - histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - - // histos.add("hLambdaNUA", "hLambdaNUA", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hAntiLambdaNUA", "hAntiLambdaNUA", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - - // histos.add("hLambdaSameForLL", "hLambdaSameForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hLambdaSameForLAL", "hLambdaSameForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hLambdaSameForALL", "hLambdaSameForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hAntiLambdaSameForALAL", "hAntiLambdaSameForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - - // histos.add("hLambdaMixForLL", "hLambdaMixForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hLambdaMixForLAL", "hLambdaMixForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hLambdaMixForALL", "hLambdaMixForALL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - // histos.add("hAntiLambdaMixForALAL", "hAntiLambdaMixForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); @@ -176,16 +163,6 @@ struct lambdaspincorrderived { histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparsePhiLambdaLambda", "hSparsePhiLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiLambdaAntiLambda", "hSparsePhiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiAntiLambdaLambda", "hSparsePhiAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiAntiLambdaAntiLambda", "hSparsePhiAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - - histos.add("hSparsePhiLambdaLambdaMixed", "hSparsePhiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiLambdaAntiLambdaMixed", "hSparsePhiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiAntiLambdaLambdaMixed", "hSparsePhiAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - histos.add("hSparsePhiAntiLambdaAntiLambdaMixed", "hSparsePhiAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPhi}, true); - ccdb->setURL(cfgCcdbParam.cfgURL); ccdbApi.init("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -195,10 +172,6 @@ struct lambdaspincorrderived { if (useweight) { hEff_L = ccdb->getForTimeStamp(ConfEffPathL.value, cfgCcdbParam.nolaterthan.value); hEff_AL = ccdb->getForTimeStamp(ConfEffPathAL.value, cfgCcdbParam.nolaterthan.value); - // hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); - // hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); - // hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); - // hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); } } @@ -263,7 +236,7 @@ struct lambdaspincorrderived { void fillHistograms(int tag1, int tag2, const ROOT::Math::PtEtaPhiMVector& particle1, const ROOT::Math::PtEtaPhiMVector& particle2, const ROOT::Math::PtEtaPhiMVector& daughpart1, const ROOT::Math::PtEtaPhiMVector& daughpart2, - int datatype, float mixpairweight, int replacedFlag) + int datatype, float mixpairweight) { auto lambda1Mass = 0.0; @@ -296,95 +269,6 @@ struct lambdaspincorrderived { auto proton1LambdaRF = boostLambda1ToCM(proton1pairCM); auto proton2LambdaRF = boostLambda2ToCM(proton2pairCM); - // =================== Opening-angle correlator: cos(Δθ) for helicity-z and beam-z =================== - - // Proton unit directions in Λ rest frames - TVector3 k1(proton1LambdaRF.Px(), proton1LambdaRF.Py(), proton1LambdaRF.Pz()); - k1 = k1.Unit(); - TVector3 k2(proton2LambdaRF.Px(), proton2LambdaRF.Py(), proton2LambdaRF.Pz()); - k2 = k2.Unit(); - - // Helper: boost a spacelike axis (t=0) from PRF into a Λ rest frame - auto transport = [](const TVector3& v, const ROOT::Math::Boost& B) -> TVector3 { - ROOT::Math::PxPyPzEVector a(v.X(), v.Y(), v.Z(), 0.0); - auto ar = B(a); - TVector3 out(ar.Px(), ar.Py(), ar.Pz()); - return (out.Mag2() > 0) ? out.Unit() : out; - }; - - // ----------------------------- (1) Helicity-z construction ----------------------------- - // z along Λ1 in PRF - TVector3 zPRF(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); - if (zPRF.Mag2() == 0) - zPRF = TVector3(0, 0, 1); - zPRF = zPRF.Unit(); - - // transverse axes in PRF - TVector3 ref(0, 0, 1); - if (std::abs(zPRF.Dot(ref)) > 0.999) - ref = TVector3(1, 0, 0); - TVector3 xPRF = (ref - (ref.Dot(zPRF)) * zPRF).Unit(); - TVector3 yPRF = (zPRF.Cross(xPRF)).Unit(); - - // carry PRF triad to Λ rest frames (flip triad for Λ2 to keep same PRF-handedness) - TVector3 z1_h = transport(zPRF, boostLambda1ToCM); - TVector3 x1_h = transport(xPRF, boostLambda1ToCM); - TVector3 y1_h = transport(yPRF, boostLambda1ToCM); - - TVector3 z2_h = transport(-zPRF, boostLambda2ToCM); - TVector3 x2_h = transport(-xPRF, boostLambda2ToCM); - TVector3 y2_h = transport(-yPRF, boostLambda2ToCM); - - // angles and cosΔθ (helicity) - double c1_h = k1.Dot(z1_h); - double s1_h = std::sqrt(std::max(0.0, 1.0 - c1_h * c1_h)); - double phi1_h = std::atan2(k1.Dot(y1_h), k1.Dot(x1_h)); - - double c2_h = k2.Dot(z2_h); - double s2_h = std::sqrt(std::max(0.0, 1.0 - c2_h * c2_h)); - double phi2_h = std::atan2(k2.Dot(y2_h), k2.Dot(x2_h)); - - double cosDeltaTheta_hel = c1_h * c2_h + s1_h * s2_h * std::cos(phi1_h - phi2_h); - if (cosDeltaTheta_hel > 1.0) - cosDeltaTheta_hel = 1.0; - if (cosDeltaTheta_hel < -1.0) - cosDeltaTheta_hel = -1.0; - - // ------------------------------- (2) Beam-z construction ------------------------------- - // z along beam in PRF; choose x by projecting Λ1 onto the ⟂ plane to fix azimuth zero - TVector3 zB(0, 0, 1); - TVector3 L1dir(lambda1CM.Px(), lambda1CM.Py(), lambda1CM.Pz()); - L1dir = L1dir.Unit(); - TVector3 xB = L1dir - (L1dir.Dot(zB)) * zB; - if (xB.Mag2() < 1e-12) - xB = TVector3(1, 0, 0); - xB = xB.Unit(); - TVector3 yB = (zB.Cross(xB)).Unit(); - - // carry beam triad to Λ rest frames (no flip for a common external axis) - TVector3 z1_b = transport(zB, boostLambda1ToCM); - TVector3 x1_b = transport(xB, boostLambda1ToCM); - TVector3 y1_b = transport(yB, boostLambda1ToCM); - - TVector3 z2_b = transport(zB, boostLambda2ToCM); - TVector3 x2_b = transport(xB, boostLambda2ToCM); - TVector3 y2_b = transport(yB, boostLambda2ToCM); - - // angles and cosΔθ (beam) - double c1_b = k1.Dot(z1_b); - double s1_b = std::sqrt(std::max(0.0, 1.0 - c1_b * c1_b)); - double phi1_b = std::atan2(k1.Dot(y1_b), k1.Dot(x1_b)); - - double c2_b = k2.Dot(z2_b); - double s2_b = std::sqrt(std::max(0.0, 1.0 - c2_b * c2_b)); - double phi2_b = std::atan2(k2.Dot(y2_b), k2.Dot(x2_b)); - - double cosDeltaTheta_beam = c1_b * c2_b + s1_b * s2_b * std::cos(phi1_b - phi2_b); - if (cosDeltaTheta_beam > 1.0) - cosDeltaTheta_beam = 1.0; - if (cosDeltaTheta_beam < -1.0) - cosDeltaTheta_beam = -1.0; - // --- STAR-style Δθ (as written: dot product of proton directions in their own Λ RFs) --- // Boost each proton into its parent's rest frame @@ -398,23 +282,30 @@ struct lambdaspincorrderived { TVector3 u1 = TVector3(p1_LRF.Px(), p1_LRF.Py(), p1_LRF.Pz()).Unit(); TVector3 u2 = TVector3(p2_LRF.Px(), p2_LRF.Py(), p2_LRF.Pz()).Unit(); + // Proton unit directions in Λ rest frames + TVector3 k1(proton1LambdaRF.Px(), proton1LambdaRF.Py(), proton1LambdaRF.Pz()); + k1 = k1.Unit(); + TVector3 k2(proton2LambdaRF.Px(), proton2LambdaRF.Py(), proton2LambdaRF.Pz()); + k2 = k2.Unit(); + // STAR-style cosΔθ definition double cosDeltaTheta_STAR_naive = u1.Dot(u2); if (cosDeltaTheta_STAR_naive > 1.0) - cosDeltaTheta_STAR_naive = 1.0; + cosDeltaTheta_STAR_naive = 111.0; if (cosDeltaTheta_STAR_naive < -1.0) - cosDeltaTheta_STAR_naive = -1.0; + cosDeltaTheta_STAR_naive = -111.0; + + double cosDeltaTheta_hel = k1.Dot(k2); + if (cosDeltaTheta_hel > 1.0) + cosDeltaTheta_hel = 111.0; + if (cosDeltaTheta_hel < -1.0) + cosDeltaTheta_hel = -111.0; auto cosThetaDiff = -999.0; - auto costhetaz1costhetaz2 = -999.0; if (cosDef == 0) { cosThetaDiff = cosDeltaTheta_STAR_naive; - if (proton1LambdaRF.P() * proton2LambdaRF.P() != 0.0) { - costhetaz1costhetaz2 = (proton1LambdaRF.Pz() * proton2LambdaRF.Pz()) / (proton1LambdaRF.P() * proton2LambdaRF.P()); - } } else { cosThetaDiff = cosDeltaTheta_hel; - costhetaz1costhetaz2 = cosDeltaTheta_beam; } double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); @@ -423,20 +314,13 @@ struct lambdaspincorrderived { double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); double epsWeightParticle1 = 1.0; - double epsWeightParticle2 = 1.0; - if (useweight && datatype == 1 && replacedFlag == 1) { + if (useweight && datatype == 1) { if (tag1 == 0) { epsWeightParticle1 = hEff_L->GetBinContent(hEff_L->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); } else { epsWeightParticle1 = hEff_AL->GetBinContent(hEff_AL->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); } - } else if (useweight && datatype == 1 && replacedFlag == 2) { - if (tag2 == 0) { - epsWeightParticle2 = hEff_L->GetBinContent(hEff_L->FindBin(particle2.Pt(), particle2.Eta(), RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic))); - } else { - epsWeightParticle2 = hEff_AL->GetBinContent(hEff_AL->FindBin(particle2.Pt(), particle2.Eta(), RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic))); - } } if (datatype == 0) { @@ -445,32 +329,19 @@ struct lambdaspincorrderived { if (tag1 == 0 && tag2 == 0) { histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - // histos.fill(HIST("hLambdaSameForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - // histos.fill(HIST("hLambdaSameForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - // histos.fill(HIST("hLambdaSameForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, mixpairweight); - // histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); } } else if (datatype == 1) { double weight = mixpairweight; - if (useweight && replacedFlag == 1) { - weight = mixpairweight / epsWeightParticle1; - } - if (useweight && replacedFlag == 2) { - weight = mixpairweight / epsWeightParticle2; - } + weight = mixpairweight / epsWeightParticle1; if (weight <= 0.0) { weight = 1.0; } @@ -478,26 +349,18 @@ struct lambdaspincorrderived { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); - // histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); - // histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); - // histos.fill(HIST("hLambdaMixForALL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), costhetaz1costhetaz2, deltaPhi, weight); - // histos.fill(HIST("hAntiLambdaMixForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight4); } } } @@ -536,20 +399,26 @@ struct lambdaspincorrderived { if (v0.pionIndex() == v02.pionIndex()) { continue; } + if (v0.protonIndex() == v02.pionIndex()) { + continue; + } + if (v0.pionIndex() == v02.protonIndex()) { + continue; + } proton2 = ROOT::Math::PtEtaPhiMVector(v02.protonPt(), v02.protonEta(), v02.protonPhi(), o2::constants::physics::MassProton); lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass()); histos.fill(HIST("deltaPhiSame"), std::abs(RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(v02.lambdaPhi(), 0.0F, harmonic))); if (v0.v0Status() == 0 && v02.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 0 && v02.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 1 && v02.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 0, 1.0); } if (v0.v0Status() == 1 && v02.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 0, 1.0); } } } @@ -612,16 +481,16 @@ struct lambdaspincorrderived { lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); histos.fill(HIST("deltaPhiMix"), std::abs(RecoDecay::constrainAngle(t3.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(t2.lambdaPhi(), 0.0F, harmonic))); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, 1.0); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, 1.0); } } } // replacement track pair @@ -692,16 +561,16 @@ struct lambdaspincorrderived { histos.fill(HIST("deltaPhiMix"), dPhi, invN); if (t3.v0Status() == 0 && t2.v0Status() == 0) { - fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, invN, 1); + fillHistograms(0, 0, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 0 && t2.v0Status() == 1) { - fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, invN, 1); + fillHistograms(0, 1, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 1 && t2.v0Status() == 0) { - fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, invN, 1); + fillHistograms(1, 0, lambda, lambda2, proton, proton2, 1, invN); } if (t3.v0Status() == 1 && t2.v0Status() == 1) { - fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, invN, 1); + fillHistograms(1, 1, lambda, lambda2, proton, proton2, 1, invN); } } } // end mixing-event loop @@ -726,10 +595,21 @@ struct lambdaspincorrderived { // select mixing bin for this event const int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); + // --- if pool is still empty, just store this event and skip mixing + if (eventPools[bin].empty()) { + auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); + if (static_cast(eventPools[bin].size()) > nEvtMixing) { + eventPools[bin].pop_front(); + } + continue; // skip directly to the next event + } + // all V0s from the current event auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); // loop over same-event candidate pairs (t1,t2) + int oldindex = -555; for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) { if (!selectionV0(t1) || !selectionV0(t2)) continue; @@ -740,106 +620,85 @@ struct lambdaspincorrderived { if (t1.pionIndex() == t2.pionIndex()) continue; - // --- Decide randomly which leg to replace: true=t1, false=t2 - const bool replaceFirst = (gRandom->Rndm() < 0.5); // requires or - - // Kinematics of the SE leg we attempt to replace - auto fillDen = [&](const auto& t) { - const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); - if (t.v0Status() == 0) - histos.fill(HIST("hMatchDen_L"), t.lambdaPt(), t.lambdaEta(), phiH); - else - histos.fill(HIST("hMatchDen_AL"), t.lambdaPt(), t.lambdaEta(), phiH); - }; - - auto fillNum = [&](const auto& t) { - const double phiH = RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic); - if (t.v0Status() == 0) - histos.fill(HIST("hMatchNum_L"), t.lambdaPt(), t.lambdaEta(), phiH); - else - histos.fill(HIST("hMatchNum_AL"), t.lambdaPt(), t.lambdaEta(), phiH); - }; - - // Denominator: every SE leg we *try* to replace counts once - fillDen(replaceFirst ? t1 : t2); - - // --- First pass over previous events: count replacements for the chosen leg + // --- First pass over previous events: count replacements for t1 (first leg) int mixes = 0; + struct PoolView { - AllTrackCandidates* pool; - double nRepl; - int collIdx; + AllTrackCandidates* pool; // pointer to slice of V0s from a prior event + int nRepl; // how many tX match t1 by checkKinematics }; + std::vector usable; - double totalRepl = 0; + int totalRepl = 0; for (auto it = eventPools[bin].rbegin(); it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { const int collision2idx = it->first; - auto& poolB = it->second; - if (collision2idx == collision1.index()) - continue; // safety - - double nRepl = 0; + auto& poolB = it->second; // V0 slice of that prior event in this bin + if (collision2idx == collision1.index()) { + continue; // skip same-event mixing + } + int nRepl = 0; for (auto& tX : poolB) { if (!selectionV0(tX)) continue; - if (replaceFirst ? checkKinematics(t1, tX) : checkKinematics(t2, tX)) - ++nRepl; + if (checkKinematics(t1, tX)) + ++nRepl; // <-- match against t1 only } + if (nRepl > 0) { - usable.push_back(PoolView{&poolB, nRepl, collision2idx}); + usable.push_back(PoolView{&poolB, nRepl}); totalRepl += nRepl; } } - // Numerator: counts only if at least one replacement exists - if (totalRepl > 0) { - fillNum(replaceFirst ? t1 : t2); + // --- Track-by-track matching efficiency (count each t1 once in this event) + if (t1.index() != oldindex) { + const double phi1 = RecoDecay::constrainAngle(t1.lambdaPhi(), 0.0F, harmonic); + if (t1.v0Status() == 0) { + histos.fill(HIST("hMatchDen_L"), t1.lambdaPt(), t1.lambdaEta(), phi1); + } else { + histos.fill(HIST("hMatchDen_AL"), t1.lambdaPt(), t1.lambdaEta(), phi1); + } + + if (totalRepl > 0) { // success for this t1 this event + if (t1.v0Status() == 0) { + histos.fill(HIST("hMatchNum_L"), t1.lambdaPt(), t1.lambdaEta(), phi1); + } else { + histos.fill(HIST("hMatchNum_AL"), t1.lambdaPt(), t1.lambdaEta(), phi1); + } + } + oldindex = t1.index(); } if (totalRepl == 0) - continue; + continue; // no viable replacement for this t1 + + // --- Second pass: build mixed pairs (tX replaces t1), normalized per-SE-leg + const float wBase = 1.0f / static_cast(totalRepl); - const float wBase = 1.0f / totalRepl; - // --- Second pass: actually build mixed pairs for the chosen leg for (auto& pv : usable) { auto& poolB = *pv.pool; for (auto& tX : poolB) { if (!selectionV0(tX)) continue; - if (!(replaceFirst ? checkKinematics(t1, tX) : checkKinematics(t2, tX))) - continue; + if (!checkKinematics(t1, tX)) + continue; // defensive re-check - if (replaceFirst) { - // Replace t1 with tX; keep t2 - proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); - lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); - proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); - lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); - - const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); - histos.fill(HIST("deltaPhiMix"), dPhi, wBase); - - fillHistograms(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 1); - } else { - // Replace t2 with tX; keep t1 - proton = ROOT::Math::PtEtaPhiMVector(t1.protonPt(), t1.protonEta(), t1.protonPhi(), o2::constants::physics::MassProton); - lambda = ROOT::Math::PtEtaPhiMVector(t1.lambdaPt(), t1.lambdaEta(), t1.lambdaPhi(), t1.lambdaMass()); - proton2 = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); - lambda2 = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); - - const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); - histos.fill(HIST("deltaPhiMix"), dPhi, wBase); + // Build mixed pair: tX (from prior event) replaces t1; t2 stays (current event) + proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); - fillHistograms(t1.v0Status(), tX.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 2); - } + const float dPhi = std::fabs( + RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - + RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, wBase); + fillHistograms(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase); } } } // end same-event pair loop - // after mixing with prior events, push current event into the pool auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); From 13c04046fd2f2cd87ff9782833af2070c6f73e19 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Wed, 8 Oct 2025 16:01:26 +0200 Subject: [PATCH 18/25] Fix histogram range --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index aaf8ec902f5..111fa2b514f 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -140,8 +140,8 @@ struct lambdaspincorrderived { histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {32, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); From c7b21f0a37d3288cd55708b2d37db60b0a472a69 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Fri, 10 Oct 2025 13:34:50 +0200 Subject: [PATCH 19/25] Add pait mass info --- .../Strangeness/lambdaspincorrderived.cxx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 111fa2b514f..ae2e7bb34a9 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -123,6 +123,7 @@ struct lambdaspincorrderived { ConfigurableAxis configThnAxisPol{"configThnAxisPol", {80, 0.0, 8.0}, "cos#it{#theta *}"}; ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0.0, 80.0}, "Centrality"}; ConfigurableAxis configThnAxisRapidity{"configThnAxisRapidity", {5, 0.0, 1.0}, "Rapidity"}; + ConfigurableAxis configThnAxisPairMass{"configThnAxisPairMass", {100, 2.0, 3.0}, "PairMass"}; ConfigurableAxis configThnAxisPhi{"configThnAxisPhi", {18, 0.0, 2.0 * TMath::Pi()}, "Phi"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -163,6 +164,16 @@ struct lambdaspincorrderived { histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparsePairMassLambdaLambda", "hSparsePairMassLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassLambdaAntiLambda", "hSparsePairMassLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaLambda", "hSparsePairMassAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaAntiLambda", "hSparsePairMassAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + + histos.add("hSparsePairMassLambdaLambdaMixed", "hSparsePairMassLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassLambdaAntiLambdaMixed", "hSparsePairMassLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaLambdaMixed", "hSparsePairMassAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaAntiLambdaMixed", "hSparsePairMassAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + ccdb->setURL(cfgCcdbParam.cfgURL); ccdbApi.init("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -329,15 +340,19 @@ struct lambdaspincorrderived { if (tag1 == 0 && tag2 == 0) { histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePairMassLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePairMassLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePairMassAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); } } else if (datatype == 1) { double weight = mixpairweight; @@ -349,18 +364,22 @@ struct lambdaspincorrderived { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePairMassLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePairMassLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePairMassAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); } } } @@ -619,6 +638,10 @@ struct lambdaspincorrderived { continue; // no shared daughter if (t1.pionIndex() == t2.pionIndex()) continue; + if (t1.protonIndex() == t2.pionIndex()) + continue; + if (t1.pionIndex() == t2.protonIndex()) + continue; // --- First pass over previous events: count replacements for t1 (first leg) int mixes = 0; From e59f26e73eb65fadce5c7c62c3a147b732c4a73c Mon Sep 17 00:00:00 2001 From: skundu692 Date: Sun, 12 Oct 2025 11:57:12 +0200 Subject: [PATCH 20/25] Improved mixed event acceptance calculation --- .../Strangeness/lambdaspincorrderived.cxx | 181 ++++++++---------- 1 file changed, 84 insertions(+), 97 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index ae2e7bb34a9..bd5e791a2fe 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -67,24 +67,14 @@ struct lambdaspincorrderived { // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. Service ccdb; o2::ccdb::CcdbApi ccdbApi; - // TH3D* hweightNUAL; - // TH3D* hweightNUAAL; - // TH3D* hweight1; - // TH3D* hweight2; - // TH3D* hweight3; - // TH3D* hweight4; - // Configurable ConfWeightPathNUAL{"ConfWeightPathNUAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - // Configurable ConfWeightPathNUAAL{"ConfWeightPathNUAAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - // Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - // Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - // Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - // Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; - - Configurable ConfEffPathL{"ConfEffPathL", "", "CCDB path to Eff (optional)"}; - Configurable ConfEffPathAL{"ConfEffPathAL", "", "CCDB path to Eff (optional)"}; - - TH3D* hEff_L = nullptr; - TH3D* hEff_AL = nullptr; + TH3D* hweight1; + TH3D* hweight2; + TH3D* hweight3; + TH3D* hweight4; + Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; // event sel///////// Configurable centMin{"centMin", 0, "Minimum Centrality"}; @@ -117,6 +107,11 @@ struct lambdaspincorrderived { Configurable phiMix{"phiMix", 0.1, "Phi cut on event mixing"}; Configurable massMix{"massMix", 0.0028, "Masscut on event mixing"}; + // --- Pair-space axes (add near your other ConfigurableAxis) + ConfigurableAxis ax_dphi_h{"ax_dphi_h", {72, 0.0, 2.0 * TMath::Pi()}, "Δφ_h"}; + ConfigurableAxis ax_deta{"ax_deta", {32, -1.6, 1.6}, "Δη"}; + ConfigurableAxis ax_ptpair{"ax_ptpair", {100, 0.0, 10.0}, "p_{T,pair} (GeV/c)"}; + // THnsparse bining ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {50, 1.09, 1.14}, "#it{M} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisR{"configThnAxisR", {80, 0.0, 8.0}, "#it{R}"}; @@ -137,12 +132,17 @@ struct lambdaspincorrderived { histos.add("ptCent", "ptCent", HistType::kTH2D, {{100, 0.0, 10.0}, {8, 0.0, 80.0}}, true); histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); - // Attempted-for-replacement (Den) and Succeeded (Num) per SE leg kinematics - histos.add("hMatchDen_L", "Attempted #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchDen_AL", "Attempted #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + // --- 3D SE/ME pair-space maps per category (LL, LAL, ALL, ALAL) + // SE = same-event (unit weight), ME = mixed-event (uses your mixing+CCDB weight) + histos.add("SE_LL", "SE pairs LL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_LAL", "SE pairs LAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALL", "SE pairs ALL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALAL", "SE pairs ALAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("hMatchNum_L", "Succeeded #Lambda; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); - histos.add("hMatchNum_AL", "Succeeded #bar{#Lambda}; p_{T}; #eta; #varphi", kTH3D, {{50, 0.0, 5.0}, {40, -1.0, 1.0}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("ME_LL", "ME pairs LL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_LAL", "ME pairs LAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALL", "ME pairs ALL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALAL", "ME pairs ALAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); @@ -181,8 +181,10 @@ struct lambdaspincorrderived { ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); LOGF(info, "Getting alignment offsets from the CCDB..."); if (useweight) { - hEff_L = ccdb->getForTimeStamp(ConfEffPathL.value, cfgCcdbParam.nolaterthan.value); - hEff_AL = ccdb->getForTimeStamp(ConfEffPathAL.value, cfgCcdbParam.nolaterthan.value); + hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); + hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); + hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); + hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); } } @@ -319,18 +321,26 @@ struct lambdaspincorrderived { cosThetaDiff = cosDeltaTheta_hel; } - double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); - double deltaEta = particle1Dummy.Eta() - particle2Dummy.Eta(); + // --- helper to compute pair-space variables + auto phi1h = RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic); + auto phi2h = RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic); + double dphi_h = std::abs(phi1h - phi2h); + double deta_pair = particle1Dummy.Eta() - particle2Dummy.Eta(); + double pt_pair = (particle1Dummy + particle2Dummy).Pt(); double deltaRap = std::abs(particle1Dummy.Rapidity() - particle2Dummy.Rapidity()); - double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); + double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_h * dphi_h); - double epsWeightParticle1 = 1.0; + double epsWeight = 1.0; if (useweight && datatype == 1) { - if (tag1 == 0) { - epsWeightParticle1 = hEff_L->GetBinContent(hEff_L->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); - } else { - epsWeightParticle1 = hEff_AL->GetBinContent(hEff_AL->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + if (tag1 == 0 && tag2 == 0) { + epsWeight = hweight1->GetBinContent(hweight1->FindBin(dphi_h, deta_pair, pt_pair)); + } else if (tag1 == 0 && tag2 == 1) { + epsWeight = hweight2->GetBinContent(hweight2->FindBin(dphi_h, deta_pair, pt_pair)); + } else if (tag1 == 1 && tag2 == 0) { + epsWeight = hweight3->GetBinContent(hweight3->FindBin(dphi_h, deta_pair, pt_pair)); + } else if (tag1 == 1 && tag2 == 1) { + epsWeight = hweight4->GetBinContent(hweight4->FindBin(dphi_h, deta_pair, pt_pair)); } } @@ -341,22 +351,26 @@ struct lambdaspincorrderived { histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePairMassLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + histos.fill(HIST("SE_LL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePairMassLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + histos.fill(HIST("SE_LAL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePairMassAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + histos.fill(HIST("SE_ALL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + histos.fill(HIST("SE_ALAL"), dphi_h, deta_pair, pt_pair); } } else if (datatype == 1) { double weight = mixpairweight; - weight = mixpairweight / epsWeightParticle1; + weight = mixpairweight / epsWeight; if (weight <= 0.0) { weight = 1.0; } @@ -365,21 +379,25 @@ struct lambdaspincorrderived { histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); histos.fill(HIST("hSparsePairMassLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + histos.fill(HIST("ME_LL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); histos.fill(HIST("hSparsePairMassLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + histos.fill(HIST("ME_LAL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); histos.fill(HIST("hSparsePairMassAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + histos.fill(HIST("ME_ALL"), dphi_h, deta_pair, pt_pair); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + histos.fill(HIST("ME_ALAL"), dphi_h, deta_pair, pt_pair); } } } @@ -606,36 +624,32 @@ struct lambdaspincorrderived { void processMEV3(EventCandidates const& collisions, AllTrackCandidates const& V0s) { - // one pool (deque) per mixing bin; each entry holds (collision index, slice of its V0s) auto nBins = colBinning.getAllBinsCount(); std::vector>> eventPools(nBins); for (auto& collision1 : collisions) { - // select mixing bin for this event const int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); - // --- if pool is still empty, just store this event and skip mixing + // if pool empty, push and continue if (eventPools[bin].empty()) { auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); - if (static_cast(eventPools[bin].size()) > nEvtMixing) { + if ((int)eventPools[bin].size() > nEvtMixing) eventPools[bin].pop_front(); - } - continue; // skip directly to the next event + continue; } - // all V0s from the current event + // current event slice auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); - // loop over same-event candidate pairs (t1,t2) - int oldindex = -555; + // loop over SE unordered pairs (t1,t2) for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) { if (!selectionV0(t1) || !selectionV0(t2)) continue; if (t2.index() <= t1.index()) - continue; // unique unordered pairs + continue; if (t1.protonIndex() == t2.protonIndex()) - continue; // no shared daughter + continue; if (t1.pionIndex() == t2.pionIndex()) continue; if (t1.protonIndex() == t2.pionIndex()) @@ -643,94 +657,67 @@ struct lambdaspincorrderived { if (t1.pionIndex() == t2.protonIndex()) continue; - // --- First pass over previous events: count replacements for t1 (first leg) - int mixes = 0; - - struct PoolView { - AllTrackCandidates* pool; // pointer to slice of V0s from a prior event - int nRepl; // how many tX match t1 by checkKinematics + // scan prior events for replacements for t1 + struct PV { + AllTrackCandidates* pool; + int nRepl; }; - - std::vector usable; + std::vector usable; int totalRepl = 0; + int mixes = 0; for (auto it = eventPools[bin].rbegin(); it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { const int collision2idx = it->first; - auto& poolB = it->second; // V0 slice of that prior event in this bin - if (collision2idx == collision1.index()) { - continue; // skip same-event mixing - } + auto& poolB = it->second; + if (collision2idx == collision1.index()) + continue; + int nRepl = 0; for (auto& tX : poolB) { if (!selectionV0(tX)) continue; if (checkKinematics(t1, tX)) - ++nRepl; // <-- match against t1 only + ++nRepl; } - if (nRepl > 0) { - usable.push_back(PoolView{&poolB, nRepl}); + usable.push_back(PV{&poolB, nRepl}); totalRepl += nRepl; } } - // --- Track-by-track matching efficiency (count each t1 once in this event) - if (t1.index() != oldindex) { - const double phi1 = RecoDecay::constrainAngle(t1.lambdaPhi(), 0.0F, harmonic); - if (t1.v0Status() == 0) { - histos.fill(HIST("hMatchDen_L"), t1.lambdaPt(), t1.lambdaEta(), phi1); - } else { - histos.fill(HIST("hMatchDen_AL"), t1.lambdaPt(), t1.lambdaEta(), phi1); - } - - if (totalRepl > 0) { // success for this t1 this event - if (t1.v0Status() == 0) { - histos.fill(HIST("hMatchNum_L"), t1.lambdaPt(), t1.lambdaEta(), phi1); - } else { - histos.fill(HIST("hMatchNum_AL"), t1.lambdaPt(), t1.lambdaEta(), phi1); - } - } - oldindex = t1.index(); - } - if (totalRepl == 0) - continue; // no viable replacement for this t1 - - // --- Second pass: build mixed pairs (tX replaces t1), normalized per-SE-leg + continue; const float wBase = 1.0f / static_cast(totalRepl); + // emit mixed pairs: tX replaces t1; t2 stays for (auto& pv : usable) { auto& poolB = *pv.pool; for (auto& tX : poolB) { if (!selectionV0(tX)) continue; if (!checkKinematics(t1, tX)) - continue; // defensive re-check + continue; - // Build mixed pair: tX (from prior event) replaces t1; t2 stays (current event) - proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); - lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); - proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); - lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + auto proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); + auto lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); + auto proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + auto lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); - const float dPhi = std::fabs( - RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); histos.fill(HIST("deltaPhiMix"), dPhi, wBase); fillHistograms(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase); } } - } // end same-event pair loop - // after mixing with prior events, push current event into the pool + } + // push current event into pool auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); - if (static_cast(eventPools[bin].size()) > nEvtMixing) { + if ((int)eventPools[bin].size() > nEvtMixing) eventPools[bin].pop_front(); - } - } // end primary-event loop + } } - PROCESS_SWITCH(lambdaspincorrderived, processMEV3, "Process data ME", false); + PROCESS_SWITCH(lambdaspincorrderived, processMEV3, "Process data ME (first-leg, pair-3D maps)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { From 7b1f622a7ab34c1d83b5afe7ba2002275b0807c2 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Sun, 12 Oct 2025 12:09:00 +0200 Subject: [PATCH 21/25] Improve mix event weight --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index bd5e791a2fe..770c2c7291e 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -107,7 +107,6 @@ struct lambdaspincorrderived { Configurable phiMix{"phiMix", 0.1, "Phi cut on event mixing"}; Configurable massMix{"massMix", 0.0028, "Masscut on event mixing"}; - // --- Pair-space axes (add near your other ConfigurableAxis) ConfigurableAxis ax_dphi_h{"ax_dphi_h", {72, 0.0, 2.0 * TMath::Pi()}, "Δφ_h"}; ConfigurableAxis ax_deta{"ax_deta", {32, -1.6, 1.6}, "Δη"}; ConfigurableAxis ax_ptpair{"ax_ptpair", {100, 0.0, 10.0}, "p_{T,pair} (GeV/c)"}; @@ -133,7 +132,6 @@ struct lambdaspincorrderived { histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); // --- 3D SE/ME pair-space maps per category (LL, LAL, ALL, ALAL) - // SE = same-event (unit weight), ME = mixed-event (uses your mixing+CCDB weight) histos.add("SE_LL", "SE pairs LL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); histos.add("SE_LAL", "SE pairs LAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); histos.add("SE_ALL", "SE pairs ALL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); From 4c0c3b8821d545b783be0bf841f71a8beb780f75 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 14 Oct 2025 10:09:33 +0200 Subject: [PATCH 22/25] Add delta phi info and improve mixed event weight --- .../Strangeness/lambdaspincorrderived.cxx | 83 ++++++++++++------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 770c2c7291e..a5e2bb23a61 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -108,7 +108,7 @@ struct lambdaspincorrderived { Configurable massMix{"massMix", 0.0028, "Masscut on event mixing"}; ConfigurableAxis ax_dphi_h{"ax_dphi_h", {72, 0.0, 2.0 * TMath::Pi()}, "Δφ_h"}; - ConfigurableAxis ax_deta{"ax_deta", {32, -1.6, 1.6}, "Δη"}; + ConfigurableAxis ax_deta{"ax_deta", {40, -1.0, 1.0}, "Δη"}; ConfigurableAxis ax_ptpair{"ax_ptpair", {100, 0.0, 10.0}, "p_{T,pair} (GeV/c)"}; // THnsparse bining @@ -132,15 +132,15 @@ struct lambdaspincorrderived { histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); // --- 3D SE/ME pair-space maps per category (LL, LAL, ALL, ALAL) - histos.add("SE_LL", "SE pairs LL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("SE_LAL", "SE pairs LAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("SE_ALL", "SE pairs ALL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("SE_ALAL", "SE pairs ALAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_LL", "SE pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_LAL", "SE pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALL", "SE pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALAL", "SE pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("ME_LL", "ME pairs LL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("ME_LAL", "ME pairs LAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("ME_ALL", "ME pairs ALL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); - histos.add("ME_ALAL", "ME pairs ALAL;Δφ_h;Δη;p_{T,pair}", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_LL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_LAL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALAL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); @@ -162,6 +162,16 @@ struct lambdaspincorrderived { histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparsePhiLambdaLambda", "hSparsePhiLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiLambdaAntiLambda", "hSparsePhiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaLambda", "hSparsePhiAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaAntiLambda", "hSparsePhiAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + + histos.add("hSparsePhiLambdaLambdaMixed", "hSparsePhiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiLambdaAntiLambdaMixed", "hSparsePhiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaLambdaMixed", "hSparsePhiAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaAntiLambdaMixed", "hSparsePhiAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePairMassLambdaLambda", "hSparsePairMassLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); histos.add("hSparsePairMassLambdaAntiLambda", "hSparsePairMassLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); histos.add("hSparsePairMassAntiLambdaLambda", "hSparsePairMassAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); @@ -319,26 +329,33 @@ struct lambdaspincorrderived { cosThetaDiff = cosDeltaTheta_hel; } - // --- helper to compute pair-space variables - auto phi1h = RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic); - auto phi2h = RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic); - double dphi_h = std::abs(phi1h - phi2h); - double deta_pair = particle1Dummy.Eta() - particle2Dummy.Eta(); - double pt_pair = (particle1Dummy + particle2Dummy).Pt(); - double deltaRap = std::abs(particle1Dummy.Rapidity() - particle2Dummy.Rapidity()); - double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_h * dphi_h); + double pt1 = particle1.Pt(); + double dphi1 = RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic); + ; + double deta1 = particle1.Eta(); + + double dphi2 = RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic); + ; + double deta2 = particle2.Eta(); + + double deta_pair = std::abs(deta1 - deta2); + double dphi_pair = std::abs(dphi1 - dphi2); + + double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_pair * dphi_pair); + + double deltaRap = std::abs(particle1.Rapidity() - particle2.Rapidity()); double epsWeight = 1.0; if (useweight && datatype == 1) { if (tag1 == 0 && tag2 == 0) { - epsWeight = hweight1->GetBinContent(hweight1->FindBin(dphi_h, deta_pair, pt_pair)); + epsWeight = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1)); } else if (tag1 == 0 && tag2 == 1) { - epsWeight = hweight2->GetBinContent(hweight2->FindBin(dphi_h, deta_pair, pt_pair)); + epsWeight = hweight2->GetBinContent(hweight2->FindBin(dphi1, deta1, pt1)); } else if (tag1 == 1 && tag2 == 0) { - epsWeight = hweight3->GetBinContent(hweight3->FindBin(dphi_h, deta_pair, pt_pair)); + epsWeight = hweight3->GetBinContent(hweight3->FindBin(dphi1, deta1, pt1)); } else if (tag1 == 1 && tag2 == 1) { - epsWeight = hweight4->GetBinContent(hweight4->FindBin(dphi_h, deta_pair, pt_pair)); + epsWeight = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1)); } } @@ -348,23 +365,27 @@ struct lambdaspincorrderived { if (tag1 == 0 && tag2 == 0) { histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); histos.fill(HIST("hSparsePairMassLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); - histos.fill(HIST("SE_LL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("SE_LL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); histos.fill(HIST("hSparsePairMassLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); - histos.fill(HIST("SE_LAL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("SE_LAL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); histos.fill(HIST("hSparsePairMassAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); - histos.fill(HIST("SE_ALL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("SE_ALL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); - histos.fill(HIST("SE_ALAL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("SE_ALAL"), dphi1, deta1, pt1, mixpairweight); } } else if (datatype == 1) { double weight = mixpairweight; @@ -376,26 +397,30 @@ struct lambdaspincorrderived { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); histos.fill(HIST("hSparsePairMassLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); - histos.fill(HIST("ME_LL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("ME_LL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 0 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); histos.fill(HIST("hSparsePairMassLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); - histos.fill(HIST("ME_LAL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("ME_LAL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); histos.fill(HIST("hSparsePairMassAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); - histos.fill(HIST("ME_ALL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("ME_ALL"), dphi1, deta1, pt1, mixpairweight); } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); - histos.fill(HIST("ME_ALAL"), dphi_h, deta_pair, pt_pair); + histos.fill(HIST("ME_ALAL"), dphi1, deta1, pt1, mixpairweight); } } } From 7c6d0c9979e77934c85b8b984ba0f9070b264207 Mon Sep 17 00:00:00 2001 From: skundu692 Date: Tue, 14 Oct 2025 10:13:01 +0200 Subject: [PATCH 23/25] Remove spacing --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index a5e2bb23a61..8a75b7205e7 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -331,18 +331,15 @@ struct lambdaspincorrderived { double pt1 = particle1.Pt(); double dphi1 = RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic); - ; double deta1 = particle1.Eta(); double dphi2 = RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic); - ; double deta2 = particle2.Eta(); double deta_pair = std::abs(deta1 - deta2); double dphi_pair = std::abs(dphi1 - dphi2); double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_pair * dphi_pair); - double deltaRap = std::abs(particle1.Rapidity() - particle2.Rapidity()); double epsWeight = 1.0; From 3327c0a0b141a3f9f003e13fa47510b4d62b8afe Mon Sep 17 00:00:00 2001 From: skundu692 Date: Fri, 17 Oct 2025 13:35:34 +0200 Subject: [PATCH 24/25] Use kinematic differential buffer for event mixing to reproduce better the acceptance effect --- .../Strangeness/lambdaspincorrderived.cxx | 445 +++++++++++++++--- 1 file changed, 373 insertions(+), 72 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index 8a75b7205e7..bb3e564bc82 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -38,9 +38,12 @@ #include #include // for std::fabs +#include #include #include #include +#include +#include #include // <<< CHANGED: for dedup sets #include #include @@ -71,20 +74,34 @@ struct lambdaspincorrderived { TH3D* hweight2; TH3D* hweight3; TH3D* hweight4; + + TH3D* hweight12; + TH3D* hweight22; + TH3D* hweight32; + TH3D* hweight42; + Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; Configurable ConfWeightPathALL{"ConfWeightPathALL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathLL2{"ConfWeightPathLL2", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path 2"}; + Configurable ConfWeightPathALAL2{"ConfWeightPathALAL2", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path 2"}; + Configurable ConfWeightPathLAL2{"ConfWeightPathLAL2", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path 2"}; + Configurable ConfWeightPathALL2{"ConfWeightPathALL2", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path 2"}; + // event sel///////// Configurable centMin{"centMin", 0, "Minimum Centrality"}; Configurable centMax{"centMax", 80, "Maximum Centrality"}; - + Configurable rngSeed{"rngSeed", 12345, "Seed for random mixing (reproducible)"}; + std::mt19937 rng{12345}; // Lambda selection //////////// Configurable harmonic{"harmonic", 1, "Harmonic delta phi"}; Configurable useweight{"useweight", 0, "Use weight"}; + Configurable usebothweight{"usebothweight", 1, "Use both weight"}; // Configurable useNUA{"useNUA", 0, "Use NUA weight"}; Configurable usePDGM{"usePDGM", 1, "Use PDG mass"}; + Configurable useAdditionalHisto{"useAdditionalHisto", 0, "Use additional histogram"}; Configurable checkDoubleStatus{"checkDoubleStatus", 0, "Check Double status"}; Configurable cosPA{"cosPA", 0.995, "Cosine Pointing Angle"}; Configurable radiusMin{"radiusMin", 3, "Minimum V0 radius"}; @@ -94,6 +111,8 @@ struct lambdaspincorrderived { Configurable dcaDaughters{"dcaDaughters", 1.0, "DCA between daughters"}; Configurable ptMin{"ptMin", 0.5, "V0 Pt minimum"}; Configurable ptMax{"ptMax", 3.0, "V0 Pt maximum"}; + Configurable MassMin{"MassMin", 1.09, "V0 Mass minimum"}; + Configurable MassMax{"MassMax", 1.14, "V0 Mass maximum"}; Configurable rapidity{"rapidity", 0.5, "Rapidity cut on lambda"}; Configurable v0eta{"v0eta", 0.8, "Eta cut on lambda"}; @@ -142,6 +161,16 @@ struct lambdaspincorrderived { histos.add("ME_ALL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); histos.add("ME_ALAL", "ME pairs", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_LL2", "SE pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_LAL2", "SE pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALL2", "SE pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("SE_ALAL2", "SE pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + + histos.add("ME_LL2", "ME pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_LAL2", "ME pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALL2", "ME pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("ME_ALAL2", "ME pairs 2", HistType::kTH3D, {ax_dphi_h, ax_deta, ax_ptpair}, true); + histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseAntiLambdaLambda", "hSparseAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); @@ -151,37 +180,38 @@ struct lambdaspincorrderived { histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseAntiLambdaLambdaMixed", "hSparseAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisR}, true); - - histos.add("hSparseRapLambdaLambda", "hSparseRapLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapLambdaAntiLambda", "hSparseRapLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapAntiLambdaLambda", "hSparseRapAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapAntiLambdaAntiLambda", "hSparseRapAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - - histos.add("hSparseRapLambdaLambdaMixed", "hSparseRapLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapLambdaAntiLambdaMixed", "hSparseRapLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); - - histos.add("hSparsePhiLambdaLambda", "hSparsePhiLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiLambdaAntiLambda", "hSparsePhiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiAntiLambdaLambda", "hSparsePhiAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiAntiLambdaAntiLambda", "hSparsePhiAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - - histos.add("hSparsePhiLambdaLambdaMixed", "hSparsePhiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiLambdaAntiLambdaMixed", "hSparsePhiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiAntiLambdaLambdaMixed", "hSparsePhiAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - histos.add("hSparsePhiAntiLambdaAntiLambdaMixed", "hSparsePhiAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); - - histos.add("hSparsePairMassLambdaLambda", "hSparsePairMassLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassLambdaAntiLambda", "hSparsePairMassLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassAntiLambdaLambda", "hSparsePairMassAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassAntiLambdaAntiLambda", "hSparsePairMassAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - - histos.add("hSparsePairMassLambdaLambdaMixed", "hSparsePairMassLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassLambdaAntiLambdaMixed", "hSparsePairMassLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassAntiLambdaLambdaMixed", "hSparsePairMassAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - histos.add("hSparsePairMassAntiLambdaAntiLambdaMixed", "hSparsePairMassAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); - + if (useAdditionalHisto) { + histos.add("hSparseRapLambdaLambda", "hSparseRapLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapLambdaAntiLambda", "hSparseRapLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaLambda", "hSparseRapAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaAntiLambda", "hSparseRapAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + + histos.add("hSparseRapLambdaLambdaMixed", "hSparseRapLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapLambdaAntiLambdaMixed", "hSparseRapLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaLambdaMixed", "hSparseRapAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + histos.add("hSparseRapAntiLambdaAntiLambdaMixed", "hSparseRapAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisRapidity}, true); + + histos.add("hSparsePhiLambdaLambda", "hSparsePhiLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiLambdaAntiLambda", "hSparsePhiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaLambda", "hSparsePhiAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaAntiLambda", "hSparsePhiAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + + histos.add("hSparsePhiLambdaLambdaMixed", "hSparsePhiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiLambdaAntiLambdaMixed", "hSparsePhiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaLambdaMixed", "hSparsePhiAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + histos.add("hSparsePhiAntiLambdaAntiLambdaMixed", "hSparsePhiAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, ax_dphi_h}, true); + + histos.add("hSparsePairMassLambdaLambda", "hSparsePairMassLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassLambdaAntiLambda", "hSparsePairMassLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaLambda", "hSparsePairMassAntiLambdLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaAntiLambda", "hSparsePairMassAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + + histos.add("hSparsePairMassLambdaLambdaMixed", "hSparsePairMassLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassLambdaAntiLambdaMixed", "hSparsePairMassLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaLambdaMixed", "hSparsePairMassAntiLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + histos.add("hSparsePairMassAntiLambdaAntiLambdaMixed", "hSparsePairMassAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisPairMass}, true); + } + rng.seed(static_cast(rngSeed.value)); ccdb->setURL(cfgCcdbParam.cfgURL); ccdbApi.init("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -193,6 +223,11 @@ struct lambdaspincorrderived { hweight2 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); hweight3 = ccdb->getForTimeStamp(ConfWeightPathALL.value, cfgCcdbParam.nolaterthan.value); hweight4 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); + + hweight12 = ccdb->getForTimeStamp(ConfWeightPathLL2.value, cfgCcdbParam.nolaterthan.value); + hweight22 = ccdb->getForTimeStamp(ConfWeightPathLAL2.value, cfgCcdbParam.nolaterthan.value); + hweight32 = ccdb->getForTimeStamp(ConfWeightPathALL2.value, cfgCcdbParam.nolaterthan.value); + hweight42 = ccdb->getForTimeStamp(ConfWeightPathALAL2.value, cfgCcdbParam.nolaterthan.value); } } @@ -203,6 +238,9 @@ struct lambdaspincorrderived { if (std::abs(particle.Rapidity()) > rapidity || std::abs(particle.Eta()) > v0eta) { return false; } + if (candidate.lambdaMass() < MassMin || candidate.lambdaMass() > MassMax) { + return false; + } if (candidate.v0Cospa() < cosPA) { return false; } @@ -333,6 +371,7 @@ struct lambdaspincorrderived { double dphi1 = RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic); double deta1 = particle1.Eta(); + double pt2 = particle2.Pt(); double dphi2 = RecoDecay::constrainAngle(particle2.Phi(), 0.0F, harmonic); double deta2 = particle2.Eta(); @@ -342,17 +381,22 @@ struct lambdaspincorrderived { double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_pair * dphi_pair); double deltaRap = std::abs(particle1.Rapidity() - particle2.Rapidity()); - double epsWeight = 1.0; + double epsWeight1 = 1.0; + double epsWeight2 = 1.0; if (useweight && datatype == 1) { if (tag1 == 0 && tag2 == 0) { - epsWeight = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1)); + epsWeight1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1)); + epsWeight2 = hweight2->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2)); } else if (tag1 == 0 && tag2 == 1) { - epsWeight = hweight2->GetBinContent(hweight2->FindBin(dphi1, deta1, pt1)); + epsWeight1 = hweight2->GetBinContent(hweight2->FindBin(dphi1, deta1, pt1)); + epsWeight2 = hweight22->GetBinContent(hweight22->FindBin(dphi2, deta2, pt2)); } else if (tag1 == 1 && tag2 == 0) { - epsWeight = hweight3->GetBinContent(hweight3->FindBin(dphi1, deta1, pt1)); + epsWeight1 = hweight3->GetBinContent(hweight3->FindBin(dphi1, deta1, pt1)); + epsWeight2 = hweight32->GetBinContent(hweight32->FindBin(dphi2, deta2, pt2)); } else if (tag1 == 1 && tag2 == 1) { - epsWeight = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1)); + epsWeight1 = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1)); + epsWeight2 = hweight42->GetBinContent(hweight42->FindBin(dphi2, deta2, pt2)); } } @@ -360,64 +404,91 @@ struct lambdaspincorrderived { mixpairweight = 1.0; histos.fill(HIST("hPtYSame"), particle1.Pt(), particle1.Rapidity(), mixpairweight); if (tag1 == 0 && tag2 == 0) { - histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); - histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); - histos.fill(HIST("hSparsePairMassLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); histos.fill(HIST("SE_LL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("SE_LL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); + histos.fill(HIST("hSparsePairMassLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + } } else if (tag1 == 0 && tag2 == 1) { - histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); - histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); - histos.fill(HIST("hSparsePairMassLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); histos.fill(HIST("SE_LAL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("SE_LAL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); + histos.fill(HIST("hSparsePairMassLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + } } else if (tag1 == 1 && tag2 == 0) { histos.fill(HIST("hSparseAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); - histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); - histos.fill(HIST("hSparsePairMassAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); histos.fill(HIST("SE_ALL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("SE_ALL2"), dphi2, deta2, pt2, mixpairweight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); + histos.fill(HIST("hSparsePairMassAntiLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + } } else if (tag1 == 1 && tag2 == 1) { histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, mixpairweight); - histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); - histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); - histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); histos.fill(HIST("SE_ALAL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("SE_ALAL2"), dphi2, deta2, pt2, mixpairweight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, mixpairweight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, mixpairweight); + histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), mixpairweight); + } } } else if (datatype == 1) { double weight = mixpairweight; - weight = mixpairweight / epsWeight; + if (useweight) { + if (usebothweight) { + weight = mixpairweight / (epsWeight1 * epsWeight2); + } else { + weight = mixpairweight / (epsWeight1); + } + } if (weight <= 0.0) { weight = 1.0; } + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); if (tag1 == 0 && tag2 == 0) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); - histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); - histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); - histos.fill(HIST("hSparsePairMassLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); histos.fill(HIST("ME_LL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("ME_LL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); + histos.fill(HIST("hSparsePairMassLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + } } else if (tag1 == 0 && tag2 == 1) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); - histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); - histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); - histos.fill(HIST("hSparsePairMassLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); histos.fill(HIST("ME_LAL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("ME_LAL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); + histos.fill(HIST("hSparsePairMassLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + } } else if (tag1 == 1 && tag2 == 0) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); - histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); - histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); - histos.fill(HIST("hSparsePairMassAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); histos.fill(HIST("ME_ALL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("ME_ALL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); + histos.fill(HIST("hSparsePairMassAntiLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + } } else if (tag1 == 1 && tag2 == 1) { - histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity(), weight); - histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); - histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); - histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); - histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); histos.fill(HIST("ME_ALAL"), dphi1, deta1, pt1, mixpairweight); + histos.fill(HIST("ME_ALAL2"), dphi2, deta2, pt2, mixpairweight); + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaR, weight); + if (useAdditionalHisto) { + histos.fill(HIST("hSparseRapAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, deltaRap, weight); + histos.fill(HIST("hSparsePhiAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, dphi_pair, weight); + histos.fill(HIST("hSparsePairMassAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, pairDummy.M(), weight); + } } } } @@ -738,6 +809,236 @@ struct lambdaspincorrderived { } } PROCESS_SWITCH(lambdaspincorrderived, processMEV3, "Process data ME (first-leg, pair-3D maps)", false); + + static constexpr int N_STATUS = 2; // v0Status ∈ {0,1} + + struct MixBinner { + // constructed from the task's configurables; φ is assumed already constrained into [0, 2π) + float ptMin, ptMax, ptStep; + float etaMin, etaMax, etaStep; + float phiMin, phiMax, phiStep; + + // Mass binning: [1.09, 1.14) with 50 bins (1e-3 GeV/c^2) + static constexpr float mMin = 1.09f; + static constexpr float mMax = 1.14f; // exclusive + static constexpr int nM_ = 1; + static constexpr float mStep = (mMax - mMin) / nM_; + + int nPt_, nEta_, nPhi_; + + MixBinner(float ptMin_, float ptMax_, float ptStep_, + float etaAbsMax, float etaStep_, + float phiStep_) + : ptMin(ptMin_), ptMax(ptMax_), ptStep(ptStep_), etaMin(-etaAbsMax), etaMax(+etaAbsMax), etaStep(etaStep_), phiMin(0.f), phiMax(static_cast(2.0 * TMath::Pi())), phiStep(phiStep_) + { + ptStep = (ptStep > 0.f ? ptStep : 0.1f); + etaStep = (etaStep > 0.f ? etaStep : 0.1f); + phiStep = (phiStep > 0.f ? phiStep : 0.1f); + + nPt_ = std::max(1, static_cast(std::floor((ptMax - ptMin) / ptStep + 0.5f))); + nEta_ = std::max(1, static_cast(std::floor((etaMax - etaMin) / etaStep + 0.5f))); + nPhi_ = std::max(1, static_cast(std::ceil((phiMax - phiMin) / phiStep))); + } + + inline int nPt() const { return nPt_; } + inline int nEta() const { return nEta_; } + inline int nPhi() const { return nPhi_; } + inline int nM() const { return nM_; } + + inline int binFromValue(float v, float vmin, float step, int nBins) const + { + if (!std::isfinite(v)) + return -1; + const float x = (v - vmin) / step; + int b = static_cast(std::floor(x + 1e-6f)); + if (b < 0) + return -1; + if (b >= nBins) + b = nBins - 1; // clamp exact-top edge + return b; + } + + inline int ptBin(float pt) const { return binFromValue(pt, ptMin, ptStep, nPt_); } + inline int etaBin(float eta) const { return binFromValue(eta, etaMin, etaStep, nEta_); } + inline int phiBin(float phi) const { return binFromValue(phi, phiMin, phiStep, nPhi_); } // φ already constrained upstream + inline int massBin(float m) const { return binFromValue(m, mMin, mStep, nM_); } + }; + + struct BufferCand { + int64_t collisionIdx; // from col.index() + int64_t rowIndex; // global row id in V0s + uint8_t v0Status; + uint16_t ptBin, etaBin, phiBin, mBin; + }; + + struct MatchRef { + int64_t collisionIdx; + int64_t rowIndex; + }; + + // 6D key: (colBin, status, pt, eta, phi, mass) + static inline size_t linearKey(int colBin, int statBin, + int ptBin, int etaBin, int phiBin, int mBin, + int nStatus, int nPt, int nEta, int nPhi, int nM) + { + return ((((((static_cast(colBin) * nStatus + statBin) * nPt + ptBin) * nEta + etaBin) * nPhi + phiBin) * nM + mBin)); + } + + // ===================== Main mixing (with mass-bin + random unique sampling) ===================== + void processMEV4(EventCandidates const& collisions, AllTrackCandidates const& V0s) + { + // Build binner from your existing configurables + MixBinner mb{ + ptMin.value, ptMax.value, ptMix.value, // pT range & step + v0eta.value, etaMix.value, // |eta| max & step + phiMix.value // φ step; φ range fixed to [0, 2π) + }; + + const int nCol = colBinning.getAllBinsCount(); // event-class bins (vz, centrality) + const int nStat = N_STATUS; // 2 + const int nPt = mb.nPt(); + const int nEta = mb.nEta(); + const int nPhi = mb.nPhi(); + const int nM = mb.nM(); + + const size_t nKeys = static_cast(nCol) * nStat * nPt * nEta * nPhi * nM; + std::vector> buffer(nKeys); + + // ---- PASS 1: fill 6D buffer ---- + for (auto const& col : collisions) { + const int colBin = colBinning.getBin(std::make_tuple(col.posz(), col.cent())); + auto slice = V0s.sliceBy(tracksPerCollisionV0, col.index()); + + for (auto const& t : slice) { + if (!selectionV0(t)) + continue; + + const int status = static_cast(t.v0Status()); + if (status < 0 || status >= nStat) + continue; + + // Bin kinematics (φ already constrained via your call-site) + const int ptB = mb.ptBin(t.lambdaPt()); + const int etaB = mb.etaBin(t.lambdaEta()); + const int phiB = mb.phiBin(RecoDecay::constrainAngle(t.lambdaPhi(), 0.0F, harmonic)); + const int mB = mb.massBin(t.lambdaMass()); + if (ptB < 0 || etaB < 0 || phiB < 0 || mB < 0) + continue; + + const size_t key = linearKey(colBin, status, ptB, etaB, phiB, mB, + nStat, nPt, nEta, nPhi, nM); + + buffer[key].push_back(BufferCand{ + .collisionIdx = static_cast(col.index()), + .rowIndex = static_cast(t.globalIndex()), // adapt accessor if needed + .v0Status = static_cast(status), + .ptBin = static_cast(ptB), + .etaBin = static_cast(etaB), + .phiBin = static_cast(phiB), + .mBin = static_cast(mB)}); + } + } + + // ---- PASS 2: mixing over same-event pairs ---- + for (auto const& collision1 : collisions) { + const int colBin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); + auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + + for (auto const& [t1, t2] : + soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) { + + if (!selectionV0(t1) || !selectionV0(t2)) + continue; + if (t2.index() <= t1.index()) + continue; + + // no shared daughters + if (t1.protonIndex() == t2.protonIndex()) + continue; + if (t1.pionIndex() == t2.pionIndex()) + continue; + if (t1.protonIndex() == t2.pionIndex()) + continue; + if (t1.pionIndex() == t2.protonIndex()) + continue; + + const int status = static_cast(t1.v0Status()); + if (status < 0 || status >= nStat) + continue; + + // Bin of t1 defines where to search (exact 6D bin) + const int ptB = mb.ptBin(t1.lambdaPt()); + const int etaB = mb.etaBin(t1.lambdaEta()); + const int phiB = mb.phiBin(RecoDecay::constrainAngle(t1.lambdaPhi(), 0.0F, harmonic)); // φ already constrained upstream + const int mB = mb.massBin(t1.lambdaMass()); + if (ptB < 0 || etaB < 0 || phiB < 0 || mB < 0) + continue; + + const size_t key = linearKey(colBin, status, ptB, etaB, phiB, mB, + nStat, nPt, nEta, nPhi, nM); + auto const& binVec = buffer[key]; + if (binVec.empty()) + continue; + + // Collect all partners from this 6D bin but different collision + std::vector matches; + matches.reserve(binVec.size()); + const int64_t curColIdx = static_cast(collision1.index()); + + for (const auto& bc : binVec) { + if (bc.collisionIdx == curColIdx) + continue; // ensure different event + matches.push_back(MatchRef{bc.collisionIdx, bc.rowIndex}); + } + if (matches.empty()) + continue; + + // ---------- YOUR PREFERRED RANDOM UNIQUE SAMPLING BLOCK ---------- + const int cap = nEvtMixing.value; + const int n = static_cast(matches.size()); + if (cap > 0 && cap < n) { + std::uniform_int_distribution dist(0, n - 1); + // pick cap unique indices + std::unordered_set chosen; + chosen.reserve(cap * 2); + while ((int)chosen.size() < cap) { + chosen.insert(dist(rng)); + } + std::vector subset; + subset.reserve(cap); + for (int idx : chosen) + subset.push_back(matches[idx]); + matches.swap(subset); + } else { + std::shuffle(matches.begin(), matches.end(), rng); + } + // ---------------------------------------------------------------- + + const float wBase = 1.0f / static_cast(matches.size()); + + // Emit mixed pairs: tX replaces t1; keep t2 + for (const auto& m : matches) { + auto tX = V0s.iteratorAt(m.rowIndex); // replace accessor if different + if (!selectionV0(tX)) + continue; // optional extra guard + if (!checkKinematics(t1, tX)) + continue; + + auto proton = ROOT::Math::PtEtaPhiMVector(tX.protonPt(), tX.protonEta(), tX.protonPhi(), o2::constants::physics::MassProton); + auto lambda = ROOT::Math::PtEtaPhiMVector(tX.lambdaPt(), tX.lambdaEta(), tX.lambdaPhi(), tX.lambdaMass()); + auto proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + auto lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + + const float dPhi = std::fabs( + RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - + RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, wBase); + fillHistograms(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase); + } + } + } + } + PROCESS_SWITCH(lambdaspincorrderived, processMEV4, "Process data ME (5d buffer)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { From 893df72260f52253114c00c61a5b21a0f3e4960f Mon Sep 17 00:00:00 2001 From: skundu692 Date: Thu, 23 Oct 2025 13:50:00 +0200 Subject: [PATCH 25/25] Fix bug in histogram access from ccdb --- PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx index bb3e564bc82..59d73923ac6 100644 --- a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -387,7 +387,7 @@ struct lambdaspincorrderived { if (useweight && datatype == 1) { if (tag1 == 0 && tag2 == 0) { epsWeight1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1)); - epsWeight2 = hweight2->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2)); + epsWeight2 = hweight12->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2)); } else if (tag1 == 0 && tag2 == 1) { epsWeight1 = hweight2->GetBinContent(hweight2->FindBin(dphi1, deta1, pt1)); epsWeight2 = hweight22->GetBinContent(hweight22->FindBin(dphi2, deta2, pt2));