Skip to content

Commit 0d493f5

Browse files
committed
Updated wrong casts and implicit conversions
1 parent 6eba5f4 commit 0d493f5

1 file changed

Lines changed: 37 additions & 35 deletions

File tree

ALICE3/Tasks/alice3-dq-efficiency.cxx

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ struct AnalysisTrackSelection {
331331
if (addTrackCutsStr != "") {
332332
std::vector<AnalysisCut*> addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data());
333333
for (const auto& t : addTrackCuts) {
334-
fTrackCuts.push_back(static_cast<AnalysisCompositeCut*>(t));
334+
fTrackCuts.push_back(dynamic_cast<AnalysisCompositeCut*>(t));
335335
}
336336
}
337337
VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill
@@ -457,7 +457,7 @@ struct AnalysisTrackSelection {
457457
// mcDecision |= (static_cast<uint32_t>(1) << isig);
458458
// loop over cuts and fill histograms for the cuts that are fulfilled
459459
for (unsigned int icut = 0; icut < fTrackCuts.size(); icut++) {
460-
if (filterMap & (static_cast<uint32_t>(1) << icut)) {
460+
if ((filterMap & (static_cast<uint32_t>(1) << icut)) != 0u) {
461461
if (isCorrectAssoc) {
462462
fHistMan->FillHistClass(fHistNamesMCMatched[icut * 2 * fMCSignals.size() + 2 * isig].Data(), dqefficiency_helpers::varValues());
463463
} else {
@@ -473,15 +473,15 @@ struct AnalysisTrackSelection {
473473
if (fConfigPublishAmbiguity && filterMap > 0) {
474474
if (event.isEventSelected_bit(1)) {
475475
// for this track, count the number of associated collisions with in-bunch pileup and out of bunch associations
476-
if (fNAssocsInBunch.find(track.globalIndex()) == fNAssocsInBunch.end()) {
476+
if (!fNAssocsInBunch.contains(track.globalIndex())) {
477477
std::vector<int64_t> evVector = {event.globalIndex()};
478478
fNAssocsInBunch[track.globalIndex()] = evVector;
479479
} else {
480480
auto& evVector = fNAssocsInBunch[track.globalIndex()];
481481
evVector.push_back(event.globalIndex());
482482
}
483483
} else {
484-
if (fNAssocsOutOfBunch.find(track.globalIndex()) == fNAssocsOutOfBunch.end()) {
484+
if (!fNAssocsOutOfBunch.contains(track.globalIndex())) {
485485
std::vector<int64_t> evVector = {event.globalIndex()};
486486
fNAssocsOutOfBunch[track.globalIndex()] = evVector;
487487
} else {
@@ -523,11 +523,11 @@ struct AnalysisTrackSelection {
523523
// publish the ambiguity table
524524
for (const auto& track : tracks) {
525525
int8_t nInBunch = 0;
526-
if (fNAssocsInBunch.find(track.globalIndex()) != fNAssocsInBunch.end()) {
526+
if (!fNAssocsInBunch.contains(track.globalIndex())) {
527527
nInBunch = fNAssocsInBunch[track.globalIndex()].size();
528528
}
529529
int8_t nOutOfBunch = 0;
530-
if (fNAssocsOutOfBunch.find(track.globalIndex()) != fNAssocsOutOfBunch.end()) {
530+
if (!fNAssocsOutOfBunch.contains(track.globalIndex())) {
531531
nOutOfBunch = fNAssocsOutOfBunch[track.globalIndex()].size();
532532
}
533533
trackAmbiguities(nInBunch, nOutOfBunch);
@@ -677,10 +677,10 @@ struct AnalysisPrefilterSelection {
677677
}
678678
// if the pair fullfils the criteria, add an entry into the prefilter map for the two tracks
679679
if (fPairCut->IsSelected(dqefficiency_helpers::varValues())) {
680-
if (fPrefilterMap.find(track1.globalIndex()) == fPrefilterMap.end() && track1Candidate > 0) {
680+
if (!fPrefilterMap.contains(track1.globalIndex()) && track1Candidate > 0) {
681681
fPrefilterMap[track1.globalIndex()] = track1Candidate;
682682
}
683-
if (fPrefilterMap.find(track2.globalIndex()) == fPrefilterMap.end() && track2Candidate > 0) {
683+
if (!fPrefilterMap.contains(track2.globalIndex()) && track2Candidate > 0) {
684684
fPrefilterMap[track2.globalIndex()] = track2Candidate;
685685
}
686686
}
@@ -710,7 +710,7 @@ struct AnalysisPrefilterSelection {
710710
// TODO: just use the index from the assoc (no need to cast the whole track)
711711
auto track = assoc.template reducedA3track_as<MyBarrelTracks>();
712712
mymap = -1;
713-
if (fPrefilterMap.find(track.globalIndex()) != fPrefilterMap.end()) {
713+
if (!fPrefilterMap.contains(track.globalIndex())) {
714714
// NOTE: publish the bitwise negated bits (~), so there will be zeroes for cuts that failed the prefiltering and 1 everywhere else
715715
mymap = ~fPrefilterMap[track.globalIndex()];
716716
prefilter(mymap);
@@ -1027,7 +1027,7 @@ struct AnalysisSameEventPairing {
10271027
auto groupedAssocs = assocs.sliceBy(preslice, event.globalIndex());
10281028
size_t nGood = 0;
10291029
for (auto const& t : groupedAssocs) {
1030-
if (t.isBarrelSelected_raw()) {
1030+
if (t.isBarrelSelected_raw() > 0u) {
10311031
nGood++;
10321032
}
10331033
}
@@ -1060,7 +1060,7 @@ struct AnalysisSameEventPairing {
10601060

10611061
twoTrackFilter = a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isBarrelSelectedPrefilter_raw() & fTrackFilterMask;
10621062

1063-
if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue
1063+
if (twoTrackFilter == 0u) { // the tracks must have at least one filter bit in common to continue
10641064
continue;
10651065
}
10661066

@@ -1114,13 +1114,13 @@ struct AnalysisSameEventPairing {
11141114
bool isAmbiOutOfBunch = false;
11151115

11161116
for (int icut = 0; icut < ncuts; icut++) {
1117-
if (twoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
1118-
isAmbiInBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 28)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 29));
1119-
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
1117+
if ((twoTrackFilter & (static_cast<uint32_t>(1) << icut)) != 0u) {
1118+
isAmbiInBunch = ((twoTrackFilter & (static_cast<uint32_t>(1) << 28)) != 0u) || ((twoTrackFilter & (static_cast<uint32_t>(1) << 29)) != 0u);
1119+
isAmbiOutOfBunch = ((twoTrackFilter & (static_cast<uint32_t>(1) << 30)) != 0u) || ((twoTrackFilter & (static_cast<uint32_t>(1) << 31)) != 0u);
11201120
if (sign1 * sign2 < 0) { // +- pairs
11211121
fHistMan->FillHistClass(histNames[icut][0].Data(), dqefficiency_helpers::varValues()); // reconstructed, unmatched
11221122
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
1123-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
1123+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
11241124
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][0].Data(), dqefficiency_helpers::varValues()); // matched signal
11251125
if (fConfigQA) {
11261126
if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { // correct track-collision association
@@ -1159,7 +1159,7 @@ struct AnalysisSameEventPairing {
11591159
if (sign1 > 0) { // ++ pairs
11601160
fHistMan->FillHistClass(histNames[icut][1].Data(), dqefficiency_helpers::varValues());
11611161
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
1162-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
1162+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
11631163
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][1].Data(), dqefficiency_helpers::varValues());
11641164
}
11651165
}
@@ -1174,7 +1174,7 @@ struct AnalysisSameEventPairing {
11741174
} else { // -- pairs
11751175
fHistMan->FillHistClass(histNames[icut][2].Data(), dqefficiency_helpers::varValues());
11761176
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
1177-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
1177+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
11781178
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][2].Data(), dqefficiency_helpers::varValues());
11791179
}
11801180
}
@@ -1190,8 +1190,9 @@ struct AnalysisSameEventPairing {
11901190
}
11911191
for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) {
11921192
AnalysisCompositeCut cut = fPairCuts.at(iPairCut);
1193-
if (!(cut.IsSelected(dqefficiency_helpers::varValues()))) // apply pair cuts
1193+
if (!(cut.IsSelected(dqefficiency_helpers::varValues()))) { // apply pair cuts
11941194
continue;
1195+
}
11951196
if (sign1 * sign2 < 0) {
11961197
fHistMan->FillHistClass(histNames[ncuts + icut * ncuts + iPairCut][0].Data(), dqefficiency_helpers::varValues());
11971198
} else {
@@ -1609,7 +1610,7 @@ struct AnalysisAsymmetricPairing {
16091610
if (addPairCutsStr != "") {
16101611
std::vector<AnalysisCut*> addPairCuts = dqcuts::GetCutsFromJSON(addPairCutsStr.Data());
16111612
for (const auto& t : addPairCuts) {
1612-
fPairCuts.push_back(static_cast<AnalysisCompositeCut*>(t));
1613+
fPairCuts.push_back(dynamic_cast<AnalysisCompositeCut*>(t));
16131614
cutNamesStr += Form(",%s", t->GetName());
16141615
}
16151616
}
@@ -1948,25 +1949,24 @@ struct AnalysisAsymmetricPairing {
19481949
}
19491950

19501951
for (const auto& [a1, a2] : combinations(soa::CombinationsFullIndexPolicy(groupedLegAAssocs, groupedLegBAssocs))) {
1951-
19521952
uint32_t twoTrackFilter = 0;
19531953
uint32_t twoTrackCommonFilter = 0;
19541954
uint32_t pairFilter = 0;
19551955
bool isPairIdWrong = false;
19561956
for (int icut = 0; icut < fNLegCuts; ++icut) {
19571957
// Find leg pair definitions both candidates participate in
1958-
if ((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) && (a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut])) {
1958+
if (((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) != 0u) && ((a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut]) != 0u)) {
19591959
twoTrackFilter |= static_cast<uint32_t>(1) << icut;
19601960
// If the supposed pion passes a kaon cut, this is a K+K-. Skip it.
19611961
if (fConfigSkipAmbiguousIdCombinations.value) {
1962-
if (a2.isBarrelSelected_raw() & fLegAFilterMask) {
1962+
if ((a2.isBarrelSelected_raw() & fLegAFilterMask) != 0u) {
19631963
isPairIdWrong = true;
19641964
}
19651965
}
19661966
}
19671967
}
19681968

1969-
if (!twoTrackFilter || isPairIdWrong) {
1969+
if (twoTrackFilter == 0u || isPairIdWrong) {
19701970
continue;
19711971
}
19721972

@@ -1983,12 +1983,12 @@ struct AnalysisAsymmetricPairing {
19831983

19841984
bool isReflected = false;
19851985
std::pair<int32_t, int32_t> trackIds(t1.globalIndex(), t2.globalIndex());
1986-
if (fPairCount.find(trackIds) != fPairCount.end()) {
1986+
if (fPairCount.contains(trackIds)) {
19871987
// Double counting is possible due to track-collision ambiguity. Skip pairs which were counted before
19881988
fPairCount[trackIds] += 1;
19891989
continue;
19901990
}
1991-
if (fPairCount.find(std::pair(trackIds.second, trackIds.first)) != fPairCount.end()) {
1991+
if (fPairCount.contains(std::pair(trackIds.second, trackIds.first))) {
19921992
isReflected = true;
19931993
}
19941994
fPairCount[trackIds] += 1;
@@ -2021,8 +2021,8 @@ struct AnalysisAsymmetricPairing {
20212021
// Fill histograms
20222022
bool isAmbi = false;
20232023
for (int icut = 0; icut < fNLegCuts; icut++) {
2024-
if (twoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
2025-
isAmbi = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
2024+
if ((twoTrackFilter & (static_cast<uint32_t>(1) << icut)) != 0u) {
2025+
isAmbi = ((twoTrackFilter & (static_cast<uint32_t>(1) << 30)) != 0u) || ((twoTrackFilter & (static_cast<uint32_t>(1) << 31)) != 0u);
20262026
if (sign1 * sign2 < 0) { // +- pairs
20272027
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fLegCutNames[icut].Data()), dqefficiency_helpers::varValues()); // reconstructed, unmatched
20282028
if (isAmbi && fConfigQA) {
@@ -2051,7 +2051,7 @@ struct AnalysisAsymmetricPairing {
20512051
}
20522052
}
20532053
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
2054-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
2054+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
20552055
if (sign1 * sign2 < 0) {
20562056
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), dqefficiency_helpers::varValues());
20572057
if (isReflected && fConfigReflectedHistograms.value) {
@@ -2073,7 +2073,7 @@ struct AnalysisAsymmetricPairing {
20732073
}
20742074
}
20752075
for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) {
2076-
if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) {
2076+
if ((twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) != 0u) {
20772077
if (sign1 * sign2 < 0) {
20782078
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), dqefficiency_helpers::varValues());
20792079
} else if (fConfigSameSignHistograms.value) {
@@ -2084,7 +2084,7 @@ struct AnalysisAsymmetricPairing {
20842084
}
20852085
}
20862086
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
2087-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
2087+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
20882088
if (sign1 * sign2 < 0) {
20892089
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fRecMCSignalNames[isig].Data()), dqefficiency_helpers::varValues());
20902090
} else if (fConfigSameSignHistograms.value) {
@@ -2100,8 +2100,9 @@ struct AnalysisAsymmetricPairing {
21002100
} // end loop (common cuts)
21012101
int iPairCut = 0;
21022102
for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) {
2103-
if (!((*cut)->IsSelected(dqefficiency_helpers::varValues()))) // apply pair cuts
2103+
if (!((*cut)->IsSelected(dqefficiency_helpers::varValues()))) { // apply pair cuts
21042104
continue;
2105+
}
21052106
pairFilter |= (static_cast<uint32_t>(1) << iPairCut);
21062107
// Histograms with pair cuts
21072108
if (sign1 * sign2 < 0) {
@@ -2114,7 +2115,7 @@ struct AnalysisAsymmetricPairing {
21142115
}
21152116
}
21162117
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
2117-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
2118+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
21182119
if (sign1 * sign2 < 0) {
21192120
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), dqefficiency_helpers::varValues());
21202121
} else if (fConfigSameSignHistograms.value) {
@@ -2128,7 +2129,7 @@ struct AnalysisAsymmetricPairing {
21282129
}
21292130
// Histograms with pair cuts and common track cuts
21302131
for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) {
2131-
if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) {
2132+
if ((twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) != 0u) {
21322133
if (sign1 * sign2 < 0) {
21332134
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), dqefficiency_helpers::varValues());
21342135
} else if (fConfigSameSignHistograms.value) {
@@ -2139,7 +2140,7 @@ struct AnalysisAsymmetricPairing {
21392140
}
21402141
}
21412142
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals
2142-
if (mcDecision & (static_cast<uint32_t>(1) << isig)) {
2143+
if ((mcDecision & (static_cast<uint32_t>(1) << isig)) != 0u) {
21432144
if (sign1 * sign2 < 0) {
21442145
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), dqefficiency_helpers::varValues());
21452146
} else if (fConfigSameSignHistograms.value) {
@@ -2314,8 +2315,9 @@ struct AnalysisAsymmetricPairing {
23142315
} // end loop (common cuts)
23152316
int iPairCut = 0;
23162317
for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) {
2317-
if (!((*cut)->IsSelected(dqefficiency_helpers::varValues()))) // apply pair cuts
2318+
if (!((*cut)->IsSelected(dqefficiency_helpers::varValues()))) { // apply pair cuts
23182319
continue;
2320+
}
23192321
// Histograms with pair cuts
23202322
fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), dqefficiency_helpers::varValues());
23212323
for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals

0 commit comments

Comments
 (0)