Skip to content

Commit cec707a

Browse files
committed
Fix event mixing sliding for spin correlation
1 parent a63d925 commit cec707a

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,9 +1869,10 @@ struct lambdaspincorrderived {
18691869
}
18701870
}
18711871

1872-
// Neighbor policy (continuous mixing)
1873-
constexpr int nN_pt = 1; // ±1 pt-bin
1874-
constexpr int nN_eta = 1; // ±1 eta/y-bin (can make configurable later)
1872+
// Neighbor policy from configurables
1873+
const int nN_pt = std::max(0, cfgV5NeighborPt.value);
1874+
const int nN_eta = std::max(0, cfgV5NeighborEta.value);
1875+
const int nN_phi = std::max(0, cfgV5NeighborPhi.value);
18751876

18761877
std::vector<int> ptBins, etaBins, phiBins;
18771878
std::vector<MatchRef> matches;
@@ -1897,6 +1898,7 @@ struct lambdaspincorrderived {
18971898
continue; // same-event ordering
18981899
}
18991900

1901+
// no shared daughters (same-event)
19001902
if (t1.protonIndex() == t2.protonIndex())
19011903
continue;
19021904
if (t1.pionIndex() == t2.pionIndex())
@@ -1928,7 +1930,7 @@ struct lambdaspincorrderived {
19281930

19291931
collectNeighborBinsClamp(ptB, nPt, nN_pt, ptBins);
19301932
collectNeighborBinsClamp(etaB, nEta, nN_eta, etaBins);
1931-
collectPhiBinsWithEdgeWrap(phiB, nPhi, phiBins);
1933+
collectNeighborBinsPhi(phiB, nPhi, nN_phi, phiBins);
19321934

19331935
matches.clear();
19341936

@@ -1949,12 +1951,10 @@ struct lambdaspincorrderived {
19491951
continue;
19501952
}
19511953

1952-
// extra strict kinematic check (uses eta or rapidity based on userapidity)
19531954
if (!checkKinematics(t1, tX)) {
19541955
continue;
19551956
}
19561957

1957-
// safety (should be redundant because different event)
19581958
if (tX.globalIndex() == t1.globalIndex())
19591959
continue;
19601960
if (tX.globalIndex() == t2.globalIndex())
@@ -1970,7 +1970,6 @@ struct lambdaspincorrderived {
19701970
continue;
19711971
}
19721972

1973-
// dedupe
19741973
std::sort(matches.begin(), matches.end(),
19751974
[](auto const& a, auto const& b) {
19761975
return std::tie(a.collisionIdx, a.rowIndex) < std::tie(b.collisionIdx, b.rowIndex);
@@ -1984,9 +1983,8 @@ struct lambdaspincorrderived {
19841983
continue;
19851984
}
19861985

1987-
// unbiased cap (cfgV5MaxMatches==1 => pick-one mode)
19881986
if (cfgV5MaxMatches.value > 0 && (int)matches.size() > cfgV5MaxMatches.value) {
1989-
uint64_t seed = 0;
1987+
uint64_t seed = cfgMixSeed.value;
19901988
seed ^= splitmix64((uint64_t)t1.globalIndex());
19911989
seed ^= splitmix64((uint64_t)t2.globalIndex() + 0x1234567ULL);
19921990
seed ^= splitmix64((uint64_t)curColIdx + 0x9abcULL);
@@ -2029,8 +2027,6 @@ struct lambdaspincorrderived {
20292027

20302028
void processMCMEV5(EventCandidatesMC const& collisions, AllTrackCandidatesMC const& V0sMC)
20312029
{
2032-
// Buffer binning: v0etaMixBuffer = max(|eta|) or max(|y|) if userapidity
2033-
// etaMix = step for that axis (and also your matching window inside checkKinematicsMC)
20342030
MixBinner mb{
20352031
ptMin.value, ptMax.value, ptMix.value,
20362032
v0etaMixBuffer.value, etaMix.value,
@@ -2039,7 +2035,7 @@ struct lambdaspincorrderived {
20392035
const int nCol = colBinning.getAllBinsCount();
20402036
const int nStat = N_STATUS;
20412037
const int nPt = mb.nPt();
2042-
const int nEta = mb.nEta(); // logical "nY" if userapidity=true
2038+
const int nEta = mb.nEta();
20432039
const int nPhi = mb.nPhi();
20442040

20452041
const size_t nKeys = static_cast<size_t>(nCol) * nStat * nPt * nEta * nPhi;
@@ -2098,8 +2094,9 @@ struct lambdaspincorrderived {
20982094
}
20992095
}
21002096

2101-
constexpr int nN_pt = 1;
2102-
constexpr int nN_eta = 1;
2097+
const int nN_pt = std::max(0, cfgV5NeighborPt.value);
2098+
const int nN_eta = std::max(0, cfgV5NeighborEta.value);
2099+
const int nN_phi = std::max(0, cfgV5NeighborPhi.value);
21032100

21042101
std::vector<int> ptBins, etaBins, phiBins;
21052102
std::vector<MatchRef> matches;
@@ -2125,7 +2122,6 @@ struct lambdaspincorrderived {
21252122
continue;
21262123
}
21272124

2128-
// no shared daughters
21292125
if (mcacc::prIdx(t1) == mcacc::prIdx(t2))
21302126
continue;
21312127
if (mcacc::piIdx(t1) == mcacc::piIdx(t2))
@@ -2136,7 +2132,6 @@ struct lambdaspincorrderived {
21362132
continue;
21372133

21382134
const int status = mcacc::v0Status(t1);
2139-
21402135
if (status < 0 || status >= nStat) {
21412136
continue;
21422137
}
@@ -2157,7 +2152,7 @@ struct lambdaspincorrderived {
21572152

21582153
collectNeighborBinsClamp(ptB, nPt, nN_pt, ptBins);
21592154
collectNeighborBinsClamp(etaB, nEta, nN_eta, etaBins);
2160-
collectPhiBinsWithEdgeWrap(phiB, nPhi, phiBins);
2155+
collectNeighborBinsPhi(phiB, nPhi, nN_phi, phiBins);
21612156

21622157
matches.clear();
21632158

@@ -2168,7 +2163,7 @@ struct lambdaspincorrderived {
21682163

21692164
for (auto const& bc : vec) {
21702165
if (bc.collisionIdx == curColIdx) {
2171-
continue; // different event
2166+
continue;
21722167
}
21732168

21742169
auto tX = V0sMC.iteratorAt(static_cast<uint64_t>(bc.rowIndex));
@@ -2179,7 +2174,6 @@ struct lambdaspincorrderived {
21792174
continue;
21802175
}
21812176

2182-
// safety (should be redundant due to different event)
21832177
if (tX.globalIndex() == t1.globalIndex())
21842178
continue;
21852179
if (tX.globalIndex() == t2.globalIndex())
@@ -2195,7 +2189,6 @@ struct lambdaspincorrderived {
21952189
continue;
21962190
}
21972191

2198-
// dedupe
21992192
std::sort(matches.begin(), matches.end(),
22002193
[](auto const& a, auto const& b) {
22012194
return std::tie(a.collisionIdx, a.rowIndex) < std::tie(b.collisionIdx, b.rowIndex);
@@ -2209,9 +2202,8 @@ struct lambdaspincorrderived {
22092202
continue;
22102203
}
22112204

2212-
// unbiased cap (cfgV5MaxMatches==1 => pick-one mode)
22132205
if (cfgV5MaxMatches.value > 0 && (int)matches.size() > cfgV5MaxMatches.value) {
2214-
uint64_t seed = 0;
2206+
uint64_t seed = cfgMixSeed.value;
22152207
seed ^= splitmix64((uint64_t)t1.globalIndex());
22162208
seed ^= splitmix64((uint64_t)t2.globalIndex() + 0x1234567ULL);
22172209
seed ^= splitmix64((uint64_t)curColIdx + 0x9abcULL);

0 commit comments

Comments
 (0)