Skip to content

Commit 6376e54

Browse files
author
Victor Gonzalez
committed
[PWGCF] DptDpt - Filter and skimming framework fix linter issues
1 parent 4091c09 commit 6376e54

20 files changed

Lines changed: 1088 additions & 969 deletions

‎PWGCF/TwoParticleCorrelations/Core/EventSelectionFilterAndAnalysis.cxx‎

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
/// \file EventSelectionFilterAndAnalysis.cxx
13+
/// \brief Implementation of the EventSelectionFilterAndAnalysis class for
14+
/// filtering collisions for derived data production
15+
/// \author victor.gonzalez.sebastian@gmail.com
16+
1217
#include "EventSelectionFilterAndAnalysis.h"
1318

1419
#include "PWGCF/TwoParticleCorrelations/Core/SelectionFilterAndAnalysis.h"
@@ -35,7 +40,7 @@
3540
#include <vector>
3641

3742
using namespace o2;
38-
using namespace o2::analysis::PWGCF;
43+
using namespace o2::analysis::pwgcf;
3944
using namespace boost;
4045

4146
EventSelectionConfigurable::EventSelectionConfigurable(const std::vector<std::string>& bfieldsel,
@@ -83,7 +88,7 @@ EventSelectionConfigurable::EventSelectionConfigurable(const std::vector<std::st
8388
{
8489
TString bfield = "bfield{";
8590
bool first = true;
86-
for (auto& pol : bfieldsel) {
91+
for (const auto& pol : bfieldsel) {
8792
if (not first) {
8893
bfield += ',';
8994
}
@@ -118,19 +123,19 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis()
118123
}
119124

120125
/// \brief Constructor from regular expression
121-
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const TString& cutstr, selmodes mode)
126+
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const TString& cutstr, Selmodes mode)
122127
: SelectionFilterAndAnalysis("", mode),
123128
mBFieldSelection{},
124129
mMultiplicityClasses(nullptr),
125130
mTriggerSelection(nullptr),
126131
mZVertex(nullptr),
127132
mPileUpRejection(nullptr)
128133
{
129-
ConstructCutFromString(cutstr);
134+
constructCutFromString(cutstr);
130135
}
131136

132137
/// \brief Constructor from the event selection configurable
133-
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSelectionConfigurable& evtsel, selmodes mode)
138+
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSelectionConfigurable& evtsel, Selmodes mode)
134139
: SelectionFilterAndAnalysis("", mode),
135140
mBFieldSelection{},
136141
mMultiplicityClasses(nullptr),
@@ -140,6 +145,7 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSele
140145
{
141146
TString cutString = "eventsel{";
142147
bool first = true;
148+
constexpr int MaskMaxLength = 64;
143149

144150
auto appendCut = [&cutString, &first](const std::string& str) {
145151
if (str.size() > 0) {
@@ -158,29 +164,29 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSele
158164
appendCut(evtsel.mPileUpRejection);
159165

160166
cutString += "}";
161-
ConstructCutFromString(cutString);
162-
if (mMaskLength > 64) {
163-
LOGF(fatal, "EventSelectionFilterAndAnalysis not ready for filter mask of %d bits. Just 64 available for the time being", mMaskLength);
167+
constructCutFromString(cutString);
168+
if (mMaskLength > MaskMaxLength) {
169+
LOGF(fatal, "EventSelectionFilterAndAnalysis not ready for filter mask of %d bits. Just %d available for the time being", mMaskLength, MaskMaxLength);
164170
}
165171
mCutStringSignature = cutString.ReplaceAll("-yes", "").ReplaceAll("-no", "");
166-
if (mode == kAnalysis) {
167-
StoreArmedMask();
172+
if (mode == KAnalysis) {
173+
storeArmedMask();
168174
}
169175
}
170176

171177
/// \brief Calculates the length of the mask needed to store the selection cuts
172-
int EventSelectionFilterAndAnalysis::CalculateMaskLength()
178+
int EventSelectionFilterAndAnalysis::calculateMaskLength()
173179
{
174180
int length = 0;
175181
auto addLength = [&length](auto& brick) {
176182
if (brick != nullptr) {
177-
length += brick->Length();
178-
LOGF(info, "EventSelectionFilterAndAnalysis::CalculateMaskLength, cumulated length: %d", length);
183+
length += brick->length();
184+
LOGF(info, "EventSelectionFilterAndAnalysis::calculateMaskLength, cumulated length: %d", length);
179185
}
180186
};
181187

182-
for (auto brick : mBFieldSelection) {
183-
length += brick->Length();
188+
for (const auto& brick : mBFieldSelection) {
189+
length += brick->length();
184190
}
185191
addLength(mMultiplicityClasses);
186192
addLength(mTriggerSelection);
@@ -303,7 +309,7 @@ void EventSelectionFilterAndAnalysis::PileUpRejBrick::initialize()
303309
}
304310
}
305311

306-
void EventSelectionFilterAndAnalysis::ConstructCutFromString(const TString& cutstr)
312+
void EventSelectionFilterAndAnalysis::constructCutFromString(const TString& cutstr)
307313
{
308314
LOGF(info, "Cut string: %s", cutstr.Data());
309315
/* let's catch the first level */
@@ -312,8 +318,9 @@ void EventSelectionFilterAndAnalysis::ConstructCutFromString(const TString& cuts
312318
smatch m;
313319

314320
bool res = regex_search(in, m, cutregex);
315-
if (not res or m.empty() or (m.size() > 2)) {
316-
LOGF(fatal, "EventSelectionFilterAndAnalysis::ConstructCutFromString", "Wrong RE: %s, try eventsel{bfield{positive-yes,negative-yes},zvtx{cwv{rg{-7.0,7.0}-yes:rg{-10.0,10.0}-no,rg{-3.0,3.0}-no}}} for instance", cutstr.Data());
321+
constexpr int ExpectedMaxLength = 2;
322+
if (not res || m.empty() || (m.size() > ExpectedMaxLength)) {
323+
LOGF(fatal, "EventSelectionFilterAndAnalysis::constructCutFromString", "Wrong RE: %s, try eventsel{bfield{positive-yes,negative-yes},zvtx{cwv{rg{-7.0,7.0}-yes:rg{-10.0,10.0}-no,rg{-3.0,3.0}-no}}} for instance", cutstr.Data());
317324
}
318325
this->SetName("EventSelectionFilterAndAnalysisCuts");
319326
this->SetTitle(cutstr.Data());
@@ -334,9 +341,10 @@ void EventSelectionFilterAndAnalysis::ConstructCutFromString(const TString& cuts
334341
std::string in(lev2str.Data());
335342
smatch m;
336343
bool res = regex_search(in, m, cutregex);
344+
constexpr int ExpectedComponents = 3;
337345

338-
if (not res or m.empty() or (m.size() != 3)) {
339-
Fatal("EventSelectionFilterAndAnalysis::::ConstructCutFromString", "Wrong RE: %s, try tracksel{ttype{FB32,FB96};nclstpc{th{70}},nxr{cwv{th{70},th{80}}}} for instance", cutstr.Data());
346+
if (not res or m.empty() or (m.size() != ExpectedComponents)) {
347+
Fatal("EventSelectionFilterAndAnalysis::::constructCutFromString", "Wrong RE: %s, try tracksel{ttype{FB32,FB96};nclstpc{th{70}},nxr{cwv{th{70},th{80}}}} for instance", cutstr.Data());
340348
}
341349
LOGF(info, "Captured %s", m[1].str().c_str());
342350
auto storeIntCut = [&m, &allowed](CutBrick<int>*& brickvar) {
@@ -358,7 +366,7 @@ void EventSelectionFilterAndAnalysis::ConstructCutFromString(const TString& cuts
358366
auto addBFieldBrick = [&brickvector](auto name, auto regex, bool arm) {
359367
std::set<std::string> allowed = {"lim", "th"};
360368
CutBrick<float>* brick = CutBrick<float>::constructBrick(name, regex, allowed);
361-
brick->Arm(arm);
369+
brick->arm(arm);
362370
brickvector.push_back(brick);
363371
};
364372
if (TString(regex).Contains("positive")) {
@@ -394,15 +402,15 @@ void EventSelectionFilterAndAnalysis::ConstructCutFromString(const TString& cuts
394402
lev2str.Remove(0, m[0].length());
395403
}
396404
}
397-
mMaskLength = CalculateMaskLength();
405+
mMaskLength = calculateMaskLength();
398406
}
399407

400408
///
401409
void EventSelectionFilterAndAnalysis::ComplexBrickHelper::armedBrick(uint64_t& armedmask, uint64_t& optmask, uint64_t& forcedmask, int& bit)
402410
{
403411
auto armedBrick = [&](auto brick, bool opt = false) {
404-
std::vector<bool> res = brick->IsArmed();
405-
for (auto b : res) {
412+
std::vector<bool> res = brick->isArmed();
413+
for (const auto& b : res) {
406414
if (b) {
407415
SETBIT(armedmask, bit);
408416
if (opt) {
@@ -418,12 +426,12 @@ void EventSelectionFilterAndAnalysis::ComplexBrickHelper::armedBrick(uint64_t& a
418426
if (mAlternateEstimatorIndex.size() > 0) {
419427
/* we have alternative estimators so our brick is of kind cwv */
420428
if (mBrick->IsA() != CutWithVariations<float>::Class()) {
421-
LOGF(fatal, "EventSelectionFilterAndAnalysis::Filter() expected class with variations cut but it is not there");
429+
LOGF(fatal, "EventSelectionFilterAndAnalysis::filter() expected class with variations cut but it is not there");
422430
}
423431
/* first the default */
424432
TList& deflst = dynamic_cast<CutWithVariations<float>*>(mBrick)->getDefaultBricks();
425433
if (deflst.GetEntries() > 1) {
426-
LOGF(fatal, "EventSelectionFilterAndAnalysis::Filter() expected only one default multiplicity class estimator");
434+
LOGF(fatal, "EventSelectionFilterAndAnalysis::filter() expected only one default multiplicity class estimator");
427435
}
428436
armedBrick((CutBrick<float>*)deflst.At(0), true);
429437
/* and now the variants */
@@ -438,7 +446,7 @@ void EventSelectionFilterAndAnalysis::ComplexBrickHelper::armedBrick(uint64_t& a
438446
}
439447

440448
/// \brief Fills the filter cuts mask
441-
void EventSelectionFilterAndAnalysis::StoreArmedMask()
449+
void EventSelectionFilterAndAnalysis::storeArmedMask()
442450
{
443451
uint64_t armedMask = 0UL;
444452
uint64_t optMask = 0UL;
@@ -449,8 +457,8 @@ void EventSelectionFilterAndAnalysis::StoreArmedMask()
449457
int bit = 0;
450458

451459
auto armedBrick = [&](auto brick, bool opt = false) {
452-
std::vector<bool> res = brick->IsArmed();
453-
for (auto b : res) {
460+
std::vector<bool> res = brick->isArmed();
461+
for (const auto& b : res) {
454462
if (b) {
455463
SETBIT(armedMask, bit);
456464
if (opt) {
@@ -464,7 +472,7 @@ void EventSelectionFilterAndAnalysis::StoreArmedMask()
464472
};
465473

466474
optMask = 0UL;
467-
for (auto brick : mBFieldSelection) {
475+
for (const auto& brick : mBFieldSelection) {
468476
armedBrick(brick, true);
469477
}
470478
mOptArmedMask.push_back(optMask);
@@ -480,7 +488,7 @@ void EventSelectionFilterAndAnalysis::StoreArmedMask()
480488
if (mPileUpRejection != nullptr) {
481489
mPileUpRejection->armedBrick(armedMask, optMask, forcedMask, bit);
482490
}
483-
LOGF(info, "EventSelectionFilterAndAnalysis::StoreArmedMask(), masks 0x%016lx, %s, 0x%016lx", armedMask, printOptionalMasks().Data(), forcedMask);
491+
LOGF(info, "EventSelectionFilterAndAnalysis::storeArmedMask(), masks 0x%016lx, %s, 0x%016lx", armedMask, printOptionalMasks().Data(), forcedMask);
484492
mArmedMask = armedMask;
485493
mForcedArmedMask = forcedMask;
486494
}

0 commit comments

Comments
 (0)