Skip to content

Commit be3408b

Browse files
committed
Fix: fix linter warnings
1 parent f7ef77d commit be3408b

25 files changed

Lines changed: 224 additions & 643 deletions

PWGCF/FemtoUnited/Core/baseSelection.h

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2022 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//
@@ -10,7 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
/// \file baseSelection.h
13-
/// \brief Definition of the BaseSelection class
13+
/// \brief Defines the BaseSelection class for managing and evaluating multiple selections over multiple observables.
1414
/// \author Anton Riedel, TU München, anton.riedel@tum.de
1515

1616
#ifndef PWGCF_FEMTOUNITED_CORE_BASESELECTION_H_
@@ -23,29 +23,37 @@
2323
#include <algorithm>
2424
#include <iomanip>
2525
#include <string>
26+
#include <unordered_map>
2627
#include <vector>
2728

2829
namespace o2::analysis::femtounited
2930
{
31+
3032
/// \class BaseSelection
31-
/// \brief Base class to contain all cuts and assemble bitmask
32-
/// \tparam T Data type used for the selections (float/int/...)
33-
/// \tparam BitmaskType Compute size of the bitmask from BitmaskType
34-
/// \tparam NObservables Number of observables
33+
/// \brief Template class for managing selection criteria across multiple observables.
34+
///
35+
/// This class manages an array of SelectionContainer objects, each corresponding to a specific observable.
36+
/// It evaluates which selections are fulfilled, assembles a final bitmask, and tracks required vs. optional cuts.
37+
///
38+
/// \tparam T Type of observable values (mostly floats).
39+
/// \tparam BitmaskType Type used for internal bitmask operations (e.g., uint32_t, uint64_t).
40+
/// \tparam NumObservables Total number of observables handled.
3541
template <typename T, typename BitmaskType, size_t NumObservables>
3642
class BaseSelection
3743
{
3844
public:
39-
/// Constructor
45+
/// \brief Default constructor.
4046
BaseSelection() {}
4147

42-
/// Destructor
48+
/// \brief Destructor
4349
virtual ~BaseSelection() = default;
4450

45-
/// Pass the Configurable of selection values in the analysis task to the selection class
46-
/// \param configSelections Vector of configurables containing the values employed for the selection
47-
/// \param Observable Observable to be employed for the selection
48-
/// \param limitType Type of the selection limit
51+
/// \brief Add a static-value based selection for a specific observable.
52+
/// \param selectionValues Vector of threshold values.
53+
/// \param observableIndex Index of the observable.
54+
/// \param limitType Type of limit (from limits::LimitType).
55+
/// \param skipMostPermissiveBit Whether to skip the loosest threshold in the bitmask.
56+
/// \param isMinimalCut Whether this cut is mandatory or optional.
4957
void addSelection(std::vector<T> const& selectionValues, int observableIndex, limits::LimitType limitType, bool skipMostPermissiveBit, bool isMinimalCut)
5058
{
5159
if (static_cast<size_t>(observableIndex) >= NumObservables) {
@@ -57,15 +65,20 @@ class BaseSelection
5765
}
5866
// check if any cut is optional
5967
if (!isMinimalCut) {
60-
mHasOptionalCuts = true;
68+
mHasOptionalSelection = true;
6169
}
6270
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(selectionValues, limitType, skipMostPermissiveBit, isMinimalCut);
6371
}
6472

65-
/// Pass the Configurable of selection values in the analysis task to the selection class
66-
/// \param configSelection Vector from configurable containing the values employed for the selection
67-
/// \param observableType Observable to be employed for the selection
68-
/// \param limitType Type of the selection limit
73+
/// \brief Add a function-based selection for a specific observable.
74+
/// \param baseName Base name for TF1 functions.
75+
/// \param lowerLimit Lower bound for the TF1 domain.
76+
/// \param upperLimit Upper bound for the TF1 domain.
77+
/// \param selectionValues Function definitions as strings.
78+
/// \param observableIndex Index of the observable.
79+
/// \param limitType Type of limit.
80+
/// \param skipMostPermissiveBit Whether to skip the loosest threshold in the bitmask.
81+
/// \param isMinimalCut Whether this cut is mandatory or optional.
6982
void addSelection(std::string const& baseName, T lowerLimit, T upperLimit, std::vector<std::string> const& selectionValues, int observableIndex, limits::LimitType limitType, bool skipMostPermissiveBit, bool isMinimalCut)
7083
{
7184
if (static_cast<size_t>(observableIndex) >= NumObservables) {
@@ -78,20 +91,24 @@ class BaseSelection
7891
mSelectionContainers.at(observableIndex) = SelectionContainer<T, BitmaskType>(baseName, lowerLimit, upperLimit, selectionValues, limitType, skipMostPermissiveBit, isMinimalCut);
7992
}
8093

94+
/// \brief Update the limits of a function-based selection for a specific observable.
95+
/// \param observable Index of the observable.
96+
/// \param value Value at which to evaluate the selection functions.
8197
void updateLimits(int observable, T value) { mSelectionContainers.at(observable).updateLimits(value); }
8298

99+
/// \brief Reset the internal bitmask and evaluation flags before evaluating a new event.
83100
void reset()
84101
{
85102
mFinalBitmask.reset();
86-
mPassesMinimalCuts = true;
103+
mPassesMinimalSelections = true;
87104
// will be true if no optional cut as been defined and
88105
// will be set to false if we have optional cuts (but will be set to true in the case at least one optional cut succeeds)
89-
mPassesOptionalCuts = !mHasOptionalCuts;
106+
mPassesOptionalSelections = !mHasOptionalSelection;
90107
}
91108

92-
/// set bitmask for a given observable
93-
/// \param observable Observable to be checked
94-
/// \param value Value of the observable
109+
/// \brief Evaluate a single observable against its configured selections.
110+
/// \param observableIndex Index of the observable.
111+
/// \param value Value of the observable.
95112
void evaluateObservable(int observableIndex, T value)
96113
{
97114
// if there are no selections configured, bail out
@@ -100,37 +117,41 @@ class BaseSelection
100117
}
101118
// if any previous observable did not pass minimal selections, there is no point in setting bitmask for other observables
102119
// minimal selection for each observable is computed after adding it
103-
if (mPassesMinimalCuts == false) {
120+
if (mPassesMinimalSelections == false) {
104121
return;
105122
}
106123
// set bitmask for given observable
107124
mSelectionContainers.at(observableIndex).evaluate(value);
108125
// check if minimal selction for this observable holds
109126
if (mSelectionContainers.at(observableIndex).passesAsMinimalCut() == false) {
110-
mPassesMinimalCuts = false;
127+
mPassesMinimalSelections = false;
111128
}
112129
// check if any optional selection holds
113130
if (mSelectionContainers.at(observableIndex).passesAsOptionalCut() == true) {
114-
mPassesOptionalCuts = true;
131+
mPassesOptionalSelections = true;
115132
}
116133
}
117134

118-
/// check if minimal Selections are passed
135+
/// \brief Check if all required (minimal) and optional cuts are passed.
136+
/// \return True if all required and at least one optional cut (if present) is passed.
119137
bool passesAllRequiredSelections() const
120138
{
121-
return mPassesMinimalCuts && mPassesOptionalCuts;
139+
return mPassesMinimalSelections && mPassesOptionalSelections;
122140
}
123141

124-
bool passesOptionalCut(int observableIndex) const
142+
/// \brief Check if the optional selection for a specific observable is passed.
143+
/// \param observableIndex Index of the observable.
144+
/// \return True if at least one optional selection is fulfilled.
145+
bool passesOptionalSelection(int observableIndex) const
125146
{
126147
return mSelectionContainers.at(observableIndex).passesAsOptionalCut();
127148
}
128149

129-
/// assemble final bitmask
150+
/// \brief Assemble the global selection bitmask from individual observable selections.
130151
void assembleBitmask()
131152
{
132153
// if minimal selections are not passed, just set bitmask to 0
133-
if (mPassesMinimalCuts == false) {
154+
if (mPassesMinimalSelections == false) {
134155
mFinalBitmask.reset();
135156
return;
136157
}
@@ -147,11 +168,15 @@ class BaseSelection
147168
}
148169
}
149170

171+
/// \brief Retrieve the assembled bitmask as an integer value.
172+
/// \return The combined selection bitmask.
150173
BitmaskType getBitmask() const { return static_cast<BitmaskType>(mFinalBitmask.to_ullong()); }
151174

152-
#include <iomanip> // for setw, left
153-
#include <sstream>
154-
175+
/// \brief Print detailed information about all configured selections.
176+
///
177+
/// \tparam MapType Type used in the observable name map (usually an enum or int).
178+
/// \param objectName Name of the current object (e.g. particle species).
179+
/// \param observableNames Map from observable index to human-readable names.
155180
template <typename MapType>
156181
void printSelections(const std::string& objectName, const std::unordered_map<MapType, std::string>& observableNames) const
157182
{
@@ -179,9 +204,9 @@ class BaseSelection
179204
const auto& values = container.getSelectionValues();
180205
bool skipMostPermissive = container.skipMostPermissiveBit();
181206

182-
constexpr int valWidth = 15;
183-
constexpr int bitWidth = 20;
184-
constexpr int maskWidth = 12;
207+
int valWidth = 15;
208+
int bitWidth = 20;
209+
int maskWidth = 12;
185210

186211
for (size_t j = 0; j < values.size(); ++j) {
187212
std::stringstream line;
@@ -214,9 +239,9 @@ class BaseSelection
214239
std::array<SelectionContainer<T, BitmaskType>, NumObservables> mSelectionContainers = {}; ///< Array containing all selections
215240
std::bitset<sizeof(BitmaskType) * CHAR_BIT> mFinalBitmask = {}; ///< final bitmaks
216241
size_t mNSelections = 0; ///< Number of selections
217-
bool mPassesMinimalCuts = true; ///< Set to true if all minimal (mandatory) cuts are passed
218-
bool mHasOptionalCuts = false; ///< Set to true if at least one cut is optional
219-
bool mPassesOptionalCuts = true; ///< Set to true if at least one optional (non-mandatory) cut is passed
242+
bool mPassesMinimalSelections = true; ///< Set to true if all minimal (mandatory) selections are passed
243+
bool mHasOptionalSelection = false; ///< Set to true if at least one selections is optional
244+
bool mPassesOptionalSelections = true; ///< Set to true if at least one optional (non-mandatory) selections is passed
220245
};
221246
} // namespace o2::analysis::femtounited
222247

PWGCF/FemtoUnited/Core/cascadeSelection.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <algorithm>
2626
#include <cmath>
2727
#include <string>
28+
#include <unordered_map>
2829

2930
namespace o2::analysis::femtounited
3031
{
@@ -131,9 +132,9 @@ enum CascadeSels {
131132
kCascadeSelsMax
132133
};
133134

134-
const std::string omegaSelsName = std::string("Omega Selection Object");
135-
const std::string xiSelsName = std::string("Xi Selection Object");
136-
const std::unordered_map<CascadeSels, std::string> CascadeSelsNames = {
135+
const char omegaSelsName[] = "Omega Selection Object";
136+
const char xiSelsName[] = "Xi Selection Object";
137+
const std::unordered_map<CascadeSels, std::string> cascadeSelsNames = {
137138
{kCascadeCpaMin, "Cascade CPA Min"},
138139
{kCascadeDcaDaughMax, "Cascade DCA Daughters Max"},
139140
{kCascadeTransRadMin, "Cascade Transverse Radius Min"},

PWGCF/FemtoUnited/Core/closePairRejection.h

Lines changed: 3 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626

2727
#include <array>
2828
#include <map>
29+
#include <memory>
2930
#include <numeric>
3031
#include <string>
3132
#include <type_traits>
33+
#include <unordered_map>
3234
#include <vector>
3335

3436
namespace o2::analysis::femtounited
@@ -255,7 +257,7 @@ class ClosePairRejection
255257

256258
void setMagField(float magField)
257259
{
258-
for (auto& [_, rejection] : mRejections) {
260+
for (auto const& [_, rejection] : mRejections) {
259261
rejection->setMagField(magField);
260262
}
261263
}
@@ -410,118 +412,6 @@ class ClosePairRejection
410412
bool mIsActivated = true;
411413
};
412414

413-
// {
414-
// mHistogramRegistry = registry;
415-
//
416-
// mHistogramRegistry->add(analysisDir + GetHistNamev2(kRadius8, HistTable), GetHistDesc(kRadius8, HistTable), GetHistType(kRadius8, HistTable), {Specs[kRadius8]});
417-
// }
418-
//
419-
// // if constexpr (isFlagSet(mode, modes::Mode::kQA)) {
420-
// // std::string qaDir = std::string(prefix) + std::string(QaDir);
421-
// // }
422-
// }
423-
//
424-
// void activate(bool activate) { mIsActivated = activate; }
425-
// bool isActivated() const { return mIsActivated; }
426-
// void setMagField(float magField) { mMagField = magField; }
427-
// void setLimits(float detaMax, float dphistarMax)
428-
// {
429-
// mDetaMax = detaMax;
430-
// mDphistarMax = dphistarMax;
431-
// };
432-
//
433-
// void reset(){
434-
//
435-
// mSameCharge = true;
436-
// }
437-
//
438-
// template <typename T1, typename T2>
439-
// void compute(T1 const& track1, T2 const& track2)
440-
// {
441-
// if (track1.sign() != track2.sign()) {
442-
// mSameCharge = false;
443-
// return;
444-
// }
445-
// // reset
446-
// mSameCharge = true;
447-
// mDphistar.fill(0.f);
448-
// mDeta = track1.eta() - track2.eta();
449-
// mDphi = track1.phi() - track2.phi();
450-
// for (size_t i = 0; i < kTpcRadius.size(); i++) {
451-
// auto dphi1 = utils::dphistar(mMagField, kTpcRadius.at(i), track1.sign(), track1.pt(), track1.phi());
452-
// auto dphi2 = utils::dphistar(mMagField, kTpcRadius.at(i), track2.sign(), track2.pt(), track2.phi());
453-
// if (dphi1 && dphi2) {
454-
// mDphistar.at(i) = (dphi1.value() - dphi2.value());
455-
// } else {
456-
// mDphistar.at(i) = 0;
457-
// }
458-
// }
459-
// mAverageDphistar = std::accumulate(mDphistar.begin(), mDphistar.end(), 0.f) / mDphistar.size();
460-
// }
461-
//
462-
// template <typename T1, typename T2>
463-
// void setPair(T1 const& track1, T2 const& track2)
464-
// {
465-
// if constexpr (modes::isEqual(pair, modes::Pairs::kTrackTrack)) {
466-
// this->compute(track1, track2);
467-
// }
468-
// }
469-
//
470-
// template <typename T1, typename T2, typename T3>
471-
// void setPair(T1 const& particle, T2 const& track, T3 const& /*tracks*/)
472-
// {
473-
// if constexpr (modes::isEqual(pair, modes::Pairs::kTrackV0) ||
474-
// modes::isEqual(pair, modes::Pairs::kTrackResonance)) {
475-
//
476-
// auto posDaughter = particle.template posDau_as<T3>();
477-
// auto negDaughter = particle.template negDau_as<T3>();
478-
//
479-
// if (track.sign() == posDaughter.sign()) {
480-
// this->compute(track, posDaughter);
481-
// } else if (track.sign() == negDaughter.sign()) {
482-
// this->compute(track, negDaughter);
483-
// } else {
484-
// LOG(warn) << "Invalid charge combination in close pair rejection";
485-
// }
486-
// }
487-
// }
488-
//
489-
// bool isClosePair() const { return mSameCharge || (std::hypot(mAverageDphistar / mDphistarMax, mDeta / mDetaMax) < 1.); }
490-
//
491-
// void fill()
492-
// {
493-
// if constexpr (isFlagSet(mode, modes::Mode::kANALYSIS)) {
494-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kAverage, HistTable)), mDeta, mAverageDphistar);
495-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius0, HistTable)), mDeta, mDphistar.at(0));
496-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius1, HistTable)), mDeta, mDphistar.at(1));
497-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius2, HistTable)), mDeta, mDphistar.at(2));
498-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius3, HistTable)), mDeta, mDphistar.at(3));
499-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius4, HistTable)), mDeta, mDphistar.at(4));
500-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius5, HistTable)), mDeta, mDphistar.at(5));
501-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius6, HistTable)), mDeta, mDphistar.at(6));
502-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius7, HistTable)), mDeta, mDphistar.at(7));
503-
// mHistogramRegistry->fill(HIST(prefix) + HIST(AnalysisDir) + HIST(GetHistName(kRadius8, HistTable)), mDeta, mDphistar.at(8));
504-
// }
505-
// // to be implemented
506-
// // if constexpr (isFlagSet(mode, modes::Mode::kQA)) {
507-
// // }
508-
// }
509-
//
510-
// private:
511-
// o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;
512-
// float mMagField = 0.f;
513-
//
514-
// float mDphi = 0.f;
515-
// float mDphistarMax = 0.f;
516-
// float mAverageDphistar = 0.f;
517-
// std::array<float, kNradii> mDphistar = {};
518-
//
519-
// float mDetaMax = 0.f;
520-
// float mDeta = 0.f;
521-
//
522-
// bool mIsActivated = false;
523-
// bool mSameCharge = true;
524-
// };
525415
}; // namespace closepairrejection
526416
}; // namespace o2::analysis::femtounited
527417
#endif // PWGCF_FEMTOUNITED_CORE_CLOSEPAIRREJECTION_H_

PWGCF/FemtoUnited/Core/dataTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2024 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//

PWGCF/FemtoUnited/Core/modes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2024 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//

0 commit comments

Comments
 (0)