Skip to content

Commit d942cb6

Browse files
yuanz-USTCalibuild
andauthored
[PWGDQ] Save the information of ambiguous pairs (#10733)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 044e814 commit d942cb6

File tree

1 file changed

+82
-33
lines changed

1 file changed

+82
-33
lines changed

PWGDQ/Tasks/tableReader_withAssoc.cxx

Lines changed: 82 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <numeric>
2020
#include <vector>
2121
#include <algorithm>
22+
#include <utility>
2223
#include <set>
2324
#include <map>
2425
#include <string>
@@ -1178,6 +1179,8 @@ struct AnalysisSameEventPairing {
11781179
std::map<int, std::vector<TString>> fMuonHistNames;
11791180
std::map<int, std::vector<TString>> fTrackMuonHistNames;
11801181
std::vector<AnalysisCompositeCut> fPairCuts;
1182+
std::vector<TString> fTrackCuts;
1183+
std::map<std::pair<uint32_t, uint32_t>, uint32_t> fAmbiguousPairs;
11811184

11821185
uint32_t fTrackFilterMask; // mask for the track cuts required in this task to be applied on the barrel cuts produced upstream
11831186
uint32_t fMuonFilterMask; // mask for the muon cuts required in this task to be applied on the muon cuts produced upstream
@@ -1213,6 +1216,7 @@ struct AnalysisSameEventPairing {
12131216
// Keep track of all the histogram class names to avoid composing strings in the pairing loop
12141217
TString histNames = "";
12151218
std::vector<TString> names;
1219+
fTrackCuts.clear();
12161220

12171221
// NOTE: Pair cuts are only applied on the histogram output. The produced pair tables do not have these cuts applied
12181222
TString cutNamesStr = fConfigCuts.pair.value;
@@ -1254,6 +1258,7 @@ struct AnalysisSameEventPairing {
12541258
fNCutsBarrel = objArray->GetEntries();
12551259
for (int icut = 0; icut < objArray->GetEntries(); ++icut) {
12561260
TString tempStr = objArray->At(icut)->GetName();
1261+
fTrackCuts.push_back(tempStr);
12571262
if (objArrayTrackCuts->FindObject(tempStr.Data()) != nullptr) {
12581263
fTrackFilterMask |= (static_cast<uint32_t>(1) << icut);
12591264

@@ -1263,20 +1268,16 @@ struct AnalysisSameEventPairing {
12631268
Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()),
12641269
Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())};
12651270
histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data());
1271+
names.push_back(Form("PairsBarrelSEPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
1272+
names.push_back(Form("PairsBarrelSEPP_ambiguousextra_%s", objArray->At(icut)->GetName()));
1273+
names.push_back(Form("PairsBarrelSEMM_ambiguousextra_%s", objArray->At(icut)->GetName()));
1274+
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
12661275
if (fEnableBarrelMixingHistos) {
12671276
names.push_back(Form("PairsBarrelMEPM_%s", objArray->At(icut)->GetName()));
12681277
names.push_back(Form("PairsBarrelMEPP_%s", objArray->At(icut)->GetName()));
12691278
names.push_back(Form("PairsBarrelMEMM_%s", objArray->At(icut)->GetName()));
1270-
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
1279+
histNames += Form("%s;%s;%s;", names[6].Data(), names[7].Data(), names[8].Data());
12711280
}
1272-
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
1273-
names.push_back(Form("PairsBarrelSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
1274-
names.push_back(Form("PairsBarrelSEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
1275-
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
1276-
names.push_back(Form("PairsBarrelSEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
1277-
names.push_back(Form("PairsBarrelSEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
1278-
histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 6 : 3)].Data(), names[(fEnableBarrelMixingHistos ? 7 : 4)].Data(), names[(fEnableBarrelMixingHistos ? 8 : 5)].Data());
1279-
histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 9 : 6)].Data(), names[(fEnableBarrelMixingHistos ? 10 : 7)].Data(), names[(fEnableBarrelMixingHistos ? 11 : 8)].Data());
12801281
fTrackHistNames[icut] = names;
12811282

12821283
TString cutNamesStr = fConfigCuts.pair.value;
@@ -1529,6 +1530,7 @@ struct AnalysisSameEventPairing {
15291530
dielectronAllList.reserve(1);
15301531
dimuonAllList.reserve(1);
15311532
}
1533+
fAmbiguousPairs.clear();
15321534
constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0);
15331535
constexpr bool eventHasQvectorCentr = ((TEventFillMap & VarManager::ObjTypes::CollisionQvect) > 0);
15341536
constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0);
@@ -1720,52 +1722,89 @@ struct AnalysisSameEventPairing {
17201722
bool isAmbiInBunch = false;
17211723
bool isAmbiOutOfBunch = false;
17221724
bool isUnambiguous = false;
1725+
bool isLeg1Ambi = false;
1726+
bool isLeg2Ambi = false;
1727+
bool isAmbiExtra = false;
17231728
for (int icut = 0; icut < ncuts; icut++) {
17241729
if (twoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
17251730
isAmbiInBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 28)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 29));
17261731
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
17271732
isUnambiguous = !(isAmbiInBunch || isAmbiOutOfBunch);
1733+
isLeg1Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 28) || (twoTrackFilter & (static_cast<uint32_t>(1) << 30)));
1734+
isLeg2Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 29) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31)));
1735+
if constexpr (TPairType == VarManager::kDecayToEE) {
1736+
if (isLeg1Ambi && isLeg2Ambi) {
1737+
std::pair<uint32_t, uint32_t> iPair(a1.reducedtrackId(), a2.reducedtrackId());
1738+
if (fAmbiguousPairs.find(iPair) != fAmbiguousPairs.end()) {
1739+
if (fAmbiguousPairs[iPair] & (static_cast<uint32_t>(1) << icut)) { // if this pair is already stored with this cut
1740+
isAmbiExtra = true;
1741+
} else {
1742+
fAmbiguousPairs[iPair] |= static_cast<uint32_t>(1) << icut;
1743+
}
1744+
} else {
1745+
fAmbiguousPairs[iPair] = static_cast<uint32_t>(1) << icut;
1746+
}
1747+
}
1748+
}
17281749
if (sign1 * sign2 < 0) {
1729-
fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues);
17301750
PromptNonPromptSepTable(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kVertexingTauxyProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjectedPoleJPsiMass], VarManager::fgValues[VarManager::kVertexingTauzProjected], isAmbiInBunch, isAmbiOutOfBunch);
1731-
if (isAmbiInBunch) {
1732-
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues);
1733-
}
1734-
if (isAmbiOutOfBunch) {
1735-
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues);
1736-
}
17371751
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1752+
fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues);
1753+
if (isAmbiInBunch) {
1754+
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues);
1755+
}
1756+
if (isAmbiOutOfBunch) {
1757+
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues);
1758+
}
17381759
if (isUnambiguous) {
17391760
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 6].Data(), VarManager::fgValues);
17401761
}
17411762
}
1763+
if constexpr (TPairType == VarManager::kDecayToEE) {
1764+
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1765+
if (isAmbiExtra) {
1766+
fHistMan->FillHistClass(Form("PairsBarrelSEPM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1767+
}
1768+
}
17421769
} else {
17431770
if (sign1 > 0) {
1744-
fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues);
1745-
if (isAmbiInBunch) {
1746-
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues);
1747-
}
1748-
if (isAmbiOutOfBunch) {
1749-
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues);
1750-
}
17511771
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1772+
fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues);
1773+
if (isAmbiInBunch) {
1774+
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues);
1775+
}
1776+
if (isAmbiOutOfBunch) {
1777+
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues);
1778+
}
17521779
if (isUnambiguous) {
17531780
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 6].Data(), VarManager::fgValues);
17541781
}
17551782
}
1756-
} else {
1757-
fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues);
1758-
if (isAmbiInBunch) {
1759-
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues);
1760-
}
1761-
if (isAmbiOutOfBunch) {
1762-
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues);
1783+
if constexpr (TPairType == VarManager::kDecayToEE) {
1784+
fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1785+
if (isAmbiExtra) {
1786+
fHistMan->FillHistClass(Form("PairsBarrelSEPP_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1787+
}
17631788
}
1789+
} else {
17641790
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1791+
fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues);
1792+
if (isAmbiInBunch) {
1793+
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues);
1794+
}
1795+
if (isAmbiOutOfBunch) {
1796+
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues);
1797+
}
17651798
if (isUnambiguous) {
17661799
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 6].Data(), VarManager::fgValues);
17671800
}
17681801
}
1802+
if constexpr (TPairType == VarManager::kDecayToEE) {
1803+
fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1804+
if (isAmbiExtra) {
1805+
fHistMan->FillHistClass(Form("PairsBarrelSEMM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1806+
}
1807+
}
17691808
}
17701809
}
17711810
for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) {
@@ -1887,8 +1926,8 @@ struct AnalysisSameEventPairing {
18871926
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
18881927
isUnambiguous = !((twoTrackFilter & (static_cast<uint32_t>(1) << 28)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 29)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31)));
18891928
if (pairSign == 0) {
1890-
fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues);
18911929
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1930+
fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues);
18921931
if (isAmbiInBunch) {
18931932
fHistMan->FillHistClass(histNames[icut][15].Data(), VarManager::fgValues);
18941933
}
@@ -1899,10 +1938,13 @@ struct AnalysisSameEventPairing {
18991938
fHistMan->FillHistClass(histNames[icut][21].Data(), VarManager::fgValues);
19001939
}
19011940
}
1941+
if constexpr (TPairType == VarManager::kDecayToEE) {
1942+
fHistMan->FillHistClass(Form("PairsBarrelMEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1943+
}
19021944
} else {
19031945
if (pairSign > 0) {
1904-
fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues);
19051946
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1947+
fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues);
19061948
if (isAmbiInBunch) {
19071949
fHistMan->FillHistClass(histNames[icut][16].Data(), VarManager::fgValues);
19081950
}
@@ -1913,9 +1955,12 @@ struct AnalysisSameEventPairing {
19131955
fHistMan->FillHistClass(histNames[icut][22].Data(), VarManager::fgValues);
19141956
}
19151957
}
1958+
if constexpr (TPairType == VarManager::kDecayToEE) {
1959+
fHistMan->FillHistClass(Form("PairsBarrelMEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1960+
}
19161961
} else {
1917-
fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues);
19181962
if constexpr (TPairType == VarManager::kDecayToMuMu) {
1963+
fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues);
19191964
if (isAmbiInBunch) {
19201965
fHistMan->FillHistClass(histNames[icut][17].Data(), VarManager::fgValues);
19211966
}
@@ -1926,6 +1971,9 @@ struct AnalysisSameEventPairing {
19261971
fHistMan->FillHistClass(histNames[icut][23].Data(), VarManager::fgValues);
19271972
}
19281973
}
1974+
if constexpr (TPairType == VarManager::kDecayToEE) {
1975+
fHistMan->FillHistClass(Form("PairsBarrelMEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
1976+
}
19291977
}
19301978
}
19311979
} // end for (cuts)
@@ -1939,6 +1987,7 @@ struct AnalysisSameEventPairing {
19391987
{
19401988
events.bindExternalIndices(&assocs);
19411989
int mixingDepth = fConfigMixingDepth.value;
1990+
fAmbiguousPairs.clear();
19421991
for (auto& [event1, event2] : selfCombinations(hashBin, mixingDepth, -1, events, events)) {
19431992
VarManager::ResetValues(0, VarManager::kNVars);
19441993
VarManager::FillEvent<TEventFillMap>(event1, VarManager::fgValues);

0 commit comments

Comments
 (0)