Skip to content

Commit 7ae589e

Browse files
committed
Add OmegaC ML response QA header
1 parent 3fedfd7 commit 7ae589e

1 file changed

Lines changed: 244 additions & 0 deletions

File tree

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
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 HfMlResponseOmegacToOmegaPiQa.h
13+
/// \brief Class to compute the ML response for Ωc± → Ω∓ π± analysis selections
14+
/// \author Yunfan Liu <yunfan.liu@cern.ch>, China University of Geosciences
15+
/// \author Maria Fernanda Torres Cabrera <maria.fernanda.torres.cabrera@cern.ch>, University of Houston
16+
17+
#ifndef PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPIQA_H_
18+
#define PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPIQA_H_
19+
20+
#include "PWGHF/Core/HfMlResponse.h"
21+
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
22+
23+
#include "Tools/ML/MlResponse.h"
24+
25+
#include <cstdint>
26+
#include <map>
27+
#include <string>
28+
#include <vector>
29+
30+
// Fill the map of available input features
31+
// the key is the feature's name (std::string)
32+
// the value is the corresponding value in EnumInputFeatures
33+
#define FILL_MAP_OMEGAC0(FEATURE) \
34+
{ \
35+
#FEATURE, static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE) \
36+
}
37+
38+
// Check if the index of mCachedIndices (index associated to a FEATURE)
39+
// matches the entry in EnumInputFeatures associated to this FEATURE
40+
// if so, the inputFeatures vector is filled with the FEATURE's value
41+
// by calling the corresponding GETTER from OBJECT
42+
#define CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER) \
43+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE): { \
44+
inputFeatures.emplace_back(OBJECT.GETTER()); \
45+
break; \
46+
}
47+
48+
// Specific case of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER)
49+
// where OBJECT is named candidate and FEATURE = GETTER
50+
#define CHECK_AND_FILL_VEC_OMEGAC0(GETTER) \
51+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::GETTER): { \
52+
inputFeatures.emplace_back(candidate.GETTER()); \
53+
break; \
54+
}
55+
56+
// Variation of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER)
57+
// where GETTER is a method of HfHelper
58+
#define CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER(OBJECT, FEATURE, GETTER) \
59+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE): { \
60+
inputFeatures.emplace_back(HfHelper::GETTER(OBJECT)); \
61+
break; \
62+
}
63+
namespace o2::analysis
64+
{
65+
enum class InputFeaturesOmegacToOmegaPi : uint8_t {
66+
67+
// Common variables
68+
dcaCharmBaryonDau = 0,
69+
dcaCascDau,
70+
nSigmaTPCPiFromV0,
71+
nSigmaTPCPiFromOmegac,
72+
nSigmaTPCKaFromCasc,
73+
74+
// DCAFitter variables
75+
impactParBachFromCharmBaryonXY,
76+
impactParBachFromCharmBaryonZ,
77+
impactParCascXY,
78+
impactParCascZ,
79+
cosPACharmBaryon,
80+
cosPACasc,
81+
82+
// KFPartcile variables
83+
cosPaOmegacToPv,
84+
kfDcaXYPiFromOmegac,
85+
chi2TopoPiFromOmegacToPv,
86+
invMassCascade,
87+
massCascChi2OverNdf,
88+
kfDcaXYCascToPv,
89+
cosPaCascToPv,
90+
cosThetaStarPiFromOmegac,
91+
chi2NdfTopoOmegacToPv,
92+
ldlCasc,
93+
cosPaCascToOmegac,
94+
decayLenXYCasc,
95+
decayLenXYOmegac,
96+
ldlOmegac,
97+
chi2NdfTopoCascToOmegac,
98+
chi2NdfTopoCascToPv,
99+
chi2GeoOmegac,
100+
chi2GeoCasc,
101+
};
102+
103+
template <typename TypeOutputScore = float, hf_cand_casc_lf::ConstructMethod reconstructionType = hf_cand_casc_lf::ConstructMethod::DcaFitter>
104+
class HfMlResponseOmegacToOmegaPi : public HfMlResponse<TypeOutputScore>
105+
{
106+
public:
107+
/// Default constructor
108+
HfMlResponseOmegacToOmegaPi() = default;
109+
/// Default destructor
110+
virtual ~HfMlResponseOmegacToOmegaPi() = default;
111+
112+
/// Method to get the input features vector needed for ML inference
113+
/// \param candidate is the OMEGAC0 candidate
114+
/// \param lamProngPi is the candidate's lamProngPi
115+
/// \return inputFeatures vector
116+
template <typename T1, typename T2, typename T3>
117+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProng, T3 const& charmBaryonProng)
118+
{
119+
std::vector<float> inputFeatures;
120+
121+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
122+
123+
// Variables common to DCAFitter and KFParticle
124+
switch (idx) {
125+
126+
CHECK_AND_FILL_VEC_OMEGAC0(dcaCharmBaryonDau);
127+
CHECK_AND_FILL_VEC_OMEGAC0(dcaCascDau);
128+
// TPC PID variables
129+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(lamProngPi, nSigmaTPCPiFromV0, tpcNSigmaPi);
130+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(cascProng, nSigmaTPCKaFromCasc, tpcNSigmaKa);
131+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(charmBaryonProng, nSigmaTPCPiFromOmegac, tpcNSigmaPi);
132+
}
133+
134+
// DCAFitter variables
135+
if constexpr (reconstructionType == hf_cand_casc_lf::ConstructMethod::DcaFitter) {
136+
137+
switch (idx) {
138+
139+
CHECK_AND_FILL_VEC_OMEGAC0(impactParBachFromCharmBaryonXY);
140+
CHECK_AND_FILL_VEC_OMEGAC0(impactParBachFromCharmBaryonZ);
141+
CHECK_AND_FILL_VEC_OMEGAC0(impactParCascXY);
142+
CHECK_AND_FILL_VEC_OMEGAC0(impactParCascZ);
143+
CHECK_AND_FILL_VEC_OMEGAC0(cosPACharmBaryon);
144+
CHECK_AND_FILL_VEC_OMEGAC0(cosPACasc);
145+
}
146+
}
147+
148+
// KFParticle variables
149+
if constexpr (reconstructionType == hf_cand_casc_lf::ConstructMethod::KfParticle) {
150+
151+
switch (idx) {
152+
153+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaOmegacToPv, cosPACharmBaryon);
154+
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYPiFromOmegac);
155+
CHECK_AND_FILL_VEC_OMEGAC0(chi2TopoPiFromOmegacToPv);
156+
CHECK_AND_FILL_VEC_OMEGAC0(invMassCascade);
157+
CHECK_AND_FILL_VEC_OMEGAC0(massCascChi2OverNdf);
158+
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYCascToPv);
159+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaCascToPv, cosPACasc);
160+
CHECK_AND_FILL_VEC_OMEGAC0(cosThetaStarPiFromOmegac);
161+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoOmegacToPv, chi2TopoOmegacToPv);
162+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlCasc, cascldl);
163+
CHECK_AND_FILL_VEC_OMEGAC0(cosPaCascToOmegac);
164+
CHECK_AND_FILL_VEC_OMEGAC0(decayLenXYCasc);
165+
CHECK_AND_FILL_VEC_OMEGAC0(decayLenXYOmegac);
166+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlOmegac, omegacldl);
167+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToOmegac, chi2TopoCascToOmegac);
168+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToPv, chi2TopoCascToPv);
169+
CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoOmegac);
170+
CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoCasc);
171+
}
172+
}
173+
}
174+
175+
return inputFeatures;
176+
}
177+
178+
protected:
179+
/// Method to fill the map of available input features
180+
void setAvailableInputFeatures()
181+
{
182+
// Common variables
183+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
184+
185+
FILL_MAP_OMEGAC0(dcaCharmBaryonDau),
186+
FILL_MAP_OMEGAC0(dcaCascDau),
187+
FILL_MAP_OMEGAC0(nSigmaTPCPiFromV0),
188+
FILL_MAP_OMEGAC0(nSigmaTPCPiFromOmegac),
189+
FILL_MAP_OMEGAC0(nSigmaTPCKaFromCasc)
190+
};
191+
192+
// DCAFitter variables
193+
if constexpr (reconstructionType == hf_cand_casc_lf::ConstructMethod::DcaFitter) {
194+
195+
std::map<std::string, uint8_t> mapDcaFeatures{
196+
197+
FILL_MAP_OMEGAC0(impactParBachFromCharmBaryonXY),
198+
FILL_MAP_OMEGAC0(impactParBachFromCharmBaryonZ),
199+
FILL_MAP_OMEGAC0(impactParCascXY),
200+
FILL_MAP_OMEGAC0(impactParCascZ),
201+
FILL_MAP_OMEGAC0(cosPACharmBaryon),
202+
FILL_MAP_OMEGAC0(cosPACasc)
203+
};
204+
205+
MlResponse<TypeOutputScore>::mAvailableInputFeatures.insert(mapDcaFeatures.begin(), mapDcaFeatures.end());
206+
}
207+
208+
// KFPartcile variables
209+
if constexpr (reconstructionType == hf_cand_casc_lf::ConstructMethod::KfParticle) {
210+
211+
std::map<std::string, uint8_t> mapKfFeatures{
212+
213+
FILL_MAP_OMEGAC0(cosPaOmegacToPv),
214+
FILL_MAP_OMEGAC0(kfDcaXYPiFromOmegac),
215+
FILL_MAP_OMEGAC0(chi2TopoPiFromOmegacToPv),
216+
FILL_MAP_OMEGAC0(invMassCascade),
217+
FILL_MAP_OMEGAC0(massCascChi2OverNdf),
218+
FILL_MAP_OMEGAC0(kfDcaXYCascToPv),
219+
FILL_MAP_OMEGAC0(cosPaCascToPv),
220+
FILL_MAP_OMEGAC0(cosThetaStarPiFromOmegac),
221+
FILL_MAP_OMEGAC0(chi2NdfTopoOmegacToPv),
222+
FILL_MAP_OMEGAC0(ldlCasc),
223+
FILL_MAP_OMEGAC0(cosPaCascToOmegac),
224+
FILL_MAP_OMEGAC0(decayLenXYCasc),
225+
FILL_MAP_OMEGAC0(decayLenXYOmegac),
226+
FILL_MAP_OMEGAC0(ldlOmegac),
227+
FILL_MAP_OMEGAC0(chi2NdfTopoCascToOmegac),
228+
FILL_MAP_OMEGAC0(chi2NdfTopoCascToPv),
229+
FILL_MAP_OMEGAC0(chi2GeoOmegac),
230+
FILL_MAP_OMEGAC0(chi2GeoCasc)
231+
};
232+
233+
MlResponse<TypeOutputScore>::mAvailableInputFeatures.insert(mapKfFeatures.begin(), mapKfFeatures.end());
234+
}
235+
}
236+
};
237+
238+
} // namespace o2::analysis
239+
240+
#undef FILL_MAP_OMEGAC0
241+
#undef CHECK_AND_FILL_VEC_OMEGAC0_FULL
242+
#undef CHECK_AND_FILL_VEC_OMEGAC0
243+
#undef CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER
244+
#endif // PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPIQA_H_

0 commit comments

Comments
 (0)