Skip to content

Commit 0abad0c

Browse files
author
Victor Gonzalez
committed
[PWGCF] DptDpt - Filter and skimming framework fix MegaLinter issues
1 parent 6376e54 commit 0abad0c

18 files changed

Lines changed: 280 additions & 420 deletions

‎PWGCF/TwoParticleCorrelations/Core/EventSelectionFilterAndAnalysis.cxx‎

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,33 @@ EventSelectionConfigurable::EventSelectionConfigurable(const std::vector<std::st
4848
std::vector<std::string> trigsel,
4949
std::vector<std::string> zvtxsel,
5050
std::vector<std::string> pileuprej)
51-
: mBFiledSel(""),
52-
mMultSel(""),
53-
mTriggerSel(""),
54-
mZVertexSel(""),
55-
mPileUpRejection("")
51+
5652
{
5753
auto storeCutString = [](auto& selvector, const std::string& selname) {
5854
if (selvector.size() != 0) {
5955
if (selvector.size() == 1) {
6056
if (selvector[0].size() != 0) {
6157
return TString::Format("%s{%s}", selname.c_str(), selvector[0].c_str());
62-
} else {
63-
return TString("");
6458
}
65-
} else {
66-
TString scut = selname + "{cwv{";
67-
bool def = true;
68-
bool firstvar = true;
69-
for (const auto& cut : selvector) {
70-
if (def) {
71-
scut += cut + ':';
72-
def = false;
73-
} else {
74-
if (not firstvar) {
75-
scut += ',';
76-
}
77-
scut += cut;
78-
firstvar = false;
59+
return TString("");
60+
}
61+
TString scut = selname + "{cwv{";
62+
bool def = true;
63+
bool firstvar = true;
64+
for (const auto& cut : selvector) {
65+
if (def) {
66+
scut += cut + ':';
67+
def = false;
68+
} else {
69+
if (not firstvar) {
70+
scut += ',';
7971
}
72+
scut += cut;
73+
firstvar = false;
8074
}
81-
scut += "}}";
82-
return scut;
8375
}
76+
scut += "}}";
77+
return scut;
8478
}
8579
return TString("");
8680
};
@@ -113,9 +107,7 @@ const char* multiplicityCorrelators[nNoOfPileUpCorrelators] = {"V0M_TPCOUT", "V0
113107

114108
/// \brief Default constructor
115109
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis()
116-
: SelectionFilterAndAnalysis(),
117-
mBFieldSelection{},
118-
mMultiplicityClasses(nullptr),
110+
: mMultiplicityClasses(nullptr),
119111
mTriggerSelection(nullptr),
120112
mZVertex(nullptr),
121113
mPileUpRejection(nullptr)
@@ -125,7 +117,7 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis()
125117
/// \brief Constructor from regular expression
126118
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const TString& cutstr, Selmodes mode)
127119
: SelectionFilterAndAnalysis("", mode),
128-
mBFieldSelection{},
120+
129121
mMultiplicityClasses(nullptr),
130122
mTriggerSelection(nullptr),
131123
mZVertex(nullptr),
@@ -137,7 +129,7 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const TString&
137129
/// \brief Constructor from the event selection configurable
138130
EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSelectionConfigurable& evtsel, Selmodes mode)
139131
: SelectionFilterAndAnalysis("", mode),
140-
mBFieldSelection{},
132+
141133
mMultiplicityClasses(nullptr),
142134
mTriggerSelection(nullptr),
143135
mZVertex(nullptr),
@@ -148,7 +140,7 @@ EventSelectionFilterAndAnalysis::EventSelectionFilterAndAnalysis(const EventSele
148140
constexpr int MaskMaxLength = 64;
149141

150142
auto appendCut = [&cutString, &first](const std::string& str) {
151-
if (str.size() > 0) {
143+
if (!str.empty()) {
152144
if (first) {
153145
cutString += str;
154146
first = false;
@@ -246,7 +238,7 @@ void EventSelectionFilterAndAnalysis::MultiplicityBrick::initialize()
246238
}
247239
}
248240
}
249-
if (mAlternateEstimatorIndex.size() != (uint)(varlst.GetEntries())) {
241+
if (mAlternateEstimatorIndex.size() != static_cast<uint>(varlst.GetEntries())) {
250242
LOGF(fatal, "EventSelectionFilterAndAnalysis::InitializeMultiplicityFilter() variant multiplicity class estimators not all implemented");
251243
}
252244
}
@@ -303,7 +295,7 @@ void EventSelectionFilterAndAnalysis::PileUpRejBrick::initialize()
303295
}
304296
}
305297
}
306-
if (mAlternateEstimatorIndex.size() != (uint)(varlst.GetEntries())) {
298+
if (mAlternateEstimatorIndex.size() != static_cast<uint>(varlst.GetEntries())) {
307299
LOGF(fatal, "EventSelectionFilterAndAnalysis::InitializeMultiplicityFilter() variant pile-up correlator estimators not all implemented");
308300
}
309301
}
@@ -348,15 +340,13 @@ void EventSelectionFilterAndAnalysis::constructCutFromString(const TString& cuts
348340
}
349341
LOGF(info, "Captured %s", m[1].str().c_str());
350342
auto storeIntCut = [&m, &allowed](CutBrick<int>*& brickvar) {
351-
if (brickvar != nullptr) {
352-
delete brickvar;
353-
}
343+
delete brickvar;
344+
354345
brickvar = CutBrick<int>::constructBrick(m[1].str().c_str(), m[2].str().c_str(), allowed);
355346
};
356347
auto storeFloatCut = [&m, &allowed](CutBrick<float>*& brickvar) {
357-
if (brickvar != nullptr) {
358-
delete brickvar;
359-
}
348+
delete brickvar;
349+
360350
brickvar = CutBrick<float>::constructBrick(m[1].str().c_str(), m[2].str().c_str(), allowed);
361351
};
362352
/* b-field requires speciat treatment */
@@ -423,7 +413,7 @@ void EventSelectionFilterAndAnalysis::ComplexBrickHelper::armedBrick(uint64_t& a
423413
}
424414
};
425415

426-
if (mAlternateEstimatorIndex.size() > 0) {
416+
if (!mAlternateEstimatorIndex.empty()) {
427417
/* we have alternative estimators so our brick is of kind cwv */
428418
if (mBrick->IsA() != CutWithVariations<float>::Class()) {
429419
LOGF(fatal, "EventSelectionFilterAndAnalysis::filter() expected class with variations cut but it is not there");
@@ -433,11 +423,11 @@ void EventSelectionFilterAndAnalysis::ComplexBrickHelper::armedBrick(uint64_t& a
433423
if (deflst.GetEntries() > 1) {
434424
LOGF(fatal, "EventSelectionFilterAndAnalysis::filter() expected only one default multiplicity class estimator");
435425
}
436-
armedBrick((CutBrick<float>*)deflst.At(0), true);
426+
armedBrick(dynamic_cast<CutBrick<float>*>(deflst.At(0)), true);
437427
/* and now the variants */
438428
TList& varlst = dynamic_cast<CutWithVariations<float>*>(mBrick)->getVariantBricks();
439429
for (int i = 0; i < varlst.GetEntries(); ++i) {
440-
armedBrick((CutBrick<float>*)varlst.At(i), true);
430+
armedBrick(dynamic_cast<CutBrick<float>*>(varlst.At(i)), true);
441431
}
442432
} else {
443433
/* no alternative estimators, just the default */

‎PWGCF/TwoParticleCorrelations/Core/EventSelectionFilterAndAnalysis.h‎

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
#include <utility>
3333
#include <vector>
3434

35-
namespace o2
36-
{
37-
namespace analysis
38-
{
39-
namespace pwgcf
35+
namespace o2::analysis::pwgcf
4036
{
4137
/* forward declaration */
4238
class EventSelectionFilterAndAnalysis;
@@ -62,13 +58,12 @@ class EventSelectionConfigurable
6258
std::vector<std::string> pileuprej);
6359

6460
private:
65-
std::string mBFiledSel = ""; //! the magnetic field selection cuts
66-
std::string mMultSel = ""; //! the multiplicity selection cuts
67-
std::string mTriggerSel = ""; //! the trigger selection cuts
68-
std::string mZVertexSel = ""; //! the z vertex selection cuts
69-
std::string mPileUpRejection = ""; //! the pile-up rejection criteria
61+
std::string mBFiledSel; //! the magnetic field selection cuts
62+
std::string mMultSel; //! the multiplicity selection cuts
63+
std::string mTriggerSel; //! the trigger selection cuts
64+
std::string mZVertexSel; //! the z vertex selection cuts
65+
std::string mPileUpRejection; //! the pile-up rejection criteria
7066

71-
private:
7267
ClassDefNV(EventSelectionConfigurable, 1);
7368
};
7469

@@ -91,8 +86,8 @@ class EventSelectionFilterAndAnalysis : public SelectionFilterAndAnalysis
9186
virtual ~ComplexBrickHelper() = default;
9287
CutBrick<float>* mBrick = nullptr;
9388
int mDefaultEstimatorIndex = -1;
94-
std::vector<int> mAlternateEstimatorIndex = std::vector<int>{};
95-
std::vector<float> mValues = std::vector<float>{};
89+
std::vector<int> mAlternateEstimatorIndex;
90+
std::vector<float> mValues;
9691
int length() { return mBrick->length(); }
9792
virtual void initialize() = 0;
9893
virtual bool filter(uint64_t& mask, int& bit, CutBrick<float>* brick, int index) = 0;
@@ -107,16 +102,16 @@ class EventSelectionFilterAndAnalysis : public SelectionFilterAndAnalysis
107102
};
108103
struct PileUpRejBrick : public ComplexBrickHelper {
109104
void initialize() override;
110-
std::vector<float> mIndepVar = std::vector<float>{};
105+
std::vector<float> mIndepVar;
111106
bool filter(uint64_t& mask, int& bit, CutBrick<float>* brick, int index) override;
112107
};
113108

114109
static bool filterBrickValue(uint64_t& mask, int& bit, CutBrick<float>* brick, float value);
115110
void constructCutFromString(const TString&);
116111
template <typename CollisionToFilter, typename AssociatedTracks>
117112
void storeMultiplicities(CollisionToFilter const&, AssociatedTracks const&);
118-
int calculateMaskLength() override;
119-
void storeArmedMask() override;
113+
int calculateMaskLength() final;
114+
void storeArmedMask() final;
120115

121116
std::vector<CutBrick<float>*> mBFieldSelection; //! the magnetic field selection cuts
122117
MultiplicityBrick* mMultiplicityClasses; //! the multiplicity classes cuts
@@ -180,19 +175,19 @@ inline bool EventSelectionFilterAndAnalysis::filterBrickValue(uint64_t& mask, in
180175
inline bool EventSelectionFilterAndAnalysis::ComplexBrickHelper::filter(uint64_t& mask, int& bit)
181176
{
182177
bool acceptcollision = true;
183-
if (mAlternateEstimatorIndex.size() > 0) {
178+
if (!mAlternateEstimatorIndex.empty()) {
184179
bool atleastonealternative = false;
185180
/* if (mBrick->IsA() != CutWithVariations<float>::Class()) {
186181
LOGF(fatal, "EventSelectionFilterAndAnalysis::filter() expected class with variations cut but it is not there");
187182
} */
188183
/* first the default */
189184
TList& deflst = dynamic_cast<CutWithVariations<float>*>(mBrick)->getDefaultBricks();
190-
bool acc = filter(mask, bit, (CutBrick<float>*)deflst.At(0), mDefaultEstimatorIndex);
185+
bool acc = filter(mask, bit, dynamic_cast<CutBrick<float>*>(deflst.At(0)), mDefaultEstimatorIndex);
191186
atleastonealternative = atleastonealternative || acc;
192187
/* and now the variants */
193188
TList& varlst = dynamic_cast<CutWithVariations<float>*>(mBrick)->getVariantBricks();
194189
for (int i = 0; i < varlst.GetEntries(); ++i) {
195-
bool acc = filter(mask, bit, (CutBrick<float>*)varlst.At(i), mAlternateEstimatorIndex[i]);
190+
bool acc = filter(mask, bit, dynamic_cast<CutBrick<float>*>(varlst.At(i)), mAlternateEstimatorIndex[i]);
196191
atleastonealternative = atleastonealternative || acc;
197192
}
198193
acceptcollision = acceptcollision && atleastonealternative;
@@ -226,7 +221,7 @@ inline uint64_t EventSelectionFilterAndAnalysis::filter(CollisionToFilter const&
226221

227222
/* we require the collision be accepted by the whole set of filters */
228223
bool acceptcollision = true;
229-
if (mBFieldSelection.size() > 0) {
224+
if (!mBFieldSelection.empty()) {
230225
bool oneatleast = false;
231226
for (const auto& brick : mBFieldSelection) {
232227
bool acc = filterBrickValue(selectedMask, bit, brick, bfield);
@@ -258,7 +253,7 @@ inline std::vector<float> EventSelectionFilterAndAnalysis::MultiplicityBrick::ge
258253
{
259254
std::vector<float> res;
260255

261-
if (mAlternateEstimatorIndex.size() > 0) {
256+
if (!mAlternateEstimatorIndex.empty()) {
262257
/* first the default */
263258
res.push_back(mValues[mDefaultEstimatorIndex]);
264259
/* and now the variants */
@@ -273,8 +268,6 @@ inline std::vector<float> EventSelectionFilterAndAnalysis::MultiplicityBrick::ge
273268
return res;
274269
}
275270

276-
} // namespace pwgcf
277-
} // namespace analysis
278-
} // namespace o2
271+
} // namespace o2::analysis::pwgcf
279272

280273
#endif // PWGCF_TWOPARTICLECORRELATIONS_CORE_EVENTSELECTIONFILTERANDANALYSIS_H_

‎PWGCF/TwoParticleCorrelations/Core/FilterAndAnalysisFramework.cxx‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <Framework/Logger.h>
2727

2828
#include <TList.h>
29-
#include <TNamed.h>
3029
#include <TObjString.h>
3130

3231
#include <Rtypes.h>
@@ -45,19 +44,8 @@ ClassImp(FilterAndAnalysisFramework);
4544

4645
/// \brief Default constructor
4746
FilterAndAnalysisFramework::FilterAndAnalysisFramework()
48-
: TNamed(),
49-
ccdburl(""),
50-
ccdbpath(""),
51-
filterdate(""),
52-
forceupdate(false),
53-
fTrackFilter(nullptr),
54-
fEventFilter(nullptr),
55-
fPIDFilter(nullptr),
56-
tmpTrackFilter(nullptr),
57-
tmpEventFilter(nullptr),
58-
tmpPIDFilter(nullptr)
59-
{
60-
}
47+
48+
= default;
6149

6250
/// \brief Named constructor for a concrete operating mode
6351
void FilterAndAnalysisFramework::setConfiguration(EventSelectionConfigurable& evtf, TrackSelectionConfigurable& trkf, PIDSelectionConfigurable& pidf, SelectionFilterAndAnalysis::Selmodes mode)
@@ -96,15 +84,15 @@ void FilterAndAnalysisFramework::registerConfiguration()
9684
uint64_t eot = timestamp + (12 * 60 * 60 * 1000 - 1000); /* one second before the end of the day */
9785

9886
/* get access to the CCDB */
99-
o2::ccdb::CcdbApi* ccdb = new o2::ccdb::CcdbApi();
87+
auto* ccdb = new o2::ccdb::CcdbApi();
10088
ccdb->init(ccdburl);
10189
o2::ccdb::BasicCCDBManager* ccdbm = &o2::ccdb::BasicCCDBManager::instance();
10290
ccdbm->setFatalWhenNull(false); /* we need to check the availability of objects */
10391
ccdbm->setURL(ccdburl);
10492
signatures = ccdbm->getForTimeStamp<TList>(ccdbpath, timestamp);
10593

10694
auto storesignatures = [&]() {
107-
TList* siglst = new TList();
95+
auto* siglst = new TList();
10896
siglst->SetOwner();
10997
siglst->SetName("Skimming signatures");
11098
siglst->Add(new TObjString(tmpEventFilter->getCutStringSignature().Data()));

‎PWGCF/TwoParticleCorrelations/Core/FilterAndAnalysisFramework.h‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030
#include <string>
3131
#include <vector>
3232

33-
namespace o2
34-
{
35-
namespace analysis
36-
{
37-
namespace pwgcf
33+
namespace o2::analysis::pwgcf
3834
{
3935

4036
/// \brief Base class for filter and selection once filetered
@@ -68,9 +64,9 @@ class FilterAndAnalysisFramework : public TNamed
6864
std::vector<uint64_t>& getTrackOptMask() { return fTrackFilter->getOptMask(); }
6965
std::vector<uint64_t>& getPIDOptMask() { return fPIDFilter->getOptMask(); }
7066
/// \brief provides the optional part mask of the different objects in a printable shape
71-
TString printCollisionOptionalMasks() const { return fEventFilter->printOptionalMasks(); }
72-
TString printTrackOptionalMasks() const { return fTrackFilter->printOptionalMasks(); }
73-
TString printPIDOptionalMasks() const { return fPIDFilter->printOptionalMasks(); }
67+
[[nodiscard]] TString printCollisionOptionalMasks() const { return fEventFilter->printOptionalMasks(); }
68+
[[nodiscard]] TString printTrackOptionalMasks() const { return fTrackFilter->printOptionalMasks(); }
69+
[[nodiscard]] TString printPIDOptionalMasks() const { return fPIDFilter->printOptionalMasks(); }
7470
/// \brief get the valid (armed) mandatory part mask associated to the configuration of the different objects
7571
/// \return the corresponding armed forced mask
7672
/// A clear example of the mandatory part mask is the mask of the zvertex and their
@@ -105,9 +101,9 @@ class FilterAndAnalysisFramework : public TNamed
105101
const TString& getPIDFilterCutStringSignature() { return fPIDFilter->getCutStringSignature(); }
106102

107103
private:
108-
std::string ccdburl = "";
109-
std::string ccdbpath = "";
110-
std::string filterdate = "";
104+
std::string ccdburl;
105+
std::string ccdbpath;
106+
std::string filterdate;
111107
bool forceupdate = false;
112108
pwgcf::TrackSelectionFilterAndAnalysis* fTrackFilter = nullptr; /// the track filter
113109
pwgcf::EventSelectionFilterAndAnalysis* fEventFilter = nullptr; /// the event filter
@@ -121,8 +117,6 @@ class FilterAndAnalysisFramework : public TNamed
121117

122118
extern void registerConfiguration(o2::analysis::pwgcf::FilterAndAnalysisFramework*);
123119

124-
} // namespace pwgcf
125-
} // namespace analysis
126-
} // namespace o2
120+
} // namespace o2::analysis::pwgcf
127121

128122
#endif // PWGCF_TWOPARTICLECORRELATIONS_CORE_FILTERANDANALYSISFRAMEWORK_H_

0 commit comments

Comments
 (0)