Skip to content

Commit dbc579b

Browse files
authored
Add files via upload
1 parent eff8922 commit dbc579b

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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 HfMlResponseXic0ToXiPi.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_HFMLRESPONSEXIC0TOXIPI_H_
17+
#define PWGHF_CORE_HFMLRESPONSEXIC0TOXIPI_H_
18+
19+
#include "PWGHF/Core/HfMlResponse.h"
20+
21+
#include "Tools/ML/MlResponse.h"
22+
23+
#include <cstdint>
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_XIC0TOXIPI(FEATURE) \
30+
{ \
31+
#FEATURE, static_cast<uint8_t>(InputFeaturesXic0ToXiPi::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_XIC0TOXIPI_FULL(OBJECT, FEATURE, GETTER) \
39+
case static_cast<uint8_t>(InputFeaturesXic0ToXiPi::FEATURE): { \
40+
inputFeatures.emplace_back(OBJECT.GETTER()); \
41+
break; \
42+
}
43+
44+
// where OBJECT is named candidate and FEATURE = GETTER
45+
#define CHECK_AND_FILL_VEC_XIC0TOXIPI(GETTER) \
46+
case static_cast<uint8_t>(InputFeaturesXic0ToXiPi::GETTER): { \
47+
inputFeatures.emplace_back(candidate.GETTER()); \
48+
break; \
49+
}
50+
51+
namespace o2::analysis
52+
{
53+
54+
enum class InputFeaturesXic0ToXiPi : uint8_t {
55+
tpcNSigmaPiFromLambda,
56+
tpcNSigmaPiFromCasc,
57+
tpcNSigmaPiFromCharmBaryon,
58+
dcaCascDau,
59+
dcaCharmBaryonDau,
60+
cosPACharmBaryon,
61+
cosPAV0,
62+
impactParBachFromCharmBaryonXY,
63+
impactParCascXY
64+
};
65+
66+
template <typename TypeOutputScore = float>
67+
class HfMlResponseXic0ToXiPi : public HfMlResponse<TypeOutputScore>
68+
{
69+
public:
70+
/// Default constructor
71+
HfMlResponseXic0ToXiPi() = default;
72+
/// Default destructor
73+
virtual ~HfMlResponseXic0ToXiPi() = default;
74+
75+
/// Method to get the input features vector needed for ML inference
76+
/// \param candidate is the Xic0 candidate
77+
/// \return inputFeatures vector
78+
template <typename T1, typename T2, typename T3>
79+
// std::vector<float> getInputFeatures(T1 const& candidate)
80+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProngPi, T3 const& charmBaryonProngPi)
81+
{
82+
std::vector<float> inputFeatures;
83+
84+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
85+
switch (idx) {
86+
// PID variables
87+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(lamProngPi, tpcNSigmaPiFromLambda, tpcNSigmaPi);
88+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(cascProngPi, tpcNSigmaPiFromCasc, tpcNSigmaPi);
89+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(charmBaryonProngPi, tpcNSigmaPiFromCharmBaryon, tpcNSigmaPi);
90+
// DCA
91+
CHECK_AND_FILL_VEC_XIC0TOXIPI(dcaCascDau);
92+
CHECK_AND_FILL_VEC_XIC0TOXIPI(dcaCharmBaryonDau);
93+
// CosPA
94+
CHECK_AND_FILL_VEC_XIC0TOXIPI(cosPACharmBaryon);
95+
CHECK_AND_FILL_VEC_XIC0TOXIPI(cosPAV0);
96+
// ImpactPar
97+
CHECK_AND_FILL_VEC_XIC0TOXIPI(impactParBachFromCharmBaryonXY);
98+
CHECK_AND_FILL_VEC_XIC0TOXIPI(impactParCascXY);
99+
}
100+
}
101+
102+
return inputFeatures;
103+
}
104+
105+
protected:
106+
/// Method to fill the map of available input features
107+
void setAvailableInputFeatures()
108+
{
109+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
110+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromLambda),
111+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromCasc),
112+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromCharmBaryon),
113+
FILL_MAP_XIC0TOXIPI(dcaCascDau),
114+
FILL_MAP_XIC0TOXIPI(dcaCharmBaryonDau),
115+
FILL_MAP_XIC0TOXIPI(cosPACharmBaryon),
116+
FILL_MAP_XIC0TOXIPI(cosPAV0),
117+
FILL_MAP_XIC0TOXIPI(impactParBachFromCharmBaryonXY),
118+
FILL_MAP_XIC0TOXIPI(impactParCascXY)
119+
};
120+
}
121+
};
122+
123+
} // namespace o2::analysis
124+
125+
#undef FILL_MAP_XIC0TOXIPI
126+
#undef CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL
127+
#undef CHECK_AND_FILL_VEC_XIC0TOXIPI
128+
129+
#endif // PWGHF_CORE_HFMLRESPONSEXIC0TOXIPI_H_

0 commit comments

Comments
 (0)