Skip to content
Open
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
49 changes: 31 additions & 18 deletions PWGDQ/Core/MixingHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

#include <Rtypes.h>

#include <algorithm>
#include <array>
#include <iostream>

Check failure on line 29 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <map>
#include <vector>

Expand All @@ -39,11 +40,11 @@
float eta;
float phi;
uint32_t filteringFlags;
// flip a bit to zero (needed when a track was already used in mixing for that bit for the required pool depth)
void FlipBit(int64_t mask) { filteringFlags ^= mask; }
// Clear a bit once the track was used in mixing for that bit for the required pool depth.
void ClearBit(uint32_t mask) { filteringFlags &= ~mask; }
void Print() const
{
std::cout << "pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", filteringFlags: " << filteringFlags << std::endl;

Check failure on line 47 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

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

Expand All @@ -68,57 +69,65 @@
tracks2.push_back(track);
filteringMask |= track.filteringFlags;
}
// flip bits in the filtering mask
void FlipFilteringMask(int64_t mask) { filteringMask ^= mask; }
// Clear bits in the filtering mask.
void ClearFilteringMask(uint32_t mask) { filteringMask &= ~mask; }
// 1) increment the counters for a given track cut bit mask and if the counters reached the pool depth,
// 2) flip the corresponding bit in the tracks filtering flags to exclude them from further mixing
// 2) clear the corresponding bit in the tracks filtering flags to exclude them from further mixing
// 3) for each track, if there are no more active bits in the filtering mask, then remove the track from the event
void IncrementCounters(uint32_t mask, short poolDepth)
{
for (int i = 0; i < 32; i++) {
if (mask & (1ULL << i)) {
uint32_t bitMask = (static_cast<uint32_t>(1) << i);
if (mask & bitMask) {
counters[i]++;
if (counters[i] >= poolDepth) {
for (auto& track : tracks1) {
track.FlipBit(1ULL << i);
if (track.filteringFlags == 0) {
track = tracks1.back();
tracks1.pop_back();
track.ClearBit(bitMask);
}
for (auto track = tracks1.begin(); track != tracks1.end();) {
if (track->filteringFlags == 0) {
track = tracks1.erase(track);
} else {
++track;
}
}

for (auto& track : tracks2) {
track.FlipBit(1ULL << i);
if (track.filteringFlags == 0) {
track = tracks2.back();
tracks2.pop_back();
track.ClearBit(bitMask);
}
for (auto track = tracks2.begin(); track != tracks2.end();) {
if (track->filteringFlags == 0) {
track = tracks2.erase(track);
} else {
++track;
}
}
FlipFilteringMask(1ULL << i);
ClearFilteringMask(bitMask);
}
}
}
}
void Print() const
{
std::cout << "Event filtering mask: ";

Check failure on line 112 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
for (int i = 0; i < 32; i++) {
if (filteringMask & (1ULL << i)) {
std::cout << "1";

Check failure on line 115 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
} else {
std::cout << "0";

Check failure on line 117 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
std::cout << std::endl;

Check failure on line 120 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
for (int i = 0; i < 32; i++) {
if (filteringMask & (1ULL << i)) {
std::cout << "Counter " << i << ": " << counters[i] << std::endl;

Check failure on line 123 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
std::cout << "Tracks 1: " << std::endl;

Check failure on line 126 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
for (const auto& track : tracks1) {
track.Print();
}
std::cout << "Tracks 2: " << std::endl;

Check failure on line 130 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
for (const auto& track : tracks2) {
track.Print();
}
Expand All @@ -131,9 +140,13 @@
// check which events in the pool are empty (i.e. no active tracks for mixing) and remove them from the pool
void CleanPool()
{
events.erase(std::remove_if(events.begin(), events.end(),
[](const MixingEvent& event) { return event.tracks1.empty() && event.tracks2.empty(); }),
events.end());
for (auto event = events.begin(); event != events.end();) {
if (event->tracks1.empty() && event->tracks2.empty()) {
event = events.erase(event);
} else {
++event;
}
}
}
// The function that performs the mixing is called outside this class, but the pool provides the events and tracks to be mixed and takes care of updating the events after mixing
// (e.g. incrementing the counters and removing the tracks that reached the pool depth for a given cut)
Expand All @@ -150,7 +163,7 @@

void Print() const
{
std::cout << "Mixing pool with " << events.size() << " events:" << std::endl;

Check failure on line 166 in PWGDQ/Core/MixingHandler.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
for (const auto& event : events) {
event.Print();
}
Expand Down
10 changes: 10 additions & 0 deletions PWGDQ/DataModel/ReducedInfoTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ DECLARE_SOA_COLUMN(PairDCAxyz, pairDCAxyz, float);
DECLARE_SOA_COLUMN(PairDCAxy, pairDCAxy, float); //! Pair DCAxy to PV from KFParticle
DECLARE_SOA_COLUMN(DeviationPairKF, deviationPairKF, float); //! Pair chi2 deviation to PV from KFParticle
DECLARE_SOA_COLUMN(DeviationxyPairKF, deviationxyPairKF, float); //! Pair chi2 deviation to PV in XY from KFParticle
DECLARE_SOA_COLUMN(BdtBackground, bdtBackground, float); //! BDT output score for the background class
DECLARE_SOA_COLUMN(BdtPrompt, bdtPrompt, float); //! BDT output score for the prompt class
DECLARE_SOA_COLUMN(BdtNonprompt, bdtNonprompt, float); //! BDT output score for the nonprompt class
// DECLARE_SOA_INDEX_COLUMN(ReducedMuon, reducedmuon2); //!
DECLARE_SOA_COLUMN(CosThetaHE, costhetaHE, float); //! Cosine in the helicity frame
DECLARE_SOA_COLUMN(PhiHE, phiHe, float); //! Phi in the helicity frame
Expand Down Expand Up @@ -936,6 +939,12 @@ DECLARE_SOA_TABLE_STAGED(DielectronsAll, "RTDIELECTRONALL", //!
reducedpair::Lz,
reducedpair::Lxy);

DECLARE_SOA_TABLE_STAGED(DielectronsMls, "RTDIELECTRONML", //!
reducedpair::CentFT0C,
reducedpair::BdtBackground,
reducedpair::BdtPrompt,
reducedpair::BdtNonprompt);

DECLARE_SOA_TABLE(DimuonsAll, "AOD", "RTDIMUONALL", //!
collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib,
evsel::Selection, reducedpair::EventSelection,
Expand Down Expand Up @@ -1010,6 +1019,7 @@ using DimuonExtra = DimuonsExtra::iterator;
using DileptonFlow = DileptonsFlow::iterator;
using DileptonInfo = DileptonsInfo::iterator;
using DielectronAll = DielectronsAll::iterator;
using DielectronMl = DielectronsMls::iterator;
using DimuonAll = DimuonsAll::iterator;
using DileptonMiniTree = DileptonsMiniTree::iterator;
using DileptonMiniTreeGen = DileptonsMiniTreeGen::iterator;
Expand Down
10 changes: 9 additions & 1 deletion PWGDQ/Tasks/tableReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ struct AnalysisSameEventPairing {
Produces<aod::DielectronsInfo> dielectronInfoList;
Produces<aod::DimuonsExtra> dimuonExtraList;
Produces<aod::DielectronsAll> dielectronAllList;
Produces<aod::DielectronsMls> dielectronMlList;
Produces<aod::DimuonsAll> dimuonAllList;
Produces<aod::DileptonFlow> dileptonFlowList;
Produces<aod::DileptonsInfo> dileptonInfoList;
Expand Down Expand Up @@ -1380,6 +1381,7 @@ struct AnalysisSameEventPairing {
dileptonFlowList.reserve(1);
if (fConfigFlatTables.value) {
dielectronAllList.reserve(1);
dielectronMlList.reserve(1);
dimuonAllList.reserve(1);
}
if (useMiniTree.fConfigMiniTree) {
Expand Down Expand Up @@ -1466,6 +1468,8 @@ struct AnalysisSameEventPairing {
}
}
if constexpr ((TPairType == pairTypeEE) && (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) {
isSelectedBDT = false;
fOutputMlPsi2ee.clear();
if (applyBDT) {
std::vector<float> dqInputFeatures = fDQMlResponse.getInputFeatures(t1, t2, VarManager::fgValues);

Expand Down Expand Up @@ -1497,7 +1501,7 @@ struct AnalysisSameEventPairing {

LOG(debug) << "Model index: " << modelIndex << ", pT: " << VarManager::fgValues[VarManager::kPt] << ", centrality (kCentFT0C): " << VarManager::fgValues[VarManager::kCentFT0C];
isSelectedBDT = fDQMlResponse.isSelectedMl(dqInputFeatures, modelIndex, fOutputMlPsi2ee);
VarManager::FillBdtScore(fOutputMlPsi2ee); // TODO: check if this is needed or not
VarManager::FillBdtScore(fOutputMlPsi2ee);
}

if (applyBDT && !isSelectedBDT)
Expand All @@ -1512,6 +1516,10 @@ struct AnalysisSameEventPairing {
VarManager::fgValues[VarManager::kKFMass], VarManager::fgValues[VarManager::kKFChi2OverNDFGeo], VarManager::fgValues[VarManager::kVertexingLxyz], VarManager::fgValues[VarManager::kVertexingLxyzOverErr], VarManager::fgValues[VarManager::kVertexingLxy], VarManager::fgValues[VarManager::kVertexingLxyOverErr], VarManager::fgValues[VarManager::kVertexingTauxy], VarManager::fgValues[VarManager::kVertexingTauxyErr], VarManager::fgValues[VarManager::kKFCosPA], VarManager::fgValues[VarManager::kKFJpsiDCAxyz], VarManager::fgValues[VarManager::kKFJpsiDCAxy],
VarManager::fgValues[VarManager::kKFPairDeviationFromPV], VarManager::fgValues[VarManager::kKFPairDeviationxyFromPV],
VarManager::fgValues[VarManager::kKFMassGeoTop], VarManager::fgValues[VarManager::kKFChi2OverNDFGeoTop], VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]);
dielectronMlList(VarManager::fgValues[VarManager::kCentFT0C],
(applyBDT && fOutputMlPsi2ee.size() > 0) ? VarManager::fgValues[VarManager::kBdtBackground] : -999.f,
(applyBDT && fOutputMlPsi2ee.size() > 1) ? VarManager::fgValues[VarManager::kBdtPrompt] : -999.f,
(applyBDT && fOutputMlPsi2ee.size() > 2) ? VarManager::fgValues[VarManager::kBdtNonprompt] : -999.f);
}
}
if constexpr (TPairType == pairTypeMuMu) {
Expand Down
Loading
Loading