Skip to content

Commit f852a61

Browse files
committed
Move XiC Qa workflow to new data schema
1 parent 500c5ad commit f852a61

4 files changed

Lines changed: 691 additions & 507 deletions

File tree

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
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 HfMlResponseXic0ToXiPiQa.h
13+
/// \brief Class to compute the ML response for XiC0 to Xi Pi selections
14+
/// \author Fabio Catalano <fabio.catalano@cern.ch>, University of Houston
15+
16+
#ifndef PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIQA_H_
17+
#define PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIQA_H_
18+
19+
#include "PWGHF/Core/HfMlResponse.h"
20+
#include "PWGHF/DataModel/CandidateReconstructionTablesQa.h"
21+
22+
#include "Tools/ML/MlResponse.h"
23+
24+
#include <cstdint>
25+
#include <map>
26+
#include <string>
27+
#include <vector>
28+
29+
// Fill the map of available input features
30+
// the key is the feature's name (std::string)
31+
// the value is the corresponding value in EnumInputFeatures
32+
#define FILL_MAP_XIC0(FEATURE) \
33+
{ \
34+
#FEATURE, static_cast<uint8_t>(InputFeaturesXic0ToXiPiQa::FEATURE)}
35+
36+
// Specific case of CHECK_AND_FILL_VEC_XIC0_FULL(OBJECT, FEATURE, GETTER)
37+
// where OBJECT is candidate and FEATURE = GETTER
38+
#define CHECK_AND_FILL_VEC_XIC0(GETTER) \
39+
case static_cast<uint8_t>(InputFeaturesXic0ToXiPiQa::GETTER): { \
40+
inputFeatures.emplace_back(candidate.GETTER()); \
41+
break; \
42+
}
43+
44+
// Check whether the cached feature index matches FEATURE, then append
45+
// OBJECT.GETTER() to the input feature vector
46+
#define CHECK_AND_FILL_VEC_XIC0_FULL(OBJECT, FEATURE, GETTER) \
47+
case static_cast<uint8_t>(InputFeaturesXic0ToXiPiQa::FEATURE): { \
48+
inputFeatures.emplace_back(OBJECT.GETTER()); \
49+
break; \
50+
}
51+
52+
// Variation of CHECK_AND_FILL_VEC_XIC0_FULL for HfHelper methods
53+
#define CHECK_AND_FILL_VEC_XIC0_HFHELPER(OBJECT, FEATURE, GETTER) \
54+
case static_cast<uint8_t>(InputFeaturesXic0ToXiPiQa::FEATURE): { \
55+
inputFeatures.emplace_back(HfHelperQa::GETTER(OBJECT)); \
56+
break; \
57+
}
58+
59+
namespace o2::analysis
60+
{
61+
enum class InputFeaturesXic0ToXiPiQa : uint8_t {
62+
// Common variables
63+
impactParameterXYCharmBachelor = 0,
64+
impactParameterZCharmBachelor,
65+
impactParameterXYCascade,
66+
impactParameterZCascade,
67+
impactParameterXYCascadeBach,
68+
impactParameterXYV0PosDau,
69+
impactParameterXYV0NegDau,
70+
dcaDaughters,
71+
dcaCascadeDaughters,
72+
dcaV0Daughters,
73+
cpa,
74+
cpaCascade,
75+
cpaV0,
76+
cpaCascadeToCharmHadron,
77+
cpaV0ToCascade,
78+
cosThetaStarPiFromXic0,
79+
decayLengthXY,
80+
decayLengthXYCascade,
81+
decayLengthXYV0,
82+
nSigmaTPCPiFromV0,
83+
nSigmaTPCPrFromV0,
84+
nSigmaTPCPiFromXic0,
85+
nSigmaTPCPiFromCasc,
86+
87+
// KFParticle variables
88+
decayLengthNormKf,
89+
decayLengthNormKfCascade,
90+
chi2GeoOverNdf,
91+
chi2TopoOverNdfToPv,
92+
chi2GeoOverNdfCascade,
93+
chi2TopoOverNdfCascadeToCharmHadron,
94+
chi2TopoOverNdfCascadeToPv,
95+
chi2GeoOverNdfV0,
96+
chi2TopoOverNdfV0ToPv,
97+
chi2TopoOverNdfV0ToCascade
98+
99+
// Legacy KF inputs not stored in the shared QA candidate tables
100+
// chi2TopoPiFromXicToPv,
101+
// kfptPiFromXic
102+
};
103+
104+
template <typename TypeOutputScore = float, aod::hf_cand_casc_lf::ConstructMethod reconstructionType = aod::hf_cand_casc_lf::ConstructMethod::DcaFitter>
105+
class HfMlResponseXic0ToXiPiQa : public HfMlResponse<TypeOutputScore>
106+
{
107+
public:
108+
HfMlResponseXic0ToXiPiQa() = default;
109+
virtual ~HfMlResponseXic0ToXiPiQa() = default;
110+
111+
/// Method to get the input features vector needed for ML inference
112+
/// \param candidate is the XiC0 candidate
113+
/// \param lamProngPi is the candidate's pion from the Lambda decay
114+
/// \param lamProngPr is the candidate's proton from the Lambda decay
115+
/// \param cascProng is the bachelor track from the Xi decay
116+
/// \param charmBaryonProng is the bachelor pion from the XiC decay
117+
/// \return inputFeatures vector
118+
template <typename T1, typename T2, typename T3>
119+
std::vector<float> getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& lamProngPr,
120+
T2 const& cascProng, T3 const& charmBaryonProng)
121+
{
122+
std::vector<float> inputFeatures;
123+
inputFeatures.reserve(MlResponse<TypeOutputScore>::mCachedIndices.size());
124+
125+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
126+
127+
// Variables common to DCAFitter and KFParticle
128+
switch (idx) {
129+
CHECK_AND_FILL_VEC_XIC0_FULL(candidate, impactParameterXYCharmBachelor, impactParameter1);
130+
CHECK_AND_FILL_VEC_XIC0_FULL(candidate, impactParameterZCharmBachelor, impactParameterZ1);
131+
CHECK_AND_FILL_VEC_XIC0_FULL(candidate, impactParameterXYCascade, impactParameter0);
132+
CHECK_AND_FILL_VEC_XIC0_FULL(candidate, impactParameterZCascade, impactParameterZ0);
133+
CHECK_AND_FILL_VEC_XIC0(impactParameterXYCascadeBach);
134+
CHECK_AND_FILL_VEC_XIC0(impactParameterXYV0PosDau);
135+
CHECK_AND_FILL_VEC_XIC0(impactParameterXYV0NegDau);
136+
CHECK_AND_FILL_VEC_XIC0(dcaDaughters);
137+
CHECK_AND_FILL_VEC_XIC0(dcaCascadeDaughters);
138+
CHECK_AND_FILL_VEC_XIC0(dcaV0Daughters);
139+
CHECK_AND_FILL_VEC_XIC0(cpa);
140+
CHECK_AND_FILL_VEC_XIC0(cpaCascade);
141+
CHECK_AND_FILL_VEC_XIC0(cpaV0);
142+
CHECK_AND_FILL_VEC_XIC0(cpaCascadeToCharmHadron);
143+
CHECK_AND_FILL_VEC_XIC0(cpaV0ToCascade);
144+
CHECK_AND_FILL_VEC_XIC0_HFHELPER(candidate, cosThetaStarPiFromXic0, cosThetaStarXiczeroToXiPi);
145+
CHECK_AND_FILL_VEC_XIC0(decayLengthXY);
146+
CHECK_AND_FILL_VEC_XIC0(decayLengthXYCascade);
147+
CHECK_AND_FILL_VEC_XIC0(decayLengthXYV0);
148+
CHECK_AND_FILL_VEC_XIC0_FULL(lamProngPi, nSigmaTPCPiFromV0, tpcNSigmaPi);
149+
CHECK_AND_FILL_VEC_XIC0_FULL(lamProngPr, nSigmaTPCPrFromV0, tpcNSigmaPr);
150+
CHECK_AND_FILL_VEC_XIC0_FULL(charmBaryonProng, nSigmaTPCPiFromXic0, tpcNSigmaPi);
151+
CHECK_AND_FILL_VEC_XIC0_FULL(cascProng, nSigmaTPCPiFromCasc, tpcNSigmaPi);
152+
}
153+
154+
// KFParticle variables
155+
if constexpr (reconstructionType == aod::hf_cand_casc_lf::ConstructMethod::KfParticle) {
156+
switch (idx) {
157+
CHECK_AND_FILL_VEC_XIC0(decayLengthNormKf);
158+
CHECK_AND_FILL_VEC_XIC0(decayLengthNormKfCascade);
159+
CHECK_AND_FILL_VEC_XIC0(chi2GeoOverNdf);
160+
CHECK_AND_FILL_VEC_XIC0(chi2TopoOverNdfToPv);
161+
CHECK_AND_FILL_VEC_XIC0(chi2GeoOverNdfCascade);
162+
CHECK_AND_FILL_VEC_XIC0(chi2TopoOverNdfCascadeToCharmHadron);
163+
CHECK_AND_FILL_VEC_XIC0(chi2TopoOverNdfCascadeToPv);
164+
CHECK_AND_FILL_VEC_XIC0(chi2GeoOverNdfV0);
165+
CHECK_AND_FILL_VEC_XIC0(chi2TopoOverNdfV0ToPv);
166+
CHECK_AND_FILL_VEC_XIC0(chi2TopoOverNdfV0ToCascade);
167+
}
168+
}
169+
}
170+
171+
return inputFeatures;
172+
}
173+
174+
protected:
175+
/// Method to fill the map of available input features
176+
void setAvailableInputFeatures()
177+
{
178+
// Common variables
179+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
180+
FILL_MAP_XIC0(impactParameterXYCharmBachelor),
181+
FILL_MAP_XIC0(impactParameterZCharmBachelor),
182+
FILL_MAP_XIC0(impactParameterXYCascade),
183+
FILL_MAP_XIC0(impactParameterZCascade),
184+
FILL_MAP_XIC0(impactParameterXYCascadeBach),
185+
FILL_MAP_XIC0(impactParameterXYV0PosDau),
186+
FILL_MAP_XIC0(impactParameterXYV0NegDau),
187+
FILL_MAP_XIC0(dcaDaughters),
188+
FILL_MAP_XIC0(dcaCascadeDaughters),
189+
FILL_MAP_XIC0(dcaV0Daughters),
190+
FILL_MAP_XIC0(cpa),
191+
FILL_MAP_XIC0(cpaCascade),
192+
FILL_MAP_XIC0(cpaV0),
193+
FILL_MAP_XIC0(cpaCascadeToCharmHadron),
194+
FILL_MAP_XIC0(cpaV0ToCascade),
195+
FILL_MAP_XIC0(cosThetaStarPiFromXic0),
196+
FILL_MAP_XIC0(decayLengthXY),
197+
FILL_MAP_XIC0(decayLengthXYCascade),
198+
FILL_MAP_XIC0(decayLengthXYV0),
199+
FILL_MAP_XIC0(nSigmaTPCPiFromV0),
200+
FILL_MAP_XIC0(nSigmaTPCPrFromV0),
201+
FILL_MAP_XIC0(nSigmaTPCPiFromXic0),
202+
FILL_MAP_XIC0(nSigmaTPCPiFromCasc)};
203+
204+
// KFParticle variables
205+
if constexpr (reconstructionType == aod::hf_cand_casc_lf::ConstructMethod::KfParticle) {
206+
std::map<std::string, uint8_t> mapKfFeatures{
207+
FILL_MAP_XIC0(decayLengthNormKf),
208+
FILL_MAP_XIC0(decayLengthNormKfCascade),
209+
FILL_MAP_XIC0(chi2GeoOverNdf),
210+
FILL_MAP_XIC0(chi2TopoOverNdfToPv),
211+
FILL_MAP_XIC0(chi2GeoOverNdfCascade),
212+
FILL_MAP_XIC0(chi2TopoOverNdfCascadeToCharmHadron),
213+
FILL_MAP_XIC0(chi2TopoOverNdfCascadeToPv),
214+
FILL_MAP_XIC0(chi2GeoOverNdfV0),
215+
FILL_MAP_XIC0(chi2TopoOverNdfV0ToPv),
216+
FILL_MAP_XIC0(chi2TopoOverNdfV0ToCascade)};
217+
218+
MlResponse<TypeOutputScore>::mAvailableInputFeatures.insert(mapKfFeatures.begin(), mapKfFeatures.end());
219+
}
220+
}
221+
};
222+
223+
} // namespace o2::analysis
224+
225+
#undef FILL_MAP_XIC0
226+
#undef CHECK_AND_FILL_VEC_XIC0
227+
#undef CHECK_AND_FILL_VEC_XIC0_FULL
228+
#undef CHECK_AND_FILL_VEC_XIC0_HFHELPER
229+
230+
#endif // PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIQA_H_

‎PWGHF/DataModel/CandidateReconstructionTablesQa.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ DECLARE_SOA_TABLE(HfSelOmegaC0ToOmegaPi, "AOD", "HFSELOMEGAC0", //!
317317

318318
DECLARE_SOA_TABLE(HfMlOmegaC0ToOmegaPi, "AOD", "HFMLOMEGAC0", //!
319319
hf_sel_candidate_omegac0_qa::MlProbOmegaC0ToOmegaPi);
320+
321+
namespace hf_sel_candidate_to_xi_pi_qa
322+
{
323+
DECLARE_SOA_COLUMN(IsSelToXiPi, isSelToXiPi, int); //!
324+
DECLARE_SOA_COLUMN(MlProbToXiPi, mlProbToXiPi, std::vector<float>); //!
325+
} // namespace hf_sel_candidate_to_xi_pi_qa
326+
327+
DECLARE_SOA_TABLE(HfSelToXiPiQa, "AOD", "HFSELTOXIPIQA", //!
328+
hf_sel_candidate_to_xi_pi_qa::IsSelToXiPi);
329+
330+
DECLARE_SOA_TABLE(HfMlToXiPiQa, "AOD", "HFMLTOXIPIQA", //!
331+
hf_sel_candidate_to_xi_pi_qa::MlProbToXiPi);
320332
} // namespace o2::aod
321333

322334
namespace o2::hf_decay

0 commit comments

Comments
 (0)