@@ -759,7 +759,8 @@ struct lambdaspincorrderived {
759759 continue ;
760760 proton2 = ROOT::Math::PtEtaPhiMVector (v02.protonPt (), v02.protonEta (), v02.protonPhi (), o2::constants::physics::MassProton);
761761 lambda2 = ROOT::Math::PtEtaPhiMVector (v02.lambdaPt (), v02.lambdaEta (), v02.lambdaPhi (), v02.lambdaMass ());
762- histos.fill (HIST (" deltaPhiSame" ), RecoDecay::constrainAngle (v0.lambdaPhi () - v02.lambdaPhi (), -TMath::Pi (), harmonicDphi));
762+ if ((v0.v0Status () == 0 && v02.v0Status () == 1 ) || (v0.v0Status () == 1 && v02.v0Status () == 0 ))
763+ histos.fill (HIST (" deltaPhiSame" ), RecoDecay::constrainAngle (v0.lambdaPhi () - v02.lambdaPhi (), -TMath::Pi (), harmonicDphi));
763764 // const int ptype = pairTypeCode(v0.v0Status(), v02.v0Status());
764765 if (v0.v0Status () == 0 && v02.v0Status () == 0 ) {
765766 fillHistograms (0 , 0 , lambda, lambda2, proton, proton2, 0 , 1.0 );
@@ -768,7 +769,7 @@ struct lambdaspincorrderived {
768769 fillHistograms (0 , 1 , lambda, lambda2, proton, proton2, 0 , 1.0 );
769770 }
770771 if (v0.v0Status () == 1 && v02.v0Status () == 0 ) {
771- fillHistograms (1 , 0 , lambda , lambda2, proton , proton2, 0 , 1.0 );
772+ fillHistograms (0 , 1 , lambda2, lambda , proton2, proton , 0 , 1.0 );
772773 }
773774 if (v0.v0Status () == 1 && v02.v0Status () == 1 ) {
774775 fillHistograms (1 , 1 , lambda, lambda2, proton, proton2, 0 , 1.0 );
@@ -1301,11 +1302,18 @@ struct lambdaspincorrderived {
13011302 RecoDecay::constrainAngle (mcacc::lamPhi (v0) - mcacc::lamPhi (v02),
13021303 -TMath::Pi (), harmonicDphi));
13031304
1304- // const int ptype = pairTypeCode(mcacc::v0Status(v0), mcacc::v0Status(v02));
1305- // datatype=0 (same event)
1306- fillHistograms (mcacc::v0Status (v0), mcacc::v0Status (v02),
1307- lambda, lambda2, proton, proton2,
1308- /* datatype=*/ 0 , /* mixpairweight=*/ 1 .0f );
1305+ const int s1 = mcacc::v0Status (v0);
1306+ const int s2 = mcacc::v0Status (v02);
1307+
1308+ if (s1 == 0 && s2 == 0 ) {
1309+ fillHistograms (0 , 0 , lambda, lambda2, proton, proton2, 0 , 1 .0f );
1310+ } else if (s1 == 0 && s2 == 1 ) {
1311+ fillHistograms (0 , 1 , lambda, lambda2, proton, proton2, 0 , 1 .0f );
1312+ } else if (s1 == 1 && s2 == 0 ) {
1313+ fillHistograms (0 , 1 , lambda2, lambda, proton2, proton, 0 , 1 .0f );
1314+ } else if (s1 == 1 && s2 == 1 ) {
1315+ fillHistograms (1 , 1 , lambda, lambda2, proton, proton2, 0 , 1 .0f );
1316+ }
13091317 }
13101318 }
13111319 }
@@ -1752,8 +1760,18 @@ struct lambdaspincorrderived {
17521760
17531761 const float meWeight = wSE;
17541762 const float dPhi = deltaPhiMinusPiToPi ((float )lambda.Phi (), (float )lambda2.Phi ());
1755- histos.fill (HIST (" deltaPhiMix" ), dPhi, wSE);
1756- fillHistograms (tX.v0Status (), t2.v0Status (), lambda, lambda2, proton, proton2, 1 , meWeight, 1 );
1763+ if ((tX.v0Status () == 0 && t2.v0Status () == 1 ) || (tX.v0Status () == 1 && t2.v0Status () == 0 ))
1764+ histos.fill (HIST (" deltaPhiMix" ), dPhi, wSE);
1765+ const int s1 = tX.v0Status ();
1766+ const int s2 = t2.v0Status ();
1767+
1768+ if (s1 == 0 && s2 == 1 ) {
1769+ fillHistograms (0 , 1 , lambda, lambda2, proton, proton2, 1 , meWeight, 1 );
1770+ } else if (s1 == 1 && s2 == 0 ) {
1771+ fillHistograms (0 , 1 , lambda2, lambda, proton2, proton, 1 , meWeight, 2 );
1772+ } else {
1773+ fillHistograms (s1, s2, lambda, lambda2, proton, proton2, 1 , meWeight, 1 );
1774+ }
17571775 }
17581776 }
17591777
@@ -1785,7 +1803,15 @@ struct lambdaspincorrderived {
17851803 const float meWeight = wSE;
17861804 const float dPhi = deltaPhiMinusPiToPi ((float )lambda.Phi (), (float )lambda2.Phi ());
17871805 histos.fill (HIST (" deltaPhiMix" ), dPhi, wSE);
1788- fillHistograms (t1.v0Status (), tY.v0Status (), lambda, lambda2, proton, proton2, 1 , meWeight, 2 );
1806+ const int s1 = t1.v0Status ();
1807+ const int s2 = tY.v0Status ();
1808+ if (s1 == 0 && s2 == 1 ) {
1809+ fillHistograms (0 , 1 , lambda, lambda2, proton, proton2, 1 , meWeight, 2 );
1810+ } else if (s1 == 1 && s2 == 0 ) {
1811+ fillHistograms (0 , 1 , lambda2, lambda, proton2, proton, 1 , meWeight, 1 );
1812+ } else {
1813+ fillHistograms (s1, s2, lambda, lambda2, proton, proton2, 1 , meWeight, 2 );
1814+ }
17891815 }
17901816 }
17911817 }
@@ -1948,26 +1974,59 @@ struct lambdaspincorrderived {
19481974
19491975 collectFromBins (ptBins, etaBins, phiBins);
19501976
1951- // 2) if exact bin does not give enough, top up from neighbors
1977+ // 2) if exact bin gives fewer than required matches, also search neighbors
19521978 const int targetMatches = (cfgV5MaxMatches.value > 0 ) ? cfgV5MaxMatches.value : 1 ;
19531979
19541980 if ((int )matches.size () < targetMatches) {
1955- collectNeighborBinsClamp (ptB, nPt, nN_pt, ptBins);
1956- collectNeighborBinsClamp (etaB, nEta, nN_eta, etaBins);
1957- collectNeighborBinsPhi (phiB, nPhi, nN_phi, phiBins);
1981+ std::vector<int > ptBinsN, etaBinsN, phiBinsN;
1982+ collectNeighborBinsClamp (ptB, nPt, nN_pt, ptBinsN);
1983+ collectNeighborBinsClamp (etaB, nEta, nN_eta, etaBinsN);
1984+ collectNeighborBinsPhi (phiB, nPhi, nN_phi, phiBinsN);
19581985
1959- collectFromBins (ptBins, etaBins, phiBins);
1960- }
1986+ for (int ptUse : ptBinsN) {
1987+ for (int etaUse : etaBinsN) {
1988+ for (int phiUse : phiBinsN) {
1989+ if (ptUse == ptB && etaUse == etaB && phiUse == phiB) {
1990+ continue ;
1991+ }
19611992
1962- // if nothing found, then try neighboring bins
1963- if (matches.empty ()) {
1964- collectNeighborBinsClamp (ptB, nPt, nN_pt, ptBins);
1965- collectNeighborBinsClamp (etaB, nEta, nN_eta, etaBins);
1966- collectNeighborBinsPhi (phiB, nPhi, nN_phi, phiBins);
1993+ const auto & vec = buffer[linearKeyR (colBin, status, ptUse, etaUse, phiUse, mB , rB,
1994+ nStat, nPt, nEta, nPhi, nM, nR)];
19671995
1968- collectFromBins (ptBins, etaBins, phiBins);
1969- }
1996+ for (auto const & bc : vec) {
1997+ if (bc.collisionIdx == curColIdx) {
1998+ continue ;
1999+ }
19702000
2001+ auto tX = V0sMC.iteratorAt (static_cast <uint64_t >(bc.rowIndex ));
2002+
2003+ if (!selectionV0MC (tX)) {
2004+ continue ;
2005+ }
2006+ if (!checkKinematicsMC (tRep, tX)) {
2007+ continue ;
2008+ }
2009+
2010+ if (tX.globalIndex () == tRep.globalIndex ()) {
2011+ continue ;
2012+ }
2013+ if (tX.globalIndex () == tKeep.globalIndex ()) {
2014+ continue ;
2015+ }
2016+
2017+ if (hasSharedDaughtersMC (tX, tKeep)) {
2018+ continue ;
2019+ }
2020+ if (hasSharedDaughtersMC (tX, tRep)) {
2021+ continue ;
2022+ }
2023+
2024+ matches.push_back (MatchRef{bc.collisionIdx , bc.rowIndex });
2025+ }
2026+ }
2027+ }
2028+ }
2029+ }
19712030 std::sort (matches.begin (), matches.end (),
19722031 [](auto const & a, auto const & b) {
19732032 return std::tie (a.collisionIdx , a.rowIndex ) < std::tie (b.collisionIdx , b.rowIndex );
@@ -2124,9 +2183,16 @@ struct lambdaspincorrderived {
21242183 const float meWeight = wSE;
21252184 const float dPhi = deltaPhiMinusPiToPi ((float )lX.Phi (), (float )l2.Phi ());
21262185 histos.fill (HIST (" deltaPhiMix" ), dPhi, wSE);
2127- fillHistograms (mcacc::v0Status (tX), mcacc::v0Status (t2),
2128- lX, l2, pX, p2,
2129- 1 , meWeight, 1 );
2186+ const int s1 = mcacc::v0Status (tX);
2187+ const int s2 = mcacc::v0Status (t2);
2188+
2189+ if (s1 == 0 && s2 == 1 ) {
2190+ fillHistograms (0 , 1 , lX, l2, pX, p2, 1 , meWeight, 1 );
2191+ } else if (s1 == 1 && s2 == 0 ) {
2192+ fillHistograms (0 , 1 , l2, lX, p2, pX, 1 , meWeight, 2 );
2193+ } else {
2194+ fillHistograms (s1, s2, lX, l2, pX, p2, 1 , meWeight, 1 );
2195+ }
21302196 }
21312197 }
21322198 if (doMixLeg2 && nFill2 > 0 ) {
@@ -2162,9 +2228,16 @@ struct lambdaspincorrderived {
21622228 const float meWeight = wSE;
21632229 const float dPhi = deltaPhiMinusPiToPi ((float )l1.Phi (), (float )lY.Phi ());
21642230 histos.fill (HIST (" deltaPhiMix" ), dPhi, wSE);
2165- fillHistograms (mcacc::v0Status (t1), mcacc::v0Status (tY),
2166- l1, lY, p1, pY,
2167- 1 , meWeight, 2 );
2231+ const int s1 = mcacc::v0Status (t1);
2232+ const int s2 = mcacc::v0Status (tY);
2233+
2234+ if (s1 == 0 && s2 == 1 ) {
2235+ fillHistograms (0 , 1 , l1, lY, p1, pY, 1 , meWeight, 2 );
2236+ } else if (s1 == 1 && s2 == 0 ) {
2237+ fillHistograms (0 , 1 , lY, l1, pY, p1, 1 , meWeight, 1 );
2238+ } else {
2239+ fillHistograms (s1, s2, l1, lY, p1, pY, 1 , meWeight, 2 );
2240+ }
21682241 }
21692242 }
21702243 }
0 commit comments