Skip to content

Commit 5d0b98b

Browse files
authored
Merge pull request #33 from alibuild/alibot-cleanup-16528
[PWGDQ] Please consider the following formatting changes to #16528
2 parents 3c09b3f + 04ea8b7 commit 5d0b98b

3 files changed

Lines changed: 34 additions & 28 deletions

File tree

PWGDQ/Core/MixingHandler.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int MixingHandler::FindEventCategory(float* values)
134134
return -1; // all variables must be inside limits
135135
}
136136
bin.push_back(binValue - 1);
137-
}
137+
}
138138

139139
// Hash the bin values to define a unique category
140140
// The hashing is done such that the original bin values can be retrieved from the category

PWGDQ/Core/MixingHandler.h

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,32 @@
2424

2525
#include <Rtypes.h>
2626

27-
#include <vector>
28-
#include <map>
2927
#include <array>
3028
#include <iostream>
29+
#include <map>
30+
#include <vector>
3131

3232
class MixingHandler : public TNamed
3333
{
3434

3535
public:
36-
3736
// Struct to define track properties relevant for mixing and few utility functions
3837
struct MixingTrack {
3938
float pt;
4039
float eta;
4140
float phi;
4241
uint32_t filteringFlags;
4342
// flip a bit to zero (needed when a track was already used in mixing for that bit for the required pool depth)
44-
void FlipBit(int64_t mask) { filteringFlags ^= mask;}
45-
void Print() const {
43+
void FlipBit(int64_t mask) { filteringFlags ^= mask; }
44+
void Print() const
45+
{
4646
std::cout << "pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", filteringFlags: " << filteringFlags << std::endl;
4747
}
4848
};
4949

5050
// Struct to define events used in mixing and few utility functions.
51-
// An event is defined as two vectors of tracks (typically the legs of a two-body
52-
//decay or the two-particles in a correlation analysis)
51+
// An event is defined as two vectors of tracks (typically the legs of a two-body
52+
// decay or the two-particles in a correlation analysis)
5353
struct MixingEvent {
5454
std::vector<MixingTrack> tracks1;
5555
std::vector<MixingTrack> tracks2;
@@ -58,20 +58,23 @@ class MixingHandler : public TNamed
5858
// counters to keep track of how many times the event was used for mixing (for each track cut separately)
5959
std::array<short, 64> counters = {0};
6060
// add a track to the event and update the filtering mask accordingly
61-
void AddTrack1(const MixingTrack& track) {
61+
void AddTrack1(const MixingTrack& track)
62+
{
6263
tracks1.push_back(track);
6364
filteringMask |= track.filteringFlags;
6465
}
65-
void AddTrack2(const MixingTrack& track) {
66+
void AddTrack2(const MixingTrack& track)
67+
{
6668
tracks2.push_back(track);
6769
filteringMask |= track.filteringFlags;
6870
}
6971
// flip bits in the filtering mask
7072
void FlipFilteringMask(int64_t mask) { filteringMask ^= mask; }
71-
// 1) increment the counters for a given track cut bit mask and if the counters reached the pool depth,
73+
// 1) increment the counters for a given track cut bit mask and if the counters reached the pool depth,
7274
// 2) flip the corresponding bit in the tracks filtering flags to exclude them from further mixing
7375
// 3) for each track, if there are no more active bits in the filtering mask, then remove the track from the event
74-
void IncrementCounters(uint32_t mask, short poolDepth) {
76+
void IncrementCounters(uint32_t mask, short poolDepth)
77+
{
7578
for (int i = 0; i < 32; i++) {
7679
if (mask & (1ULL << i)) {
7780
counters[i]++;
@@ -95,7 +98,8 @@ class MixingHandler : public TNamed
9598
}
9699
}
97100
}
98-
void Print() const {
101+
void Print() const
102+
{
99103
std::cout << "Event filtering mask: ";
100104
for (int i = 0; i < 32; i++) {
101105
if (filteringMask & (1ULL << i)) {
@@ -123,16 +127,18 @@ class MixingHandler : public TNamed
123127

124128
struct MixingPool {
125129
std::vector<MixingEvent> events;
126-
130+
127131
// check which events in the pool are empty (i.e. no active tracks for mixing) and remove them from the pool
128-
void CleanPool() {
132+
void CleanPool()
133+
{
129134
events.erase(std::remove_if(events.begin(), events.end(),
130135
[](const MixingEvent& event) { return event.tracks1.empty() && event.tracks2.empty(); }),
131136
events.end());
132137
}
133-
// 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
138+
// 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
134139
// (e.g. incrementing the counters and removing the tracks that reached the pool depth for a given cut)
135-
void UpdatePool(const MixingEvent& event, short poolDepth) {
140+
void UpdatePool(const MixingEvent& event, short poolDepth)
141+
{
136142
for (auto& event : events) {
137143
event.IncrementCounters(event.filteringMask, poolDepth);
138144
}
@@ -142,14 +148,15 @@ class MixingHandler : public TNamed
142148
// getter for the events in the pool
143149
const std::vector<MixingEvent>& GetEvents() const { return events; }
144150

145-
void Print() const {
151+
void Print() const
152+
{
146153
std::cout << "Mixing pool with " << events.size() << " events:" << std::endl;
147154
for (const auto& event : events) {
148155
event.Print();
149156
}
150157
}
151158
};
152-
159+
153160
MixingHandler();
154161
MixingHandler(const char* name, const char* title);
155162
virtual ~MixingHandler();
@@ -159,9 +166,9 @@ class MixingHandler : public TNamed
159166
void SetPoolDepth(short depth) { fPoolDepth = depth; }
160167

161168
// getters
162-
//int GetNMixingVariables() const { return fVariables.size(); }
163-
//int GetMixingVariable(VarManager::Variables var); // returns the position in the internal varible list of the handler. Useful for checks, mostly
164-
//std::vector<float> GetMixingVariableLimits(VarManager::Variables var);
169+
// int GetNMixingVariables() const { return fVariables.size(); }
170+
// int GetMixingVariable(VarManager::Variables var); // returns the position in the internal varible list of the handler. Useful for checks, mostly
171+
// std::vector<float> GetMixingVariableLimits(VarManager::Variables var);
165172
MixingPool& GetPool(int category) { return fPools[category]; }
166173
short GetPoolDepth() const { return fPoolDepth; }
167174

@@ -178,10 +185,10 @@ class MixingHandler : public TNamed
178185

179186
// 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
180187
std::vector<std::vector<float>> fVariableLimits;
181-
std::map<int, int> fVariables; // key: variable, value: position in the internal variable list of the handler (used to map the variables to the values passed to FindEventCategory)
188+
std::map<int, int> fVariables; // key: variable, value: position in the internal variable list of the handler (used to map the variables to the values passed to FindEventCategory)
182189

183-
short fPoolDepth; // number of events to be kept in each pool
184-
std::map<int, MixingPool> fPools; // key: category, value: pool of events corresponding to that category
190+
short fPoolDepth; // number of events to be kept in each pool
191+
std::map<int, MixingPool> fPools; // key: category, value: pool of events corresponding to that category
185192

186193
ClassDef(MixingHandler, 2);
187194
};

PWGDQ/Tasks/tableReader_withAssoc.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ struct AnalysisSameEventPairing {
16301630
TString mixVarsJsonString = fConfigMixingVariablesJson.value;
16311631
std::unique_ptr<TObjArray> objArray(mixVarsString.Tokenize(","));
16321632
if (objArray->GetEntries() > 0 || mixVarsJsonString != "") {
1633-
//fMixingHandler = new MixingHandler("mixingHandler", "mixing handler");
1633+
// fMixingHandler = new MixingHandler("mixingHandler", "mixing handler");
16341634
if (objArray->GetEntries() > 0) {
16351635
for (int iVar = 0; iVar < objArray->GetEntries(); ++iVar) {
16361636
dqmixing::SetUpMixing(&fMixingHandler, objArray->At(iVar)->GetName());
@@ -1643,7 +1643,6 @@ struct AnalysisSameEventPairing {
16431643
fMixingHandler.SetPoolDepth(fConfigMixingDepth);
16441644
fMixingHandler.Init();
16451645
}
1646-
16471646

16481647
fCurrentRun = 0;
16491648

@@ -2294,7 +2293,7 @@ struct AnalysisSameEventPairing {
22942293
}
22952294
// 3) add the current event to the pool
22962295
pool.UpdatePool(mixingEvent, fMixingHandler.GetPoolDepth());
2297-
//pool.Print();
2296+
// pool.Print();
22982297
}
22992298
} // end loop over events
23002299
}

0 commit comments

Comments
 (0)