Skip to content

Commit 2ae60a8

Browse files
committed
Improve the cut function for generating signals
1 parent fa56742 commit 2ae60a8

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ struct AnalysisSameEventPairing {
13351335
Configurable<std::string> track{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"};
13361336
Configurable<std::string> muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"};
13371337
Configurable<std::string> pair{"cfgPairCuts", "", "Comma separated list of pair cuts, !!! Use only if you know what you are doing, otherwise leave empty"};
1338-
Configurable<std::string> MCgenAcc{"cfgMCGenAccCut", "", "cut for MC generated particles acceptance"};
1338+
Configurable<std::string> MCgenAcc{"cfgMCGenAccCuts", "", "Comma separated list of MC generated particles acceptance cuts, !!! Use only if you know what you are doing, otherwise leave empty"};
13391339
// TODO: Add pair cuts via JSON
13401340
} fConfigCuts;
13411341

@@ -1396,7 +1396,7 @@ struct AnalysisSameEventPairing {
13961396
std::vector<MCSignal*> fGenMCSignals;
13971397

13981398
std::vector<AnalysisCompositeCut> fPairCuts;
1399-
AnalysisCompositeCut fMCGenAccCut;
1399+
std::vector<AnalysisCut*> fMCGenAccCuts;
14001400
bool fUseMCGenAccCut = false;
14011401

14021402
uint32_t fTrackFilterMask; // mask for the track cuts required in this task to be applied on the barrel cuts produced upstream
@@ -1485,16 +1485,6 @@ struct AnalysisSameEventPairing {
14851485
}
14861486
}
14871487

1488-
// get the mc generated acceptance cut
1489-
TString mcGenAccCutStr = fConfigCuts.MCgenAcc.value;
1490-
if (mcGenAccCutStr != "") {
1491-
AnalysisCut* cut = dqcuts::GetAnalysisCut(mcGenAccCutStr.Data());
1492-
if (cut != nullptr) {
1493-
fMCGenAccCut.AddCut(cut);
1494-
}
1495-
fUseMCGenAccCut = true;
1496-
}
1497-
14981488
// check that the barrel track cuts array required in this task is not empty
14991489
if (!trackCutsStr.IsNull()) {
15001490
// tokenize and loop over the barrel cuts produced by the barrel track selection task
@@ -1663,6 +1653,19 @@ struct AnalysisSameEventPairing {
16631653
} // end loop over cuts
16641654
} // end if (muonCutsStr)
16651655

1656+
// get the mc generated acceptance cuts
1657+
TString mcgenCutsStr = fConfigCuts.MCgenAcc.value;
1658+
if (!mcgenCutsStr.IsNull()) {
1659+
std::unique_ptr<TObjArray> objArray(mcgenCutsStr.Tokenize(","));
1660+
for (int icut = 0; icut < objArray->GetEntries(); ++icut) {
1661+
AnalysisCut* cut = dqcuts::GetAnalysisCut(objArray->At(icut)->GetName());
1662+
if (cut != nullptr) {
1663+
fMCGenAccCuts.push_back(cut);
1664+
}
1665+
}
1666+
fUseMCGenAccCut = true;
1667+
}
1668+
16661669
// Add histogram classes for each specified MCsignal at the generator level
16671670
// TODO: create a std::vector of hist classes to be used at Fill time, to avoid using Form in the process function
16681671
TString sigGenNamesStr = fConfigMC.genSignals.value;
@@ -1695,6 +1698,12 @@ struct AnalysisSameEventPairing {
16951698
histNames += Form("MCTruthGenPair_%s;", sig->GetName());
16961699
histNames += Form("MCTruthGenPairSel_%s;", sig->GetName());
16971700
fHasTwoProngGenMCsignals = true;
1701+
// for these pair level signals, also add histograms for each MCgenAcc cut if specified
1702+
if (fUseMCGenAccCut) {
1703+
for (auto& cut : fMCGenAccCuts) {
1704+
histNames += Form("MCTruthGenPairSel_%s_%s;", cut->GetName(), sig->GetName());
1705+
}
1706+
}
16981707
}
16991708
}
17001709
}
@@ -2147,12 +2156,6 @@ struct AnalysisSameEventPairing {
21472156

21482157
for (auto& mctrack : mcTracks) {
21492158
VarManager::FillTrackMC(mcTracks, mctrack);
2150-
// if we have a mc generated acceptance cut, apply it here
2151-
if (fUseMCGenAccCut) {
2152-
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
2153-
continue;
2154-
}
2155-
}
21562159
// NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete.
21572160
// NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member.
21582161
// TODO: Use the mcReducedFlags to select signals
@@ -2176,12 +2179,6 @@ struct AnalysisSameEventPairing {
21762179
continue;
21772180
}
21782181
VarManager::FillTrackMC(mcTracks, track);
2179-
// if we have a mc generated acceptance cut, apply it here
2180-
if (fUseMCGenAccCut) {
2181-
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
2182-
continue;
2183-
}
2184-
}
21852182
auto track_raw = mcTracks.rawIteratorAt(track.globalIndex());
21862183
mcDecision = 0;
21872184
isig = 0;
@@ -2212,11 +2209,6 @@ struct AnalysisSameEventPairing {
22122209
}
22132210
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
22142211
VarManager::FillPairMC<TPairType>(t1, t2);
2215-
if (fUseMCGenAccCut) {
2216-
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
2217-
continue;
2218-
}
2219-
}
22202212
fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig->GetName()), VarManager::fgValues);
22212213
}
22222214
}
@@ -2247,12 +2239,15 @@ struct AnalysisSameEventPairing {
22472239
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
22482240
mcDecision |= (static_cast<uint32_t>(1) << isig);
22492241
VarManager::FillPairMC<TPairType>(t1, t2);
2242+
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues);
2243+
// Fill also acceptance cut histograms if requested
22502244
if (fUseMCGenAccCut) {
2251-
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
2252-
continue;
2245+
for (auto& accCut : fMCGenAccCuts) {
2246+
if (accCut.IsSelected(VarManager::fgValues)) {
2247+
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s_%s", sig->GetName(), accCut.GetName()), VarManager::fgValues);
2248+
}
22532249
}
22542250
}
2255-
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues);
22562251
if (useMiniTree.fConfigMiniTree) {
22572252
// WARNING! To be checked
22582253
dileptonMiniTreeGen(mcDecision, -999, t1.pt(), t1.eta(), t1.phi(), t2.pt(), t2.eta(), t2.phi());

0 commit comments

Comments
 (0)