Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 50 additions & 46 deletions PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <Math/GenVector/Boost.h>
#include <Math/Vector3D.h>
#include <Math/Vector4D.h>
#include <TLorentzVector.h>

Check failure on line 33 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/lorentz-vector]

Do not use the TLorentzVector legacy class. Use std::array with RecoDecay methods or the ROOT::Math::LorentzVector template instead.
#include <TMath.h>
#include <TRandom3.h>

Expand All @@ -40,7 +40,7 @@
#include <cmath> // for std::fabs
#include <cstdint>
#include <deque>
#include <iostream>

Check failure on line 43 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <iterator>
#include <limits>
#include <random>
Expand Down Expand Up @@ -529,7 +529,7 @@
void fillHistograms2(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 mixedLeg)
{

auto lambda1Mass = 0.0;
Expand Down Expand Up @@ -615,39 +615,43 @@
double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_pair * dphi_pair);
double deltaRap = std::abs(particle1.Rapidity() - particle2.Rapidity());

double epsWeight1 = 1.0;
double epsWeight2 = 1.0;

if (useweight && datatype == 1) {
// --- Leg 1: choose map only by species (tag1) ---
if (tag1 == 0) { // Λ
if (hweight1) {
epsWeight1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1));
// -----------------------------
// Kinematic *matching* weight
// (only for mixed events, only mixed leg)
// -----------------------------
double epsWeightMixedLeg = 1.0;
if (useweight && datatype == 1) { // only for ME
if (mixedLeg == 1) {
// Only leg 1 is from the mixing pool
double w1 = 1.0;
if (tag1 == 0) { // Λ
if (hweight1) {
w1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1));
}
} else { // Λbar
if (hweight4) {
w1 = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1));
}
}
} else { // Λ̄
if (hweight4) {
epsWeight1 = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1));
if (w1 > 0.0 && std::isfinite(w1)) {
epsWeightMixedLeg = w1;
}
}

// --- Leg 2: choose map only by species (tag2) ---
if (tag2 == 0) { // Λ
if (hweight12) {
epsWeight2 = hweight12->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2));
} else if (mixedLeg == 2) {
// Only leg 2 is from the mixing pool
double w2 = 1.0;
if (tag2 == 0) { // Λ
if (hweight12) {
w2 = hweight12->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2));
}
} else { // Λbar
if (hweight42) {
w2 = hweight42->GetBinContent(hweight42->FindBin(dphi2, deta2, pt2));
}
}
} else { // Λ̄
if (hweight42) {
epsWeight2 = hweight42->GetBinContent(hweight42->FindBin(dphi2, deta2, pt2));
if (w2 > 0.0 && std::isfinite(w2)) {
epsWeightMixedLeg = w2;
}
}

// Safety: avoid zero/NaN
if (epsWeight1 <= 0.0 || !std::isfinite(epsWeight1)) {
epsWeight1 = 1.0;
}
if (epsWeight2 <= 0.0 || !std::isfinite(epsWeight2)) {
epsWeight2 = 1.0;
}
}

if (datatype == 0) {
Expand Down Expand Up @@ -694,9 +698,9 @@
double weight = mixpairweight;
if (useweight) {
if (usebothweight) {
weight = mixpairweight / (epsWeight1 * epsWeight2);
weight = mixpairweight / (epsWeightMixedLeg);
} else {
weight = mixpairweight / (epsWeight1);
weight = mixpairweight / (epsWeightMixedLeg);
}
}
if (weight <= 0.0) {
Expand Down Expand Up @@ -787,16 +791,16 @@
lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass());
histos.fill(HIST("deltaPhiSame"), RecoDecay::constrainAngle(v0.lambdaPhi() - v02.lambdaPhi(), 0.0F, harmonicDphi));
if (v0.v0Status() == 0 && v02.v0Status() == 0) {
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 0, 1.0);
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0);
}
if (v0.v0Status() == 0 && v02.v0Status() == 1) {
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 0, 1.0);
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0);
}
if (v0.v0Status() == 1 && v02.v0Status() == 0) {
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 0, 1.0);
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0);
}
if (v0.v0Status() == 1 && v02.v0Status() == 1) {
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 0, 1.0);
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0);
}
}
}
Expand All @@ -812,7 +816,7 @@
{
auto collOldIndex = -999;
std::vector<bool> t1Used;
for (auto& [collision1, collision2] : selfCombinations(colBinning, nEvtMixing, -1, collisions, collisions)) {

Check failure on line 819 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
// LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index());
// auto centrality = collision1.cent();
auto groupV01 = V0s.sliceBy(tracksPerCollisionV0, collision1.index());
Expand All @@ -826,7 +830,7 @@
// std::vector<bool> t1Used(groupV01.size(), false); // <-- reset here
collOldIndex = collNewIndex;
}
for (auto& [t1, t3] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV03))) {

Check failure on line 833 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (t1Used[t1.index()]) {
continue;
}
Expand Down Expand Up @@ -859,16 +863,16 @@
lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass());
histos.fill(HIST("deltaPhiMix"), RecoDecay::constrainAngle(t3.lambdaPhi() - t2.lambdaPhi(), 0.0F, harmonicDphi));
if (t3.v0Status() == 0 && t2.v0Status() == 0) {
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, 1.0);
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1);
}
if (t3.v0Status() == 0 && t2.v0Status() == 1) {
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, 1.0);
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1);
}
if (t3.v0Status() == 1 && t2.v0Status() == 0) {
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, 1.0);
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1);
}
if (t3.v0Status() == 1 && t2.v0Status() == 1) {
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, 1.0);
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1);
}
}
} // replacement track pair
Expand All @@ -881,7 +885,7 @@
auto nBins = colBinning.getAllBinsCount();
std::vector<std::deque<std::pair<int, AllTrackCandidates>>> eventPools(nBins);

for (auto& collision1 : collisions) {

Check failure on line 888 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent()));
auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index());
// float centrality = collision1.cent();
Expand All @@ -889,7 +893,7 @@
// <<< CHANGED: map old collision index → set of (t2.idx, t3.idx) we've already filled
std::unordered_map<int, std::set<std::pair<int, int>>> seenMap;

for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) {

Check failure on line 896 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (!selectionV0(t1) || !selectionV0(t2))
continue;
if (t2.index() <= t1.index())
Expand All @@ -905,7 +909,7 @@
AllTrackCandidates& poolB = it->second;

int nRepl = 0;
for (auto& t3 : poolB) {

Check failure on line 912 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (selectionV0(t3) && checkKinematics(t1, t3)) {
++nRepl;
}
Expand All @@ -914,7 +918,7 @@
continue;
float invN = 1.0f / static_cast<float>(nRepl);

for (auto& t3 : poolB) {

Check failure on line 921 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (!(selectionV0(t3) && checkKinematics(t1, t3))) {
continue;
}
Expand All @@ -939,16 +943,16 @@
histos.fill(HIST("deltaPhiMix"), dPhi, invN);

if (t3.v0Status() == 0 && t2.v0Status() == 0) {
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, invN);
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, invN, 1);
}
if (t3.v0Status() == 0 && t2.v0Status() == 1) {
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, invN);
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, invN, 1);
}
if (t3.v0Status() == 1 && t2.v0Status() == 0) {
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, invN);
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, invN, 1);
}
if (t3.v0Status() == 1 && t2.v0Status() == 1) {
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, invN);
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, invN, 1);
}
}
} // end mixing-event loop
Expand All @@ -968,7 +972,7 @@
auto nBins = colBinning.getAllBinsCount();
std::vector<std::deque<std::pair<int, AllTrackCandidates>>> eventPools(nBins);

for (auto& collision1 : collisions) {

Check failure on line 975 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
const int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent()));

// if pool empty, push and continue
Expand All @@ -984,7 +988,7 @@
auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index());

// loop over SE unordered pairs (t1,t2)
for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) {

Check failure on line 991 in PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (!selectionV0(t1) || !selectionV0(t2))
continue;
if (t2.index() <= t1.index())
Expand Down Expand Up @@ -1047,7 +1051,7 @@

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);
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase);
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 1);
}
}
}
Expand Down Expand Up @@ -1285,7 +1289,7 @@
const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda1.Phi() - lambda2.Phi(), 0.0F, harmonicDphi));
histos.fill(HIST("deltaPhiMix"), dPhi, w1);

fillHistograms2(tX.v0Status(), t2.v0Status(), lambda1, lambda2, proton1, proton2, 1, w1);
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda1, lambda2, proton1, proton2, 1, w1, 1);
}

// --- Type B: replace leg 2 → (t1, tY) ---
Expand All @@ -1305,7 +1309,7 @@
const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda1.Phi() - lambda2.Phi(), 0.0F, harmonicDphi));
histos.fill(HIST("deltaPhiMix"), dPhi, w2);

fillHistograms2(t1.v0Status(), tY.v0Status(), lambda1, lambda2, proton1, proton2, 1, w2);
fillHistograms2(t1.v0Status(), tY.v0Status(), lambda1, lambda2, proton1, proton2, 1, w2, 2);
}
}
}
Expand Down
Loading