Skip to content

Commit 7170abe

Browse files
Tao-Fangalibuild
andauthored
[PWGHF] Add ML to Xic0ToXiPi DCA Filter analysis (#12758)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 937021c commit 7170abe

File tree

9 files changed

+411
-100
lines changed

9 files changed

+411
-100
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
cosPACasc,
62+
cosPAV0,
63+
impactParBachFromCharmBaryonXY,
64+
impactParCascXY
65+
};
66+
67+
template <typename TypeOutputScore = float>
68+
class HfMlResponseXic0ToXiPi : public HfMlResponse<TypeOutputScore>
69+
{
70+
public:
71+
/// Default constructor
72+
HfMlResponseXic0ToXiPi() = default;
73+
/// Default destructor
74+
virtual ~HfMlResponseXic0ToXiPi() = default;
75+
76+
/// Method to get the input features vector needed for ML inference
77+
/// \param candidate is the Xic0 candidate
78+
/// \return inputFeatures vector
79+
template <typename T1, typename T2, typename T3>
80+
// std::vector<float> getInputFeatures(T1 const& candidate)
81+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProngPi, T3 const& charmBaryonProngPi)
82+
{
83+
std::vector<float> inputFeatures;
84+
85+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
86+
switch (idx) {
87+
// PID variables
88+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(lamProngPi, tpcNSigmaPiFromLambda, tpcNSigmaPi);
89+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(cascProngPi, tpcNSigmaPiFromCasc, tpcNSigmaPi);
90+
CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL(charmBaryonProngPi, tpcNSigmaPiFromCharmBaryon, tpcNSigmaPi);
91+
// DCA
92+
CHECK_AND_FILL_VEC_XIC0TOXIPI(dcaCascDau);
93+
CHECK_AND_FILL_VEC_XIC0TOXIPI(dcaCharmBaryonDau);
94+
// CosPA
95+
CHECK_AND_FILL_VEC_XIC0TOXIPI(cosPACharmBaryon);
96+
CHECK_AND_FILL_VEC_XIC0TOXIPI(cosPACasc);
97+
CHECK_AND_FILL_VEC_XIC0TOXIPI(cosPAV0);
98+
// ImpactPar
99+
CHECK_AND_FILL_VEC_XIC0TOXIPI(impactParBachFromCharmBaryonXY);
100+
CHECK_AND_FILL_VEC_XIC0TOXIPI(impactParCascXY);
101+
}
102+
}
103+
104+
return inputFeatures;
105+
}
106+
107+
protected:
108+
/// Method to fill the map of available input features
109+
void setAvailableInputFeatures()
110+
{
111+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
112+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromLambda),
113+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromCasc),
114+
FILL_MAP_XIC0TOXIPI(tpcNSigmaPiFromCharmBaryon),
115+
FILL_MAP_XIC0TOXIPI(dcaCascDau),
116+
FILL_MAP_XIC0TOXIPI(dcaCharmBaryonDau),
117+
FILL_MAP_XIC0TOXIPI(cosPACharmBaryon),
118+
FILL_MAP_XIC0TOXIPI(cosPACasc),
119+
FILL_MAP_XIC0TOXIPI(cosPAV0),
120+
FILL_MAP_XIC0TOXIPI(impactParBachFromCharmBaryonXY),
121+
FILL_MAP_XIC0TOXIPI(impactParCascXY)};
122+
}
123+
};
124+
125+
} // namespace o2::analysis
126+
127+
#undef FILL_MAP_XIC0TOXIPI
128+
#undef CHECK_AND_FILL_VEC_XIC0TOXIPI_FULL
129+
#undef CHECK_AND_FILL_VEC_XIC0TOXIPI
130+
131+
#endif // PWGHF_CORE_HFMLRESPONSEXIC0TOXIPI_H_

PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct HfTaskFlowCharmHadrons {
133133
using CandXicData = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelXicToPKPi>>;
134134
using CandXicDataWMl = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelXicToPKPi, aod::HfMlXicToPKPi>>;
135135
using CandXic0Data = soa::Filtered<soa::Join<aod::HfCandToXiPiKf, aod::HfSelToXiPiKf>>;
136-
using CandXic0DataWMl = soa::Filtered<soa::Join<aod::HfCandToXiPiKf, aod::HfSelToXiPiKf, aod::HfMlToXiPiKf>>;
136+
using CandXic0DataWMl = soa::Filtered<soa::Join<aod::HfCandToXiPiKf, aod::HfSelToXiPiKf, aod::HfMlToXiPi>>;
137137
using CandD0DataWMl = soa::Filtered<soa::Join<aod::HfCand2Prong, aod::HfSelD0, aod::HfMlD0>>;
138138
using CandD0Data = soa::Filtered<soa::Join<aod::HfCand2Prong, aod::HfSelD0>>;
139139
using CollsWithQvecs = soa::Join<aod::Collisions, aod::EvSels, aod::QvectorFT0Cs, aod::QvectorFT0As, aod::QvectorFT0Ms, aod::QvectorFV0As, aod::QvectorBPoss, aod::QvectorBNegs, aod::QvectorBTots, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs>;

0 commit comments

Comments
 (0)