diff --git a/PWGDQ/Core/MixingHandler.cxx b/PWGDQ/Core/MixingHandler.cxx index 834fa14e91c..5b769fed65d 100644 --- a/PWGDQ/Core/MixingHandler.cxx +++ b/PWGDQ/Core/MixingHandler.cxx @@ -134,7 +134,7 @@ int MixingHandler::FindEventCategory(float* values) return -1; // all variables must be inside limits } bin.push_back(binValue - 1); - } + } // Hash the bin values to define a unique category // The hashing is done such that the original bin values can be retrieved from the category diff --git a/PWGDQ/Core/MixingHandler.h b/PWGDQ/Core/MixingHandler.h index 6d720c8d578..2a396ab7d35 100644 --- a/PWGDQ/Core/MixingHandler.h +++ b/PWGDQ/Core/MixingHandler.h @@ -24,16 +24,15 @@ #include -#include -#include #include #include +#include +#include class MixingHandler : public TNamed { public: - // Struct to define track properties relevant for mixing and few utility functions struct MixingTrack { float pt; @@ -41,15 +40,16 @@ class MixingHandler : public TNamed 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;} - void Print() const { + void FlipBit(int64_t mask) { filteringFlags ^= mask; } + void Print() const + { std::cout << "pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", filteringFlags: " << filteringFlags << std::endl; } }; // Struct to define events used in mixing and few utility functions. - // An event is defined as two vectors of tracks (typically the legs of a two-body - //decay or the two-particles in a correlation analysis) + // An event is defined as two vectors of tracks (typically the legs of a two-body + // decay or the two-particles in a correlation analysis) struct MixingEvent { std::vector tracks1; std::vector tracks2; @@ -58,20 +58,23 @@ class MixingHandler : public TNamed // counters to keep track of how many times the event was used for mixing (for each track cut separately) std::array counters = {0}; // add a track to the event and update the filtering mask accordingly - void AddTrack1(const MixingTrack& track) { + void AddTrack1(const MixingTrack& track) + { tracks1.push_back(track); filteringMask |= track.filteringFlags; } - void AddTrack2(const MixingTrack& track) { + void AddTrack2(const MixingTrack& track) + { tracks2.push_back(track); filteringMask |= track.filteringFlags; } // flip bits in the filtering mask void FlipFilteringMask(int64_t mask) { filteringMask ^= mask; } - // 1) increment the counters for a given track cut bit mask and if the counters reached the pool depth, + // 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 // 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) { + void IncrementCounters(uint32_t mask, short poolDepth) + { for (int i = 0; i < 32; i++) { if (mask & (1ULL << i)) { counters[i]++; @@ -95,7 +98,8 @@ class MixingHandler : public TNamed } } } - void Print() const { + void Print() const + { std::cout << "Event filtering mask: "; for (int i = 0; i < 32; i++) { if (filteringMask & (1ULL << i)) { @@ -123,16 +127,18 @@ class MixingHandler : public TNamed struct MixingPool { std::vector events; - + // check which events in the pool are empty (i.e. no active tracks for mixing) and remove them from the pool - void CleanPool() { + void CleanPool() + { events.erase(std::remove_if(events.begin(), events.end(), [](const MixingEvent& event) { return event.tracks1.empty() && event.tracks2.empty(); }), events.end()); } - // 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 + // 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) - void UpdatePool(const MixingEvent& event, short poolDepth) { + void UpdatePool(const MixingEvent& event, short poolDepth) + { for (auto& event : events) { event.IncrementCounters(event.filteringMask, poolDepth); } @@ -142,14 +148,15 @@ class MixingHandler : public TNamed // getter for the events in the pool const std::vector& GetEvents() const { return events; } - void Print() const { + void Print() const + { std::cout << "Mixing pool with " << events.size() << " events:" << std::endl; for (const auto& event : events) { event.Print(); } } }; - + MixingHandler(); MixingHandler(const char* name, const char* title); virtual ~MixingHandler(); @@ -159,9 +166,9 @@ class MixingHandler : public TNamed void SetPoolDepth(short depth) { fPoolDepth = depth; } // getters - //int GetNMixingVariables() const { return fVariables.size(); } - //int GetMixingVariable(VarManager::Variables var); // returns the position in the internal varible list of the handler. Useful for checks, mostly - //std::vector GetMixingVariableLimits(VarManager::Variables var); + // int GetNMixingVariables() const { return fVariables.size(); } + // int GetMixingVariable(VarManager::Variables var); // returns the position in the internal varible list of the handler. Useful for checks, mostly + // std::vector GetMixingVariableLimits(VarManager::Variables var); MixingPool& GetPool(int category) { return fPools[category]; } short GetPoolDepth() const { return fPoolDepth; } @@ -178,10 +185,10 @@ class MixingHandler : public TNamed // bin limits for the variables used for mixing, the number of vectors corresponds to the number of variables and the content of each vector corresponds to the bin limits for that variable std::vector> fVariableLimits; - std::map fVariables; // key: variable, value: position in the internal variable list of the handler (used to map the variables to the values passed to FindEventCategory) + std::map fVariables; // key: variable, value: position in the internal variable list of the handler (used to map the variables to the values passed to FindEventCategory) - short fPoolDepth; // number of events to be kept in each pool - std::map fPools; // key: category, value: pool of events corresponding to that category + short fPoolDepth; // number of events to be kept in each pool + std::map fPools; // key: category, value: pool of events corresponding to that category ClassDef(MixingHandler, 2); }; diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index c82d8a84663..182d1959ac4 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -1630,7 +1630,7 @@ struct AnalysisSameEventPairing { TString mixVarsJsonString = fConfigMixingVariablesJson.value; std::unique_ptr objArray(mixVarsString.Tokenize(",")); if (objArray->GetEntries() > 0 || mixVarsJsonString != "") { - //fMixingHandler = new MixingHandler("mixingHandler", "mixing handler"); + // fMixingHandler = new MixingHandler("mixingHandler", "mixing handler"); if (objArray->GetEntries() > 0) { for (int iVar = 0; iVar < objArray->GetEntries(); ++iVar) { dqmixing::SetUpMixing(&fMixingHandler, objArray->At(iVar)->GetName()); @@ -1643,7 +1643,6 @@ struct AnalysisSameEventPairing { fMixingHandler.SetPoolDepth(fConfigMixingDepth); fMixingHandler.Init(); } - fCurrentRun = 0; @@ -2294,7 +2293,7 @@ struct AnalysisSameEventPairing { } // 3) add the current event to the pool pool.UpdatePool(mixingEvent, fMixingHandler.GetPoolDepth()); - //pool.Print(); + // pool.Print(); } } // end loop over events }