Skip to content

Commit d1774aa

Browse files
Yunfan-Liurootalibuildfgrosa
authored
[PWGHF] Add and update ML and efficiency calculations tasks for OmegacToOmegaPi (#9944)
Co-authored-by: root <root@USER-20161104VR.localdomain> Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: Fabrizio <fabrizio.grosa@cern.ch>
1 parent 362f548 commit d1774aa

10 files changed

+692
-56
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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 HfMlResponseOmegacToOmegaPi.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+
16+
#ifndef PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_
17+
#define PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_
18+
19+
#include <map>
20+
#include <string>
21+
#include <vector>
22+
23+
#include "CommonConstants/PhysicsConstants.h"
24+
25+
#include "PWGHF/Core/HfHelper.h"
26+
#include "PWGHF/Core/HfMlResponse.h"
27+
28+
// Fill the map of available input features
29+
// the key is the feature's name (std::string)
30+
// the value is the corresponding value in EnumInputFeatures
31+
#define FILL_MAP_OMEGAC0(FEATURE) \
32+
{ \
33+
#FEATURE, static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE) \
34+
}
35+
36+
// Check if the index of mCachedIndices (index associated to a FEATURE)
37+
// matches the entry in EnumInputFeatures associated to this FEATURE
38+
// if so, the inputFeatures vector is filled with the FEATURE's value
39+
// by calling the corresponding GETTER from OBJECT
40+
#define CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER) \
41+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE): { \
42+
inputFeatures.emplace_back(OBJECT.GETTER()); \
43+
break; \
44+
}
45+
46+
// Specific case of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER)
47+
// where OBJECT is named candidate and FEATURE = GETTER
48+
#define CHECK_AND_FILL_VEC_OMEGAC0(GETTER) \
49+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::GETTER): { \
50+
inputFeatures.emplace_back(candidate.GETTER()); \
51+
break; \
52+
}
53+
54+
// Variation of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER)
55+
// where GETTER is a method of hfHelper
56+
#define CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER(OBJECT, FEATURE, GETTER) \
57+
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE): { \
58+
inputFeatures.emplace_back(hfHelper.GETTER(OBJECT)); \
59+
break; \
60+
}
61+
namespace o2::analysis
62+
{
63+
enum class InputFeaturesOmegacToOmegaPi : uint8_t {
64+
65+
cosPaOmegacToPv = 0,
66+
kfDcaXYPiFromOmegac,
67+
cosThetaStarPiFromOmegac,
68+
chi2TopoPiFromOmegacToPv,
69+
dcaCharmBaryonDau,
70+
invMassCascade,
71+
massCascChi2OverNdf,
72+
cosPaCascToPv,
73+
kfDcaXYCascToPv,
74+
nSigmaTPCPiFromV0,
75+
nSigmaTPCPiFromOmegac,
76+
nSigmaTPCKaFromCasc
77+
78+
};
79+
80+
template <typename TypeOutputScore = float>
81+
class HfMlResponseOmegacToOmegaPi : public HfMlResponse<TypeOutputScore>
82+
{
83+
public:
84+
/// Default constructor
85+
HfMlResponseOmegacToOmegaPi() = default;
86+
/// Default destructor
87+
virtual ~HfMlResponseOmegacToOmegaPi() = default;
88+
89+
HfHelper hfHelper;
90+
91+
/// Method to get the input features vector needed for ML inference
92+
/// \param candidate is the OMEGAC0 candidate
93+
/// \param lamProngPi is the candidate's lamProngPi
94+
/// \return inputFeatures vector
95+
template <typename T1, typename T2, typename T3>
96+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProng, T3 const& charmBaryonProng)
97+
{
98+
std::vector<float> inputFeatures;
99+
100+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
101+
switch (idx) {
102+
103+
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYPiFromOmegac);
104+
CHECK_AND_FILL_VEC_OMEGAC0(cosThetaStarPiFromOmegac);
105+
CHECK_AND_FILL_VEC_OMEGAC0(chi2TopoPiFromOmegacToPv);
106+
CHECK_AND_FILL_VEC_OMEGAC0(dcaCharmBaryonDau);
107+
CHECK_AND_FILL_VEC_OMEGAC0(invMassCascade);
108+
CHECK_AND_FILL_VEC_OMEGAC0(massCascChi2OverNdf);
109+
CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYCascToPv);
110+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaOmegacToPv, cosPACharmBaryon);
111+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaCascToPv, cosPACasc);
112+
// TPC PID variables
113+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(lamProngPi, nSigmaTPCPiFromV0, tpcNSigmaPi);
114+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(cascProng, nSigmaTPCKaFromCasc, tpcNSigmaKa);
115+
CHECK_AND_FILL_VEC_OMEGAC0_FULL(charmBaryonProng, nSigmaTPCPiFromOmegac, tpcNSigmaPi);
116+
}
117+
}
118+
119+
return inputFeatures;
120+
}
121+
122+
protected:
123+
/// Method to fill the map of available input features
124+
void setAvailableInputFeatures()
125+
{
126+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
127+
128+
FILL_MAP_OMEGAC0(invMassCascade),
129+
FILL_MAP_OMEGAC0(cosPaOmegacToPv),
130+
FILL_MAP_OMEGAC0(dcaCharmBaryonDau),
131+
FILL_MAP_OMEGAC0(kfDcaXYPiFromOmegac),
132+
FILL_MAP_OMEGAC0(cosThetaStarPiFromOmegac),
133+
FILL_MAP_OMEGAC0(chi2TopoPiFromOmegacToPv),
134+
FILL_MAP_OMEGAC0(massCascChi2OverNdf),
135+
FILL_MAP_OMEGAC0(cosPaCascToPv),
136+
FILL_MAP_OMEGAC0(kfDcaXYCascToPv),
137+
// TPC PID variables
138+
FILL_MAP_OMEGAC0(nSigmaTPCPiFromV0),
139+
FILL_MAP_OMEGAC0(nSigmaTPCKaFromCasc),
140+
FILL_MAP_OMEGAC0(nSigmaTPCPiFromOmegac),
141+
142+
};
143+
}
144+
};
145+
146+
} // namespace o2::analysis
147+
148+
#undef FILL_MAP_OMEGAC0
149+
#undef CHECK_AND_FILL_VEC_OMEGAC0_FULL
150+
#undef CHECK_AND_FILL_VEC_OMEGAC0
151+
#undef CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER
152+
#endif // PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_

PWGHF/Core/SelectorCuts.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,40 @@ static const std::vector<std::string> labelsPt = {
651651
static const std::vector<std::string> labelsCutVar = {"deltaM", "pT Pi", "pT K", "decay length", "normalized decay length XY", "cos pointing angle", "cos pointing angle XY", "impact parameter XY", "deltaM Phi", "cos^3 theta_PiK", "chi2PCA"};
652652
} // namespace hf_cuts_ds_to_k_k_pi
653653

654+
namespace hf_cuts_omegac_to_omega_pi
655+
{
656+
static constexpr int nBinsPt = 4;
657+
static constexpr int nCutVars = 1;
658+
// default values for the pT bin edges (can be used to configure histogram axis)
659+
// offset by 1 from the bin numbers in cuts array
660+
constexpr double binsPt[nBinsPt + 1] = {
661+
662+
1.0,
663+
2.0,
664+
4.0,
665+
6.0,
666+
12.0};
667+
668+
auto vecBinsPt = std::vector<double>{binsPt, binsPt + nBinsPt + 1};
669+
670+
// default values for the cuts
671+
// pi_pT
672+
constexpr double cuts[nBinsPt][nCutVars] = {{0.2}, /* 1 < pt < 2 */
673+
{0.2}, /* 2 < pt < 4 */
674+
{0.6}, /* 4 < pt < 6 */
675+
{0.8}}; /* 6 < pt < 12 */
676+
677+
// row labels
678+
static const std::vector<std::string> labelsPt = {
679+
"pT bin 0",
680+
"pT bin 1",
681+
"pT bin 2",
682+
"pT bin 3"};
683+
684+
// column labels
685+
static const std::vector<std::string> labelsCutVar = {"pT pi from Omegac"};
686+
} // namespace hf_cuts_omegac_to_omega_pi
687+
654688
namespace hf_cuts_xic_to_p_k_pi
655689
{
656690
static const int nBinsPt = 10;

PWGHF/D2H/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ o2physics_add_dpl_workflow(task-lc-to-k0s-p
9494
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
9595
COMPONENT_NAME Analysis)
9696

97+
o2physics_add_dpl_workflow(task-omegac0-to-omega-pi
98+
SOURCES taskOmegac0ToOmegapi.cxx
99+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
100+
COMPONENT_NAME Analysis)
101+
97102
o2physics_add_dpl_workflow(task-sigmac
98103
SOURCES taskSigmac.cxx
99104
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore

0 commit comments

Comments
 (0)