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
106 changes: 105 additions & 1 deletion PWGDQ/Tasks/dqEfficiency_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <TString.h>

#include <algorithm>
#include <iostream>

Check failure on line 50 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -241,7 +241,7 @@
void PrintBitMap(TMap map, int nbits)
{
for (int i = 0; i < nbits; i++) {
cout << ((map & (TMap(1) << i)) > 0 ? "1" : "0");

Check failure on line 244 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}

Expand Down Expand Up @@ -294,7 +294,7 @@
TString eventCutJSONStr = fConfigEventCutsJSON.value;
if (eventCutJSONStr != "") {
std::vector<AnalysisCut*> jsonCuts = dqcuts::GetCutsFromJSON(eventCutJSONStr.Data());
for (auto& cutIt : jsonCuts) {

Check failure on line 297 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
fEventCut->AddCut(cutIt);
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@
fSelMap.clear();
fBCCollMap.clear();

for (auto& event : events) {

Check failure on line 339 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
// Reset the fValues array and fill event observables
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
VarManager::FillEvent<TEventFillMap>(event);
Expand Down Expand Up @@ -365,7 +365,7 @@
}
}

for (auto& event : mcEvents) {

Check failure on line 368 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
// Reset the fValues array and fill event observables
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
VarManager::FillEvent<VarManager::ObjTypes::ReducedEventMC>(event);
Expand Down Expand Up @@ -413,10 +413,10 @@
auto const& bc2Events = bc2It->second;

// loop over events in the first BC
for (auto ev1It : bc1Events) {

Check failure on line 416 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto ev1 = events.rawIteratorAt(ev1It);
// loop over events in the second BC
for (auto ev2It : bc2Events) {

Check failure on line 419 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto ev2 = events.rawIteratorAt(ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
Expand Down Expand Up @@ -1386,7 +1386,7 @@
if (context.mOptions.get<bool>("processDummy")) {
return;
}
bool isMCGen = context.mOptions.get<bool>("processMCGen");
bool isMCGen = context.mOptions.get<bool>("processMCGen") || context.mOptions.get<bool>("processMCGenWithGrouping");
VarManager::SetDefaultVarNames();

fEnableBarrelHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithCollSkimmed");
Expand Down Expand Up @@ -2318,6 +2318,109 @@
} // end loop over reconstructed events
}

void processMCGenWithGrouping(soa::Filtered<MyEventsVtxCovSelected> const& events, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks)
{
uint32_t mcDecision = 0;
int isig = 0;

for (auto& mctrack : mcTracks) {
VarManager::FillTrackMC(mcTracks, mctrack);
// NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete.
// NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member.
// TODO: Use the mcReducedFlags to select signals
for (auto& sig : fGenMCSignals) {
if (sig->CheckSignal(true, mctrack)) {
fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues);
}
}
}
// Fill Generated histograms taking into account selected collisions
for (auto& event : events) {
if (!event.isEventSelected_bit(0)) {
continue;
}
if (!event.has_reducedMCevent()) {
continue;
}

for (auto& track : mcTracks) {
if (track.reducedMCeventId() != event.reducedMCeventId()) {
continue;
}
VarManager::FillTrackMC(mcTracks, track);
auto track_raw = mcTracks.rawIteratorAt(track.globalIndex());
mcDecision = 0;
isig = 0;
for (auto& sig : fGenMCSignals) {
if (sig->CheckSignal(true, track_raw)) {
mcDecision |= (static_cast<uint32_t>(1) << isig);
fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues);
MCTruthTableEffi(VarManager::fgValues[VarManager::kMCPt], VarManager::fgValues[VarManager::kMCEta], VarManager::fgValues[VarManager::kMCY], VarManager::fgValues[VarManager::kMCPhi], VarManager::fgValues[VarManager::kMCVz], VarManager::fgValues[VarManager::kMCVtxZ], VarManager::fgValues[VarManager::kMultFT0A], VarManager::fgValues[VarManager::kMultFT0C], VarManager::fgValues[VarManager::kCentFT0M], VarManager::fgValues[VarManager::kVtxNcontribReal]);

if (useMiniTree.fConfigMiniTree) {
auto mcEvent = mcEvents.rawIteratorAt(track_raw.reducedMCeventId());
dileptonMiniTreeGen(mcDecision, mcEvent.impactParameter(), track_raw.pt(), track_raw.eta(), track_raw.phi(), -999, -999, -999);
}
}
isig++;
}
}
} // end loop over reconstructed events
if (fHasTwoProngGenMCsignals) {
for (auto& [t1, t2] : combinations(mcTracks, mcTracks)) {
auto t1_raw = mcTracks.rawIteratorAt(t1.globalIndex());
auto t2_raw = mcTracks.rawIteratorAt(t2.globalIndex());
if (t1_raw.reducedMCeventId() == t2_raw.reducedMCeventId()) {
for (auto& sig : fGenMCSignals) {
if (sig->GetNProngs() != 2) { // NOTE: 2-prong signals required here
continue;
}
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
VarManager::FillPairMC<VarManager::kDecayToMuMu>(t1, t2); // NOTE: This feature will only work for muons
fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig->GetName()), VarManager::fgValues);
}
}
}
}
}
for (auto& event : events) {
if (!event.isEventSelected_bit(0)) {
continue;
}
if (!event.has_reducedMCevent()) {
continue;
}
// CURRENTLY ONLY FOR 1-GENERATION 2-PRONG SIGNALS
if (fHasTwoProngGenMCsignals) {
auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.reducedMCeventId());
groupedMCTracks.bindInternalIndicesTo(&mcTracks);
for (auto& [t1, t2] : combinations(groupedMCTracks, groupedMCTracks)) {
auto t1_raw = groupedMCTracks.rawIteratorAt(t1.globalIndex());
auto t2_raw = groupedMCTracks.rawIteratorAt(t2.globalIndex());
if (t1_raw.reducedMCeventId() == t2_raw.reducedMCeventId()) {
mcDecision = 0;
isig = 0;
for (auto& sig : fGenMCSignals) {
if (sig->GetNProngs() != 2) { // NOTE: 2-prong signals required here
continue;
}
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
mcDecision |= (static_cast<uint32_t>(1) << isig);
VarManager::FillPairMC<VarManager::kDecayToMuMu>(t1, t2); // NOTE: This feature will only work for muons
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues);
if (useMiniTree.fConfigMiniTree) {
// WARNING! To be checked
dileptonMiniTreeGen(mcDecision, -999, t1.pt(), t1.eta(), t1.phi(), t2.pt(), t2.eta(), t2.phi());
}
}
isig++;
}
}
}
} // end loop over reconstructed events
}
}

void processDummy(MyEvents&)
{
// do nothing
Expand All @@ -2328,6 +2431,7 @@
PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlyWithCollSkimmed, "Run barrel only pairing, with skimmed tracks and with collision information", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMuonOnlySkimmed, "Run muon only pairing, with skimmed tracks", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMCGen, "Loop over MC particle stack and fill generator level histograms", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMCGenWithGrouping, "Loop over MC particle stack (grouped MCTracks) and fill generator level histograms", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", true);
};

Expand Down Expand Up @@ -4041,12 +4145,12 @@
mctrack.mcReducedFlags() > 0) {
/*cout << ">>>>>>>>>>>>>>>>>>>>>>> track idx / pdg / selections: " << mctrack.globalIndex() << " / " << mctrack.pdgCode() << " / ";
PrintBitMap(mctrack.mcReducedFlags(), 16);
cout << endl;

Check failure on line 4148 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
if (mctrack.has_mothers()) {
for (auto& m : mctrack.mothersIds()) {
if (m < mcTracks.size()) { // protect against bad mother indices
auto aMother = mcTracks.rawIteratorAt(m);
cout << "<<<<<< mother idx / pdg: " << m << " / " << aMother.pdgCode() << endl;

Check failure on line 4153 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
}
Expand All @@ -4055,7 +4159,7 @@
for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) {
if (d < mcTracks.size()) { // protect against bad daughter indices
auto aDaughter = mcTracks.rawIteratorAt(d);
cout << "<<<<<< daughter idx / pdg: " << d << " / " << aDaughter.pdgCode() << endl;

Check failure on line 4162 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
}*/
Expand Down
Loading