Skip to content

Commit d5842b8

Browse files
authored
PWGHF: factorise 2 and 3 prong configurables, fix bug in D0 <-D*mass cut (#7405)
* PWGHF: factorise 2 and 3 prong configurables, fix bug in D0 <-D*mass cut * Implement Vit's suggestions
1 parent ad9a2f5 commit d5842b8

3 files changed

Lines changed: 44 additions & 55 deletions

File tree

PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ struct HfCandidateSelectorDplusToPiKPi {
7676
// Mass Cut for trigger analysis
7777
Configurable<bool> useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrize pT differential mass cut for triggered data"};
7878

79-
o2::analysis::HfMlResponseDplusToPiKPi<float> hfMlResponse;
79+
HfMlResponseDplusToPiKPi<float> hfMlResponse;
8080
std::vector<float> outputMlNotPreselected = {};
8181
std::vector<float> outputMl = {};
8282
o2::ccdb::CcdbApi ccdbApi;
8383
TrackSelectorPi selectorPion;
8484
TrackSelectorKa selectorKaon;
8585
HfHelper hfHelper;
86-
o2::analysis::HfTriggerCuts hfTriggerCuts;
86+
HfTrigger3ProngCuts hfTriggerCuts;
8787

8888
using TracksSel = soa::Join<aod::TracksWExtra, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
8989

@@ -153,7 +153,7 @@ struct HfCandidateSelectorDplusToPiKPi {
153153
if (std::abs(hfHelper.invMassDplusToPiKPi(candidate) - o2::constants::physics::MassDPlus) > cuts->get(pTBin, "deltaM")) {
154154
return false;
155155
}
156-
if (useTriggerMassCut && !hfTriggerCuts.isCandidateInMassRange<3>(hfHelper.invMassDplusToPiKPi(candidate), o2::constants::physics::MassDPlus, ptCand)) {
156+
if (useTriggerMassCut && !isCandidateInMassRange(hfHelper.invMassDplusToPiKPi(candidate), o2::constants::physics::MassDPlus, ptCand, hfTriggerCuts)) {
157157
return false;
158158
}
159159
if (candidate.decayLength() < cuts->get(pTBin, "decay length")) {

PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct HfCandidateSelectorDstarToD0Pi {
110110
AxisSpec axisSelStatus{2, -0.5f, 1.5f};
111111
HistogramRegistry registry{"registry"};
112112

113-
HfTriggerCuts hfTriggerCuts;
113+
HfTrigger2ProngCuts hfTriggerCuts;
114114

115115
void init(InitContext&)
116116
{
@@ -286,7 +286,7 @@ struct HfCandidateSelectorDstarToD0Pi {
286286
if (std::abs(mInvD0 - massD0) > cutsD0->get(binPt, "m")) {
287287
return false;
288288
}
289-
if (useTriggerMassCut && !hfTriggerCuts.isCandidateInMassRange<2>(mInvD0, massD0, candidate.pt())) {
289+
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0, massD0, candidate.ptD0(), hfTriggerCuts)) {
290290
return false;
291291
}
292292
// cut on daughter pT
@@ -314,6 +314,9 @@ struct HfCandidateSelectorDstarToD0Pi {
314314
if (std::abs(mInvD0Bar - massD0) > cutsD0->get(binPt, "m")) {
315315
return false;
316316
}
317+
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0Bar, massD0, candidate.ptD0(), hfTriggerCuts)) {
318+
return false;
319+
}
317320
// cut on daughter pT
318321
auto d0prong0 = candidate.template prong0_as<TracksSel>();
319322
auto d0prong1 = candidate.template prong1_as<TracksSel>();

PWGHF/Utils/utilsAnalysis.h

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -109,62 +109,48 @@ bool isSelectedTrackTpcQuality(T const& track, const int tpcNClustersFoundMin, c
109109
return true;
110110
}
111111

112-
/// Configurable group to apply trigger specific cuts for HF analysis
113-
struct HfTriggerCuts : o2::framework::ConfigurableGroup {
114-
std::string prefix = "hfTriggerCuts"; // JSON group name
112+
/// Mass selection of 2 or 3 prong canidates in triggered data analysis
113+
/// \tparam nProngs switch between 2-prong and 3-prong selection
114+
/// \param invMass is the invariant mass of the candidate
115+
/// \param pdgMass is the pdg Mass of the candidate particle
116+
/// \param pt is the pT of the candidate
117+
/// \param cutConfig is the struct with the pt-dependent mass configurations
118+
/// \return true if candidate passes selection
119+
template <typename Config>
120+
bool isCandidateInMassRange(const float& invMass, const double& pdgMass, const float& pt, Config const& cutConfig)
121+
{
122+
float peakMean = (pt < cutConfig.ptDeltaMassMax.value) ? ((pdgMass + cutConfig.deltaMassPars->get("constant")) + cutConfig.deltaMassPars->get("linear") * pt) : pdgMass;
123+
float peakWidth = cutConfig.sigmaPars->get("constant") + cutConfig.sigmaPars->get("linear") * pt;
115124

116-
static constexpr float defaultDeltaMassPars3Prong[1][2] = {{-0.0025f, 0.0001f}};
117-
static constexpr float defaultSigmaPars3Prong[1][2] = {{0.00796f, 0.00176f}};
118-
static constexpr float defaultDeltaMassPars2Prong[1][2] = {{-0.0025f, 0.0001f}};
119-
static constexpr float defaultSigmaPars2Prong[1][2] = {{0.01424f, 0.00178f}};
120-
o2::framework::Configurable<float> nSigma3ProngMax{"nSigma3ProngMax", 2, "Maximum number of sigmas for pT-differential mass cut for 3-prong candidates"};
121-
o2::framework::Configurable<float> nSigma2ProngMax{"nSigma2ProngMax", 2, "Maximum number of sigmas for pT-differential mass cut for 2-prong candidates"};
122-
o2::framework::Configurable<float> ptDeltaMass3ProngMax{"ptDeltaMass3ProngMax", 10., "Max pT to apply delta mass shift to PDG mass value for 3-prong candidates"};
123-
o2::framework::Configurable<float> ptDeltaMass2ProngMax{"ptDeltaMass2ProngMax", 10., "Max pT to apply delta mass shift to PDG mass value for 2-prong candidates"};
124-
o2::framework::Configurable<float> ptMassCut3ProngMax{"ptMassCut3ProngMax", 8., "Max pT to apply pT-differential cut for 3-prong candidates"};
125-
o2::framework::Configurable<float> ptMassCut2ProngMax{"ptMassCut2ProngMax", 8., "Max pT to apply pT-differential cut for 2-prong candidates"};
126-
o2::framework::Configurable<o2::framework::LabeledArray<float>> deltaMassPars3Prong{"deltaMassPars3Prong", {defaultDeltaMassPars3Prong[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 3-prong trigger mass cut"};
127-
o2::framework::Configurable<o2::framework::LabeledArray<float>> deltaMassPars2Prong{"deltaMassPars2Prong", {defaultDeltaMassPars2Prong[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 2-prong trigger mass cut"};
128-
o2::framework::Configurable<o2::framework::LabeledArray<float>> sigmaPars3Prong{"sigmaPars3Prong", {defaultSigmaPars3Prong[0], 2, {"constant", "linear"}}, "sigma parameters for HF 3-prong trigger mass cut"};
129-
o2::framework::Configurable<o2::framework::LabeledArray<float>> sigmaPars2Prong{"sigmaPars2Prong", {defaultSigmaPars2Prong[0], 2, {"constant", "linear"}}, "sigma parameters for HF 2-prong trigger mass cut"};
125+
return (!(std::abs(invMass - peakMean) > cutConfig.nSigmaMax.value * peakWidth && pt < cutConfig.ptMassCutMax.value));
126+
}
130127

131-
/// Mass selection of 2 or 3 prong canidates in triggered data analysis
132-
/// \tparam nProngs switch between 2-prong and 3-prong selection
133-
/// \param invMass is the invariant mass of the candidate
134-
/// \param pdgMass is the pdg Mass of the candidate particle
135-
/// \param pt is the pT of the candidate
136-
/// \return true if candidate passes selection
137-
template <uint8_t nProngs>
138-
bool isCandidateInMassRange(const float& invMass, const double& pdgMass, const float& pt)
139-
{
140-
float ptMassCutMax{0.};
141-
float ptDeltaMassMax{0.};
142-
float nSigmaMax{0.};
143-
o2::framework::LabeledArray<float> deltaMassPars;
144-
o2::framework::LabeledArray<float> sigmaPars;
128+
/// Configurable group to apply trigger specific cuts for 2-prong HF analysis
129+
struct HfTrigger2ProngCuts : o2::framework::ConfigurableGroup {
130+
std::string prefix = "hfTrigger2ProngCuts"; // JSON group name
145131

146-
if constexpr (nProngs == 2) {
147-
deltaMassPars = deltaMassPars2Prong;
148-
sigmaPars = sigmaPars2Prong;
149-
ptDeltaMassMax = ptDeltaMass2ProngMax;
150-
ptMassCutMax = ptMassCut2ProngMax;
151-
nSigmaMax = nSigma2ProngMax;
152-
} else if constexpr (nProngs == 3) {
153-
deltaMassPars = deltaMassPars3Prong;
154-
sigmaPars = sigmaPars3Prong;
155-
ptDeltaMassMax = ptDeltaMass3ProngMax;
156-
ptMassCutMax = ptMassCut3ProngMax;
157-
nSigmaMax = nSigma3ProngMax;
158-
} else {
159-
LOGF(fatal, "nProngs %d not supported!", nProngs);
160-
}
132+
static constexpr float defaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}};
133+
static constexpr float defaultSigmaPars[1][2] = {{0.01424f, 0.00178f}};
134+
o2::framework::Configurable<float> nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 2-prong candidates"};
135+
o2::framework::Configurable<float> ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 2-prong candidates"};
136+
o2::framework::Configurable<float> ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 2-prong candidates"};
137+
o2::framework::Configurable<o2::framework::LabeledArray<float>> deltaMassPars{"deltaMassPars", {defaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 2-prong trigger mass cut"};
138+
o2::framework::Configurable<o2::framework::LabeledArray<float>> sigmaPars{"sigmaPars", {defaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 2-prong trigger mass cut"};
139+
};
161140

162-
float peakMean = (pt < ptDeltaMassMax) ? ((pdgMass + deltaMassPars.get("constant")) + deltaMassPars.get("linear") * pt) : pdgMass;
163-
float peakWidth = sigmaPars.get("constant") + sigmaPars.get("linear") * pt;
141+
/// Configurable group to apply trigger specific cuts for 3-prong HF analysis
142+
struct HfTrigger3ProngCuts : o2::framework::ConfigurableGroup {
143+
std::string prefix = "hfTrigger3ProngCuts"; // JSON group name
164144

165-
return (!(std::abs(invMass - peakMean) > nSigmaMax * peakWidth && pt < ptMassCutMax));
166-
}
145+
static constexpr float defaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}};
146+
static constexpr float defaultSigmaPars[1][2] = {{0.00796f, 0.00176f}};
147+
o2::framework::Configurable<float> nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 3-prong candidates"};
148+
o2::framework::Configurable<float> ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 3-prong candidates"};
149+
o2::framework::Configurable<float> ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 3-prong candidates"};
150+
o2::framework::Configurable<o2::framework::LabeledArray<float>> deltaMassPars{"deltaMassPars", {defaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 3-prong trigger mass cut"};
151+
o2::framework::Configurable<o2::framework::LabeledArray<float>> sigmaPars{"sigmaPars", {defaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 3-prong trigger mass cut"};
167152
};
153+
168154
} // namespace o2::analysis
169155

170156
#endif // PWGHF_UTILS_UTILSANALYSIS_H_

0 commit comments

Comments
 (0)