Skip to content

Commit 3ba13b4

Browse files
committed
Initializing some variables for safer code (TableProducer). Adding integrated Ring vs Centrality and a single histogram comparing the 4 kinematic ring cuts on Lambdas and Jets. Fixing shadowed variables in the hasValidSubJet and hasValidLeadP blocks that calculated the ring observable
1 parent 08a03a1 commit 3ba13b4

File tree

2 files changed

+79
-26
lines changed

2 files changed

+79
-26
lines changed

PWGLF/TableProducer/Strangeness/lambdaJetPolarizationIons.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ struct lambdajetpolarizationions {
13461346

13471347
// Loop over reconstructed tracks:
13481348
std::vector<fastjet::PseudoJet> fjParticles;
1349-
int leadingParticleIdx; // An index inside fjParticles
1349+
int leadingParticleIdx = -1; // Initialized as -1, but could leave it unitialized as well. We reject any invalid events where this could pose a problem (e.g., pT<=0)
13501350
float leadingParticlePt = 0;
13511351
for (auto const& track : tracks){
13521352
// Require that tracks pass selection criteria
@@ -1359,8 +1359,9 @@ struct lambdajetpolarizationions {
13591359
fjParticles.emplace_back(candidate);
13601360

13611361
// Calculating leading particle
1362-
if (track.pt() > leadingParticlePt){
1363-
leadingParticlePt = track.pt();
1362+
float pt = candidate.pt();
1363+
if (pt > leadingParticlePt){
1364+
leadingParticlePt = pt;
13641365
leadingParticleIdx = fjParticles.size() - 1;
13651366
}
13661367
}

PWGLF/Tasks/Strangeness/lambdaJetPolarizationIonsDerived.cxx

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ constexpr double polPrefactorAntiLambda = 3.0/antiLambdaWeakDecayConstant;
150150
X(FOLDER "/p2dRingObservableMassVsCent", v0LambdaLikeMass, centrality, ringObservable) \
151151
/* 3D Profiles: Angle vs Mass vs Centrality */ \
152152
X(FOLDER "/p3dRingObservableDeltaPhiVsMassVsCent", deltaPhiJet, v0LambdaLikeMass, centrality, ringObservable) \
153-
X(FOLDER "/p3dRingObservableDeltaThetaVsMassVsCent", deltaThetaJet, v0LambdaLikeMass, centrality, ringObservable)
153+
X(FOLDER "/p3dRingObservableDeltaThetaVsMassVsCent", deltaThetaJet, v0LambdaLikeMass, centrality, ringObservable) \
154+
X(FOLDER "/pRingIntVsCentrality", centrality, ringObservable)
154155
// (TODO: add counters for regular TH2Ds about centrality)
155156

156157
// For leading particle
@@ -406,6 +407,8 @@ struct lambdajetpolarizationionsderived {
406407
histos.add((folder + "/p3dRingObservableDeltaPhiVsMassVsCent").c_str(), "p3dRingObservableDeltaPhiVsMassVsCent;#Delta#varphi;m_{p#pi};Centrality;<#it{R}>", kTProfile3D, {axisConfigurations.axisDeltaPhi, axisConfigurations.axisLambdaMassSigExtract, axisConfigurations.axisCentrality});
407408
// --- TProfile3D: <R> vs DeltaTheta vs Mass vs Centrality ---
408409
histos.add((folder + "/p3dRingObservableDeltaThetaVsMassVsCent").c_str(), "p3dRingObservableDeltaThetaVsMassVsCent;#Delta#theta;m_{p#pi};Centrality;<#it{R}>", kTProfile3D, {axisConfigurations.axisDeltaTheta, axisConfigurations.axisLambdaMassSigExtract, axisConfigurations.axisCentrality});
410+
// --- TProfile1D: Integrated <R> vs Centrality:
411+
histos.add((folder + "/pRingIntVsCentrality").c_str(), "pRingIntVsCentrality; Centrality (%);<#it{R}>", kTProfile, {axisConfigurations.axisCentrality});
409412

410413
// ===============================
411414
// Polarization observable QAs
@@ -444,6 +447,25 @@ struct lambdajetpolarizationionsderived {
444447
addRingObservableFamily("RingKinematicCuts");
445448
addRingObservableFamily("JetKinematicCuts");
446449
addRingObservableFamily("JetAndLambdaKinematicCuts");
450+
451+
histos.add("pRingCuts", "pRingCuts; ;<#it{R}>", kTProfile, {{4, 0, 4}});
452+
histos.get<TProfile>(HIST("pRingCuts"))->GetXaxis()->SetBinLabel(1, "All #Lambda");
453+
histos.get<TProfile>(HIST("pRingCuts"))->GetXaxis()->SetBinLabel(2, "p_{T}^{#Lambda}@[0.5,1.5],|y_{#Lambda}|<0.5"); // (v0pt > 0.5 && v0pt < 1.5) && std::abs(lambdaRapidity) < 0.5;
454+
histos.get<TProfile>(HIST("pRingCuts"))->GetXaxis()->SetBinLabel(3, "|Jet_{#eta}|<0.5");
455+
histos.get<TProfile>(HIST("pRingCuts"))->GetXaxis()->SetBinLabel(4, "#Lambda + Jet cuts");
456+
457+
// Same for subleading jet and leading particle:
458+
histos.add("pRingCutsSubLeadingJet", "pRingCutsSubLeadingJet; ;<#it{R}>", kTProfile, {{4, 0, 4}});
459+
histos.get<TProfile>(HIST("pRingCutsSubLeadingJet"))->GetXaxis()->SetBinLabel(1, "All #Lambda");
460+
histos.get<TProfile>(HIST("pRingCutsSubLeadingJet"))->GetXaxis()->SetBinLabel(2, "p_{T}^{#Lambda}@[0.5,1.5],|y_{#Lambda}|<0.5");
461+
histos.get<TProfile>(HIST("pRingCutsSubLeadingJet"))->GetXaxis()->SetBinLabel(3, "|Jet_{#eta}|<0.5");
462+
histos.get<TProfile>(HIST("pRingCutsSubLeadingJet"))->GetXaxis()->SetBinLabel(4, "#Lambda + Jet cuts");
463+
464+
histos.add("pRingCutsLeadingP", "pRingCutsLeadingP; ;<#it{R}>", kTProfile, {{4, 0, 4}});
465+
histos.get<TProfile>(HIST("pRingCutsLeadingP"))->GetXaxis()->SetBinLabel(1, "All #Lambda");
466+
histos.get<TProfile>(HIST("pRingCutsLeadingP"))->GetXaxis()->SetBinLabel(2, "p_{T}^{#Lambda}@[0.5,1.5],|y_{#Lambda}|<0.5");
467+
histos.get<TProfile>(HIST("pRingCutsLeadingP"))->GetXaxis()->SetBinLabel(3, "|Jet_{#eta}|<0.5");
468+
histos.get<TProfile>(HIST("pRingCutsLeadingP"))->GetXaxis()->SetBinLabel(4, "#Lambda + Jet cuts");
447469
}
448470

449471
// Initializing a random number generator for the worker (for perpendicular-to-jet direction QAs):
@@ -532,25 +554,25 @@ struct lambdajetpolarizationionsderived {
532554
double leadPEta = 0.; // safe dummy values -- only used when leadPPt > 0
533555
double leadPPhi = 0.;
534556
// std::optional avoids the unassigned-iterator trap again:
535-
std::optional<o2::aod::RingLeadP::iterator> leadingParticleOpt;
557+
std::optional<o2::aod::RingLeadP::iterator> leadingParticlePtr;
536558
auto leadPsInColl = leadPs.sliceBy(perColLeadPs, collId);
537559
for (auto const& lp : leadPsInColl) {
538560
// Table should contain exactly one entry per collision,
539561
// but we break immediately to be safe:
540-
leadingParticleOpt = lp;
562+
leadingParticlePtr = lp;
541563
break;
542564
}
543565
// Extract kinematics only if we actually found an entry:
544566
// (Physically, if there is at least one jet there should always be a
545567
// leading particle, but we guard against it anyway)
546-
if (leadingParticleOpt.has_value()) {
547-
leadPPt = leadingParticleOpt->leadParticlePt();
548-
leadPEta = leadingParticleOpt->leadParticleEta();
549-
leadPPhi = leadingParticleOpt->leadParticlePhi();
568+
if (leadingParticlePtr.has_value()) {
569+
leadPPt = leadingParticlePtr->leadParticlePt();
570+
leadPEta = leadingParticlePtr->leadParticleEta();
571+
leadPPhi = leadingParticlePtr->leadParticlePhi();
550572
}
551573

552-
// Defining some bools to help:
553-
bool hasValidLeadP = leadPPt > 0.;
574+
// Defining some bools to help (useful when no subleading jet was found):
575+
bool hasValidLeadP = leadPPt > 0.; // Should ALWAYS be true. There is no leading jet without a leading particle and we check for leading jets!
554576
bool hasValidSubJet = subleadingJetPt > 0.;
555577

556578
// --- Subleading jet (only valid when subleadingJetPt > 0) ---
@@ -649,13 +671,13 @@ struct lambdajetpolarizationionsderived {
649671
// Cross product
650672
XYZVector cross2ndJet = subJetUnitVec.Cross(lambdaLike3Vec);
651673
double crossProductNorm2ndJet = cross2ndJet.R();
652-
double ringObservable2ndJet = protonLikeStarUnit3Vec.Dot(cross2ndJet) / crossProductNorm2ndJet;
674+
ringObservable2ndJet = protonLikeStarUnit3Vec.Dot(cross2ndJet) / crossProductNorm2ndJet;
653675
// Adding prefactor
654676
if (!forcePolSignQA) ringObservable2ndJet *= (isLambda) ? polPrefactorLambda : polPrefactorAntiLambda;
655677
else ringObservable2ndJet *= (isLambda) ? polPrefactorLambda : -1.0 * polPrefactorAntiLambda;
656678
// Angular variables
657-
double deltaPhi2ndJet = wrapToPiFast(v0phi - subleadingJetPhi);
658-
double deltaTheta2ndJet = ROOT::Math::VectorUtil::Angle(subJetUnitVec, lambdaLike3Vec);
679+
deltaPhi2ndJet = wrapToPiFast(v0phi - subleadingJetPhi);
680+
deltaTheta2ndJet = ROOT::Math::VectorUtil::Angle(subJetUnitVec, lambdaLike3Vec);
659681
}
660682

661683
////////////////////////////////////////////
@@ -668,13 +690,13 @@ struct lambdajetpolarizationionsderived {
668690
// Cross product
669691
XYZVector crossLeadP = leadPUnitVec.Cross(lambdaLike3Vec);
670692
double crossProductNormLeadP = crossLeadP.R();
671-
double ringObservableLeadP = protonLikeStarUnit3Vec.Dot(crossLeadP) / crossProductNormLeadP;
693+
ringObservableLeadP = protonLikeStarUnit3Vec.Dot(crossLeadP) / crossProductNormLeadP;
672694
// Adding prefactor
673695
if (!forcePolSignQA) ringObservableLeadP *= (isLambda) ? polPrefactorLambda : polPrefactorAntiLambda;
674696
else ringObservableLeadP *= (isLambda) ? polPrefactorLambda : -1.0 * polPrefactorAntiLambda;
675697
// Angular variables
676-
double deltaPhiLeadP = wrapToPiFast(v0phi - leadPPhi);
677-
double deltaThetaLeadP = ROOT::Math::VectorUtil::Angle(leadPUnitVec, lambdaLike3Vec);
698+
deltaPhiLeadP = wrapToPiFast(v0phi - leadPPhi);
699+
deltaThetaLeadP = ROOT::Math::VectorUtil::Angle(leadPUnitVec, lambdaLike3Vec);
678700
}
679701

680702
// Calculating polarization observables (in the Lambda frame, because that is easier -- does not require boosts):
@@ -696,36 +718,66 @@ struct lambdajetpolarizationionsderived {
696718
// Fill ring histograms: (1D, lambda 2D correlations and jet 2D correlations):
697719
RING_OBSERVABLE_FILL_LIST(APPLY_HISTO_FILL, "Ring") // Notice the usage of macros! If you change the variable names, this WILL break the code!
698720
// No, there should NOT be any ";" here! Read the macro definition for an explanation
699-
if (hasValidLeadP) {RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "Ring")}
700-
if (hasValidSubJet) {RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "Ring")}
721+
histos.fill(HIST("pRingCuts"), 0, ringObservable); // First bin of comparison
722+
723+
// Checks with other jet proxies:
724+
if (hasValidLeadP) {
725+
RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "Ring")
726+
histos.fill(HIST("pRingCutsLeadingP"), 0, ringObservableLeadP);
727+
}
728+
if (hasValidSubJet) {
729+
RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "Ring")
730+
histos.fill(HIST("pRingCutsSubLeadingJet"), 0, ringObservable2ndJet);
731+
}
701732
POLARIZATION_PROFILE_FILL_LIST(APPLY_HISTO_FILL, "Ring")
702733

703734
// Extra kinematic criteria for Lambda candidates (removes polarization background):
704735
const bool kinematicLambdaCheck = (v0pt > 0.5 && v0pt < 1.5) && std::abs(lambdaRapidity) < 0.5;
705736
if (kinematicLambdaCheck){
706737
RING_OBSERVABLE_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")
738+
histos.fill(HIST("pRingCuts"), 1, ringObservable);
707739
POLARIZATION_PROFILE_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")
708-
if (hasValidLeadP) {RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")}
709-
if (hasValidSubJet) {RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")}
740+
if (hasValidLeadP) {
741+
RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")
742+
histos.fill(HIST("pRingCutsLeadingP"), 1, ringObservableLeadP);
743+
}
744+
if (hasValidSubJet) {
745+
RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "RingKinematicCuts")
746+
histos.fill(HIST("pRingCutsSubLeadingJet"), 1, ringObservable2ndJet);
747+
}
710748
}
711749

712750
// Extra selection criteria on jet candidates:
713751
if (kinematicJetCheck){ // This is redundant for jets with R=0.4, but for jets with R<0.4 the leading jet may be farther in eta.
714752
RING_OBSERVABLE_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")
753+
histos.fill(HIST("pRingCuts"), 2, ringObservable);
715754
POLARIZATION_PROFILE_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")
716755
}
717756

718757
// Extra selection criteria on both Lambda and jet candidates:
719758
if (kinematicLambdaCheck && kinematicJetCheck){
720759
RING_OBSERVABLE_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")
760+
histos.fill(HIST("pRingCuts"), 3, ringObservable);
721761
POLARIZATION_PROFILE_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")
722762
}
723763

724764
// Same variations for the leading particle and for the subleading jet:
725-
if (kinematicLeadPCheck){RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")}
726-
if (kinematic2ndJetCheck){RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")}
727-
if (kinematicLambdaCheck && kinematicLeadPCheck){RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")}
728-
if (kinematicLambdaCheck && kinematic2ndJetCheck){RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")}
765+
if (kinematicLeadPCheck){
766+
RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")
767+
histos.fill(HIST("pRingCutsLeadingP"), 2, ringObservableLeadP);
768+
}
769+
if (kinematic2ndJetCheck){
770+
RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "JetKinematicCuts")
771+
histos.fill(HIST("pRingCutsSubLeadingJet"), 2, ringObservable2ndJet);
772+
}
773+
if (kinematicLambdaCheck && kinematicLeadPCheck){
774+
RING_OBSERVABLE_LEADP_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")
775+
histos.fill(HIST("pRingCutsLeadingP"), 3, ringObservableLeadP);
776+
}
777+
if (kinematicLambdaCheck && kinematic2ndJetCheck){
778+
RING_OBSERVABLE_2NDJET_FILL_LIST(APPLY_HISTO_FILL, "JetAndLambdaKinematicCuts")
779+
histos.fill(HIST("pRingCutsSubLeadingJet"), 3, ringObservable2ndJet);
780+
}
729781
} // end v0s loop
730782
} // end collisions
731783
}

0 commit comments

Comments
 (0)