Skip to content

Commit a4cdb1c

Browse files
MarcellocostiMarcello Di Costanzoalibuildnjacazio
authored
[ALICE3] Implement task and tree creator for 3-prong candidates (#13845)
Co-authored-by: Marcello Di Costanzo <mdicosta@aliceml.cern.ch> Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: Nicolò Jacazio <njacazio@users.noreply.github.com>
1 parent 64790a7 commit a4cdb1c

File tree

10 files changed

+2319
-161
lines changed

10 files changed

+2319
-161
lines changed

ALICE3/DataModel/A3DecayFinderTables.h

Lines changed: 305 additions & 1 deletion
Large diffs are not rendered by default.

ALICE3/ML/HfMlResponse3Prong.h

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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 Alice3MlRResponse3Prong.h
13+
/// \brief Class to compute the ML response for HF 3-prong candidates
14+
/// \author Marcello Di Costanzo <marcello.di.costanzo@cern.ch>, Polytechnic University of Turin and INFN Turin
15+
16+
#ifndef ALICE3_ML_HFMLRESPONSE3PRONG_H_
17+
#define ALICE3_ML_HFMLRESPONSE3PRONG_H_
18+
19+
#include "Tools/ML/MlResponse.h"
20+
21+
#include <cstdint>
22+
#include <map>
23+
#include <string>
24+
#include <vector>
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_3PRONG(FEATURE) \
30+
{ \
31+
#FEATURE, static_cast<uint8_t>(InputFeatures3Prong::FEATURE) \
32+
}
33+
34+
// Specific case of CHECK_AND_FILL_ML_ALICE3_FULL(OBJECT, FEATURE, GETTER)
35+
// where OBJECT is named candidate and FEATURE = GETTER
36+
#define CHECK_AND_FILL_ML_ALICE3(GETTER) \
37+
case static_cast<uint8_t>(InputFeatures3Prong::GETTER): { \
38+
inputFeatures.emplace_back(candidate.GETTER()); \
39+
break; \
40+
}
41+
42+
namespace o2::analysis
43+
{
44+
enum class InputFeatures3Prong : uint8_t {
45+
ptProng0 = 0,
46+
ptProng1,
47+
ptProng2,
48+
impactParameterY0,
49+
impactParameterY1,
50+
impactParameterY2,
51+
impactParameterZ0,
52+
impactParameterZ1,
53+
impactParameterZ2,
54+
decayLength,
55+
decayLengthXY,
56+
decayLengthXYNormalised,
57+
cpa,
58+
cpaXY,
59+
chi2PCA,
60+
nSigRichPr0, // 0
61+
nSigRichKa0, // 0
62+
nSigRichPi0, // 0
63+
nSigRichPr1, // 1
64+
nSigRichKa1, // 1
65+
nSigRichPi1, // 1
66+
nSigRichPr2, // 2
67+
nSigRichKa2, // 2
68+
nSigRichPi2, // 2
69+
nSigInnTofPr0, // 0
70+
nSigInnTofKa0, // 0
71+
nSigInnTofPi0, // 0
72+
nSigInnTofPr1, // 1
73+
nSigInnTofKa1, // 1
74+
nSigInnTofPi1, // 1
75+
nSigInnTofPr2, // 2
76+
nSigInnTofKa2, // 2
77+
nSigInnTofPi2, // 2
78+
nSigOutTofPr0, // 0
79+
nSigOutTofKa0, // 0
80+
nSigOutTofPi0, // 0
81+
nSigOutTofPr1, // 1
82+
nSigOutTofKa1, // 1
83+
nSigOutTofPi1, // 1
84+
nSigOutTofPr2, // 2
85+
nSigOutTofKa2, // 2
86+
nSigOutTofPi2, // 2
87+
nSigTrkPr0, // 0
88+
nSigTrkKa0, // 0
89+
nSigTrkPi0, // 0
90+
nSigTrkPr1, // 1
91+
nSigTrkKa1, // 1
92+
nSigTrkPi1, // 1
93+
nSigTrkPr2, // 2
94+
nSigTrkKa2, // 2
95+
nSigTrkPi2 // 2
96+
};
97+
98+
template <typename TypeOutputScore = float>
99+
class HfMlResponse3Prong : public MlResponse<TypeOutputScore>
100+
{
101+
public:
102+
/// Default constructor
103+
HfMlResponse3Prong() = default;
104+
/// Default destructor
105+
virtual ~HfMlResponse3Prong() = default;
106+
107+
/// Method to get the input features vector needed for ML inference
108+
/// \tparam T1 type of the 3-prong candidate
109+
/// \param candidate is the 3-prong candidate
110+
/// \return inputFeatures vector
111+
template <typename T1>
112+
std::vector<float> getInputFeatures(T1 const& candidate)
113+
{
114+
std::vector<float> inputFeatures;
115+
116+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
117+
switch (idx) {
118+
CHECK_AND_FILL_ML_ALICE3(ptProng0);
119+
CHECK_AND_FILL_ML_ALICE3(ptProng1);
120+
CHECK_AND_FILL_ML_ALICE3(ptProng2);
121+
CHECK_AND_FILL_ML_ALICE3(impactParameterY0);
122+
CHECK_AND_FILL_ML_ALICE3(impactParameterY1);
123+
CHECK_AND_FILL_ML_ALICE3(impactParameterY2);
124+
CHECK_AND_FILL_ML_ALICE3(impactParameterZ0);
125+
CHECK_AND_FILL_ML_ALICE3(impactParameterZ1);
126+
CHECK_AND_FILL_ML_ALICE3(impactParameterZ2);
127+
CHECK_AND_FILL_ML_ALICE3(decayLength);
128+
CHECK_AND_FILL_ML_ALICE3(decayLengthXY);
129+
CHECK_AND_FILL_ML_ALICE3(decayLengthXYNormalised);
130+
CHECK_AND_FILL_ML_ALICE3(cpa);
131+
CHECK_AND_FILL_ML_ALICE3(cpaXY);
132+
CHECK_AND_FILL_ML_ALICE3(chi2PCA);
133+
// TRACKER PID variables
134+
CHECK_AND_FILL_ML_ALICE3(nSigTrkPr0);
135+
CHECK_AND_FILL_ML_ALICE3(nSigTrkKa1);
136+
CHECK_AND_FILL_ML_ALICE3(nSigTrkPi2);
137+
// RICH PID variables
138+
CHECK_AND_FILL_ML_ALICE3(nSigRichPr0);
139+
CHECK_AND_FILL_ML_ALICE3(nSigRichKa1);
140+
CHECK_AND_FILL_ML_ALICE3(nSigRichPi2);
141+
// INNER TOF PID variables
142+
CHECK_AND_FILL_ML_ALICE3(nSigInnTofPr0);
143+
CHECK_AND_FILL_ML_ALICE3(nSigInnTofKa1);
144+
CHECK_AND_FILL_ML_ALICE3(nSigInnTofPi2);
145+
// OUTER TOF PID variables
146+
CHECK_AND_FILL_ML_ALICE3(nSigOutTofPr0);
147+
CHECK_AND_FILL_ML_ALICE3(nSigOutTofKa1);
148+
CHECK_AND_FILL_ML_ALICE3(nSigOutTofPi2);
149+
}
150+
}
151+
return inputFeatures;
152+
}
153+
154+
protected:
155+
/// Method to fill the map of available input features
156+
void setAvailableInputFeatures()
157+
{
158+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
159+
FILL_MAP_3PRONG(ptProng0),
160+
FILL_MAP_3PRONG(ptProng1),
161+
FILL_MAP_3PRONG(ptProng2),
162+
FILL_MAP_3PRONG(impactParameterY0),
163+
FILL_MAP_3PRONG(impactParameterY1),
164+
FILL_MAP_3PRONG(impactParameterY2),
165+
FILL_MAP_3PRONG(impactParameterZ0),
166+
FILL_MAP_3PRONG(impactParameterZ1),
167+
FILL_MAP_3PRONG(impactParameterZ2),
168+
FILL_MAP_3PRONG(decayLength),
169+
FILL_MAP_3PRONG(decayLengthXY),
170+
FILL_MAP_3PRONG(decayLengthXYNormalised),
171+
FILL_MAP_3PRONG(cpa),
172+
FILL_MAP_3PRONG(cpaXY),
173+
FILL_MAP_3PRONG(chi2PCA),
174+
// RICH PID variables
175+
FILL_MAP_3PRONG(nSigRichPr0),
176+
FILL_MAP_3PRONG(nSigRichKa0),
177+
FILL_MAP_3PRONG(nSigRichPi0),
178+
FILL_MAP_3PRONG(nSigRichPr1),
179+
FILL_MAP_3PRONG(nSigRichKa1),
180+
FILL_MAP_3PRONG(nSigRichPi1),
181+
FILL_MAP_3PRONG(nSigRichPr2),
182+
FILL_MAP_3PRONG(nSigRichKa2),
183+
FILL_MAP_3PRONG(nSigRichPi2),
184+
// INNER TOF PID variables
185+
FILL_MAP_3PRONG(nSigInnTofPr0),
186+
FILL_MAP_3PRONG(nSigInnTofKa0),
187+
FILL_MAP_3PRONG(nSigInnTofPi0),
188+
FILL_MAP_3PRONG(nSigInnTofPr1),
189+
FILL_MAP_3PRONG(nSigInnTofKa1),
190+
FILL_MAP_3PRONG(nSigInnTofPi1),
191+
FILL_MAP_3PRONG(nSigInnTofPr2),
192+
FILL_MAP_3PRONG(nSigInnTofKa2),
193+
FILL_MAP_3PRONG(nSigInnTofPi2),
194+
// OUTER TOF PID variables
195+
FILL_MAP_3PRONG(nSigOutTofPr0),
196+
FILL_MAP_3PRONG(nSigOutTofKa0),
197+
FILL_MAP_3PRONG(nSigOutTofPi0),
198+
FILL_MAP_3PRONG(nSigOutTofPr1),
199+
FILL_MAP_3PRONG(nSigOutTofKa1),
200+
FILL_MAP_3PRONG(nSigOutTofPi1),
201+
FILL_MAP_3PRONG(nSigOutTofPr2),
202+
FILL_MAP_3PRONG(nSigOutTofKa2),
203+
FILL_MAP_3PRONG(nSigOutTofPi2),
204+
// TRACKER PID variables
205+
FILL_MAP_3PRONG(nSigTrkPr0),
206+
FILL_MAP_3PRONG(nSigTrkKa0),
207+
FILL_MAP_3PRONG(nSigTrkPi0),
208+
FILL_MAP_3PRONG(nSigTrkPr1),
209+
FILL_MAP_3PRONG(nSigTrkKa1),
210+
FILL_MAP_3PRONG(nSigTrkPi1),
211+
FILL_MAP_3PRONG(nSigTrkPr2),
212+
FILL_MAP_3PRONG(nSigTrkKa2),
213+
FILL_MAP_3PRONG(nSigTrkPi2)};
214+
}
215+
};
216+
217+
} // namespace o2::analysis
218+
219+
#undef FILL_MAP_3PRONG
220+
#undef CHECK_AND_FILL_ML_ALICE3
221+
222+
#endif // ALICE3_ML_HFMLRESPONSE3PRONG_H_

ALICE3/TableProducer/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ o2physics_add_dpl_workflow(alice3-correlatorddbar
4646
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
4747
COMPONENT_NAME Analysis)
4848

49+
o2physics_add_dpl_workflow(alice3-hf-selector-3prong
50+
SOURCES alice3HfSelector3Prong.cxx
51+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::MLCore
52+
COMPONENT_NAME Analysis)
53+
54+
o2physics_add_dpl_workflow(alice3-hf-tree-creator-3prong
55+
SOURCES alice3HfTreeCreator3Prong.cxx
56+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
57+
COMPONENT_NAME Analysis)
58+
4959
o2physics_add_dpl_workflow(alice3-tracking-translator
5060
SOURCES alice3TrackingTranslator.cxx
51-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
61+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
5262
COMPONENT_NAME Analysis)

0 commit comments

Comments
 (0)