1919#include " PWGHF/Core/SelectorCuts.h"
2020#include " PWGHF/D2H/DataModel/ReducedDataModel.h"
2121#include " PWGHF/DataModel/CandidateSelectionTables.h"
22+ #include " PWGHF/Utils/utilsAnalysis.h"
2223#include " PWGHF/Utils/utilsPid.h"
2324
2425#include " Common/Core/TrackSelectorPID.h"
2526
2627#include < CCDB/CcdbApi.h>
28+ #include < CommonConstants/PhysicsConstants.h>
2729#include < Framework/ASoA.h>
2830#include < Framework/AnalysisHelpers.h>
2931#include < Framework/AnalysisTask.h>
@@ -91,6 +93,7 @@ struct HfCandidateSelectorBplusToD0PiReduced {
9193 Configurable<std::vector<std::string>> onnxFileNames{" onnxFileNames" , std::vector<std::string>{" ModelHandler_onnx_BPLUSToD0Pi.onnx" }, " ONNX file names for each pT bin (if not from CCDB full path)" };
9294 Configurable<int64_t > timestampCCDB{" timestampCCDB" , -1 , " timestamp of the ONNX file for ML model used to query in CCDB" };
9395 Configurable<bool > loadModelsFromCCDB{" loadModelsFromCCDB" , false , " Flag to enable or disable the loading of models from CCDB" };
96+ Configurable<bool > useD0TriggerMassCut{" useD0TriggerMassCut" , false , " Flag to enable parametrize pT differential mass cut for triggered data" };
9497 // variable that will store the value of selectionFlagD (defined in dataCreatorD0PiReduced.cxx)
9598 int mySelectionFlagD0 = -1 ;
9699 int mySelectionFlagD0bar = -1 ;
@@ -101,6 +104,7 @@ struct HfCandidateSelectorBplusToD0PiReduced {
101104 o2::ccdb::CcdbApi ccdbApi;
102105
103106 TrackSelectorPi selectorPion;
107+ HfTrigger2ProngCuts hfTriggerCuts;
104108
105109 using TracksPion = soa::Join<HfRedTracks, HfRedTracksPid>;
106110
@@ -154,6 +158,19 @@ struct HfCandidateSelectorBplusToD0PiReduced {
154158 }
155159 }
156160
161+ // / Utility function to apply the pT-differential mass cut for triggered data
162+ // / on the D0 daughter of the B+ candidate
163+ // / \param candidate is the B+ candidate
164+ // / \param trackPi is the bachelor pion of the B+ candidate
165+ // / \return true if the D0 daughter passes the mass selection
166+ template <typename T1 >
167+ bool isDmesInMassRange (const T1 & candidate, TracksPion::iterator const & trackPi)
168+ {
169+ const auto candD0 = candidate.template prong0_as <HfRed2Prongs>();
170+ const auto invMassD0 = (trackPi.signed1Pt () < 0 ) ? candD0.invMassHypo0 () : candD0.invMassHypo1 ();
171+ return isCandidateInMassRange (invMassD0, o2::constants::physics::MassD0, candidate.ptProng0 (), hfTriggerCuts);
172+ }
173+
157174 // / Main function to perform B+ candidate creation
158175 // / \param withDmesMl is the flag to use the table with ML scores for the D- daughter (only possible if present in the derived data)
159176 // / \param hfCandsBp B+ candidates
@@ -189,6 +206,18 @@ struct HfCandidateSelectorBplusToD0PiReduced {
189206 continue ;
190207 }
191208
209+ auto trackPi = hfCandBp.template prong1_as <TracksPion>();
210+
211+ // pT-differential mass cut on the D0 daughter for triggered data
212+ if (useD0TriggerMassCut && !isDmesInMassRange (hfCandBp, trackPi)) {
213+ hfSelBplusToD0PiCandidate (statusBplus);
214+ if (applyBplusMl) {
215+ hfMlBplusToD0PiCandidate (outputMlNotPreselected);
216+ }
217+ // LOGF(info, "B+ candidate selection failed at D0-meson mass selection");
218+ continue ;
219+ }
220+
192221 if constexpr (WithDmesMl) { // we include it in the topological selections
193222 if (!HfHelper::selectionDmesMlScoresForBReduced (hfCandBp, cutsDmesMl, binsPtDmesMl)) {
194223 hfSelBplusToD0PiCandidate (statusBplus);
@@ -206,7 +235,6 @@ struct HfCandidateSelectorBplusToD0PiReduced {
206235 }
207236
208237 // track-level PID selection
209- auto trackPi = hfCandBp.template prong1_as <TracksPion>();
210238 if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) {
211239 int pidTrackPi{TrackSelectorPID::Status::NotApplicable};
212240 if (pionPidMethod == PidMethod::TpcOrTof) {
@@ -250,7 +278,8 @@ struct HfCandidateSelectorBplusToD0PiReduced {
250278
251279 void processSelection (HfRedCandBplus const & hfCandsBp,
252280 TracksPion const & pionTracks,
253- HfCandBpConfigs const & configs)
281+ HfCandBpConfigs const & configs,
282+ HfRed2Prongs const & /* candsD*/ )
254283 {
255284 runSelection<false >(hfCandsBp, pionTracks, configs);
256285 } // processSelection
@@ -259,7 +288,8 @@ struct HfCandidateSelectorBplusToD0PiReduced {
259288
260289 void processSelectionWithDmesMl (soa::Join<HfRedCandBplus, HfRedBplusD0Mls> const & hfCandsBp,
261290 TracksPion const & pionTracks,
262- HfCandBpConfigs const & configs)
291+ HfCandBpConfigs const & configs,
292+ HfRed2Prongs const & /* candsD*/ )
263293 {
264294 runSelection<true >(hfCandsBp, pionTracks, configs);
265295 } // processSelectionWithDmesMl
0 commit comments