Skip to content

Commit fa44f24

Browse files
fcatalan92alibuildvkucera
authored
PWGHF: Add Bs candidate creator, selector, and task for reduced data format (AliceO2Group#7990)
* Add Bs reduced candidate creator * Add Bs selector and HfMlResponse class for reduced data format * Please consider the following formatting changes (AliceO2Group#8) * Add Bs task for reduced data model * Fix typo * Add check for MC process functions * Update PWGHF/D2H/Utils/utilsRedDataFormat.h Co-authored-by: Vít Kučera <[email protected]> * Update PWGHF/D2H/Utils/utilsRedDataFormat.h Co-authored-by: Vít Kučera <[email protected]> * Update PWGHF/D2H/Utils/utilsRedDataFormat.h Co-authored-by: Vít Kučera <[email protected]> --------- Co-authored-by: ALICE Builder <[email protected]> Co-authored-by: Vít Kučera <[email protected]>
1 parent 4085de2 commit fa44f24

16 files changed

+1606
-60
lines changed

PWGHF/Core/HfMlResponseB0ToDPi.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <vector>
2222

2323
#include "PWGHF/Core/HfMlResponse.h"
24+
#include "PWGHF/D2H/Utils/utilsRedDataFormat.h"
2425

2526
// Fill the map of available input features
2627
// the key is the feature's name (std::string)
@@ -58,31 +59,6 @@
5859
break; \
5960
}
6061

61-
namespace o2::pid_tpc_tof_utils
62-
{
63-
template <typename T1>
64-
float getTpcTofNSigmaPi1(const T1& prong1)
65-
{
66-
float defaultNSigma = -999.f; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h
67-
68-
bool hasTpc = prong1.hasTPC();
69-
bool hasTof = prong1.hasTOF();
70-
71-
if (hasTpc && hasTof) {
72-
float tpcNSigma = prong1.tpcNSigmaPi();
73-
float tofNSigma = prong1.tofNSigmaPi();
74-
return sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma);
75-
}
76-
if (hasTpc) {
77-
return abs(prong1.tpcNSigmaPi());
78-
}
79-
if (hasTof) {
80-
return abs(prong1.tofNSigmaPi());
81-
}
82-
return defaultNSigma;
83-
}
84-
} // namespace o2::pid_tpc_tof_utils
85-
8662
namespace o2::analysis
8763
{
8864

PWGHF/Core/HfMlResponseBplusToD0Pi.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <vector>
2222

2323
#include "PWGHF/Core/HfMlResponse.h"
24+
#include "PWGHF/D2H/Utils/utilsRedDataFormat.h"
2425

2526
// Fill the map of available input features
2627
// the key is the feature's name (std::string)
@@ -58,31 +59,6 @@
5859
break; \
5960
}
6061

61-
namespace o2::pid_tpc_tof_utils
62-
{
63-
template <typename T1>
64-
float getTpcTofNSigmaPi1(const T1& prong1)
65-
{
66-
float defaultNSigma = -999.f; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h
67-
68-
bool hasTpc = prong1.hasTPC();
69-
bool hasTof = prong1.hasTOF();
70-
71-
if (hasTpc && hasTof) {
72-
float tpcNSigma = prong1.tpcNSigmaPi();
73-
float tofNSigma = prong1.tofNSigmaPi();
74-
return sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma);
75-
}
76-
if (hasTpc) {
77-
return abs(prong1.tpcNSigmaPi());
78-
}
79-
if (hasTof) {
80-
return abs(prong1.tofNSigmaPi());
81-
}
82-
return defaultNSigma;
83-
}
84-
} // namespace o2::pid_tpc_tof_utils
85-
8662
namespace o2::analysis
8763
{
8864

PWGHF/Core/HfMlResponseBsToDsPi.h

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file HfMlResponsBsToDsPi.h
13+
/// \brief Class to compute the ML response for Bs → Ds∓ π± analysis selections
14+
/// \author Fabio Catalano <[email protected]>, CERN
15+
16+
#ifndef PWGHF_CORE_HFMLRESPONSEBSTODSPI_H_
17+
#define PWGHF_CORE_HFMLRESPONSEBSTODSPI_H_
18+
19+
#include <map>
20+
#include <string>
21+
#include <vector>
22+
23+
#include "PWGHF/Core/HfMlResponse.h"
24+
#include "PWGHF/D2H/Utils/utilsRedDataFormat.h"
25+
26+
// Fill the map of available input features
27+
// the key is the feature's name (std::string)
28+
// the value is the corresponding value in EnumInputFeatures
29+
#define FILL_MAP_BS(FEATURE) \
30+
{ \
31+
#FEATURE, static_cast<uint8_t>(InputFeaturesBsToDsPi::FEATURE) \
32+
}
33+
34+
// Check if the index of mCachedIndices (index associated to a FEATURE)
35+
// matches the entry in EnumInputFeatures associated to this FEATURE
36+
// if so, the inputFeatures vector is filled with the FEATURE's value
37+
// by calling the corresponding GETTER from OBJECT
38+
#define CHECK_AND_FILL_VEC_BS_FULL(OBJECT, FEATURE, GETTER) \
39+
case static_cast<uint8_t>(InputFeaturesBsToDsPi::FEATURE): { \
40+
inputFeatures.emplace_back(OBJECT.GETTER()); \
41+
break; \
42+
}
43+
44+
// Check if the index of mCachedIndices (index associated to a FEATURE)
45+
// matches the entry in EnumInputFeatures associated to this FEATURE
46+
// if so, the inputFeatures vector is filled with the FEATURE's value
47+
// by calling the GETTER function taking OBJECT in argument
48+
#define CHECK_AND_FILL_VEC_BS_FUNC(OBJECT, FEATURE, GETTER) \
49+
case static_cast<uint8_t>(InputFeaturesBsToDsPi::FEATURE): { \
50+
inputFeatures.emplace_back(GETTER(OBJECT)); \
51+
break; \
52+
}
53+
54+
// Specific case of CHECK_AND_FILL_VEC_BS_FULL(OBJECT, FEATURE, GETTER)
55+
// where OBJECT is named candidate and FEATURE = GETTER
56+
#define CHECK_AND_FILL_VEC_BS(GETTER) \
57+
case static_cast<uint8_t>(InputFeaturesBsToDsPi::GETTER): { \
58+
inputFeatures.emplace_back(candidate.GETTER()); \
59+
break; \
60+
}
61+
62+
namespace o2::analysis
63+
{
64+
65+
enum class InputFeaturesBsToDsPi : uint8_t {
66+
ptProng0 = 0,
67+
ptProng1,
68+
impactParameter0,
69+
impactParameter1,
70+
impactParameterProduct,
71+
chi2PCA,
72+
decayLength,
73+
decayLengthXY,
74+
decayLengthNormalised,
75+
decayLengthXYNormalised,
76+
cpa,
77+
cpaXY,
78+
maxNormalisedDeltaIP,
79+
prong0MlScoreBkg,
80+
prong0MlScorePrompt,
81+
prong0MlScoreNonprompt,
82+
tpcNSigmaPi1,
83+
tofNSigmaPi1,
84+
tpcTofNSigmaPi1
85+
};
86+
87+
template <typename TypeOutputScore = float>
88+
class HfMlResponseBsToDsPi : public HfMlResponse<TypeOutputScore>
89+
{
90+
public:
91+
/// Default constructor
92+
HfMlResponseBsToDsPi() = default;
93+
/// Default destructor
94+
virtual ~HfMlResponseBsToDsPi() = default;
95+
96+
/// Method to get the input features vector needed for ML inference
97+
/// \param candidate is the Bs candidate
98+
/// \param prong1 is the candidate's prong1
99+
/// \return inputFeatures vector
100+
template <bool withDmesMl, typename T1, typename T2>
101+
std::vector<float> getInputFeatures(T1 const& candidate,
102+
T2 const& prong1)
103+
{
104+
std::vector<float> inputFeatures;
105+
106+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
107+
if constexpr (withDmesMl) {
108+
switch (idx) {
109+
CHECK_AND_FILL_VEC_BS(ptProng0);
110+
CHECK_AND_FILL_VEC_BS(ptProng1);
111+
CHECK_AND_FILL_VEC_BS(impactParameter0);
112+
CHECK_AND_FILL_VEC_BS(impactParameter1);
113+
CHECK_AND_FILL_VEC_BS(impactParameterProduct);
114+
CHECK_AND_FILL_VEC_BS(chi2PCA);
115+
CHECK_AND_FILL_VEC_BS(decayLength);
116+
CHECK_AND_FILL_VEC_BS(decayLengthXY);
117+
CHECK_AND_FILL_VEC_BS(decayLengthNormalised);
118+
CHECK_AND_FILL_VEC_BS(decayLengthXYNormalised);
119+
CHECK_AND_FILL_VEC_BS(cpa);
120+
CHECK_AND_FILL_VEC_BS(cpaXY);
121+
CHECK_AND_FILL_VEC_BS(maxNormalisedDeltaIP);
122+
CHECK_AND_FILL_VEC_BS(prong0MlScoreBkg);
123+
CHECK_AND_FILL_VEC_BS(prong0MlScorePrompt);
124+
CHECK_AND_FILL_VEC_BS(prong0MlScoreNonprompt);
125+
// Pion PID variables
126+
CHECK_AND_FILL_VEC_BS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
127+
CHECK_AND_FILL_VEC_BS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
128+
CHECK_AND_FILL_VEC_BS_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
129+
}
130+
} else {
131+
switch (idx) {
132+
CHECK_AND_FILL_VEC_BS(ptProng0);
133+
CHECK_AND_FILL_VEC_BS(ptProng1);
134+
CHECK_AND_FILL_VEC_BS(impactParameter0);
135+
CHECK_AND_FILL_VEC_BS(impactParameter1);
136+
CHECK_AND_FILL_VEC_BS(impactParameterProduct);
137+
CHECK_AND_FILL_VEC_BS(chi2PCA);
138+
CHECK_AND_FILL_VEC_BS(decayLength);
139+
CHECK_AND_FILL_VEC_BS(decayLengthXY);
140+
CHECK_AND_FILL_VEC_BS(decayLengthNormalised);
141+
CHECK_AND_FILL_VEC_BS(decayLengthXYNormalised);
142+
CHECK_AND_FILL_VEC_BS(cpa);
143+
CHECK_AND_FILL_VEC_BS(cpaXY);
144+
CHECK_AND_FILL_VEC_BS(maxNormalisedDeltaIP);
145+
// Pion PID variables
146+
CHECK_AND_FILL_VEC_BS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
147+
CHECK_AND_FILL_VEC_BS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
148+
CHECK_AND_FILL_VEC_BS_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
149+
}
150+
}
151+
}
152+
153+
return inputFeatures;
154+
}
155+
156+
protected:
157+
/// Method to fill the map of available input features
158+
void setAvailableInputFeatures()
159+
{
160+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
161+
FILL_MAP_BS(ptProng0),
162+
FILL_MAP_BS(ptProng1),
163+
FILL_MAP_BS(impactParameter0),
164+
FILL_MAP_BS(impactParameter1),
165+
FILL_MAP_BS(impactParameterProduct),
166+
FILL_MAP_BS(chi2PCA),
167+
FILL_MAP_BS(decayLength),
168+
FILL_MAP_BS(decayLengthXY),
169+
FILL_MAP_BS(decayLengthNormalised),
170+
FILL_MAP_BS(decayLengthXYNormalised),
171+
FILL_MAP_BS(cpa),
172+
FILL_MAP_BS(cpaXY),
173+
FILL_MAP_BS(maxNormalisedDeltaIP),
174+
FILL_MAP_BS(prong0MlScoreBkg),
175+
FILL_MAP_BS(prong0MlScorePrompt),
176+
FILL_MAP_BS(prong0MlScoreNonprompt),
177+
// Pion PID variables
178+
FILL_MAP_BS(tpcNSigmaPi1),
179+
FILL_MAP_BS(tofNSigmaPi1),
180+
FILL_MAP_BS(tpcTofNSigmaPi1)};
181+
}
182+
};
183+
184+
} // namespace o2::analysis
185+
186+
#undef FILL_MAP_BS
187+
#undef CHECK_AND_FILL_VEC_BS_FULL
188+
#undef CHECK_AND_FILL_VEC_BS_FUNC
189+
#undef CHECK_AND_FILL_VEC_BS
190+
191+
#endif // PWGHF_CORE_HFMLRESPONSEBSTODSPI_H_

PWGHF/Core/SelectorCuts.h

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,25 +903,50 @@ static const std::vector<std::string> labelsCutVar = {"m", "CPA", "Chi2PCA", "d0
903903

904904
namespace hf_cuts_bs_to_ds_pi
905905
{
906-
static constexpr int nBinsPt = 2;
906+
static constexpr int nBinsPt = 10;
907907
static constexpr int nCutVars = 10;
908908
// default values for the pT bin edges (can be used to configure histogram axis)
909909
// offset by 1 from the bin numbers in cuts array
910910
constexpr double binsPt[nBinsPt + 1] = {
911911
0,
912912
1.0,
913-
2.0};
913+
2.0,
914+
3.0,
915+
4.0,
916+
5.0,
917+
8.0,
918+
10.0,
919+
12.0,
920+
16.0,
921+
24.0};
914922

915923
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};
916924

917925
// default values for the cuts
918926
// DeltaM CPA chi2PCA d0Ds d0Pi pTDs pTPi BsDecayLength BsDecayLengthXY IPProd
919927
constexpr double cuts[nBinsPt][nCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 0 < pt < 1 */
920-
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}}; /* 1 < pt < 2 */
928+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 1 < pt < 2 */
929+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 2 < pt < 3 */
930+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 3 < pt < 4 */
931+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 4 < pt < 5 */
932+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 5 < pt < 6 */
933+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 8 < pt < 10 */
934+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 10 < pt < 12 */
935+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 12 < pt < 16 */
936+
{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}}; /* 16 < pt < 24 */
937+
921938
// row labels
922939
static const std::vector<std::string> labelsPt = {
923940
"pT bin 0",
924-
"pT bin 1"};
941+
"pT bin 1",
942+
"pT bin 2",
943+
"pT bin 3",
944+
"pT bin 4",
945+
"pT bin 5",
946+
"pT bin 6",
947+
"pT bin 7",
948+
"pT bin 8",
949+
"pT bin 9"};
925950

926951
// column labels
927952
static const std::vector<std::string> labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 Ds", "d0 Pi", "pT Ds", "pT Pi", "Bs decLen", "Bs decLenXY", "Imp. Par. Product"};

PWGHF/D2H/TableProducer/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ o2physics_add_dpl_workflow(candidate-creator-bplus-reduced
2121
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
2222
COMPONENT_NAME Analysis)
2323

24+
o2physics_add_dpl_workflow(candidate-creator-bs-reduced
25+
SOURCES candidateCreatorBsReduced.cxx
26+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
27+
COMPONENT_NAME Analysis)
28+
2429
o2physics_add_dpl_workflow(candidate-creator-charm-reso-reduced
2530
SOURCES candidateCreatorCharmResoReduced.cxx
2631
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
@@ -38,6 +43,11 @@ o2physics_add_dpl_workflow(candidate-selector-bplus-to-d0-pi-reduced
3843
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore
3944
COMPONENT_NAME Analysis)
4045

46+
o2physics_add_dpl_workflow(candidate-selector-bs-to-ds-pi-reduced
47+
SOURCES candidateSelectorBsToDsPiReduced.cxx
48+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore
49+
COMPONENT_NAME Analysis)
50+
4151
# Data creators
4252

4353
o2physics_add_dpl_workflow(data-creator-charm-had-pi-reduced

0 commit comments

Comments
 (0)