Skip to content

Commit 4be120a

Browse files
ddobrigkalibuild
andauthored
[PWGLF] Fix strangeness builder indexing (#10038)
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent f3a7ec6 commit 4be120a

File tree

3 files changed

+128
-85
lines changed

3 files changed

+128
-85
lines changed

PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
// -- processMonteCarlo[Run2] .......: use this OR processRealData but NOT both
2323
//
2424

25+
#include <string>
26+
#include <vector>
27+
2528
#include "Framework/runDataProcessing.h"
2629
#include "Framework/AnalysisTask.h"
2730
#include "Framework/AnalysisDataModel.h"
@@ -414,10 +417,22 @@ struct StrangenessBuilder {
414417
}
415418
}
416419

417-
// list enabled tables
418420
LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*");
419-
LOGF(info, " Strangeness builder: enabled table listing");
421+
LOGF(info, " Strangeness builder: basic configuration listing");
420422
LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*");
423+
424+
if (doprocessRealData) {
425+
LOGF(info, " ===> process function enabled: processRealData");
426+
}
427+
if (doprocessRealDataRun2) {
428+
LOGF(info, " ===> process function enabled: processRealDataRun2");
429+
}
430+
if (doprocessMonteCarlo) {
431+
LOGF(info, " ===> process function enabled: processMonteCarlo");
432+
}
433+
if (doprocessMonteCarloRun2) {
434+
LOGF(info, " ===> process function enabled: processMonteCarloRun2");
435+
}
421436
for (int i = 0; i < nTables; i++) {
422437
// printout to be improved in the future
423438
if (mEnabledTables[i]) {
@@ -531,25 +546,25 @@ struct StrangenessBuilder {
531546
void populateCascadeInterlinks()
532547
{
533548
if (mEnabledTables[kCascToKFRefs]) {
534-
for (auto& cascCore : interlinks.cascCoreToCascades) {
549+
for (const auto& cascCore : interlinks.cascCoreToCascades) {
535550
cascToKFRefs(interlinks.cascadeToKFCascCores[cascCore]);
536551
histos.fill(HIST("hTableBuildingStatistics"), kCascToKFRefs);
537552
}
538553
}
539554
if (mEnabledTables[kCascToTraRefs]) {
540-
for (auto& cascCore : interlinks.cascCoreToCascades) {
555+
for (const auto& cascCore : interlinks.cascCoreToCascades) {
541556
cascToTraRefs(interlinks.cascadeToTraCascCores[cascCore]);
542557
histos.fill(HIST("hTableBuildingStatistics"), kCascToTraRefs);
543558
}
544559
}
545560
if (mEnabledTables[kKFToCascRefs]) {
546-
for (auto& kfCascCore : interlinks.kfCascCoreToCascades) {
561+
for (const auto& kfCascCore : interlinks.kfCascCoreToCascades) {
547562
kfToCascRefs(interlinks.cascadeToCascCores[kfCascCore]);
548563
histos.fill(HIST("hTableBuildingStatistics"), kKFToCascRefs);
549564
}
550565
}
551566
if (mEnabledTables[kTraToCascRefs]) {
552-
for (auto& traCascCore : interlinks.traCascCoreToCascades) {
567+
for (const auto& traCascCore : interlinks.traCascCoreToCascades) {
553568
traToCascRefs(interlinks.cascadeToCascCores[traCascCore]);
554569
histos.fill(HIST("hTableBuildingStatistics"), kTraToCascRefs);
555570
}
@@ -565,7 +580,7 @@ struct StrangenessBuilder {
565580
v0Map.clear();
566581
v0Map.resize(v0s.size(), -2); // marks not used
567582
if (mEnabledTables[kStoredCascCores]) {
568-
for (auto& cascade : cascades) {
583+
for (const auto& cascade : cascades) {
569584
if (v0Map[cascade.v0Id()] == -2) {
570585
v0sUsedInCascades++;
571586
}
@@ -576,7 +591,7 @@ struct StrangenessBuilder {
576591
if constexpr (soa::is_table<TTrackedCascades>) {
577592
if (mEnabledTables[kStoredTraCascCores]) {
578593
trackedCascadeCount = trackedCascades.size();
579-
for (auto& trackedCascade : trackedCascades) {
594+
for (const auto& trackedCascade : trackedCascades) {
580595
auto const& cascade = trackedCascade.cascade();
581596
if (v0Map[cascade.v0Id()] == -2) {
582597
v0sUsedInCascades++;
@@ -604,7 +619,7 @@ struct StrangenessBuilder {
604619
int nV0s = 0;
605620
// Loops over all V0s in the time frame
606621
histos.fill(HIST("hInputStatistics"), kV0CoresBase, v0s.size());
607-
for (auto& v0 : v0s) {
622+
for (const auto& v0 : v0s) {
608623
if (!mEnabledTables[kV0CoresBase] && v0Map[v0.globalIndex()] == -2) {
609624
// this v0 hasn't been used by cascades and we're not generating V0s, so skip it
610625
v0dataLink(-1, -1);
@@ -736,7 +751,7 @@ struct StrangenessBuilder {
736751
thisInfo.momentum[2] = originatingV0.pz();
737752

738753
if (originatingV0.has_mothers()) {
739-
for (auto& lV0Mother : originatingV0.template mothers_as<aod::McParticles>()) {
754+
for (const auto& lV0Mother : originatingV0.template mothers_as<aod::McParticles>()) {
740755
thisInfo.pdgCodeMother = lV0Mother.pdgCode();
741756
thisInfo.motherLabel = lV0Mother.globalIndex();
742757
}
@@ -816,7 +831,7 @@ struct StrangenessBuilder {
816831
if constexpr (soa::is_table<TMCParticles>) {
817832
if (v0BuilderOpts.mc_populateV0MCCoresAsymmetric && (mEnabledTables[kV0MCCores] || mEnabledTables[kV0MCCollRefs])) {
818833
// first step: add any un-recoed v0mmcores that were requested
819-
for (auto& mcParticle : mcParticles) {
834+
for (const auto& mcParticle : mcParticles) {
820835
thisInfo.label = -1;
821836
thisInfo.motherLabel = -1;
822837
thisInfo.pdgCode = 0;
@@ -832,7 +847,7 @@ struct StrangenessBuilder {
832847
if (mcParticleIsReco[mcParticle.globalIndex()] == true)
833848
continue; // skip if already created in list
834849

835-
if (TMath::Abs(mcParticle.y()) > v0BuilderOpts.mc_rapidityWindow)
850+
if (std::fabs(mcParticle.y()) > v0BuilderOpts.mc_rapidityWindow)
836851
continue; // skip outside midrapidity
837852

838853
if (
@@ -861,7 +876,7 @@ struct StrangenessBuilder {
861876
if (mcParticle.has_daughters()) {
862877
auto const& daughters = mcParticle.template daughters_as<aod::McParticles>();
863878

864-
for (auto& dau : daughters) {
879+
for (const auto& dau : daughters) {
865880
if (dau.getProcess() != 4)
866881
continue;
867882

@@ -890,7 +905,7 @@ struct StrangenessBuilder {
890905
}
891906
}
892907

893-
for (auto info : mcV0infos) {
908+
for (const auto& info : mcV0infos) {
894909
if (mEnabledTables[kV0MCCores]) {
895910
v0mccores(
896911
info.label, info.pdgCode,
@@ -978,7 +993,7 @@ struct StrangenessBuilder {
978993
thisCascInfo.pdgCodeV0 = originatingV0.pdgCode();
979994

980995
if (originatingV0.has_mothers()) {
981-
for (auto& lV0Mother : originatingV0.template mothers_as<aod::McParticles>()) {
996+
for (const auto& lV0Mother : originatingV0.template mothers_as<aod::McParticles>()) {
982997
if (lV0Mother.globalIndex() == bachOriginating) { // found mother particle
983998
thisCascInfo.label = lV0Mother.globalIndex();
984999

@@ -995,7 +1010,7 @@ struct StrangenessBuilder {
9951010
thisCascInfo.momentum[1] = lV0Mother.py();
9961011
thisCascInfo.momentum[2] = lV0Mother.pz();
9971012
if (lV0Mother.has_mothers()) {
998-
for (auto& lV0GrandMother : lV0Mother.template mothers_as<aod::McParticles>()) {
1013+
for (const auto& lV0GrandMother : lV0Mother.template mothers_as<aod::McParticles>()) {
9991014
thisCascInfo.pdgCodeMother = lV0GrandMother.pdgCode();
10001015
thisCascInfo.motherLabel = lV0GrandMother.globalIndex();
10011016
}
@@ -1026,7 +1041,7 @@ struct StrangenessBuilder {
10261041
int nCascades = 0;
10271042
// Loops over all cascades in the time frame
10281043
histos.fill(HIST("hInputStatistics"), kStoredCascCores, cascades.size());
1029-
for (auto& cascade : cascades) {
1044+
for (const auto& cascade : cascades) {
10301045
// Get tracks and generate candidate
10311046
auto const& collision = cascade.collision();
10321047
auto const& v0 = cascade.v0();
@@ -1162,8 +1177,8 @@ struct StrangenessBuilder {
11621177
if (negTrack.has_mcParticle()) {
11631178
auto baryonParticle = negTrack.template mcParticle_as<aod::McParticles>();
11641179
if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == -2212) {
1165-
for (auto& baryonMother : baryonParticle.template mothers_as<aod::McParticles>()) {
1166-
for (auto& pionMother : bachelorParticle.template mothers_as<aod::McParticles>()) {
1180+
for (const auto& baryonMother : baryonParticle.template mothers_as<aod::McParticles>()) {
1181+
for (const auto& pionMother : bachelorParticle.template mothers_as<aod::McParticles>()) {
11671182
if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == -3122) {
11681183
bbTag = true;
11691184
}
@@ -1176,8 +1191,8 @@ struct StrangenessBuilder {
11761191
if (posTrack.has_mcParticle()) {
11771192
auto baryonParticle = posTrack.template mcParticle_as<aod::McParticles>();
11781193
if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == 2212) {
1179-
for (auto& baryonMother : baryonParticle.template mothers_as<aod::McParticles>()) {
1180-
for (auto& pionMother : bachelorParticle.template mothers_as<aod::McParticles>()) {
1194+
for (const auto& baryonMother : baryonParticle.template mothers_as<aod::McParticles>()) {
1195+
for (const auto& pionMother : bachelorParticle.template mothers_as<aod::McParticles>()) {
11811196
if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == 3122) {
11821197
bbTag = true;
11831198
}
@@ -1202,7 +1217,7 @@ struct StrangenessBuilder {
12021217
// now populate V0MCCores if in asymmetric mode
12031218
if (cascadeBuilderOpts.mc_populateCascMCCoresAsymmetric) {
12041219
// first step: add any un-recoed v0mmcores that were requested
1205-
for (auto& mcParticle : mcParticles) {
1220+
for (const auto& mcParticle : mcParticles) {
12061221
thisCascInfo.pdgCode = -1, thisCascInfo.pdgCodeMother = -1;
12071222
thisCascInfo.pdgCodePositive = -1, thisCascInfo.pdgCodeNegative = -1;
12081223
thisCascInfo.pdgCodeBachelor = -1, thisCascInfo.pdgCodeV0 = -1;
@@ -1221,7 +1236,7 @@ struct StrangenessBuilder {
12211236
if (mcParticleIsReco[mcParticle.globalIndex()] == true)
12221237
continue; // skip if already created in list
12231238

1224-
if (TMath::Abs(mcParticle.y()) > cascadeBuilderOpts.mc_rapidityWindow)
1239+
if (std::fabs(mcParticle.y()) > cascadeBuilderOpts.mc_rapidityWindow)
12251240
continue; // skip outside midrapidity
12261241

12271242
if (
@@ -1242,11 +1257,11 @@ struct StrangenessBuilder {
12421257

12431258
if (mcParticle.has_daughters()) {
12441259
auto const& daughters = mcParticle.template daughters_as<aod::McParticles>();
1245-
for (auto& dau : daughters) {
1260+
for (const auto& dau : daughters) {
12461261
if (dau.getProcess() != 4) // check whether the daughter comes from a decay
12471262
continue;
12481263

1249-
if (TMath::Abs(dau.pdgCode()) == 211 || TMath::Abs(dau.pdgCode()) == 321) {
1264+
if (std::abs(dau.pdgCode()) == 211 || std::abs(dau.pdgCode()) == 321) {
12501265
thisCascInfo.pdgCodeBachelor = dau.pdgCode();
12511266
thisCascInfo.bachP[0] = dau.px();
12521267
thisCascInfo.bachP[1] = dau.py();
@@ -1256,10 +1271,10 @@ struct StrangenessBuilder {
12561271
thisCascInfo.xyz[2] = dau.vz();
12571272
thisCascInfo.mcParticleBachelor = dau.globalIndex();
12581273
}
1259-
if (TMath::Abs(dau.pdgCode()) == 2212) {
1274+
if (std::abs(dau.pdgCode()) == 2212) {
12601275
thisCascInfo.pdgCodeV0 = dau.pdgCode();
12611276

1262-
for (auto& v0Dau : dau.template daughters_as<aod::McParticles>()) {
1277+
for (const auto& v0Dau : dau.template daughters_as<aod::McParticles>()) {
12631278
if (v0Dau.getProcess() != 4)
12641279
continue;
12651280

@@ -1292,7 +1307,7 @@ struct StrangenessBuilder {
12921307
}
12931308
}
12941309

1295-
for (auto thisInfoToFill : mcCascinfos) {
1310+
for (const auto& thisInfoToFill : mcCascinfos) {
12961311
if (mEnabledTables[kCascMCCores]) {
12971312
cascmccores( // a lot of the info below will be compressed in case of not-recoed MC (good!)
12981313
thisInfoToFill.pdgCode, thisInfoToFill.pdgCodeMother, thisInfoToFill.pdgCodeV0, thisInfoToFill.isPhysicalPrimary,
@@ -1327,7 +1342,7 @@ struct StrangenessBuilder {
13271342
int nCascades = 0;
13281343
// Loops over all cascades in the time frame
13291344
histos.fill(HIST("hInputStatistics"), kStoredKFCascCores, cascades.size());
1330-
for (auto& cascade : cascades) {
1345+
for (const auto& cascade : cascades) {
13311346
// Get tracks and generate candidate
13321347
auto const& collision = cascade.collision();
13331348
auto const& v0 = cascade.v0();
@@ -1412,7 +1427,7 @@ struct StrangenessBuilder {
14121427
int nCascades = 0;
14131428
// Loops over all V0s in the time frame
14141429
histos.fill(HIST("hInputStatistics"), kStoredTraCascCores, cascadeTracks.size());
1415-
for (auto& cascadeTrack : cascadeTracks) {
1430+
for (const auto& cascadeTrack : cascadeTracks) {
14161431
// Get tracks and generate candidate
14171432
if (!cascadeTrack.has_track())
14181433
continue; // safety (should be fine but depends on future stratrack dev)
@@ -1564,12 +1579,12 @@ struct StrangenessBuilder {
15641579

15651580
void processRealData(aod::Collisions const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIU const& tracks, aod::BCsWithTimestamps const& bcs)
15661581
{
1567-
dataProcess(collisions, v0s, cascades, trackedCascades, tracks, bcs, (TObject*)nullptr);
1582+
dataProcess(collisions, v0s, cascades, trackedCascades, tracks, bcs, static_cast<TObject*>(nullptr));
15681583
}
15691584

15701585
void processRealDataRun2(aod::Collisions const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExt const& tracks, aod::BCsWithTimestamps const& bcs)
15711586
{
1572-
dataProcess(collisions, v0s, cascades, (TObject*)nullptr, tracks, bcs, (TObject*)nullptr);
1587+
dataProcess(collisions, v0s, cascades, static_cast<TObject*>(nullptr), tracks, bcs, static_cast<TObject*>(nullptr));
15731588
}
15741589

15751590
void processMonteCarlo(aod::Collisions const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtLabeledIU const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles)
@@ -1579,12 +1594,12 @@ struct StrangenessBuilder {
15791594

15801595
void processMonteCarloRun2(aod::Collisions const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExtLabeled const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles)
15811596
{
1582-
dataProcess(collisions, v0s, cascades, (TObject*)nullptr, tracks, bcs, mcParticles);
1597+
dataProcess(collisions, v0s, cascades, static_cast<TObject*>(nullptr), tracks, bcs, mcParticles);
15831598
}
15841599

15851600
void processSimulationFindable(aod::Collisions const& collisions, aod::FindableV0s const& v0s, aod::Cascades const& cascades, FullTracksExtIU const& tracks, aod::BCsWithTimestamps const& bcs)
15861601
{
1587-
dataProcess(collisions, v0s, cascades, (TObject*)nullptr, tracks, bcs, (TObject*)nullptr);
1602+
dataProcess(collisions, v0s, cascades, static_cast<TObject*>(nullptr), tracks, bcs, static_cast<TObject*>(nullptr));
15881603
}
15891604

15901605
PROCESS_SWITCH(StrangenessBuilder, processRealData, "process real data", true);

0 commit comments

Comments
 (0)