Skip to content

Commit 37c14c2

Browse files
authored
[ALICE3] Refactor hFastTrackerQA histogram creation and logging (#14492)
1 parent 6a795e2 commit 37c14c2

File tree

1 file changed

+73
-48
lines changed

1 file changed

+73
-48
lines changed

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -460,32 +460,32 @@ struct OnTheFlyTracker {
460460
histos.add("h2dDeltaEtaVsPt", "h2dDeltaEtaVsPt", kTH2F, {axes.axisMomentum, axes.axisDeltaEta});
461461

462462
histos.add("hFastTrackerHits", "hFastTrackerHits", kTH2F, {axes.axisZ, axes.axisRadius});
463-
auto hFastTrackerQA = histos.add<TH1>("hFastTrackerQA", "hFastTrackerQA", kTH1D, {{8, -0.5f, 7.5f}});
464-
hFastTrackerQA->GetXaxis()->SetBinLabel(1, "Negative eigenvalue");
465-
hFastTrackerQA->GetXaxis()->SetBinLabel(2, "Failed sanity check");
466-
hFastTrackerQA->GetXaxis()->SetBinLabel(3, "intercept original radius");
467-
hFastTrackerQA->GetXaxis()->SetBinLabel(4, "propagate to original radius");
468-
hFastTrackerQA->GetXaxis()->SetBinLabel(5, "problematic layer");
469-
hFastTrackerQA->GetXaxis()->SetBinLabel(6, "multiple scattering");
470-
hFastTrackerQA->GetXaxis()->SetBinLabel(7, "energy loss");
471-
hFastTrackerQA->GetXaxis()->SetBinLabel(8, "efficiency");
463+
auto h = histos.add<TH1>("hFastTrackerQA", "hFastTrackerQA", kTH1D, {{8, -0.5f, 7.5f}});
464+
h->GetXaxis()->SetBinLabel(1, "Negative eigenvalue");
465+
h->GetXaxis()->SetBinLabel(2, "Failed sanity check");
466+
h->GetXaxis()->SetBinLabel(3, "intercept original radius");
467+
h->GetXaxis()->SetBinLabel(4, "propagate to original radius");
468+
h->GetXaxis()->SetBinLabel(5, "problematic layer");
469+
h->GetXaxis()->SetBinLabel(6, "multiple scattering");
470+
h->GetXaxis()->SetBinLabel(7, "energy loss");
471+
h->GetXaxis()->SetBinLabel(8, "efficiency");
472472
}
473-
if (v0DecaySettings.doV0QA) {
474473

474+
if (v0DecaySettings.doV0QA) {
475475
for (int icfg = 0; icfg < nGeometries; icfg++) {
476476
std::string v0histPath = "V0Building_Configuration_" + std::to_string(icfg) + "/";
477477
insertHist(v0histPath + "hV0Building", "hV0Building", kTH1F, {{10, -0.5f, 9.5f}});
478478
insertHist(v0histPath + "hFastTrackerHits", "hV0Building", kTH2F, {{axes.axisZ, axes.axisRadius}});
479-
auto hFastTrackerQA = histos.add<TH1>(v0histPath + "hFastTrackerQA", "hFastTrackerQA", kTH1D, {{8, -0.5f, 7.5f}});
480-
hFastTrackerQA->GetXaxis()->SetBinLabel(1, "Negative eigenvalue");
481-
hFastTrackerQA->GetXaxis()->SetBinLabel(2, "Failed sanity check");
482-
hFastTrackerQA->GetXaxis()->SetBinLabel(3, "intercept original radius");
483-
hFastTrackerQA->GetXaxis()->SetBinLabel(4, "propagate to original radius");
484-
hFastTrackerQA->GetXaxis()->SetBinLabel(5, "problematic layer");
485-
hFastTrackerQA->GetXaxis()->SetBinLabel(6, "multiple scattering");
486-
hFastTrackerQA->GetXaxis()->SetBinLabel(7, "energy loss");
487-
hFastTrackerQA->GetXaxis()->SetBinLabel(8, "efficiency");
488-
histPointers.insert({v0histPath + "hFastTrackerQA", hFastTrackerQA});
479+
auto h = histos.add<TH1>(v0histPath + "hFastTrackerQA", "hFastTrackerQA", kTH1D, {{8, -0.5f, 7.5f}});
480+
h->GetXaxis()->SetBinLabel(1, "Negative eigenvalue");
481+
h->GetXaxis()->SetBinLabel(2, "Failed sanity check");
482+
h->GetXaxis()->SetBinLabel(3, "intercept original radius");
483+
h->GetXaxis()->SetBinLabel(4, "propagate to original radius");
484+
h->GetXaxis()->SetBinLabel(5, "problematic layer");
485+
h->GetXaxis()->SetBinLabel(6, "multiple scattering");
486+
h->GetXaxis()->SetBinLabel(7, "energy loss");
487+
h->GetXaxis()->SetBinLabel(8, "efficiency");
488+
histPointers.insert({v0histPath + "hFastTrackerQA", h});
489489
// K0s
490490
insertHist(v0histPath + "K0/hGen", "hGen", kTH2F, {axes.axisDecayRadius, axes.axisMomentum});
491491
insertHist(v0histPath + "K0/hReco", "hReco", kTH2F, {axes.axisDecayRadius, axes.axisMomentum});
@@ -630,21 +630,28 @@ struct OnTheFlyTracker {
630630
double posDauMass = -1.;
631631
double ctau = -1.;
632632

633-
if (std::abs(pdgCode) == kK0Short) {
634-
v0Mass = o2::constants::physics::MassK0Short;
635-
negDauMass = o2::constants::physics::MassPionCharged;
636-
posDauMass = o2::constants::physics::MassPionCharged;
637-
ctau = 2.68;
638-
} else if (pdgCode == kLambda0) {
639-
v0Mass = o2::constants::physics::MassLambda;
640-
negDauMass = o2::constants::physics::MassPionCharged;
641-
posDauMass = o2::constants::physics::MassProton;
642-
ctau = 7.845;
643-
} else if (pdgCode == kLambda0Bar) {
644-
v0Mass = o2::constants::physics::MassLambda;
645-
negDauMass = o2::constants::physics::MassProton;
646-
posDauMass = o2::constants::physics::MassPionCharged;
647-
ctau = 7.845;
633+
switch (pdgCode) {
634+
case kK0Short:
635+
case -kK0Short:
636+
v0Mass = o2::constants::physics::MassK0Short;
637+
negDauMass = o2::constants::physics::MassPionCharged;
638+
posDauMass = o2::constants::physics::MassPionCharged;
639+
ctau = 2.68;
640+
break;
641+
case kLambda0:
642+
v0Mass = o2::constants::physics::MassLambda;
643+
negDauMass = o2::constants::physics::MassPionCharged;
644+
posDauMass = o2::constants::physics::MassProton;
645+
ctau = 7.845;
646+
break;
647+
case kLambda0Bar:
648+
v0Mass = o2::constants::physics::MassLambda;
649+
negDauMass = o2::constants::physics::MassProton;
650+
posDauMass = o2::constants::physics::MassPionCharged;
651+
ctau = 7.845;
652+
break;
653+
default:
654+
LOG(fatal) << "Trying to decay unsupported V0 with PDG " << pdgCode;
648655
}
649656

650657
const double v0BetaGamma = particle.p() / v0Mass;
@@ -666,6 +673,7 @@ struct OnTheFlyTracker {
666673
float dNdEta = 0.f; // Charged particle multiplicity to use in the efficiency evaluation
667674
void processWithLUTs(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, int const& icfg)
668675
{
676+
LOG(debug) << "Processing event " << mcCollision.globalIndex() << " with LUTs for configuration " << icfg;
669677
int lastTrackIndex = tableStoredTracksCov.lastIndex() + 1; // bookkeep the last added track
670678
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
671679

@@ -695,6 +703,7 @@ struct OnTheFlyTracker {
695703

696704
// First we compute the number of charged particles in the event
697705
dNdEta = 0.f;
706+
LOG(debug) << "Processing " << mcParticles.size() << " MC particles to compute dNch/deta";
698707
for (const auto& mcParticle : mcParticles) {
699708
if (std::abs(mcParticle.eta()) > multEtaRange) {
700709
continue;
@@ -722,6 +731,7 @@ struct OnTheFlyTracker {
722731
}
723732
dNdEta += 1.f;
724733
}
734+
LOG(debug) << "Computed dNch/deta before normalization: " << dNdEta;
725735

726736
dNdEta /= (multEtaRange * 2.0f);
727737
uint32_t multiplicityCounter = 0;
@@ -731,7 +741,7 @@ struct OnTheFlyTracker {
731741
double xiDecayRadius2D = 0;
732742
double laDecayRadius2D = 0;
733743
double v0DecayRadius2D = 0;
734-
std::vector<TLorentzVector> decayProducts;
744+
std::vector<TLorentzVector> cascadeDecayProducts;
735745
std::vector<TLorentzVector> v0DecayProducts;
736746
std::vector<double> xiDecayVertex, laDecayVertex, v0DecayVertex;
737747
for (const auto& mcParticle : mcParticles) {
@@ -742,11 +752,17 @@ struct OnTheFlyTracker {
742752
laDecayVertex.clear();
743753
v0DecayVertex.clear();
744754

755+
cascadeDecayProducts.clear();
756+
v0DecayProducts.clear();
757+
745758
if (cascadeDecaySettings.decayXi) {
746759
if (mcParticle.pdgCode() == kXiMinus) {
747760
o2::track::TrackParCov xiTrackParCov;
748761
o2::upgrade::convertMCParticleToO2Track(mcParticle, xiTrackParCov, pdgDB);
749-
decayCascade(mcParticle, xiTrackParCov, decayProducts, xiDecayVertex, laDecayVertex);
762+
decayCascade(mcParticle, xiTrackParCov, cascadeDecayProducts, xiDecayVertex, laDecayVertex);
763+
if (cascadeDecayProducts.size() != 3) {
764+
LOG(fatal) << "Xi decay did not produce 3 daughters as expected!";
765+
}
750766
xiDecayRadius2D = std::hypot(xiDecayVertex[0], xiDecayVertex[1]);
751767
laDecayRadius2D = std::hypot(laDecayVertex[0], laDecayVertex[1]);
752768
}
@@ -755,6 +771,9 @@ struct OnTheFlyTracker {
755771

756772
if (v0DecaySettings.decayV0 && isV0) {
757773
decayV0Particle(mcParticle, v0DecayProducts, v0DecayVertex, mcParticle.pdgCode());
774+
if (v0DecayProducts.size() != 2) {
775+
LOG(fatal) << "V0 decay did not produce 2 daughters as expected!";
776+
}
758777
v0DecayRadius2D = std::hypot(v0DecayVertex[0], v0DecayVertex[1]);
759778
}
760779

@@ -792,9 +811,9 @@ struct OnTheFlyTracker {
792811
}
793812
if (cascadeDecaySettings.doXiQA && mcParticle.pdgCode() == kXiMinus) {
794813
histos.fill(HIST("hGenXi"), xiDecayRadius2D, mcParticle.pt());
795-
histos.fill(HIST("hGenPiFromXi"), xiDecayRadius2D, decayProducts[0].Pt());
796-
histos.fill(HIST("hGenPiFromLa"), laDecayRadius2D, decayProducts[1].Pt());
797-
histos.fill(HIST("hGenPrFromLa"), laDecayRadius2D, decayProducts[2].Pt());
814+
histos.fill(HIST("hGenPiFromXi"), xiDecayRadius2D, cascadeDecayProducts[0].Pt());
815+
histos.fill(HIST("hGenPiFromLa"), laDecayRadius2D, cascadeDecayProducts[1].Pt());
816+
histos.fill(HIST("hGenPrFromLa"), laDecayRadius2D, cascadeDecayProducts[2].Pt());
798817
}
799818
if (v0DecaySettings.doV0QA && isV0) {
800819
for (size_t indexV0 = 0; indexV0 < v0PDGs.size(); indexV0++) {
@@ -835,9 +854,9 @@ struct OnTheFlyTracker {
835854
histos.fill(HIST("hXiBuilding"), 0.0f);
836855
}
837856

838-
o2::upgrade::convertTLorentzVectorToO2Track(kPiMinus, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0], pdgDB);
839-
o2::upgrade::convertTLorentzVectorToO2Track(kPiMinus, decayProducts[1], laDecayVertex, xiDaughterTrackParCovsPerfect[1], pdgDB);
840-
o2::upgrade::convertTLorentzVectorToO2Track(kProton, decayProducts[2], laDecayVertex, xiDaughterTrackParCovsPerfect[2], pdgDB);
857+
o2::upgrade::convertTLorentzVectorToO2Track(kPiMinus, cascadeDecayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0], pdgDB);
858+
o2::upgrade::convertTLorentzVectorToO2Track(kPiMinus, cascadeDecayProducts[1], laDecayVertex, xiDaughterTrackParCovsPerfect[1], pdgDB);
859+
o2::upgrade::convertTLorentzVectorToO2Track(kProton, cascadeDecayProducts[2], laDecayVertex, xiDaughterTrackParCovsPerfect[2], pdgDB);
841860

842861
for (int i = 0; i < kCascProngs; i++) {
843862
isReco[i] = false;
@@ -849,7 +868,7 @@ struct OnTheFlyTracker {
849868
nSiliconHits[i] = fastTracker[icfg]->GetNSiliconPoints();
850869
nTPCHits[i] = fastTracker[icfg]->GetNGasPoints();
851870

852-
if (nHits[i] < 0) { // QA
871+
if (nHits[i] < 0 && cascadeDecaySettings.doXiQA) { // QA
853872
histos.fill(HIST("hFastTrackerQA"), o2::math_utils::abs(nHits[i]));
854873
}
855874

@@ -858,7 +877,7 @@ struct OnTheFlyTracker {
858877
} else {
859878
continue; // extra sure
860879
}
861-
for (uint32_t ih = 0; ih < fastTracker[icfg]->GetNHits(); ih++) {
880+
for (uint32_t ih = 0; ih < fastTracker[icfg]->GetNHits() && cascadeDecaySettings.doXiQA; ih++) {
862881
histos.fill(HIST("hFastTrackerHits"), fastTracker[icfg]->GetHitZ(ih), std::hypot(fastTracker[icfg]->GetHitX(ih), fastTracker[icfg]->GetHitY(ih)));
863882
}
864883
} else {
@@ -884,11 +903,11 @@ struct OnTheFlyTracker {
884903
histos.fill(HIST("hRecoXi"), xiDecayRadius2D, mcParticle.pt());
885904
}
886905
if (isReco[0])
887-
histos.fill(HIST("hRecoPiFromXi"), xiDecayRadius2D, decayProducts[0].Pt());
906+
histos.fill(HIST("hRecoPiFromXi"), xiDecayRadius2D, cascadeDecayProducts[0].Pt());
888907
if (isReco[1])
889-
histos.fill(HIST("hRecoPiFromLa"), laDecayRadius2D, decayProducts[1].Pt());
908+
histos.fill(HIST("hRecoPiFromLa"), laDecayRadius2D, cascadeDecayProducts[1].Pt());
890909
if (isReco[2])
891-
histos.fill(HIST("hRecoPrFromLa"), laDecayRadius2D, decayProducts[2].Pt());
910+
histos.fill(HIST("hRecoPrFromLa"), laDecayRadius2D, cascadeDecayProducts[2].Pt());
892911
}
893912

894913
// +-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+
@@ -1409,6 +1428,7 @@ struct OnTheFlyTracker {
14091428

14101429
// *+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*
14111430
// populate tracks
1431+
LOG(debug) << "Populating " << tracksAlice3.size() << " tracks.";
14121432
for (const auto& trackParCov : tracksAlice3) {
14131433
// Fixme: collision index could be changeable
14141434
aod::track::TrackTypeEnum trackType = aod::track::Track;
@@ -1476,6 +1496,7 @@ struct OnTheFlyTracker {
14761496
}
14771497

14781498
// populate ghost tracks
1499+
LOG(debug) << "Populating " << ghostTracksAlice3.size() << " ghost tracks.";
14791500
for (const auto& trackParCov : ghostTracksAlice3) {
14801501
// Fixme: collision index could be changeable
14811502
aod::track::TrackTypeEnum trackType = aod::track::Track;
@@ -1526,6 +1547,7 @@ struct OnTheFlyTracker {
15261547
}
15271548

15281549
// populate Cascades
1550+
LOG(debug) << "Populating " << cascadesAlice3.size() << " cascades.";
15291551
for (const auto& cascade : cascadesAlice3) {
15301552
tableUpgradeCascades(tableCollisions.lastIndex(), // now we know the collision index -> populate table
15311553
cascade.cascadeTrackId,
@@ -1544,6 +1566,7 @@ struct OnTheFlyTracker {
15441566
}
15451567

15461568
// populate V0s
1569+
LOG(debug) << "Populating " << v0sAlice3.size() << " V0s.";
15471570
for (const auto& v0 : v0sAlice3) {
15481571
tableUpgradeV0s(tableCollisions.lastIndex(), // now we know the collision index -> populate table
15491572
v0.mcParticleId,
@@ -1562,11 +1585,13 @@ struct OnTheFlyTracker {
15621585
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker[icfg]->GetCovMatNotOK());
15631586
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker[icfg]->GetCovMatOK());
15641587
}
1588+
LOG(debug) << " <- Finished processing OTF tracking with LUT configuration ID " << icfg;
15651589
} // end process
15661590

15671591
void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
15681592
{
15691593
for (size_t icfg = 0; icfg < mSmearer.size(); ++icfg) {
1594+
LOG(debug) << " -> Processing OTF tracking with LUT configuration ID " << icfg;
15701595
processWithLUTs(mcCollision, mcParticles, static_cast<int>(icfg));
15711596
}
15721597
}

0 commit comments

Comments
 (0)