Skip to content

Commit 08f44c2

Browse files
committed
fix iterator handling for decay chain traversal
1 parent 3eed175 commit 08f44c2

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

PWGDQ/Core/MCSignal.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class MCSignal : public TNamed
130130
template <typename T>
131131
bool MCSignal::CheckProng(int i, bool checkSources, const T& track)
132132
{
133+
using P = typename T::parent_t;
133134
auto currentMCParticle = track;
134135
// loop over the generations specified for this prong
135136
for (int j = 0; j < fProngs[i].fNGenerations; j++) {
@@ -159,7 +160,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track)
159160
LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
160161
}*/
161162
if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
162-
currentMCParticle = currentMCParticle.mothers_first_as<>();
163+
currentMCParticle = currentMCParticle.template mothers_first_as<P>();
163164
//currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
164165
// currentMCParticle = currentMCParticle.template mother0_as<U>();
165166
}
@@ -169,7 +170,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track)
169170
return false;
170171
}
171172
if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
172-
const auto& daughtersSlice = currentMCParticle.daughters_as<>();
173+
const auto& daughtersSlice = currentMCParticle.template daughters_as<P>();
173174
for (auto& d : daughtersSlice) {
174175
if (fProngs[i].TestPDG(j + 1, d.pdgCode())) {
175176
// currentMCParticle = d;
@@ -235,7 +236,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track)
235236
/*for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
236237
LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
237238
}*/
238-
currentMCParticle = currentMCParticle.mothers_first_as<>();
239+
currentMCParticle = currentMCParticle.template mothers_first_as<P>();
239240
//currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
240241
// currentMCParticle = currentMCParticle.template mother0_as<U>();
241242
}
@@ -251,7 +252,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track)
251252
return false;
252253
}
253254
if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
254-
const auto& daughtersSlice = currentMCParticle.daughters_as<>();
255+
const auto& daughtersSlice = currentMCParticle.template daughters_as<P>();
255256
for (auto& d : daughtersSlice) {
256257
if (fProngs[i].TestPDG(j + 1, d.pdgCode())) {
257258
// currentMCParticle = d;

PWGDQ/Tasks/dqEfficiency.cxx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "Framework/runDataProcessing.h"
2323
#include "Framework/AnalysisTask.h"
2424
#include "Framework/AnalysisDataModel.h"
25-
#include "Framework/ASoAHelpers.h"
2625
#include "PWGDQ/DataModel/ReducedInfoTables.h"
2726
#include "PWGDQ/Core/VarManager.h"
2827
#include "PWGDQ/Core/HistogramManager.h"
@@ -32,12 +31,8 @@
3231
#include "PWGDQ/Core/CutsLibrary.h"
3332
#include "PWGDQ/Core/MCSignal.h"
3433
#include "PWGDQ/Core/MCSignalLibrary.h"
35-
#include "DataFormatsParameters/GRPObject.h"
3634
#include "CCDB/BasicCCDBManager.h"
3735
#include "DataFormatsParameters/GRPMagField.h"
38-
#include "Field/MagneticField.h"
39-
#include "TGeoGlobalMagField.h"
40-
#include "DetectorsBase/Propagator.h"
4136
#include "DetectorsBase/GeometryManager.h"
4237

4338
using std::cout;
@@ -810,7 +805,7 @@ struct AnalysisSameEventPairing {
810805
} // end runPairing
811806

812807
template <typename TTracksMC>
813-
void runMCGen(TTracksMC const& groupedMCTracks)
808+
void runMCGen(TTracksMC& groupedMCTracks)
814809
{
815810
// loop over mc stack and fill histograms for pure MC truth signals
816811
// group all the MC tracks which belong to the MC event corresponding to the current reconstructed event
@@ -824,7 +819,14 @@ struct AnalysisSameEventPairing {
824819
if (sig.GetNProngs() != 1) { // NOTE: 1-prong signals required
825820
continue;
826821
}
827-
if (sig.CheckSignal(false, mctrack)) {
822+
bool checked = false;
823+
if constexpr(soa::is_soa_filtered_v<TTracksMC>) {
824+
auto mctrack_raw = groupedMCTracks.rawIteratorAt(mctrack.globalIndex());
825+
checked = sig.CheckSignal(false, mctrack_raw);
826+
} else {
827+
checked = sig.CheckSignal(false, mctrack);
828+
}
829+
if (checked) {
828830
fHistMan->FillHistClass(Form("MCTruthGen_%s", sig.GetName()), VarManager::fgValues);
829831
}
830832
}
@@ -836,7 +838,15 @@ struct AnalysisSameEventPairing {
836838
continue;
837839
}
838840
for (auto& [t1, t2] : combinations(groupedMCTracks, groupedMCTracks)) {
839-
if (sig.CheckSignal(false, t1, t2)) {
841+
bool checked = false;
842+
if constexpr(soa::is_soa_filtered_v<TTracksMC>) {
843+
auto t1_raw = groupedMCTracks.rawIteratorAt(t1.globalIndex());
844+
auto t2_raw = groupedMCTracks.rawIteratorAt(t2.globalIndex());
845+
checked = sig.CheckSignal(false, t1_raw, t2_raw);
846+
} else {
847+
checked = sig.CheckSignal(false, t1, t2);
848+
}
849+
if (checked) {
840850
VarManager::FillPairMC(t1, t2);
841851
fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig.GetName()), VarManager::fgValues);
842852
}

0 commit comments

Comments
 (0)