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
132 changes: 121 additions & 11 deletions PWGDQ/Tasks/tableReader_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

Check failure on line 64 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <iterator>
#include <map>
#include <memory>
Expand Down Expand Up @@ -271,7 +271,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 274 in PWGDQ/Tasks/tableReader_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

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

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

Check failure on line 346 in PWGDQ/Tasks/tableReader_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 @@ -409,7 +409,7 @@
fSelMap.clear();
fBCCollMap.clear();

for (auto& event : events) {

Check failure on line 412 in PWGDQ/Tasks/tableReader_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 @@ -500,10 +500,10 @@
auto& bc2Events = bc2It->second;

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

Check failure on line 503 in PWGDQ/Tasks/tableReader_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 506 in PWGDQ/Tasks/tableReader_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 All @@ -522,7 +522,7 @@

// publish the table
uint8_t evSel = static_cast<uint8_t>(0);
for (auto& event : events) {

Check failure on line 525 in PWGDQ/Tasks/tableReader_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.
evSel = 0;
if (fSelMap[event.globalIndex()]) { // event passed the user cuts
evSel |= (static_cast<uint8_t>(1) << 0);
Expand Down Expand Up @@ -643,7 +643,7 @@
TString addTrackCutsStr = fConfigCutsJSON.value;
if (addTrackCutsStr != "") {
std::vector<AnalysisCut*> addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data());
for (auto& t : addTrackCuts) {

Check failure on line 646 in PWGDQ/Tasks/tableReader_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.
fTrackCuts.push_back(reinterpret_cast<AnalysisCompositeCut*>(t));
}
}
Expand All @@ -657,7 +657,7 @@

// set one histogram directory for each defined track cut
TString histDirNames = "TrackBarrel_BeforeCuts;";
for (auto& cut : fTrackCuts) {

Check failure on line 660 in PWGDQ/Tasks/tableReader_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.
histDirNames += Form("TrackBarrel_%s;", cut->GetName());
}
if (fConfigPublishAmbiguity) {
Expand Down Expand Up @@ -721,7 +721,7 @@
uint32_t filterMap = static_cast<uint32_t>(0);
int iCut = 0;

for (auto& assoc : assocs) {

Check failure on line 724 in PWGDQ/Tasks/tableReader_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.

// if the event from this association is not selected, reject also the association
auto event = assoc.template reducedevent_as<TEvents>();
Expand Down Expand Up @@ -1340,7 +1340,7 @@
bool fEnableMuonHistos;
bool fEnableMuonMixingHistos;
bool fEnableBarrelMuonHistos;
// bool fEnableBarrelMuonMixingHistos;
bool fEnableBarrelMuonMixingHistos;

NoBinningPolicy<aod::dqanalysisflags::MixingHash> hashBin;

Expand All @@ -1355,9 +1355,10 @@
fEnableMuonHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmedMultExtra") || context.mOptions.get<bool>("processMuonOnlySkimmedFlow") || context.mOptions.get<bool>("processMixingMuonSkimmed");
fEnableMuonMixingHistos = context.mOptions.get<bool>("processMixingAllSkimmed") || context.mOptions.get<bool>("processMixingMuonSkimmed");
fEnableBarrelMuonHistos = context.mOptions.get<bool>("processElectronMuonSkimmed");
fEnableBarrelMuonMixingHistos = context.mOptions.get<bool>("processMixingElectronMuonSkimmed");

if (context.mOptions.get<bool>("processDummy")) {
if (fEnableBarrelHistos || fEnableBarrelMixingHistos || fEnableMuonHistos || fEnableMuonMixingHistos || fEnableBarrelMuonHistos) {
if (fEnableBarrelHistos || fEnableBarrelMixingHistos || fEnableMuonHistos || fEnableMuonMixingHistos || fEnableBarrelMuonHistos || fEnableBarrelMuonMixingHistos) {
LOG(fatal) << "No other processing tasks should be enabled if the processDummy is enabled!!";
}
return;
Expand Down Expand Up @@ -1599,7 +1600,7 @@
VarManager::SetupMatLUTFwdDCAFitter(fLUT);
}

if (fEnableBarrelMuonHistos) {
if (fEnableBarrelMuonHistos || fEnableBarrelMuonMixingHistos) {
for (int iTrack = 0; iTrack < fNCutsBarrel; ++iTrack) {
TString trackCutName = fTrackCuts[iTrack];
if (objArrayTrackCuts->FindObject(trackCutName.Data()) == nullptr)
Expand All @@ -1618,12 +1619,12 @@
int index = iTrack * fNCutsMuon + iMuon;
fTrackMuonHistNames[index] = names;

// if (fEnableBarrelMuonMixingHistos) {
// names.push_back(Form("PairsBarrelMuonMEPM_%s_%s", trackCutName.Data(), muonCutName.Data()));
// names.push_back(Form("PairsBarrelMuonMEPP_%s_%s", trackCutName.Data(), muonCutName.Data()));
// names.push_back(Form("PairsBarrelMuonMEMM_%s_%s", trackCutName.Data(), muonCutName.Data()));
// histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
// }
if (fEnableBarrelMuonMixingHistos) {
names.push_back(Form("PairsEleMuMEPM_%s_%s", trackCutName.Data(), muonCutName.Data()));
names.push_back(Form("PairsEleMuMEPP_%s_%s", trackCutName.Data(), muonCutName.Data()));
names.push_back(Form("PairsEleMuMEMM_%s_%s", trackCutName.Data(), muonCutName.Data()));
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
}

TString cutNamesStr = fConfigCuts.pair.value;
if (!cutNamesStr.IsNull()) {
Expand All @@ -1635,6 +1636,12 @@
Form("PairsEleMuSEPP_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), objArrayPair->At(iPairCut)->GetName()),
Form("PairsEleMuSEMM_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), objArrayPair->At(iPairCut)->GetName())};
histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data());
if (fEnableBarrelMuonMixingHistos) {
names.push_back(Form("PairsEleMuMEPM_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), objArrayPair->At(iPairCut)->GetName()));
names.push_back(Form("PairsEleMuMEPP_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), objArrayPair->At(iPairCut)->GetName()));
names.push_back(Form("PairsEleMuMEMM_%s_%s_%s", trackCutName.Data(), muonCutName.Data(), objArrayPair->At(iPairCut)->GetName()));
histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data());
}
index = iTrack * (fNCutsMuon * nPairCuts) + iMuon * nPairCuts + iPairCut;
fTrackMuonHistNames[index] = names;
}
Expand All @@ -1651,10 +1658,10 @@
DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram.value.data()); // define all histograms
if (fEnableBarrelHistos) {
DefineHistograms(fHistMan, "PairingSEQA", "sameevent-pairing"); // histograms for QA of the pairing
};
}
if (fEnableBarrelMixingHistos) {
DefineHistograms(fHistMan, "PairingMEQA", "mixedevent-pairing"); // histograms for QA of the pairing
};
}
dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON
VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill
fOutputList.setObject(fHistMan->GetMainHistogramList());
Expand Down Expand Up @@ -2432,6 +2439,101 @@
} // end event loop
}

template <uint32_t TEventFillMap, typename TAssoc1, typename TAssoc2, typename TTracks1, typename TTracks2>
void runEmuMixedPairing(TAssoc1 const& assocs1, TAssoc2 const& assocs2, TTracks1 const& /*tracks1*/, TTracks2 const& /*tracks2*/)
{
const auto& histNames = fTrackMuonHistNames;
int sign1 = 0;
int sign2 = 0;
int nPairCuts = (fPairCuts.size() > 0) ? fPairCuts.size() : 1;
constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0);
constexpr bool eventHasQvectorCentr = ((TEventFillMap & VarManager::ObjTypes::CollisionQvect) > 0);

for (auto& a1 : assocs1) {
if (!(a1.isBarrelSelected_raw() & fTrackFilterMask)) {
continue;
}
for (auto& a2 : assocs2) {
if (!(a2.isMuonSelected_raw() & fMuonFilterMask)) {
continue;
}

auto t1 = a1.template reducedtrack_as<TTracks1>();
auto t2 = a2.template reducedmuon_as<TTracks2>();
sign1 = t1.sign();
sign2 = t2.sign();

VarManager::FillPairME<TEventFillMap, VarManager::kElectronMuon>(t1, t2);
if constexpr (eventHasQvector) {
VarManager::FillPairVn<VarManager::kElectronMuon>(t1, t2);
}
if constexpr (eventHasQvectorCentr) {
VarManager::FillPairVn<TEventFillMap, VarManager::kElectronMuon>(t1, t2);
}

for (int iTrack = 0; iTrack < fNCutsBarrel; ++iTrack) {
if (!(a1.isBarrelSelected_raw() & (1u << iTrack))) {
continue;
}
for (int iMuon = 0; iMuon < fNCutsMuon; ++iMuon) {
if (!(a2.isMuonSelected_raw() & (1u << iMuon))) {
continue;
}
for (int iPairCut = 0; iPairCut < nPairCuts; ++iPairCut) {
if (!fPairCuts.empty()) {
AnalysisCompositeCut cut = fPairCuts.at(iPairCut);
if (!cut.IsSelected(VarManager::fgValues)) {
continue;
}
}
int index = iTrack * (fNCutsMuon * nPairCuts) + iMuon * nPairCuts + iPairCut;
auto itHist = histNames.find(index);
if (itHist == histNames.end() || itHist->second.size() < 6) {
continue;
}
if (sign1 * sign2 < 0) {
fHistMan->FillHistClass(itHist->second[3].Data(), VarManager::fgValues);
} else {
if (sign1 > 0) {
fHistMan->FillHistClass(itHist->second[4].Data(), VarManager::fgValues);
} else {
fHistMan->FillHistClass(itHist->second[5].Data(), VarManager::fgValues);
}
}
} // end pair cut loop
} // end muon cut loop
} // end barrel cut loop
}
}
}

template <uint32_t TEventFillMap, typename TEvents, typename TTrackAssocs, typename TTracks, typename TMuonAssocs, typename TMuons>
void runEmuSameSideMixing(TEvents& events, Preslice<TTrackAssocs>& preslice1, TTrackAssocs const& assocs1, TTracks const& tracks1,
Preslice<TMuonAssocs>& preslice2, TMuonAssocs const& assocs2, TMuons const& tracks2)
{
events.bindExternalIndices(&assocs1);
events.bindExternalIndices(&assocs2);
int mixingDepth = fConfigMixingDepth.value;
for (auto& [event1, event2] : selfCombinations(hashBin, mixingDepth, -1, events, events)) {
VarManager::ResetValues(0, VarManager::kNVars);
VarManager::FillEvent<TEventFillMap>(event1, VarManager::fgValues);

auto groupedAssocs1 = assocs1.sliceBy(preslice1, event1.globalIndex());
groupedAssocs1.bindExternalIndices(&events);
if (groupedAssocs1.size() == 0) {
continue;
}

auto groupedAssocs2 = assocs2.sliceBy(preslice2, event2.globalIndex());
groupedAssocs2.bindExternalIndices(&events);
if (groupedAssocs2.size() == 0) {
continue;
}

runEmuMixedPairing<TEventFillMap>(groupedAssocs1, groupedAssocs2, tracks1, tracks2);
} // end event loop
}

void processAllSkimmed(MyEventsVtxCovSelected const& events,
soa::Join<aod::ReducedTracksAssoc, aod::BarrelTrackCuts, aod::Prefilter> const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks,
soa::Join<aod::ReducedMuonsAssoc, aod::MuonTrackCuts> const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons)
Expand Down Expand Up @@ -2546,6 +2648,13 @@
runSameSideMixing<pairTypeMuMu, gkEventFillMapWithMultExtraWithQVector>(events, muonAssocs, muons, muonAssocsPerCollision);
}

void processMixingElectronMuonSkimmed(soa::Filtered<MyEventsHashSelected>& events,
soa::Join<aod::ReducedTracksAssoc, aod::BarrelTrackCuts> const& barrelAssocs, aod::ReducedTracks const& barrelTracks,
soa::Join<aod::ReducedMuonsAssoc, aod::MuonTrackCuts> const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons)
{
runEmuSameSideMixing<gkEventFillMap>(events, trackEmuAssocsPerCollision, barrelAssocs, barrelTracks, muonAssocsPerCollision, muonAssocs, muons);
}

void processDummy(MyEventsBasic&)
{
// do nothing
Expand All @@ -2568,6 +2677,7 @@
PROCESS_SWITCH(AnalysisSameEventPairing, processMixingBarrelWithQvectorCentrSkimmedNoCov, "Run barrel type mixing pairing, with skimmed tracks and with Qvector from central framework", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMixingMuonSkimmed, "Run muon type mixing pairing, with skimmed muons", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMixingMuonSkimmedFlow, "Run muon type mixing pairing, with skimmed muons and flow", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processMixingElectronMuonSkimmed, "Run electron-muon mixing pairing, with skimmed tracks/muons", false);
PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", true);
};

Expand Down
Loading