Skip to content

Commit 6e87a8d

Browse files
MarcellocostiMarcello Di Costanzo
authored andcommitted
Implement task and tree creator for HF 3-prong candidates in ALICE3
1 parent e4fc6cf commit 6e87a8d

File tree

12 files changed

+2316
-146
lines changed

12 files changed

+2316
-146
lines changed

ALICE3/DataModel/A3DecayFinderTables.h

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

ALICE3/TableProducer/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ o2physics_add_dpl_workflow(alice3-correlatorddbar
4545
SOURCES alice3-correlatorDDbar.cxx
4646
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter
4747
COMPONENT_NAME Analysis)
48+
49+
o2physics_add_dpl_workflow(alice3-selector-3prong
50+
SOURCES alice3-selector3prong.cxx
51+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::MLCore
52+
COMPONENT_NAME Analysis)
53+
54+
o2physics_add_dpl_workflow(alice3-tree-creator-3prong
55+
SOURCES alice3-treecreator3prong.cxx
56+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::MLCore
57+
COMPONENT_NAME Analysis)

0 commit comments

Comments
 (0)