Skip to content

Commit a17517d

Browse files
authored
Add HfMlResponseXictoXiPikf.h
1 parent 96938ac commit a17517d

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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 HfMlResponseXicToXiPikf.h
13+
/// \brief Class to compute the ML response for Ξc^0 → Ξ∓ π± analysis selections
14+
/// \author Tao Fang <tao.fang@cern.ch>, Central China Normal University
15+
16+
#ifndef PWGHF_CORE_HFMLRESPONSEXICTOXIPIKF_H_
17+
#define PWGHF_CORE_HFMLRESPONSEXICTOXIPIKF_H_
18+
19+
#include <map>
20+
#include <string>
21+
#include <vector>
22+
23+
#include "PWGHF/Core/HfMlResponse.h"
24+
25+
// Fill the map of available input features
26+
// the key is the feature's name (std::string)
27+
// the value is the corresponding value in EnumInputFeatures
28+
#define FILL_MAP_XICTOXIPI(FEATURE) \
29+
{ \
30+
#FEATURE, static_cast<uint8_t>(InputFeaturesXicToXiPi::FEATURE) \
31+
}
32+
33+
// Check if the index of mCachedIndices (index associated to a FEATURE)
34+
// matches the entry in EnumInputFeatures associated to this FEATURE
35+
// if so, the inputFeatures vector is filled with the FEATURE's value
36+
// by calling the corresponding GETTER from OBJECT
37+
#define CHECK_AND_FILL_VEC_XICTOXIPI_FULL(OBJECT, FEATURE, GETTER) \
38+
case static_cast<uint8_t>(InputFeaturesXicToXiPi::FEATURE): { \
39+
inputFeatures.emplace_back(OBJECT.GETTER()); \
40+
break; \
41+
}
42+
43+
// where OBJECT is named candidate and FEATURE = GETTER
44+
#define CHECK_AND_FILL_VEC_XICTOXIPI(GETTER) \
45+
case static_cast<uint8_t>(InputFeaturesXicToXiPi::GETTER): { \
46+
inputFeatures.emplace_back(candidate.GETTER()); \
47+
break; \
48+
}
49+
50+
namespace o2::analysis
51+
{
52+
53+
enum class InputFeaturesXicToXiPi : uint8_t {
54+
tpcNSigmaPiFromLambda,
55+
tpcNSigmaPiFromCasc,
56+
tpcNSigmaPiFromCharmBaryon,
57+
dcaCascDau,
58+
dcaCharmBaryonDau,
59+
kfDcaXYPiFromXic,
60+
kfDcaXYCascToPv,
61+
cascChi2OverNdf,
62+
xicChi2OverNdf,
63+
cascldl,
64+
chi2TopoCascToPv,
65+
chi2TopoCascToXic,
66+
cosPaCascToXic,
67+
decayLenXYCasc
68+
};
69+
70+
template <typename TypeOutputScore = float>
71+
class HfMlResponseXicToXiPikf : public HfMlResponse<TypeOutputScore>
72+
{
73+
public:
74+
/// Default constructor
75+
HfMlResponseXicToXiPikf() = default;
76+
/// Default destructor
77+
virtual ~HfMlResponseXicToXiPikf() = default;
78+
79+
/// Method to get the input features vector needed for ML inference
80+
/// \param candidate is the Xic candidate
81+
/// \return inputFeatures vector
82+
template <typename T1, typename T2, typename T3>
83+
//std::vector<float> getInputFeatures(T1 const& candidate)
84+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProngPi, T3 const& charmBaryonProngPi)
85+
{
86+
std::vector<float> inputFeatures;
87+
88+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
89+
switch (idx) {
90+
// PID variables
91+
CHECK_AND_FILL_VEC_XICTOXIPI_FULL(lamProngPi, tpcNSigmaPiFromLambda, tpcNSigmaPi);
92+
CHECK_AND_FILL_VEC_XICTOXIPI_FULL(cascProngPi, tpcNSigmaPiFromCasc, tpcNSigmaPi);
93+
CHECK_AND_FILL_VEC_XICTOXIPI_FULL(charmBaryonProngPi, tpcNSigmaPiFromCharmBaryon, tpcNSigmaPi);
94+
// DCA
95+
CHECK_AND_FILL_VEC_XICTOXIPI(dcaCascDau)
96+
CHECK_AND_FILL_VEC_XICTOXIPI(dcaCharmBaryonDau);
97+
CHECK_AND_FILL_VEC_XICTOXIPI(kfDcaXYPiFromXic);
98+
CHECK_AND_FILL_VEC_XICTOXIPI(kfDcaXYCascToPv);
99+
// Chi2Geo
100+
CHECK_AND_FILL_VEC_XICTOXIPI(cascChi2OverNdf);
101+
CHECK_AND_FILL_VEC_XICTOXIPI(xicChi2OverNdf);
102+
// ldl
103+
CHECK_AND_FILL_VEC_XICTOXIPI(cascldl);
104+
// Chi2Topo
105+
CHECK_AND_FILL_VEC_XICTOXIPI(chi2TopoCascToPv);
106+
CHECK_AND_FILL_VEC_XICTOXIPI(chi2TopoCascToXic);
107+
// CosPa
108+
CHECK_AND_FILL_VEC_XICTOXIPI(cosPaCascToXic);
109+
// Decay length
110+
CHECK_AND_FILL_VEC_XICTOXIPI(decayLenXYCasc);
111+
}
112+
}
113+
114+
return inputFeatures;
115+
}
116+
117+
protected:
118+
/// Method to fill the map of available input features
119+
void setAvailableInputFeatures()
120+
{
121+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
122+
FILL_MAP_XICTOXIPI(tpcNSigmaPiFromLambda),
123+
FILL_MAP_XICTOXIPI(tpcNSigmaPiFromCasc),
124+
FILL_MAP_XICTOXIPI(tpcNSigmaPiFromCharmBaryon),
125+
FILL_MAP_XICTOXIPI(dcaCascDau),
126+
FILL_MAP_XICTOXIPI(dcaCharmBaryonDau),
127+
FILL_MAP_XICTOXIPI(kfDcaXYPiFromXic),
128+
FILL_MAP_XICTOXIPI(kfDcaXYCascToPv),
129+
FILL_MAP_XICTOXIPI(cascChi2OverNdf),
130+
FILL_MAP_XICTOXIPI(xicChi2OverNdf),
131+
FILL_MAP_XICTOXIPI(cascldl),
132+
FILL_MAP_XICTOXIPI(chi2TopoCascToPv),
133+
FILL_MAP_XICTOXIPI(chi2TopoCascToXic),
134+
FILL_MAP_XICTOXIPI(cosPaCascToXic),
135+
FILL_MAP_XICTOXIPI(decayLenXYCasc),
136+
};
137+
}
138+
};
139+
140+
} // namespace o2::analysis
141+
142+
#undef FILL_MAP_XICTOXIPI
143+
#undef CHECK_AND_FILL_VEC_XICTOXIPI_FULL
144+
#undef CHECK_AND_FILL_VEC_XICTOXIPI
145+
146+
#endif // PWGHF_CORE_HFMLRESPONSEXICTOXIPIKF_H_

0 commit comments

Comments
 (0)