Skip to content

Commit fd73601

Browse files
authored
[PWGLF] Fix single leg weight (#13789)
1 parent 5b19637 commit fd73601

File tree

1 file changed

+50
-46
lines changed

1 file changed

+50
-46
lines changed

PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ struct lambdaspincorrderived {
529529
void fillHistograms2(int tag1, int tag2,
530530
const ROOT::Math::PtEtaPhiMVector& particle1, const ROOT::Math::PtEtaPhiMVector& particle2,
531531
const ROOT::Math::PtEtaPhiMVector& daughpart1, const ROOT::Math::PtEtaPhiMVector& daughpart2,
532-
int datatype, float mixpairweight)
532+
int datatype, float mixpairweight, int mixedLeg)
533533
{
534534

535535
auto lambda1Mass = 0.0;
@@ -615,39 +615,43 @@ struct lambdaspincorrderived {
615615
double deltaR = TMath::Sqrt(deta_pair * deta_pair + dphi_pair * dphi_pair);
616616
double deltaRap = std::abs(particle1.Rapidity() - particle2.Rapidity());
617617

618-
double epsWeight1 = 1.0;
619-
double epsWeight2 = 1.0;
620-
621-
if (useweight && datatype == 1) {
622-
// --- Leg 1: choose map only by species (tag1) ---
623-
if (tag1 == 0) { // Λ
624-
if (hweight1) {
625-
epsWeight1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1));
618+
// -----------------------------
619+
// Kinematic *matching* weight
620+
// (only for mixed events, only mixed leg)
621+
// -----------------------------
622+
double epsWeightMixedLeg = 1.0;
623+
if (useweight && datatype == 1) { // only for ME
624+
if (mixedLeg == 1) {
625+
// Only leg 1 is from the mixing pool
626+
double w1 = 1.0;
627+
if (tag1 == 0) { // Λ
628+
if (hweight1) {
629+
w1 = hweight1->GetBinContent(hweight1->FindBin(dphi1, deta1, pt1));
630+
}
631+
} else { // Λbar
632+
if (hweight4) {
633+
w1 = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1));
634+
}
626635
}
627-
} else { // Λ̄
628-
if (hweight4) {
629-
epsWeight1 = hweight4->GetBinContent(hweight4->FindBin(dphi1, deta1, pt1));
636+
if (w1 > 0.0 && std::isfinite(w1)) {
637+
epsWeightMixedLeg = w1;
630638
}
631-
}
632-
633-
// --- Leg 2: choose map only by species (tag2) ---
634-
if (tag2 == 0) { // Λ
635-
if (hweight12) {
636-
epsWeight2 = hweight12->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2));
639+
} else if (mixedLeg == 2) {
640+
// Only leg 2 is from the mixing pool
641+
double w2 = 1.0;
642+
if (tag2 == 0) { // Λ
643+
if (hweight12) {
644+
w2 = hweight12->GetBinContent(hweight12->FindBin(dphi2, deta2, pt2));
645+
}
646+
} else { // Λbar
647+
if (hweight42) {
648+
w2 = hweight42->GetBinContent(hweight42->FindBin(dphi2, deta2, pt2));
649+
}
637650
}
638-
} else { // Λ̄
639-
if (hweight42) {
640-
epsWeight2 = hweight42->GetBinContent(hweight42->FindBin(dphi2, deta2, pt2));
651+
if (w2 > 0.0 && std::isfinite(w2)) {
652+
epsWeightMixedLeg = w2;
641653
}
642654
}
643-
644-
// Safety: avoid zero/NaN
645-
if (epsWeight1 <= 0.0 || !std::isfinite(epsWeight1)) {
646-
epsWeight1 = 1.0;
647-
}
648-
if (epsWeight2 <= 0.0 || !std::isfinite(epsWeight2)) {
649-
epsWeight2 = 1.0;
650-
}
651655
}
652656

653657
if (datatype == 0) {
@@ -694,9 +698,9 @@ struct lambdaspincorrderived {
694698
double weight = mixpairweight;
695699
if (useweight) {
696700
if (usebothweight) {
697-
weight = mixpairweight / (epsWeight1 * epsWeight2);
701+
weight = mixpairweight / (epsWeightMixedLeg);
698702
} else {
699-
weight = mixpairweight / (epsWeight1);
703+
weight = mixpairweight / (epsWeightMixedLeg);
700704
}
701705
}
702706
if (weight <= 0.0) {
@@ -787,16 +791,16 @@ struct lambdaspincorrderived {
787791
lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass());
788792
histos.fill(HIST("deltaPhiSame"), RecoDecay::constrainAngle(v0.lambdaPhi() - v02.lambdaPhi(), 0.0F, harmonicDphi));
789793
if (v0.v0Status() == 0 && v02.v0Status() == 0) {
790-
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 0, 1.0);
794+
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0);
791795
}
792796
if (v0.v0Status() == 0 && v02.v0Status() == 1) {
793-
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 0, 1.0);
797+
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0);
794798
}
795799
if (v0.v0Status() == 1 && v02.v0Status() == 0) {
796-
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 0, 1.0);
800+
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 0, 1.0, 0);
797801
}
798802
if (v0.v0Status() == 1 && v02.v0Status() == 1) {
799-
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 0, 1.0);
803+
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 0, 1.0, 0);
800804
}
801805
}
802806
}
@@ -859,16 +863,16 @@ struct lambdaspincorrderived {
859863
lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass());
860864
histos.fill(HIST("deltaPhiMix"), RecoDecay::constrainAngle(t3.lambdaPhi() - t2.lambdaPhi(), 0.0F, harmonicDphi));
861865
if (t3.v0Status() == 0 && t2.v0Status() == 0) {
862-
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, 1.0);
866+
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1);
863867
}
864868
if (t3.v0Status() == 0 && t2.v0Status() == 1) {
865-
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, 1.0);
869+
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1);
866870
}
867871
if (t3.v0Status() == 1 && t2.v0Status() == 0) {
868-
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, 1.0);
872+
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, 1.0, 1);
869873
}
870874
if (t3.v0Status() == 1 && t2.v0Status() == 1) {
871-
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, 1.0);
875+
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, 1.0, 1);
872876
}
873877
}
874878
} // replacement track pair
@@ -939,16 +943,16 @@ struct lambdaspincorrderived {
939943
histos.fill(HIST("deltaPhiMix"), dPhi, invN);
940944

941945
if (t3.v0Status() == 0 && t2.v0Status() == 0) {
942-
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, invN);
946+
fillHistograms2(0, 0, lambda, lambda2, proton, proton2, 1, invN, 1);
943947
}
944948
if (t3.v0Status() == 0 && t2.v0Status() == 1) {
945-
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, invN);
949+
fillHistograms2(0, 1, lambda, lambda2, proton, proton2, 1, invN, 1);
946950
}
947951
if (t3.v0Status() == 1 && t2.v0Status() == 0) {
948-
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, invN);
952+
fillHistograms2(1, 0, lambda, lambda2, proton, proton2, 1, invN, 1);
949953
}
950954
if (t3.v0Status() == 1 && t2.v0Status() == 1) {
951-
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, invN);
955+
fillHistograms2(1, 1, lambda, lambda2, proton, proton2, 1, invN, 1);
952956
}
953957
}
954958
} // end mixing-event loop
@@ -1047,7 +1051,7 @@ struct lambdaspincorrderived {
10471051

10481052
const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic));
10491053
histos.fill(HIST("deltaPhiMix"), dPhi, wBase);
1050-
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase);
1054+
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda, lambda2, proton, proton2, 1, wBase, 1);
10511055
}
10521056
}
10531057
}
@@ -1285,7 +1289,7 @@ struct lambdaspincorrderived {
12851289
const float dPhi = std::fabs(RecoDecay::constrainAngle(lambda1.Phi() - lambda2.Phi(), 0.0F, harmonicDphi));
12861290
histos.fill(HIST("deltaPhiMix"), dPhi, w1);
12871291

1288-
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda1, lambda2, proton1, proton2, 1, w1);
1292+
fillHistograms2(tX.v0Status(), t2.v0Status(), lambda1, lambda2, proton1, proton2, 1, w1, 1);
12891293
}
12901294

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

1308-
fillHistograms2(t1.v0Status(), tY.v0Status(), lambda1, lambda2, proton1, proton2, 1, w2);
1312+
fillHistograms2(t1.v0Status(), tY.v0Status(), lambda1, lambda2, proton1, proton2, 1, w2, 2);
13091313
}
13101314
}
13111315
}

0 commit comments

Comments
 (0)