Skip to content

Commit 4fe199a

Browse files
committed
Add selections to B+ task
1 parent b583bf3 commit 4fe199a

File tree

7 files changed

+494
-28
lines changed

7 files changed

+494
-28
lines changed

PWGHF/Core/HfHelper.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,106 @@ class HfHelper
877877
return true;
878878
}
879879

880+
// Apply topological cuts as defined in SelectorCuts.h
881+
/// \param candBp B+ candidate
882+
/// \param cuts B+ candidate selection per pT bin"
883+
/// \param binsPt pT bin limits
884+
/// \return true if candidate passes all selections
885+
template <typename T1, typename T2, typename T3>
886+
bool selectionBplusToJPsiKTopol(const T1& candBp, const T2& cuts, const T3& binsPt)
887+
{
888+
auto ptcandBp = candBp.pt();
889+
auto mcandBp = invMassBplusToJPsiK(candBp);
890+
auto ptJPsi = RecoDecay::pt(candBp.pxProng0(), candBp.pyProng0());
891+
auto ptKa = RecoDecay::pt(candBp.pxProng1(), candBp.pyProng1());
892+
auto candJPsi = candBp.jPsi();
893+
float pseudoPropDecLen = candBp.decayLengthXY() * mcandBp / ptcandBp;
894+
895+
int pTBin = o2::analysis::findBin(binsPt, ptcandBp);
896+
if (pTBin == -1) {
897+
return false;
898+
}
899+
900+
// B+ mass cut
901+
if (std::abs(mcandBp - o2::constants::physics::MassBPlus) > cuts->get(pTBin, "m")) {
902+
return false;
903+
}
904+
905+
// kaon pt
906+
if (ptKa < cuts->get(pTBin, "pT K")) {
907+
return false;
908+
}
909+
910+
// J/Psi pt
911+
if (ptJPsi < cuts->get(pTBin, "pT J/Psi")) {
912+
return false;
913+
}
914+
915+
// J/Psi mass
916+
if (std::abs(candJPsi.m() - o2::constants::physics::MassJPsi) < cuts->get(pTBin, "DeltaM J/Psi")) {
917+
return false;
918+
}
919+
920+
// d0(J/Psi)xd0(K)
921+
if (candBp.impactParameterProduct() > cuts->get(pTBin, "B Imp. Par. Product")) {
922+
return false;
923+
}
924+
925+
// B+ Decay length
926+
if (candBp.decayLength() < cuts->get(pTBin, "B decLen")) {
927+
return false;
928+
}
929+
930+
// B+ Decay length XY
931+
if (candBp.decayLengthXY() < cuts->get(pTBin, "B decLenXY")) {
932+
return false;
933+
}
934+
935+
// B+ CPA cut
936+
if (candBp.cpa() < cuts->get(pTBin, "CPA")) {
937+
return false;
938+
}
939+
940+
// B+ CPAXY cut
941+
if (candBp.cpaXY() < cuts->get(pTBin, "CPAXY")) {
942+
return false;
943+
}
944+
945+
// d0 of K
946+
if (std::abs(candBp.impactParameter1()) < cuts->get(pTBin, "d0 K")) {
947+
return false;
948+
}
949+
950+
// d0 of J/Psi
951+
if (std::abs(candBp.impactParameter0()) < cuts->get(pTBin, "d0 J/Psi")) {
952+
return false;
953+
}
954+
955+
// B pseudoproper decay length
956+
if (pseudoPropDecLen < cuts->get(pTBin, "B pseudoprop. decLen")) {
957+
return false;
958+
}
959+
960+
return true;
961+
}
962+
963+
/// Apply PID selection
964+
/// \param pidTrackKa PID status of trackKa (prong1 of B+ candidate)
965+
/// \param acceptPIDNotApplicable switch to accept Status::NotApplicable
966+
/// \return true if prong1 of B+ candidate passes all selections
967+
template <typename T1 = int, typename T2 = bool>
968+
bool selectionBplusToJPsiKPid(const T1& pidTrackKa, const T2& acceptPIDNotApplicable)
969+
{
970+
if (!acceptPIDNotApplicable && pidTrackKa != TrackSelectorPID::Accepted) {
971+
return false;
972+
}
973+
if (acceptPIDNotApplicable && pidTrackKa == TrackSelectorPID::Rejected) {
974+
return false;
975+
}
976+
977+
return true;
978+
}
979+
880980
/// Apply topological cuts as defined in SelectorCuts.h
881981
/// \param candBs Bs candidate
882982
/// \param cuts Bs candidate selections
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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 HfMlResponseBplusToJPsiKReduced.h
13+
/// \brief Class to compute the ML response for B± → J/Psi K± analysis selections in the reduced format
14+
/// \author Fabrizio Chinu <fabrizio.chinu@cern.ch>, Università degli Studi and INFN Torino
15+
16+
#ifndef PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_
17+
#define PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_
18+
19+
#include <map>
20+
#include <string>
21+
#include <vector>
22+
23+
#include "PWGHF/Core/HfMlResponse.h"
24+
#include "PWGHF/D2H/Utils/utilsRedDataFormat.h"
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_BPLUS(FEATURE) \
30+
{ \
31+
#FEATURE, static_cast<uint8_t>(InputFeaturesBplusToJPsiKReduced::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_BPLUS_FULL(OBJECT, FEATURE, GETTER) \
39+
case static_cast<uint8_t>(InputFeaturesBplusToJPsiKReduced::FEATURE): { \
40+
inputFeatures.emplace_back(OBJECT.GETTER()); \
41+
break; \
42+
}
43+
44+
// Check if the index of mCachedIndices (index associated to a FEATURE)
45+
// matches the entry in EnumInputFeatures associated to this FEATURE
46+
// if so, the inputFeatures vector is filled with the FEATURE's value
47+
// by calling the GETTER function taking OBJECT in argument
48+
#define CHECK_AND_FILL_VEC_BPLUS_FUNC(OBJECT, FEATURE, GETTER) \
49+
case static_cast<uint8_t>(InputFeaturesBplusToJPsiKReduced::FEATURE): { \
50+
inputFeatures.emplace_back(GETTER(OBJECT)); \
51+
break; \
52+
}
53+
54+
// Specific case of CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER)
55+
// where OBJECT is named candidate and FEATURE = GETTER
56+
#define CHECK_AND_FILL_VEC_BPLUS(GETTER) \
57+
case static_cast<uint8_t>(InputFeaturesBplusToJPsiKReduced::GETTER): { \
58+
inputFeatures.emplace_back(candidate.GETTER()); \
59+
break; \
60+
}
61+
62+
namespace o2::analysis
63+
{
64+
65+
enum class InputFeaturesBplusToJPsiKReduced : uint8_t {
66+
ptProng0 = 0,
67+
ptProng1,
68+
impactParameter0,
69+
impactParameter1,
70+
impactParameterProduct,
71+
chi2PCA,
72+
decayLength,
73+
decayLengthXY,
74+
decayLengthNormalised,
75+
decayLengthXYNormalised,
76+
cpa,
77+
cpaXY,
78+
maxNormalisedDeltaIP,
79+
tpcNSigmaKa1,
80+
tofNSigmaKa1,
81+
tpcTofNSigmaKa1
82+
};
83+
84+
template <typename TypeOutputScore = float>
85+
class HfMlResponseBplusToJPsiKReduced : public HfMlResponse<TypeOutputScore>
86+
{
87+
public:
88+
/// Default constructor
89+
HfMlResponseBplusToJPsiKReduced() = default;
90+
/// Default destructor
91+
virtual ~HfMlResponseBplusToJPsiKReduced() = default;
92+
93+
/// Method to get the input features vector needed for ML inference
94+
/// \param candidate is the B+ candidate
95+
/// \param prong1 is the candidate's prong1
96+
/// \return inputFeatures vector
97+
template <typename T1, typename T2>
98+
std::vector<float> getInputFeatures(T1 const& candidate,
99+
T2 const& prong1)
100+
{
101+
std::vector<float> inputFeatures;
102+
103+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
104+
switch (idx) {
105+
CHECK_AND_FILL_VEC_BPLUS(ptProng0);
106+
CHECK_AND_FILL_VEC_BPLUS(ptProng1);
107+
CHECK_AND_FILL_VEC_BPLUS(impactParameter0);
108+
CHECK_AND_FILL_VEC_BPLUS(impactParameter1);
109+
CHECK_AND_FILL_VEC_BPLUS(impactParameterProduct);
110+
CHECK_AND_FILL_VEC_BPLUS(chi2PCA);
111+
CHECK_AND_FILL_VEC_BPLUS(decayLength);
112+
CHECK_AND_FILL_VEC_BPLUS(decayLengthXY);
113+
CHECK_AND_FILL_VEC_BPLUS(decayLengthNormalised);
114+
CHECK_AND_FILL_VEC_BPLUS(decayLengthXYNormalised);
115+
CHECK_AND_FILL_VEC_BPLUS(cpa);
116+
CHECK_AND_FILL_VEC_BPLUS(cpaXY);
117+
CHECK_AND_FILL_VEC_BPLUS(maxNormalisedDeltaIP);
118+
// TPC PID variable
119+
CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tpcNSigmaKa1, tpcNSigmaKa);
120+
// TOF PID variable
121+
CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tofNSigmaKa1, tofNSigmaKa);
122+
// Combined PID variables
123+
CHECK_AND_FILL_VEC_BPLUS_FUNC(prong1, tpcTofNSigmaKa1, o2::pid_tpc_tof_utils::getTpcTofNSigmaKa1);
124+
}
125+
}
126+
127+
return inputFeatures;
128+
}
129+
130+
protected:
131+
/// Method to fill the map of available input features
132+
void setAvailableInputFeatures()
133+
{
134+
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
135+
FILL_MAP_BPLUS(ptProng0),
136+
FILL_MAP_BPLUS(ptProng1),
137+
FILL_MAP_BPLUS(impactParameter0),
138+
FILL_MAP_BPLUS(impactParameter1),
139+
FILL_MAP_BPLUS(impactParameterProduct),
140+
FILL_MAP_BPLUS(chi2PCA),
141+
FILL_MAP_BPLUS(decayLength),
142+
FILL_MAP_BPLUS(decayLengthXY),
143+
FILL_MAP_BPLUS(decayLengthNormalised),
144+
FILL_MAP_BPLUS(decayLengthXYNormalised),
145+
FILL_MAP_BPLUS(cpa),
146+
FILL_MAP_BPLUS(cpaXY),
147+
FILL_MAP_BPLUS(maxNormalisedDeltaIP),
148+
// TPC PID variable
149+
FILL_MAP_BPLUS(tpcNSigmaKa1),
150+
// TOF PID variable
151+
FILL_MAP_BPLUS(tofNSigmaKa1),
152+
// Combined PID variable
153+
FILL_MAP_BPLUS(tpcTofNSigmaKa1)};
154+
}
155+
};
156+
157+
} // namespace o2::analysis
158+
159+
#undef FILL_MAP_BPLUS
160+
#undef CHECK_AND_FILL_VEC_BPLUS_FULL
161+
#undef CHECK_AND_FILL_VEC_BPLUS_FUNC
162+
#undef CHECK_AND_FILL_VEC_BPLUS
163+
164+
#endif // PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_

PWGHF/Core/SelectorCuts.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,62 @@ static const std::vector<std::string> labelsPt = {
11061106
static const std::vector<std::string> labelsCutVar = {"m", "CPA", "d0 D0", "d0 Pi", "pT D0", "pT Pi", "B decLen", "B decLenXY", "Imp. Par. Product", "DeltaMD0", "Cos ThetaStar"};
11071107
} // namespace hf_cuts_bplus_to_d0_pi
11081108

1109+
namespace hf_cuts_bplus_to_jpsi_k
1110+
{
1111+
static constexpr int NBinsPt = 12;
1112+
static constexpr int NCutVars = 12;
1113+
// default values for the pT bin edges (can be used to configure histogram axis)
1114+
// offset by 1 from the bin numbers in cuts array
1115+
constexpr double BinsPt[NBinsPt + 1] = {
1116+
0,
1117+
0.5,
1118+
1.0,
1119+
2.0,
1120+
3.0,
1121+
4.0,
1122+
5.0,
1123+
7.0,
1124+
10.0,
1125+
13.0,
1126+
16.0,
1127+
20.0,
1128+
24.0};
1129+
1130+
auto vecBinsPt = std::vector<double>{BinsPt, BinsPt + NBinsPt + 1};
1131+
1132+
// default values for the cuts
1133+
// DeltaM CPA d0JPsi d0K pTJPsi pTK BDecayLength BDecayLengthXY BIPProd DeltaMJPsi JPsiIPProd
1134+
constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 0 < pt < 0.5 */
1135+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 0.5 < pt < 1 */
1136+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 1 < pt < 2 */
1137+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 2 < pt < 3 */
1138+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 3 < pt < 4 */
1139+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 4 < pt < 5 */
1140+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 5 < pt < 7 */
1141+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 7 < pt < 10 */
1142+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 10 < pt < 13 */
1143+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 13 < pt < 16 */
1144+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 16 < pt < 20 */
1145+
{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}}; /* 20 < pt < 24 */
1146+
// row labels
1147+
static const std::vector<std::string> labelsPt = {
1148+
"pT bin 0",
1149+
"pT bin 1",
1150+
"pT bin 2",
1151+
"pT bin 3",
1152+
"pT bin 4",
1153+
"pT bin 5",
1154+
"pT bin 6",
1155+
"pT bin 7",
1156+
"pT bin 8",
1157+
"pT bin 9",
1158+
"pT bin 10",
1159+
"pT bin 11"};
1160+
1161+
// column labels
1162+
static const std::vector<std::string> labelsCutVar = {"m", "CPA", "CPAXY", "d0 J/Psi", "d0 K", "pT J/Psi", "pT K", "B decLen", "B decLenXY", "B Imp. Par. Product", "DeltaM J/Psi", "B pseudoprop. decLen"};
1163+
} // namespace hf_cuts_bplus_to_jpsi_k
1164+
11091165
namespace hf_cuts_lb_to_lc_pi
11101166
{
11111167
static constexpr int NBinsPt = 12;

0 commit comments

Comments
 (0)