Skip to content

Commit a561b4c

Browse files
PWGHF: Use labeled array for configurable cuts in Jpsi to ee selector (#5768)
1 parent 1f76187 commit a561b4c

3 files changed

Lines changed: 92 additions & 67 deletions

File tree

Analysis/Core/include/AnalysisCore/HFSelectorCuts.h

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ enum code {
2222
kD0bar = -421,
2323
kDPlus = 411,
2424
kLambdaCPlus = 4122,
25-
kXiCPlus = 4232
25+
kXiCPlus = 4232,
26+
kJpsi = 443
2627
};
2728
}
2829

@@ -301,5 +302,50 @@ static const std::vector<std::string> pTBinLabels = {
301302
// column labels
302303
static const std::vector<std::string> cutVarLabels = {"m", "pT p", "pT K", "pT Pi", "DCA", "vertex sigma", "decay length", "cos pointing angle"};
303304
} // namespace hf_cuts_xic_topkpi
305+
306+
namespace hf_cuts_jpsi_toee
307+
{
308+
static constexpr int npTBins = 9;
309+
static constexpr int nCutVars = 4;
310+
// default values for the pT bin edges (can be used to configure histogram axis)
311+
// offset by 1 from the bin numbers in cuts array
312+
constexpr double pTBins[npTBins + 1] = {
313+
0,
314+
0.5,
315+
1.0,
316+
2.0,
317+
3.0,
318+
4.0,
319+
5.0,
320+
7.0,
321+
10.0,
322+
15.0,
323+
};
324+
auto pTBins_v = std::vector<double>{pTBins, pTBins + npTBins + 1};
325+
326+
// default values for the cuts
327+
constexpr double cuts[npTBins][nCutVars] = {{0.5, 0.2, 0.4, 1}, /* 0<pt<0.5 */
328+
{0.5, 0.2, 0.4, 1}, /* 0.5<pt<1 */
329+
{0.5, 0.2, 0.4, 1}, /* 1<pt<2 */
330+
{0.5, 0.2, 0.4, 1}, /* 2<pt<3 */
331+
{0.5, 0.2, 0.4, 1}, /* 3<pt<4 */
332+
{0.5, 0.2, 0.4, 1}, /* 4<pt<5 */
333+
{0.5, 0.2, 0.4, 1}, /* 5<pt<7 */
334+
{0.5, 0.2, 0.4, 1}, /* 7<pt<10 */
335+
{0.5, 0.2, 0.4, 1}}; /* 10<pt<15 */
336+
// row labels
337+
static const std::vector<std::string> pTBinLabels = {
338+
"pT bin 0",
339+
"pT bin 1",
340+
"pT bin 2",
341+
"pT bin 3",
342+
"pT bin 4",
343+
"pT bin 5",
344+
"pT bin 6",
345+
"pT bin 7",
346+
"pT bin 8"};
347+
// column labels
348+
static const std::vector<std::string> cutVarLabels = {"m", "DCA_xy", "DCA_z", "pT El"};
349+
} // namespace hf_cuts_jpsi_toee
304350
} // namespace o2::analysis
305351
#endif

Analysis/Tasks/PWGHF/HFJpsiToEECandidateSelector.cxx

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,14 @@
1515

1616
#include "Framework/runDataProcessing.h"
1717
#include "Framework/AnalysisTask.h"
18+
#include "AnalysisCore/HFSelectorCuts.h"
1819
#include "AnalysisDataModel/HFSecondaryVertex.h"
1920
#include "AnalysisDataModel/HFCandidateSelectionTables.h"
2021
using namespace o2;
2122
using namespace o2::framework;
2223
using namespace o2::aod::hf_cand_prong2;
23-
24-
static const int npTBins = 9;
25-
static const int nCutVars = 4;
26-
//temporary until 2D array in configurable is solved - then move to json
27-
// mass dcaxy dcaz pt_e
28-
constexpr double cuts[npTBins][nCutVars] =
29-
{{0.5, 0.2, 0.4, 1}, /* pt<0.5 */
30-
{0.5, 0.2, 0.4, 1}, /* 0.5<pt<1 */
31-
{0.5, 0.2, 0.4, 1}, /* 1<pt<2 */
32-
{0.5, 0.2, 0.4, 1}, /* 2<pt<3 */
33-
{0.5, 0.2, 0.4, 1}, /* 3<pt<4 */
34-
{0.5, 0.2, 0.4, 1}, /* 4<pt<5 */
35-
{0.5, 0.2, 0.4, 1}, /* 5<pt<7 */
36-
{0.5, 0.2, 0.4, 1}, /* 7<pt<10 */
37-
{0.5, 0.2, 0.4, 1}}; /* 10<pt<15 */
24+
using namespace o2::analysis;
25+
using namespace o2::analysis::hf_cuts_jpsi_toee;
3826

3927
/// Struct for applying Jpsi selection cuts
4028

@@ -50,24 +38,8 @@ struct HFJpsiToEECandidateSelector {
5038

5139
Configurable<double> d_TPCNClsFindablePIDCut{"d_TPCNClsFindablePIDCut", 70., "Lower bound of TPC findable clusters for good PID"};
5240
Configurable<double> d_nSigmaTPC{"d_nSigmaTPC", 3., "Nsigma cut on TPC only"};
53-
54-
/// Gets corresponding pT bin from cut file array
55-
/// \param candpT is the pT of the candidate
56-
/// \return corresponding bin number of array
57-
template <typename T>
58-
int getpTBin(T candpT)
59-
{
60-
double pTBins[npTBins + 1] = {0, 0.5, 1., 2., 3., 4., 5., 7., 10., 15.};
61-
if (candpT < pTBins[0] || candpT >= pTBins[npTBins]) {
62-
return -1;
63-
}
64-
for (int i = 0; i < npTBins; i++) {
65-
if (candpT < pTBins[i + 1]) {
66-
return i;
67-
}
68-
}
69-
return -1;
70-
}
41+
Configurable<std::vector<double>> pTBins{"pTBins", std::vector<double>{hf_cuts_jpsi_toee::pTBins_v}, "pT bin limits"};
42+
Configurable<LabeledArray<double>> cuts{"Jpsi_to_ee_cuts", {hf_cuts_jpsi_toee::cuts[0], npTBins, nCutVars, pTBinLabels, cutVarLabels}, "Jpsi candidate selection per pT bin"};
7143

7244
/// Selection on goodness of daughter tracks
7345
/// \note should be applied at candidate selection
@@ -91,7 +63,7 @@ struct HFJpsiToEECandidateSelector {
9163
bool selectionTopol(const T1& hfCandProng2, const T2& trackPositron, const T2& trackElectron)
9264
{
9365
auto candpT = hfCandProng2.pt();
94-
int pTBin = getpTBin(candpT);
66+
auto pTBin = findBin(pTBins, candpT);
9567
if (pTBin == -1) {
9668
return false;
9769
}
@@ -100,17 +72,17 @@ struct HFJpsiToEECandidateSelector {
10072
return false; //check that the candidate pT is within the analysis range
10173
}
10274

103-
if (TMath::Abs(InvMassJpsiToEE(hfCandProng2) - RecoDecay::getMassPDG(443)) > cuts[pTBin][0]) {
75+
if (TMath::Abs(InvMassJpsiToEE(hfCandProng2) - RecoDecay::getMassPDG(pdg::code::kJpsi)) > cuts->get(pTBin, "m")) {
10476
return false;
10577
}
10678

107-
if ((trackElectron.pt() < cuts[pTBin][3]) || (trackPositron.pt() < cuts[pTBin][3])) {
79+
if (trackElectron.pt() < cuts->get(pTBin, "pT El") || trackPositron.pt() < cuts->get(pTBin, "pT El")) {
10880
return false; //cut on daughter pT
10981
}
110-
if (TMath::Abs(trackElectron.dcaPrim0()) > cuts[pTBin][1] || TMath::Abs(trackPositron.dcaPrim0()) > cuts[pTBin][1]) {
82+
if (TMath::Abs(trackElectron.dcaPrim0()) > cuts->get(pTBin, "DCA_xy") || TMath::Abs(trackPositron.dcaPrim0()) > cuts->get(pTBin, "DCA_xy")) {
11183
return false; //cut on daughter dca - need to add secondary vertex constraint here
11284
}
113-
if (TMath::Abs(trackElectron.dcaPrim1()) > cuts[pTBin][2] || TMath::Abs(trackPositron.dcaPrim1()) > cuts[pTBin][2]) {
85+
if (TMath::Abs(trackElectron.dcaPrim1()) > cuts->get(pTBin, "DCA_z") || TMath::Abs(trackPositron.dcaPrim1()) > cuts->get(pTBin, "DCA_z")) {
11486
return false; //cut on daughter dca - need to add secondary vertex constraint here
11587
}
11688

@@ -161,7 +133,7 @@ struct HFJpsiToEECandidateSelector {
161133
return -1; //no PID info
162134
}
163135
}
164-
void process(aod::HfCandProng2 const& hfCandProng2s, aod::BigTracksPID const& tracks)
136+
void process(aod::HfCandProng2 const& hfCandProng2s, aod::BigTracksPID const&)
165137
{
166138

167139
for (auto& hfCandProng2 : hfCandProng2s) { //looping over 2 prong candidates

Analysis/Tasks/PWGHF/taskJpsi.cxx

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
/// \author Biao Zhang <biao.zhang@cern.ch>, CCNU
1717
#include "Framework/AnalysisTask.h"
1818
#include "Framework/HistogramRegistry.h"
19+
#include "AnalysisCore/HFSelectorCuts.h"
1920
#include "AnalysisDataModel/HFSecondaryVertex.h"
2021
#include "AnalysisDataModel/HFCandidateSelectionTables.h"
2122

2223
using namespace o2;
24+
using namespace o2::analysis;
25+
using namespace o2::analysis::hf_cuts_jpsi_toee;
2326
using namespace o2::framework;
2427
using namespace o2::aod::hf_cand_prong2;
2528
using namespace o2::framework::expressions;
@@ -36,53 +39,57 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
3639
struct TaskJpsi {
3740
HistogramRegistry registry{
3841
"registry",
39-
{{"hmass", "2-prong candidates;inv. mass (#e+ e-) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}},
40-
{"hptcand", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
42+
{{"hptcand", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
4143
{"hptprong0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
42-
{"hptprong1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}},
43-
{"hdeclength", "2-prong candidates;decay length (cm);entries", {HistType::kTH1F, {{200, 0., 2.}}}},
44-
{"hdeclengthxy", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH1F, {{200, 0., 2.}}}},
45-
{"hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{100, -1., 1.}}}},
46-
{"hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{100, -1., 1.}}}},
47-
{"hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH1F, {{500, -1., 1.}}}},
48-
{"hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}},
49-
{"hEta", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}},
50-
{"hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH1F, {{100, -1., 1.}}}},
51-
{"hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH1F, {{100, 0., 1.}}}},
52-
{"hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH1F, {{100, 0., 1.}}}}}};
44+
{"hptprong1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}}}};
5345

5446
Configurable<int> d_selectionFlagJpsi{"d_selectionFlagJpsi", 1, "Selection Flag for Jpsi"};
5547
Configurable<double> cutYCandMax{"cutYCandMax", -1., "max. cand. rapidity"};
48+
Configurable<std::vector<double>> bins{"pTBins", std::vector<double>{hf_cuts_jpsi_toee::pTBins_v}, "pT bin limits"};
49+
50+
void init(o2::framework::InitContext&)
51+
{
52+
registry.add("hmass", "2-prong candidates;inv. mass (e^{#plus} e^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
53+
registry.add("hdeclength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
54+
registry.add("hdeclengthxy", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
55+
registry.add("hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
56+
registry.add("hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
57+
registry.add("hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH2F, {{500, -1., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
58+
registry.add("hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
59+
registry.add("hEta", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
60+
registry.add("hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
61+
registry.add("hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
62+
registry.add("hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {(std::vector<double>)bins, "#it{p}_{T} (GeV/#it{c})"}}});
63+
}
64+
5665
Filter filterSelectCandidates = (aod::hf_selcandidate_jpsi::isSelJpsiToEE >= d_selectionFlagJpsi);
5766

5867
void process(soa::Filtered<soa::Join<aod::HfCandProng2, aod::HFSelJpsiToEECandidate>> const& candidates)
5968
// void process(aod::HfCandProng2 const& candidates)
6069
{
61-
//Printf("Candidates: %d", candidates.size());
6270
for (auto& candidate : candidates) {
6371
if (!(candidate.hfflag() & 1 << JpsiToEE)) {
6472
continue;
6573
}
6674
if (cutYCandMax >= 0. && std::abs(YJpsi(candidate)) > cutYCandMax) {
67-
//Printf("Candidate: Y rejection: %g", YJpsi(candidate));
6875
continue;
6976
}
7077

71-
registry.fill(HIST("hmass"), InvMassJpsiToEE(candidate));
78+
registry.fill(HIST("hmass"), InvMassJpsiToEE(candidate), candidate.pt());
7279
registry.fill(HIST("hptcand"), candidate.pt());
7380
registry.fill(HIST("hptprong0"), candidate.ptProng0());
7481
registry.fill(HIST("hptprong1"), candidate.ptProng1());
75-
registry.fill(HIST("hdeclength"), candidate.decayLength());
76-
registry.fill(HIST("hdeclengthxy"), candidate.decayLengthXY());
77-
registry.fill(HIST("hd0Prong0"), candidate.impactParameter0());
78-
registry.fill(HIST("hd0Prong1"), candidate.impactParameter1());
79-
registry.fill(HIST("hd0d0"), candidate.impactParameterProduct());
80-
registry.fill(HIST("hCPA"), candidate.cpa());
81-
registry.fill(HIST("hEta"), candidate.eta());
82-
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter0());
83-
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter1());
84-
registry.fill(HIST("hDecLenErr"), candidate.errorDecayLength());
85-
registry.fill(HIST("hDecLenXYErr"), candidate.errorDecayLengthXY());
82+
registry.fill(HIST("hdeclength"), candidate.decayLength(), candidate.pt());
83+
registry.fill(HIST("hdeclengthxy"), candidate.decayLengthXY(), candidate.pt());
84+
registry.fill(HIST("hd0Prong0"), candidate.impactParameter0(), candidate.pt());
85+
registry.fill(HIST("hd0Prong1"), candidate.impactParameter1(), candidate.pt());
86+
registry.fill(HIST("hd0d0"), candidate.impactParameterProduct(), candidate.pt());
87+
registry.fill(HIST("hCPA"), candidate.cpa(), candidate.pt());
88+
registry.fill(HIST("hEta"), candidate.eta(), candidate.pt());
89+
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter0(), candidate.pt());
90+
registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter1(), candidate.pt());
91+
registry.fill(HIST("hDecLenErr"), candidate.errorDecayLength(), candidate.pt());
92+
registry.fill(HIST("hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt());
8693
}
8794
}
8895
};

0 commit comments

Comments
 (0)