Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 82 additions & 33 deletions PWGDQ/Tasks/tableReader_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <numeric>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <string>
Expand Down Expand Up @@ -1178,6 +1179,8 @@ struct AnalysisSameEventPairing {
std::map<int, std::vector<TString>> fMuonHistNames;
std::map<int, std::vector<TString>> fTrackMuonHistNames;
std::vector<AnalysisCompositeCut> fPairCuts;
std::vector<TString> fTrackCuts;
std::map<std::pair<uint32_t, uint32_t>, uint32_t> fAmbiguousPairs;

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

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

Expand All @@ -1263,20 +1268,16 @@ struct AnalysisSameEventPairing {
Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()),
Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())};
histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data());
names.push_back(Form("PairsBarrelSEPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEPP_ambiguousextra_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEMM_ambiguousextra_%s", objArray->At(icut)->GetName()));
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
if (fEnableBarrelMixingHistos) {
names.push_back(Form("PairsBarrelMEPM_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelMEPP_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelMEMM_%s", objArray->At(icut)->GetName()));
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
histNames += Form("%s;%s;%s;", names[6].Data(), names[7].Data(), names[8].Data());
}
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName()));
histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 6 : 3)].Data(), names[(fEnableBarrelMixingHistos ? 7 : 4)].Data(), names[(fEnableBarrelMixingHistos ? 8 : 5)].Data());
histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 9 : 6)].Data(), names[(fEnableBarrelMixingHistos ? 10 : 7)].Data(), names[(fEnableBarrelMixingHistos ? 11 : 8)].Data());
fTrackHistNames[icut] = names;

TString cutNamesStr = fConfigCuts.pair.value;
Expand Down Expand Up @@ -1529,6 +1530,7 @@ struct AnalysisSameEventPairing {
dielectronAllList.reserve(1);
dimuonAllList.reserve(1);
}
fAmbiguousPairs.clear();
constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0);
constexpr bool eventHasQvectorCentr = ((TEventFillMap & VarManager::ObjTypes::CollisionQvect) > 0);
constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0);
Expand Down Expand Up @@ -1720,52 +1722,89 @@ struct AnalysisSameEventPairing {
bool isAmbiInBunch = false;
bool isAmbiOutOfBunch = false;
bool isUnambiguous = false;
bool isLeg1Ambi = false;
bool isLeg2Ambi = false;
bool isAmbiExtra = false;
for (int icut = 0; icut < ncuts; icut++) {
if (twoTrackFilter & (static_cast<uint32_t>(1) << icut)) {
isAmbiInBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 28)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 29));
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
isUnambiguous = !(isAmbiInBunch || isAmbiOutOfBunch);
isLeg1Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 28) || (twoTrackFilter & (static_cast<uint32_t>(1) << 30)));
isLeg2Ambi = (twoTrackFilter & (static_cast<uint32_t>(1) << 29) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31)));
if constexpr (TPairType == VarManager::kDecayToEE) {
if (isLeg1Ambi && isLeg2Ambi) {
std::pair<uint32_t, uint32_t> iPair(a1.reducedtrackId(), a2.reducedtrackId());
if (fAmbiguousPairs.find(iPair) != fAmbiguousPairs.end()) {
if (fAmbiguousPairs[iPair] & (static_cast<uint32_t>(1) << icut)) { // if this pair is already stored with this cut
isAmbiExtra = true;
} else {
fAmbiguousPairs[iPair] |= static_cast<uint32_t>(1) << icut;
}
} else {
fAmbiguousPairs[iPair] = static_cast<uint32_t>(1) << icut;
}
}
}
if (sign1 * sign2 < 0) {
fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues);
PromptNonPromptSepTable(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kVertexingTauxyProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjectedPoleJPsiMass], VarManager::fgValues[VarManager::kVertexingTauzProjected], isAmbiInBunch, isAmbiOutOfBunch);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues);
}
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues);
}
if (isUnambiguous) {
fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 6].Data(), VarManager::fgValues);
}
}
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
if (isAmbiExtra) {
fHistMan->FillHistClass(Form("PairsBarrelSEPM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
}
} else {
if (sign1 > 0) {
fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues);
}
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues);
}
if (isUnambiguous) {
fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 6].Data(), VarManager::fgValues);
}
}
} else {
fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues);
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
if (isAmbiExtra) {
fHistMan->FillHistClass(Form("PairsBarrelSEPP_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
}
} else {
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues);
}
if (isAmbiOutOfBunch) {
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues);
}
if (isUnambiguous) {
fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 6].Data(), VarManager::fgValues);
}
}
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
if (isAmbiExtra) {
fHistMan->FillHistClass(Form("PairsBarrelSEMM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
}
}
}
for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) {
Expand Down Expand Up @@ -1887,8 +1926,8 @@ struct AnalysisSameEventPairing {
isAmbiOutOfBunch = (twoTrackFilter & (static_cast<uint32_t>(1) << 30)) || (twoTrackFilter & (static_cast<uint32_t>(1) << 31));
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)));
if (pairSign == 0) {
fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues);
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][15].Data(), VarManager::fgValues);
}
Expand All @@ -1899,10 +1938,13 @@ struct AnalysisSameEventPairing {
fHistMan->FillHistClass(histNames[icut][21].Data(), VarManager::fgValues);
}
}
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelMEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
} else {
if (pairSign > 0) {
fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues);
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][16].Data(), VarManager::fgValues);
}
Expand All @@ -1913,9 +1955,12 @@ struct AnalysisSameEventPairing {
fHistMan->FillHistClass(histNames[icut][22].Data(), VarManager::fgValues);
}
}
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelMEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
} else {
fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues);
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues);
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][17].Data(), VarManager::fgValues);
}
Expand All @@ -1926,6 +1971,9 @@ struct AnalysisSameEventPairing {
fHistMan->FillHistClass(histNames[icut][23].Data(), VarManager::fgValues);
}
}
if constexpr (TPairType == VarManager::kDecayToEE) {
fHistMan->FillHistClass(Form("PairsBarrelMEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues);
}
}
}
} // end for (cuts)
Expand All @@ -1939,6 +1987,7 @@ struct AnalysisSameEventPairing {
{
events.bindExternalIndices(&assocs);
int mixingDepth = fConfigMixingDepth.value;
fAmbiguousPairs.clear();
for (auto& [event1, event2] : selfCombinations(hashBin, mixingDepth, -1, events, events)) {
VarManager::ResetValues(0, VarManager::kNVars);
VarManager::FillEvent<TEventFillMap>(event1, VarManager::fgValues);
Expand Down