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
88 changes: 74 additions & 14 deletions PWGDQ/Tasks/dqEfficiency_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no
// Configurable workflow for running several DQ or other PWG analyses

#include <iostream>

Check failure on line 15 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 <vector>
#include <algorithm>
#include <map>
Expand Down Expand Up @@ -311,7 +311,7 @@
auto ev2 = events.rawIteratorAt(*ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
collisionSplittingMap[*ev1It] = true;
collisionSplittingMap[*ev2It] = true;
}
Expand All @@ -336,7 +336,7 @@
auto ev2 = events.rawIteratorAt(ev2It);
// compute 2-event quantities and mark the candidate split collisions
VarManager::FillTwoEvents(ev1, ev2);
if (TMath::Abs(VarManager::fgValues[VarManager::kTwoEvDeltaZ]) < fConfigSplitCollisionsDeltaZ) { // this is a possible collision split

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
collisionSplittingMap[ev1It] = true;
collisionSplittingMap[ev2It] = true;
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@
Configurable<std::string> recSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"};
Configurable<std::string> recSignalsJSON{"cfgMCRecSignalsJSON", "", "Comma separated list of MC signals (reconstructed) via JSON"};
Configurable<bool> skimSignalOnly{"cfgSkimSignalOnly", false, "Configurable to select only matched candidates"};
Configurable<bool> runMCGenPair{"cfgRunMCGenPair", false, "Do pairing of true MC particles"};
// Configurable<bool> runMCGenPair{"cfgRunMCGenPair", false, "Do pairing of true MC particles"};
} fConfigMC;

struct : ConfigurableGroup {
Expand All @@ -1267,6 +1267,7 @@
Service<o2::ccdb::BasicCCDBManager> fCCDB;

// Filter filterEventSelected = aod::dqanalysisflags::isEventSelected & uint32_t(1);
Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast<uint32_t>(0);

HistogramManager* fHistMan;

Expand Down Expand Up @@ -1298,6 +1299,7 @@
if (context.mOptions.get<bool>("processDummy")) {
return;
}
bool isMCGen = context.mOptions.get<bool>("processMCGen") || context.mOptions.get<bool>("processMCGenWithEventSelection");
VarManager::SetDefaultVarNames();

fEnableBarrelHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithCollSkimmed");
Expand Down Expand Up @@ -1555,12 +1557,16 @@
}
}

for (auto& sig : fGenMCSignals) {
if (sig->GetNProngs() == 1) {
histNames += Form("MCTruthGen_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function
} else if (sig->GetNProngs() == 2) {
histNames += Form("MCTruthGenPair_%s;", sig->GetName());
fHasTwoProngGenMCsignals = true;
if (isMCGen) {
for (auto& sig : fGenMCSignals) {
if (sig->GetNProngs() == 1) {
histNames += Form("MCTruthGen_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function
histNames += Form("MCTruthGenSel_%s;", sig->GetName());
} else if (sig->GetNProngs() == 2) {
histNames += Form("MCTruthGenPair_%s;", sig->GetName());
histNames += Form("MCTruthGenPairSel_%s;", sig->GetName());
fHasTwoProngGenMCsignals = true;
}
}
}

Expand Down Expand Up @@ -2044,9 +2050,10 @@
{
runSameEventPairing<true, VarManager::kDecayToEE, gkEventFillMapWithCov, gkTrackFillMapWithCov>(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks);
runSameEventPairing<true, VarManager::kDecayToMuMu, gkEventFillMapWithCov, gkMuonFillMapWithCov>(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks);
if (fConfigMC.runMCGenPair) {
// Feature replaced by processMCGen and processMCGenWithEventSelection
/*if (fConfigMC.runMCGenPair) {
runMCGen(mcEvents, mcTracks);
}
}*/
// runSameEventPairing<true, VarManager::kElectronMuon, gkEventFillMap, gkTrackFillMap>(event, tracks, muons);
}

Expand All @@ -2055,30 +2062,81 @@
MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks)
{
runSameEventPairing<true, VarManager::kDecayToEE, gkEventFillMapWithCov, gkTrackFillMapWithCov>(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks);
if (fConfigMC.runMCGenPair) {
// Feature replaced by processMCGen and processMCGenWithEventSelection
/*if (fConfigMC.runMCGenPair) {
runMCGen(mcEvents, mcTracks);
}
}*/
}

void processBarrelOnlyWithCollSkimmed(MyEventsVtxCovSelected const& events,
soa::Join<aod::ReducedTracksAssoc, aod::BarrelTrackCuts, aod::Prefilter> const& barrelAssocs,
MyBarrelTracksWithCovWithAmbiguitiesWithColl const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks)
{
runSameEventPairing<true, VarManager::kDecayToEE, gkEventFillMapWithCov, gkTrackFillMapWithCovWithColl>(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks);
if (fConfigMC.runMCGenPair) {
// Feature replaced by processMCGen and processMCGenWithEventSelection
/*if (fConfigMC.runMCGenPair) {
runMCGen(mcEvents, mcTracks);
}
}*/
}

void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events,
soa::Join<aod::ReducedMuonsAssoc, aod::MuonTrackCuts> const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks)
{
runSameEventPairing<true, VarManager::kDecayToMuMu, gkEventFillMapWithCov, gkMuonFillMapWithCov>(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks);
if (fConfigMC.runMCGenPair) {
// Feature replaced by processMCGen and processMCGenWithEventSelection
/*if (fConfigMC.runMCGenPair) {
runMCGen(mcEvents, mcTracks);
}*/
}

void processMCGen(ReducedMCTracks const& mcTracks)
{
// loop over mc stack and fill histograms for pure MC truth signals
// group all the MC tracks which belong to the MC event corresponding to the current reconstructed event
// auto groupedMCTracks = tracksMC.sliceBy(aod::reducedtrackMC::reducedMCeventId, event.reducedMCevent().globalIndex());
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);
}
}
}
}

PresliceUnsorted<ReducedMCTracks> perReducedMcGenEvent = aod::reducedtrackMC::reducedMCeventId;

void processMCGenWithEventSelection(soa::Filtered<MyEventsVtxCovSelected> const& events,
ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks)
{
for (auto& event : events) {
if (!event.isEventSelected_bit(0)) {
continue;
}
if (!event.has_reducedMCevent()) {
continue;
}

auto groupedMCTracks = mcTracks.sliceBy(perReducedMcGenEvent, event.reducedMCeventId());
groupedMCTracks.bindInternalIndicesTo(&mcTracks);
for (auto& track : groupedMCTracks) {

VarManager::FillTrackMC(mcTracks, track);

auto track_raw = groupedMCTracks.rawIteratorAt(track.globalIndex());
for (auto& sig : fGenMCSignals) {
if (sig->CheckSignal(true, track_raw)) {
fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues);
}
}
}
} // end loop over reconstructed events
}

void processDummy(MyEvents&)
{
// do nothing
Expand All @@ -2088,6 +2146,8 @@
PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlySkimmed, "Run barrel only pairing, with skimmed tracks", false);
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, processMCGenWithEventSelection, "Loop over MC particle stack and fill generator level histograms with event selection", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", false);
};

Expand Down Expand Up @@ -2252,14 +2312,14 @@
}
}
// Check that the leg cut masks make sense
if (static_cast<int>(std::floor(TMath::Log2(fLegAFilterMask))) + 1 > objArray->GetEntries()) {

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegAFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegAFilterMask))) + 1, objArray->GetEntries());

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
}
if (static_cast<int>(std::floor(TMath::Log2(fLegBFilterMask))) + 1 > objArray->GetEntries()) {

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegBFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegBFilterMask))) + 1, objArray->GetEntries());

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
}
if (static_cast<int>(std::floor(TMath::Log2(fLegCFilterMask))) + 1 > objArray->GetEntries()) {

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
LOGF(fatal, "fConfigLegCFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast<int>(std::floor(TMath::Log2(fLegCFilterMask))) + 1, objArray->GetEntries());

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
}

// Get the cuts defining the legs
Expand Down Expand Up @@ -3920,7 +3980,7 @@
// The histogram classes and their components histograms are defined below depending on the name of the histogram class
//
std::unique_ptr<TObjArray> objArray(histClasses.Tokenize(";"));
for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) {

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

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
TString classStr = objArray->At(iclass)->GetName();
histMan->AddHistClass(classStr.Data());

Expand Down
Loading