Skip to content
Draft
Show file tree
Hide file tree
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
72 changes: 46 additions & 26 deletions PWGDQ/Tasks/dqEfficiency_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,8 @@ struct AnalysisSameEventPairing {
} fConfigCuts;

Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
Configurable<bool> fConfigAmbiguousBarrelHistograms{"cfgAmbiguousBarrelHistograms", true, "If true, add the in/out-of-bunch ambiguity histogram classes for barrel pairs"};
Configurable<bool> fConfigAmbiguousMuonHistograms{"cfgAmbiguousMuonHistograms", true, "If true, add the in/out-of-bunch ambiguity histogram classes for muon pairs"};
Configurable<std::string> fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"};
Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};

Expand Down Expand Up @@ -1913,7 +1915,7 @@ struct AnalysisSameEventPairing {
Form("PairsBarrelSEPM_%s", objArray->At(icut)->GetName()),
Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()),
Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())};
if (fConfigQA) {
if (fConfigQA && fConfigAmbiguousBarrelHistograms) {
// assign separate hist directories for ambiguous tracks
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
Expand Down Expand Up @@ -1956,12 +1958,14 @@ struct AnalysisSameEventPairing {
if (fConfigQA) {
names.push_back(Form("PairsBarrelSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
if (fConfigAmbiguousBarrelHistograms) {
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
}
}
for (auto const& n : names) {
histNames += Form("%s;", n.Data());
Expand Down Expand Up @@ -2004,7 +2008,7 @@ struct AnalysisSameEventPairing {
Form("PairsMuonSEPM_%s", objArray->At(icut)->GetName()),
Form("PairsMuonSEPP_%s", objArray->At(icut)->GetName()),
Form("PairsMuonSEMM_%s", objArray->At(icut)->GetName())};
if (fConfigQA) {
if (fConfigQA && fConfigAmbiguousMuonHistograms) {
// assign separate hist directories for ambiguous tracks
names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsMuonSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName()));
Expand Down Expand Up @@ -2045,12 +2049,14 @@ struct AnalysisSameEventPairing {
if (fConfigQA) {
names.push_back(Form("PairsMuonSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
if (fConfigAmbiguousMuonHistograms) {
names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName()));
}
}
for (auto const& n : names) {
histNames += Form("%s;", n.Data());
Expand Down Expand Up @@ -2154,12 +2160,15 @@ struct AnalysisSameEventPairing {
if (fConfigQA) {
names.push_back(Form("PairsEleMuSEPMCorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPMIncorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunch_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunchCorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunchIncorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunch_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
// the e-mu ambiguity classes mix a barrel and a muon leg, so they need both switches
if (fConfigAmbiguousBarrelHistograms && fConfigAmbiguousMuonHistograms) {
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunch_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunchCorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousInBunchIncorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunch_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
names.push_back(Form("PairsEleMuSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), sig->GetName()));
}
}
for (auto const& n : names) {
histNames += Form("%s;", n.Data());
Expand Down Expand Up @@ -2309,6 +2318,12 @@ struct AnalysisSameEventPairing {
histNamesMC = fMuonHistNamesMCmatched;
ncuts = fNCutsMuon;
}
// the in/out-of-bunch ambiguity hist classes are only booked (and therefore only fillable) when the
// corresponding switch is on; the indices below assume they are appended last in each name vector
bool fillAmbiguousHistos = fConfigAmbiguousBarrelHistograms;
if constexpr (TPairType == VarManager::kDecayToMuMu) {
fillAmbiguousHistos = fConfigAmbiguousMuonHistograms;
}

auto twoTrackFilter = static_cast<uint32_t>(0);
int sign1 = 0;
Expand Down Expand Up @@ -2629,15 +2644,15 @@ struct AnalysisSameEventPairing {
} else { // incorrect track-collision association
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][4].Data(), dqefficiency_helpers::varValues());
}
if (isAmbiInBunch) { // ambiguous in bunch
if (fillAmbiguousHistos && isAmbiInBunch) { // ambiguous in bunch
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][5].Data(), dqefficiency_helpers::varValues());
if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) {
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][6].Data(), dqefficiency_helpers::varValues());
} else {
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][7].Data(), dqefficiency_helpers::varValues());
}
}
if (isAmbiOutOfBunch) { // ambiguous out of bunch
if (fillAmbiguousHistos && isAmbiOutOfBunch) { // ambiguous out of bunch
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][8].Data(), dqefficiency_helpers::varValues());
if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) {
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][9].Data(), dqefficiency_helpers::varValues());
Expand All @@ -2647,7 +2662,7 @@ struct AnalysisSameEventPairing {
}
}
}
if (fConfigQA) {
if (fConfigQA && fillAmbiguousHistos) {
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][3].Data(), dqefficiency_helpers::varValues());
}
Expand All @@ -2664,7 +2679,7 @@ struct AnalysisSameEventPairing {
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][1].Data(), dqefficiency_helpers::varValues());
}
}
if (fConfigQA) {
if (fConfigQA && fillAmbiguousHistos) {
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][4].Data(), dqefficiency_helpers::varValues());
}
Expand All @@ -2679,7 +2694,7 @@ struct AnalysisSameEventPairing {
fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][2].Data(), dqefficiency_helpers::varValues());
}
}
if (fConfigQA) {
if (fConfigQA && fillAmbiguousHistos) {
if (isAmbiInBunch) {
fHistMan->FillHistClass(histNames[icut][5].Data(), dqefficiency_helpers::varValues());
}
Expand Down Expand Up @@ -2859,6 +2874,8 @@ struct AnalysisSameEventPairing {
const auto& histNames = fTrackMuonHistNames;
const auto& histNamesMC = fTrackMuonHistNamesMCmatched;
int nPairCuts = !fPairCuts.empty() ? static_cast<int>(fPairCuts.size()) : 1;
// e-mu pairs have one barrel and one muon leg, so the ambiguity classes need both switches
bool fillAmbiguousHistos = fConfigAmbiguousBarrelHistograms && fConfigAmbiguousMuonHistograms;

uint32_t twoTrackFilter = 0;
uint32_t mcDecision = 0;
Expand Down Expand Up @@ -3021,7 +3038,7 @@ struct AnalysisSameEventPairing {
} else {
fHistMan->FillHistClass(mcNames[2].Data(), dqefficiency_helpers::varValues());
}
if (!fConfigQA || mcNames.size() < 11) {
if (!fConfigQA || mcNames.size() < 5) {
continue;
}
// QA fills (PM only, mirroring the dilepton MC layout: indices 3..10)
Expand All @@ -3031,6 +3048,9 @@ struct AnalysisSameEventPairing {
} else {
fHistMan->FillHistClass(mcNames[4].Data(), dqefficiency_helpers::varValues());
}
if (!fillAmbiguousHistos || mcNames.size() < 11) {
continue;
}
if (isAmbiInBunch) {
fHistMan->FillHistClass(mcNames[5].Data(), dqefficiency_helpers::varValues());
if (isCorrectPair) {
Expand Down
35 changes: 21 additions & 14 deletions PWGDQ/Tasks/tableReader_withAssoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,7 @@ struct AnalysisSameEventPairing {
o2::framework::Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
o2::framework::Configurable<bool> fConfigQA{"cfgQA", true, "If true, fill output histograms"};
o2::framework::Configurable<bool> fConfigAmbiguousMuonHistograms{"cfgAmbiguousMuonHistograms", true, "If true, fill ambiguous histograms"};
o2::framework::Configurable<bool> fConfigAmbiguousBarrelHistograms{"cfgAmbiguousBarrelHistograms", true, "If true, add the ambiguity histogram classes for barrel pairs"};

// option for TR pair fill
o2::framework::Configurable<bool> fConfigTRPairs{"cfgFillTRPairs", false, "If true, fill Track rotation pairs"};
Expand Down Expand Up @@ -1708,21 +1709,27 @@ 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());
// append a hist class to both the name vector and the list of classes to be created
auto addName = [&names, &histNames](TString const& name) {
names.push_back(name);
histNames += Form("%s;", name.Data());
};
if (fConfigAmbiguousBarrelHistograms) {
addName(Form("PairsBarrelSEPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
addName(Form("PairsBarrelSEPP_ambiguousextra_%s", objArray->At(icut)->GetName()));
addName(Form("PairsBarrelSEMM_ambiguousextra_%s", objArray->At(icut)->GetName()));
}
if (fConfigTRPairs) {
names.push_back(Form("PairsBarrelTRPM_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelTRPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
names.push_back(Form("PairsBarrelTR_MEPM_%s", objArray->At(icut)->GetName()));
histNames += Form("%s;%s;%s;", names[6].Data(), names[7].Data(), names[8].Data());
addName(Form("PairsBarrelTRPM_%s", objArray->At(icut)->GetName()));
if (fConfigAmbiguousBarrelHistograms) {
addName(Form("PairsBarrelTRPM_ambiguousextra_%s", objArray->At(icut)->GetName()));
}
addName(Form("PairsBarrelTR_MEPM_%s", objArray->At(icut)->GetName()));
}
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[(fConfigTRPairs ? 9 : 6)].Data(), names[(fConfigTRPairs ? 10 : 7)].Data(), names[(fConfigTRPairs ? 11 : 8)].Data());
addName(Form("PairsBarrelMEPM_%s", objArray->At(icut)->GetName()));
addName(Form("PairsBarrelMEPP_%s", objArray->At(icut)->GetName()));
addName(Form("PairsBarrelMEMM_%s", objArray->At(icut)->GetName()));
}
fTrackHistNames[icut] = names;

Expand Down Expand Up @@ -2412,7 +2419,7 @@ struct AnalysisSameEventPairing {
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) {
if (fConfigAmbiguousBarrelHistograms && isLeg1Ambi && isLeg2Ambi) {
std::pair<uint32_t, uint32_t> iPair(a1.reducedtrackId(), a2.reducedtrackId());
if (fAmbiguousPairs.contains(iPair)) {
if (fAmbiguousPairs[iPair] & (static_cast<uint32_t>(1) << icut)) { // if this pair is already stored with this cut
Expand Down Expand Up @@ -2569,7 +2576,7 @@ struct AnalysisSameEventPairing {
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) {
if (fConfigAmbiguousBarrelHistograms && isLeg1Ambi && isLeg2Ambi) {
std::pair<uint32_t, uint32_t> iPair(a1.reducedtrackId(), a2.reducedtrackId());
if (fAmbiguousPairs.contains(iPair)) {
if (fAmbiguousPairs[iPair] & (static_cast<uint32_t>(1) << icut)) { // if this pair is already stored with this cut
Expand Down
Loading