Skip to content

Commit 161ef4f

Browse files
committed
Add custom grouping option
1 parent dd542c4 commit 161ef4f

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

PWGLF/Tasks/Strangeness/strangeCascTrack.cxx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct StrangeCascTrack {
7171
// subprocess switches:
7272

7373
Configurable<bool> doProcessIons{"doProcessIons", false, "true for PbPb and OO, false for pp and pO"};
74+
Configurable<bool> doCustomGroup{"doCustomGroup", true, "custom group tracked cascades in case of table order bug"};
7475

7576
Configurable<bool> doApplyEventCuts{"doApplyEventCuts", true, "apply general event cuts"}; // event filter - PVz, sel8, INEL>0
7677
// Xi selections
@@ -407,15 +408,16 @@ struct StrangeCascTrack {
407408
}
408409

409410
// applies selections for and fills histograms
410-
template <typename TEvent, typename TCascs>
411-
void analyseCascs(TEvent collision, TCascs cascades)
411+
template <typename TEvent, typename TCasc>
412+
void analyseCascade(TEvent collision, TCasc cascade)
412413
{
413-
int64_t casccollid = 0;
414-
for (auto const& cascade : cascades) {
415-
416414
if constexpr (requires { cascade.topologyChi2(); }) {
417415
if (!cascade.has_standardCascade())
418-
continue; // safety check: dismisses tracked cascades without proper reference
416+
return; // safety check: dismisses tracked cascades without proper reference
417+
}
418+
419+
if (cascade.straCollisionId() != collision.globalIndex()) {
420+
return; // safety check: the cascade must come from that event
419421
}
420422

421423
// for tracked cascades, make a reference to standard table
@@ -442,17 +444,6 @@ struct StrangeCascTrack {
442444

443445
double mult = (doProcessIons) ? collision.centFT0C() : collision.centFT0M(); // ion collisions use FT0C for multiplicity, pp uses both
444446

445-
// fill multiplicity for events with >=1 cascade
446-
if (collision.index() != casccollid) {
447-
histos.fill(HIST(TypeNames[Type]) + HIST("/NoSel/EvMult"), mult);
448-
if constexpr (requires { collision.straMCCollisionId(); }) {
449-
if (isMCTruth(stdCasc, "Xi") || isMCTruth(stdCasc, "Omega")) {
450-
histos.fill(HIST(TypeNames[Type]) + HIST("/NoSel-Truth/EvMult"), mult);
451-
}
452-
}
453-
casccollid = collision.index();
454-
}
455-
456447
double massXi = cascade.mXi();
457448
double massOmega = cascade.mOmega();
458449
double pt = cascade.pt();
@@ -619,7 +610,6 @@ struct StrangeCascTrack {
619610

620611
// fil rec histograms
621612
if (passedAllSelsXi || passedAllSelsOmega) {
622-
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec/EvMult"), mult);
623613
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec/Filters/PropDCAxy"), cascade.dcaXYCascToPV());
624614
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec/Filters/PropDCAz"), cascade.dcaZCascToPV());
625615
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec/Filters/BachCosPA"), stdCasc.bachBaryonCosPA());
@@ -637,7 +627,6 @@ struct StrangeCascTrack {
637627
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec/Filters/PtVsRapidityOmega"), pt, cascade.yOmega());
638628
}
639629
if (fillTruthXi || fillTruthOmega) {
640-
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec-Truth/EvMult"), mult);
641630
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec-Truth/Filters/PropDCAxy"), cascade.dcaXYCascToPV());
642631
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec-Truth/Filters/PropDCAz"), cascade.dcaZCascToPV());
643632
histos.fill(HIST(TypeNames[Type]) + HIST("/Rec-Truth/Filters/BachCosPA"), stdCasc.bachBaryonCosPA());
@@ -731,6 +720,13 @@ struct StrangeCascTrack {
731720
}
732721
}
733722
}
723+
}
724+
725+
template <typename TEvent, typename TCascs>
726+
void analyseCascs(TEvent const& collision, TCascs const& cascades)
727+
{
728+
for (auto const& cascade : cascades) {
729+
analyseCascade(collision, cascade);
734730
}
735731
}
736732

@@ -773,7 +769,6 @@ struct StrangeCascTrack {
773769
histos.add(Form("%s/NoSel/Filters/RapidityOmega", TypeNames[Type].data()), "y under Omega hypothesis", kTH1D, {{200, -1.0, 1.0}});
774770
histos.add(Form("%s/NoSel/Filters/PtVsRapidityOmega", TypeNames[Type].data()), "pt vs y under Xi hypothesis", kTH2D, {axesConfig.axisPt, {200, -1.0, 1.0}});
775771
histos.add(Form("%s/NoSel/Filters/EtaDau", TypeNames[Type].data()), "|#eta| of dau tracks", kTH1D, {axesConfig.axisEta});
776-
histos.add(Form("%s/NoSel/EvMult", TypeNames[Type].data()), "Multiplicity of events with >=1 cascade", kTH1D, {axesConfig.axisMult});
777772
histos.add(Form("%s/NoSel/GenRecPt", TypeNames[Type].data()), "Generated vs reconstructed pt", kTH2D, {axesConfig.axisPt, axesConfig.axisPt});
778773
histos.add(Form("%s/NoSel/GenRecRapidityXi", TypeNames[Type].data()), "Generated vs reconstructed y (Xi)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
779774
histos.add(Form("%s/NoSel/GenRecRapidityOmega", TypeNames[Type].data()), "Generated vs reconstructed y (Omega)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
@@ -788,7 +783,6 @@ struct StrangeCascTrack {
788783
histos.add(Form("%s/NoSel-Truth/Filters/RapidityXi", TypeNames[Type].data()), "y under Xi hypothesis", kTH1D, {{200, -1.0, 1.0}});
789784
histos.add(Form("%s/NoSel-Truth/Filters/RapidityOmega", TypeNames[Type].data()), "y under Omega hypothesis", kTH1D, {{200, -1.0, 1.0}});
790785
histos.add(Form("%s/NoSel-Truth/Filters/EtaDau", TypeNames[Type].data()), "|#eta| of dau tracks", kTH1D, {axesConfig.axisEta});
791-
histos.add(Form("%s/NoSel-Truth/EvMult", TypeNames[Type].data()), "Multiplicity of events with >=1 cascade", kTH1D, {axesConfig.axisMult});
792786
histos.add(Form("%s/NoSel-Truth/GenRecPt", TypeNames[Type].data()), "Generated vs reconstructed pt", kTH2D, {axesConfig.axisPt, axesConfig.axisPt});
793787
histos.add(Form("%s/NoSel-Truth/GenRecRapidityXi", TypeNames[Type].data()), "Generated vs reconstructed y (Xi)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
794788
histos.add(Form("%s/NoSel-Truth/GenRecRapidityOmega", TypeNames[Type].data()), "Generated vs reconstructed y (Omega)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
@@ -805,7 +799,6 @@ struct StrangeCascTrack {
805799
histos.add(Form("%s/Rec/Filters/RapidityOmega", TypeNames[Type].data()), "y under Omega hypothesis", kTH1D, {{200, -1.0, 1.0}});
806800
histos.add(Form("%s/Rec/Filters/PtVsRapidityOmega", TypeNames[Type].data()), "pt vs y under Omega hypothesis", kTH2D, {axesConfig.axisPt, {200, -1.0, 1.0}});
807801
histos.add(Form("%s/Rec/Filters/EtaDau", TypeNames[Type].data()), "|#eta| of dau tracks", kTH1D, {axesConfig.axisEta});
808-
histos.add(Form("%s/Rec/EvMult", TypeNames[Type].data()), "Multiplicity of events with >=1 selected cascade", kTH1D, {axesConfig.axisMult});
809802
histos.add(Form("%s/Rec/GenRecPt", TypeNames[Type].data()), "Generated vs reconstructed pt", kTH2D, {axesConfig.axisPt, axesConfig.axisPt});
810803
histos.add(Form("%s/Rec/GenRecRapidityXi", TypeNames[Type].data()), "Generated vs reconstructed y (Xi)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
811804
histos.add(Form("%s/Rec/GenRecRapidityOmega", TypeNames[Type].data()), "Generated vs reconstructed y (Omega)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
@@ -837,7 +830,6 @@ struct StrangeCascTrack {
837830
histos.add(Form("%s/Rec-Truth/Filters/RapidityXi", TypeNames[Type].data()), "y under Xi hypothesis", kTH1D, {{200, -1.0, 1.0}});
838831
histos.add(Form("%s/Rec-Truth/Filters/RapidityOmega", TypeNames[Type].data()), "y under Omega hypothesis", kTH1D, {{200, -1.0, 1.0}});
839832
histos.add(Form("%s/Rec-Truth/Filters/EtaDau", TypeNames[Type].data()), "|#eta| of dau tracks", kTH1D, {axesConfig.axisEta});
840-
histos.add(Form("%s/Rec-Truth/EvMult", TypeNames[Type].data()), "Multiplicity of events with >=1 cascade", kTH1D, {axesConfig.axisMult});
841833
histos.add(Form("%s/Rec-Truth/GenRecPt", TypeNames[Type].data()), "Generated vs reconstructed pt", kTH2D, {axesConfig.axisPt, axesConfig.axisPt});
842834
histos.add(Form("%s/Rec-Truth/GenRecRapidityXi", TypeNames[Type].data()), "Generated vs reconstructed y (Xi)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
843835
histos.add(Form("%s/Rec-Truth/GenRecRapidityOmega", TypeNames[Type].data()), "Generated vs reconstructed y (Omega)", kTH2D, {{200, -1.0, 1.0}, {200, -1.0, 1.0}});
@@ -1131,8 +1123,17 @@ struct StrangeCascTrack {
11311123
}
11321124
}
11331125

1134-
void processDerivedMCRec(DerMCRecCollisions::iterator const& collision, DerMCRecCascDatas const& allCascs, DerMCRecTraCascDatas const& traCascs, DauTracks const&, DerMCGenCascades const&)
1126+
std::vector<std::vector<int64_t>> traCascsGrouped;
1127+
void processDerivedMCRec(DerMCRecCollisions const& collisions, DerMCRecCascDatas const& allCascs, DerMCRecTraCascDatas const& traCascs, DauTracks const&, DerMCGenCascades const&)
11351128
{
1129+
if (doCustomGroup) {
1130+
traCascsGrouped.clear();
1131+
traCascsGrouped.resize(collisions.size());
1132+
for (const auto& casc : traCascs) {
1133+
traCascsGrouped[casc.straCollisionId()].push_back(casc.globalIndex());
1134+
}
1135+
}
1136+
for (const auto& collision : collisions) {
11361137
fillEvents(collision); // save info about all processed events
11371138
if (isValidEvent(collision, true)) {
11381139
histos.fill(HIST("Rec-Events/EvCounter"), 0.5);
@@ -1141,9 +1142,17 @@ struct StrangeCascTrack {
11411142
double mult = (doProcessIons) ? collision.centFT0C() : collision.centFT0M();
11421143
histos.fill(HIST("Rec-Events/Mult"), mult);
11431144
analyseCascs(collision, allCascs); // process all cascades
1144-
analyseCascs(collision, traCascs); // process tracked cascades
1145+
if (doCustomGroup) {
1146+
for (int idx : traCascsGrouped[collision.globalIndex()]) {
1147+
auto casc = traCascs.rawIteratorAt(idx);
1148+
analyseCascade(collision, casc);
1149+
}
1150+
} else {
1151+
analyseCascs(collision, traCascs);
1152+
}
11451153
}
11461154
}
1155+
}
11471156

11481157
PROCESS_SWITCH(StrangeCascTrack, processDerivedData, "process derived data", true);
11491158
PROCESS_SWITCH(StrangeCascTrack, processDerivedMCGen, "process derived generated mc data", false);
@@ -1155,4 +1164,4 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
11551164
return WorkflowSpec{
11561165
adaptAnalysisTask<StrangeCascTrack>(cfgc),
11571166
};
1158-
}
1167+
}

0 commit comments

Comments
 (0)