Skip to content

Commit 987524e

Browse files
committed
Feat: finish QA tasks and tools
1 parent 044e164 commit 987524e

17 files changed

+484
-423
lines changed

PWGCF/FemtoUnited/Core/BaseSelection.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,29 @@ class BaseSelection
5555
mSelections.at(Observable) = SelectionContainer<T>(configSelections, limitType, SkipLastBit);
5656
}
5757

58-
void resetMinimalSelection() { mMinimalSelected = true; }
58+
/// Pass the Configurable of selection values in the analysis task to the selection class
59+
/// \param configSelection Vector from configurable containing the values employed for the selection
60+
/// \param observableType Observable to be employed for the selection
61+
/// \param limitType Type of the selection limit
62+
void addSelection(std::string baseName, T lowerLimit, T upperLimit, std::vector<std::string>& configSelections, int Observable, limits::LimitType limitType, bool SkipLastBit)
63+
{
64+
if (static_cast<size_t>(Observable) >= NObservables) {
65+
LOG(fatal) << "Observable is not valid. Observable (index) has to be smaller than " << NObservables;
66+
}
67+
mNSelections += configSelections.size();
68+
if (mNSelections >= 8 * sizeof(BitmaskType)) {
69+
LOG(fatal) << "Too many selections. At most " << 8 * sizeof(BitmaskType) << " are supported";
70+
}
71+
mSelections.at(Observable) = SelectionContainer<T>(baseName, lowerLimit, upperLimit, configSelections, limitType, SkipLastBit);
72+
}
73+
74+
void updateLimits(int observable, T value) { mSelections.at(observable).updateLimits(value); }
75+
76+
void reset()
77+
{
78+
mBitmask.reset();
79+
mMinimalSelected = true;
80+
}
5981

6082
void setCheckMinimalSelection(bool checkMinimalSelection) { mCheckMinimalSelection = checkMinimalSelection; }
6183

@@ -64,7 +86,11 @@ class BaseSelection
6486
/// \param value Value of the observable
6587
void setBitmaskForObservable(int observable, T value)
6688
{
67-
// if any object did not pass minimal selections, there is no point in setting bitmask for other observables
89+
// if there are no values set, bail out
90+
if (mSelections.at(observable).empty()) {
91+
return;
92+
}
93+
// if any previous observable did not pass minimal selections, there is no point in setting bitmask for other observables
6894
// minimal selection for each observable is computed after adding it
6995
// can be deactivate by setting mCheckMinimalSelection to false
7096
if (mCheckMinimalSelection == true && mMinimalSelected == false) {
@@ -80,7 +106,11 @@ class BaseSelection
80106
}
81107

82108
/// check if minimal Selections are passed
83-
bool getMinimalSelection() { return mMinimalSelected; }
109+
bool
110+
getMinimalSelection()
111+
{
112+
return mMinimalSelected;
113+
}
84114

85115
/// check if any Selections are passed
86116
bool getAnySelection()
@@ -96,9 +126,11 @@ class BaseSelection
96126
// if minimal selections are not passed, just set bitmask to 0
97127
if (mCheckMinimalSelection == true && mMinimalSelected == false) {
98128
mBitmask.reset();
129+
return;
99130
}
100131

101132
// to assemble bitmask, convert all bitmask into integers
133+
// shift the current one and add the new bits
102134
uint64_t result = 0u;
103135
int shift = 0;
104136
uint64_t value = 0u;

PWGCF/FemtoUnited/Core/DataTypes.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ namespace femtodatatypes
2323
// Bitmaks for tracks
2424
using TrackMaskType = uint32_t;
2525
using TrackPidMaskType = uint32_t;
26-
// using TrackTPCMaskType = uint16_t;
27-
// using TrackTOFMaskType = uint16_t;
28-
// using TrackTPCTOFMaskType = uint16_t;
2926

3027
// Bitmaks for vzeros and daughters
3128
using VzeroMaskType = uint32_t;
32-
// using VzeroDauTrackMaskType = uint8_t;
29+
// using VzeroDaughterMaskType = uint8_t;
3330
// using VzeroDauTPCMaskType = uint8_t;
3431

3532
// Bitmaks for cascades, vzero daughter and bachelor

PWGCF/FemtoUnited/Core/SelectionContainer.h

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <vector>
2222
#include <algorithm>
2323

24+
#include <TF1.h>
25+
2426
#include "fairlogger/Logger.h"
2527
#include "CommonConstants/MathConstants.h"
2628

@@ -30,13 +32,15 @@ namespace o2::analysis::femtounited
3032
/// Limit type for selections
3133
namespace limits
3234
{
33-
enum LimitType { kUpperLimit, ///< simple upper limit for the value, e.g. p_T < 1 GeV/c
34-
kAbsUpperLimit, ///< upper limit of the absolute value, e.g. |eta| < 0.8
35-
kLowerLimit, ///< simple lower limit for the value, e.g. p_T > 0.2 GeV/c
36-
kAbsLowerLimit, ///< lower limit of the absolute value, e.g. |DCA_xyz| > 0.05 cm
37-
// kUpperFunctionLimit, ///< simple upper limit of a function value, e.g. DCA_xy > f(pt)
38-
// kAbsUpperFunctionLimit, ///< upper limit of an absolute value given by a function, e.g. |DCA_xy| > f(pt)
39-
kEqual ///< values need to be equal, e.g. sign = 1
35+
enum LimitType { kUpperLimit, ///< simple upper limit for the value, e.g. p_T < 1 GeV/c
36+
kAbsUpperLimit, ///< upper limit of the absolute value, e.g. |eta| < 0.8
37+
kLowerLimit, ///< simple lower limit for the value, e.g. p_T > 0.2 GeV/c
38+
kAbsLowerLimit, ///< lower limit of the absolute value, e.g. |DCA_xyz| > 0.05 cm
39+
kEqual, ///< values need to be equal, e.g. sign = 1
40+
kUpperFunctionLimit, ///< simple upper limit of a function value, e.g. DCA_xy > f(pt)
41+
kAbsUpperFunctionLimit, ///< upper limit of an absolute value given by a function, e.g. |DCA_xy| > f(pt)
42+
kLowerFunctionLimit, ///< simple upper limit of a function value, e.g. DCA_xy > f(pt)
43+
kAbsLowerFunctionLimit ///< upper limit of an absolute value given by a function, e.g. |DCA_xy| > f(pt)
4044
};
4145
}
4246
// bitsets need number of bits at compile time. Set reasonable limit here
@@ -70,6 +74,26 @@ class SelectionContainer
7074
sortSelections();
7175
}
7276

77+
/// Constructor
78+
/// \param values Values for the selection
79+
/// \param limitType Type of limit of the selection
80+
SelectionContainer(std::string baseName, T lowerLimit, T upperLimit, std::vector<std::string>& functions, limits::LimitType limitType, bool SkipLastBit)
81+
: mLimitType(limitType), mSkipLastBit(SkipLastBit)
82+
{
83+
if (mValues.size() > BitmaskMaxSize) {
84+
LOG(fatal) << "Too many selections for single a observable. Current limit is " << BitmaskMaxSize;
85+
}
86+
for (std::size_t i = 0; i < functions.size(); i++) {
87+
mFunctions.emplace_back((baseName + std::to_string(i)).c_str(), functions.at(i).c_str(), lowerLimit, upperLimit);
88+
}
89+
// functions for selection are not necessarily ordered correctly
90+
// use value at midpoint to order them
91+
// here we rely on the user that the functions can be ordered like this over the whole interval
92+
sortFunctions((lowerLimit + upperLimit) / 2);
93+
// initialize the values also to the midpoint
94+
this->updateLimits((lowerLimit + upperLimit) / 2);
95+
}
96+
7397
/// Destructor
7498
virtual ~SelectionContainer() = default;
7599

@@ -86,6 +110,34 @@ class SelectionContainer
86110
case (limits::kEqual):
87111
std::sort(mValues.begin(), mValues.end(), [](T a, T b) { return a <= b; });
88112
break;
113+
default:
114+
break;
115+
}
116+
}
117+
118+
// sort limit functions
119+
void sortFunctions(T value)
120+
{
121+
switch (mLimitType) {
122+
case (limits::kUpperFunctionLimit):
123+
case (limits::kAbsUpperFunctionLimit):
124+
std::sort(mFunctions.begin(), mFunctions.end(), [value](TF1 a, TF1 b) { return a.Eval(value) >= b.Eval(value); });
125+
break;
126+
case (limits::kLowerFunctionLimit):
127+
case (limits::kAbsLowerFunctionLimit):
128+
std::sort(mFunctions.begin(), mFunctions.end(), [value](TF1 a, TF1 b) { return a.Eval(value) <= b.Eval(value); });
129+
break;
130+
default:
131+
break;
132+
}
133+
}
134+
135+
// update the selection limits depending on the passed function
136+
void updateLimits(T value)
137+
{
138+
// functions are ordered so just add the values in the same order
139+
for (std::size_t i = 0; i < mValues.size(); i++) {
140+
mValues.at(i) = mFunctions.at(i).Eval(value);
89141
}
90142
}
91143

@@ -95,7 +147,7 @@ class SelectionContainer
95147
{
96148
// better safe than sorry and reset the bitmask before you evaluate a new observable
97149
mBitmask.reset();
98-
// the values are order, as soon as one comparison is not true, we can break out of the loop
150+
// the values are ordered, for most loost to most tight, as soon as one comparison is not true, we can break out of the loop
99151
bool breakLoop = false;
100152
// iterate over all limits and set the corresponding bit if we pass the selection, otherwise break out as soon as we can
101153
for (size_t i = 0; i < mValues.size(); i++) {
@@ -177,6 +229,9 @@ class SelectionContainer
177229
/// Get shift for final bitmask
178230
int getShift()
179231
{
232+
if (mValues.empty()) {
233+
return 0;
234+
}
180235
if (mSkipLastBit) {
181236
return static_cast<int>(mValues.size() - 1);
182237
} else {
@@ -186,6 +241,7 @@ class SelectionContainer
186241

187242
private:
188243
std::vector<T> mValues{}; ///< Values used for the selection
244+
std::vector<TF1> mFunctions{}; ///< Values used for the selection
189245
limits::LimitType mLimitType; ///< Limit type of selection
190246
std::bitset<BitmaskMaxSize> mBitmask; ///< bitmask for a given observable
191247
bool mSkipLastBit = false;

PWGCF/FemtoUnited/Core/TrackHistManager.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//
12
// Copyright 2019-2022 CERN and copyright holders of ALICE O2.
23
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
34
// All rights not expressly granted are reserved.
@@ -23,6 +24,7 @@
2324
#include "Framework/HistogramRegistry.h"
2425
#include "PWGCF/FemtoUnited/Core/HistManager.h"
2526
#include "PWGCF/FemtoUnited/Core/Modes.h"
27+
#include "PWGCF/FemtoUnited/Utils/FemtoUtils.h"
2628

2729
using namespace ::o2::framework;
2830

@@ -42,6 +44,9 @@ enum TrackHist {
4244
kItsClusterIb,
4345
kTpcCluster,
4446
kTpcClusterShared,
47+
// kDcaxy,
48+
// kDcaz,
49+
// kDca,
4550
// 2d qa
4651
kPtVsEta,
4752
kPtVsPhi,
@@ -50,7 +55,11 @@ enum TrackHist {
5055
kPtVsTpcCluster,
5156
kPtVsTpcClusterShared,
5257
kTpcClusterVsTpcClusterShared,
58+
kPtVsDcaxy,
59+
kPtVsDcaz,
60+
kPtVsDca,
5361
// its pid
62+
kItsSignal,
5463
kItsElectron,
5564
kItsPion,
5665
kItsKaon,
@@ -109,6 +118,10 @@ constexpr std::array<Histmanager::HistInfo<TrackHist>, kTrackHistogramLast> Hist
109118
{kPtVsTpcCluster, kTH2F, "hPtVsTpcCluster", "p_{T} vs TPC cluster found; p_{T} (GeV/#it{c}) ; TPC cluster found"},
110119
{kPtVsTpcClusterShared, kTH2F, "hPtVsTpcClusterShared", "p_{T} vs TPC cluster shared; p_{T} (GeV/#it{c}) ; TPC cluster shared"},
111120
{kTpcClusterVsTpcClusterShared, kTH2F, "hTpcClusterVsTpcClusterShared", "TPC cluster found vs TPC cluster shared; TPC cluster found; TPC cluster shared"},
121+
{kPtVsDcaxy, kTH2F, "hPtVsDcaxy", "p_{T} vs DCA_{XY}; p_{T} (GeV/#it{c}); DCA_{XY} (cm)"},
122+
{kPtVsDcaz, kTH2F, "hPtVsDcaz", "p_{T} vs DCA_{Z}; p_{T} (GeV/#it{c}); DCA_{Z} (cm)"},
123+
{kPtVsDca, kTH2F, "hPtVsDca", "p_{T} vs DCA; p_{T} (GeV/#it{c}); DCA (cm)"},
124+
{kItsSignal, kTH2F, "hItsSignal", "ITS Signal; p (GeV/#it{c}) ; <ITS Cluster Size> x <cos #lambda>"},
112125
{kItsElectron, kTH2F, "hItsPidElectron", "TPC PID Electron; p (GeV/#it{c}) ; n#sigma_{TPC,el}"},
113126
{kItsPion, kTH2F, "hItsPidPion", "ITS PID Pion; p (GeV/#it{c}) ; n#sigma_{ITS,pi}"},
114127
{kItsKaon, kTH2F, "hItsPidKaon", "ITS PID Kaon; p (GeV/#it{c}) ; n#sigma_{ITS,ka}"},
@@ -182,8 +195,14 @@ class TrackHistManager
182195
mHistogramRegistry->add(qaDir + GetHistNamev2(kPtVsTpcClusterShared, HistTable), GetHistDesc(kPtVsTpcClusterShared, HistTable), GetHistType(kPtVsTpcClusterShared, HistTable), {Specs[kPtVsTpcClusterShared]});
183196
mHistogramRegistry->add(qaDir + GetHistNamev2(kTpcClusterVsTpcClusterShared, HistTable), GetHistDesc(kTpcClusterVsTpcClusterShared, HistTable), GetHistType(kTpcClusterVsTpcClusterShared, HistTable), {Specs[kTpcClusterVsTpcClusterShared]});
184197

198+
// dca
199+
mHistogramRegistry->add(qaDir + GetHistNamev2(kPtVsDcaxy, HistTable), GetHistDesc(kPtVsDcaxy, HistTable), GetHistType(kPtVsDcaxy, HistTable), {Specs[kPtVsDcaxy]});
200+
mHistogramRegistry->add(qaDir + GetHistNamev2(kPtVsDcaz, HistTable), GetHistDesc(kPtVsDcaz, HistTable), GetHistType(kPtVsDcaz, HistTable), {Specs[kPtVsDcaz]});
201+
mHistogramRegistry->add(qaDir + GetHistNamev2(kPtVsDca, HistTable), GetHistDesc(kPtVsDca, HistTable), GetHistType(kPtVsDca, HistTable), {Specs[kPtVsDca]});
202+
185203
std::string pidDir = std::string(PidDir);
186204

205+
mHistogramRegistry->add(pidDir + GetHistNamev2(kItsSignal, HistTable), GetHistDesc(kItsSignal, HistTable), GetHistType(kItsSignal, HistTable), {Specs[kItsSignal]});
187206
mHistogramRegistry->add(pidDir + GetHistNamev2(kItsElectron, HistTable), GetHistDesc(kItsElectron, HistTable), GetHistType(kItsElectron, HistTable), {Specs[kItsElectron]});
188207
mHistogramRegistry->add(pidDir + GetHistNamev2(kItsPion, HistTable), GetHistDesc(kItsPion, HistTable), GetHistType(kItsPion, HistTable), {Specs[kItsPion]});
189208
mHistogramRegistry->add(pidDir + GetHistNamev2(kItsKaon, HistTable), GetHistDesc(kItsKaon, HistTable), GetHistType(kItsKaon, HistTable), {Specs[kItsKaon]});
@@ -244,6 +263,11 @@ class TrackHistManager
244263
mHistogramRegistry->fill(HIST(QaDir) + HIST(GetHistName(kPtVsTpcClusterShared, HistTable)), track.pt(), static_cast<float>(track.tpcNClsShared()));
245264
mHistogramRegistry->fill(HIST(QaDir) + HIST(GetHistName(kTpcClusterVsTpcClusterShared, HistTable)), static_cast<float>(track.tpcNClsFound()), static_cast<float>(track.tpcNClsShared()));
246265

266+
mHistogramRegistry->fill(HIST(QaDir) + HIST(GetHistName(kPtVsDcaxy, HistTable)), track.pt(), track.dcaXY());
267+
mHistogramRegistry->fill(HIST(QaDir) + HIST(GetHistName(kPtVsDcaz, HistTable)), track.pt(), track.dcaZ());
268+
mHistogramRegistry->fill(HIST(QaDir) + HIST(GetHistName(kPtVsDca, HistTable)), track.pt(), utils::geometricMean(track.dcaXY(), track.dcaZ()));
269+
270+
mHistogramRegistry->fill(HIST(PidDir) + HIST(GetHistName(kItsSignal, HistTable)), track.p(), o2::analysis::femtounited::utils::itsSignal(track));
247271
mHistogramRegistry->fill(HIST(PidDir) + HIST(GetHistName(kItsElectron, HistTable)), track.p(), track.itsNSigmaEl());
248272
mHistogramRegistry->fill(HIST(PidDir) + HIST(GetHistName(kItsPion, HistTable)), track.p(), track.itsNSigmaPi());
249273
mHistogramRegistry->fill(HIST(PidDir) + HIST(GetHistName(kItsKaon, HistTable)), track.p(), track.itsNSigmaKa());

PWGCF/FemtoUnited/Core/TrackPidSelection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define PWGCF_FEMTOUNITED_CORE_TRACKPIDSELECTION_H_
1818

1919
#include <cmath>
20+
2021
#include "PWGCF/FemtoUnited/Core/BaseSelection.h"
2122
#include "PWGCF/FemtoUnited/Core/DataTypes.h"
2223
#include "PWGCF/FemtoUnited/Utils/FemtoUtils.h"
@@ -73,6 +74,8 @@ class TrackPidSelection : public BaseSelection<float, o2::aod::femtodatatypes::T
7374
template <class track>
7475
void ApplySelections(track const& Track)
7576
{
77+
this->reset();
78+
7679
// its pid
7780
this->setBitmaskForObservable(TrackPidSels::kItsElectron, Track.itsNSigmaEl());
7881
this->setBitmaskForObservable(TrackPidSels::kItsPion, Track.itsNSigmaPi());

PWGCF/FemtoUnited/Core/TrackSelection.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ enum TrackSels {
3333
kTPCsClsMax, ///< Max. number of shared TPC clusters
3434
kITSnClsMin, ///< Min. number of ITS clusters
3535
kITSnClsIbMin, ///< Min. number of ITS clusters in the inner barrel
36-
kDCAxyMax, ///< Max. DCA_xy (cm)
37-
kDCAzMax, ///< Max. DCA_z (cm)
36+
kDCAxyMax, ///< Max. DCA_xy (cm) as a function of pT
37+
kDCAzMax, ///< Max. DCA_z (cm) as a function of pT
3838
kTrackselMax
3939
};
4040

@@ -48,13 +48,21 @@ class TrackSelection : public BaseSelection<float, o2::aod::femtodatatypes::Trac
4848
template <class track>
4949
void ApplySelections(track const& Track)
5050
{
51-
this->resetMinimalSelection();
51+
this->reset();
5252
this->setBitmaskForObservable(TrackSels::kSign, Track.sign());
5353
this->setBitmaskForObservable(TrackSels::kTPCnClsMin, Track.tpcNClsFound());
5454
this->setBitmaskForObservable(TrackSels::kTPCcRowsMin, Track.tpcNClsCrossedRows());
5555
this->setBitmaskForObservable(TrackSels::kTPCsClsMax, Track.tpcNClsShared());
5656
this->setBitmaskForObservable(TrackSels::kITSnClsMin, Track.itsNCls());
5757
this->setBitmaskForObservable(TrackSels::kITSnClsIbMin, Track.itsNClsInnerBarrel());
58+
59+
// evalue bitmask for pt dependent dca cuts
60+
this->updateLimits(TrackSels::kDCAxyMax, Track.pt());
61+
this->setBitmaskForObservable(TrackSels::kDCAxyMax, Track.dcaXY());
62+
63+
this->updateLimits(TrackSels::kDCAzMax, Track.pt());
64+
this->setBitmaskForObservable(TrackSels::kDCAzMax, Track.dcaZ());
65+
5866
this->assembleBismask();
5967
};
6068
}; // namespace femtoDream

PWGCF/FemtoUnited/Core/TrackTOFSelection.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)