2222
2323#include " Common/Core/trackUtilities.h"
2424#include " Common/DataModel/CollisionAssociationTables.h"
25+ #include " EventFiltering/PWGHF/HFFilterHelpers.h"
2526
2627#include " PWGHF/D2H/DataModel/ReducedDataModel.h"
28+ #include " PWGHF/D2H/Core/SelectorCutsRedDataFormat.h"
29+ #include " PWGHF/Utils/utilsAnalysis.h"
2730
2831using namespace o2 ;
2932using namespace o2 ::aod;
33+ using namespace o2 ::analysis;
3034using namespace o2 ::framework;
3135using namespace o2 ::framework::expressions;
3236
@@ -47,32 +51,36 @@ enum V0Type : uint8_t {
4751 Lambda,
4852 AntiLambda
4953};
50- const int nBins = 7 ;
51- constexpr double binsPt[nBins + 1 ] = {
54+
55+ const int nBinsPt = 7 ;
56+ constexpr double binsPt[nBinsPt + 1 ] = {
5257 1 .,
5358 2 .,
5459 4 .,
5560 6 .,
5661 8 .,
5762 12 .,
5863 24 .,
59- 50 .};
60- auto vecBins = std::vector<double >{binsPt, binsPt + nBins + 1 };
64+ 1000 .};
65+ auto vecBinsPt = std::vector<double >{binsPt, binsPt + nBinsPt + 1 };
6166
6267struct HfCandidateCreatorCharmResoReduced {
6368 // Produces: Tables with resonance info
6469 Produces<aod::HfCandCharmReso> rowCandidateReso;
65- // Optional D daughter ML scores table
70+ // Optional daughter ML scores table
6671 Produces<aod::HfCharmResoMLs> mlScores;
6772
6873 // Configurables
69- Configurable<double > invMassWindowD{" invMassWindowD" , 0.5 , " invariant-mass window for D candidates (GeV/c2)" };
70- Configurable<double > invMassWindowV0{" invMassWindowV0" , 0.5 , " invariant-mass window for V0 candidates (GeV/c2)" };
7174 Configurable<bool > rejectDV0PairsWithCommonDaughter{" rejectDV0PairsWithCommonDaughter" , true , " flag to reject the pairs that share a daughter track if not done in the derived data creation" };
75+ Configurable<bool > keepSideBands{" keepSideBands" , false , " flag to keep events from D meson sidebands for backgorund estimation" };
7276 // QA switch
7377 Configurable<bool > activateQA{" activateQA" , false , " Flag to enable QA histogram" };
74- // Hist Axis
75- Configurable<std::vector<double >> binsPt{" binsPt" , std::vector<double >{vecBins}, " pT bin limits" };
78+ Configurable<std::vector<double >> binsPt{" binsPt" , std::vector<double >{vecBinsPt}, " Histogram pT bin limits" };
79+ // Daughters selection cuts
80+ Configurable<LabeledArray<double >> cutsD{" cutsDdaughter" , {hf_cuts_d_daughter::cuts[0 ], hf_cuts_d_daughter::nBinsPt, hf_cuts_d_daughter::nCutVars, hf_cuts_d_daughter::labelsPt, hf_cuts_d_daughter::labelsCutVar}, " D daughter selections" };
81+ Configurable<std::vector<double >> binsPtD{" binsPtD" , std::vector<double >{hf_cuts_d_daughter::vecBinsPt}, " pT bin limits for D daughter cuts" };
82+ Configurable<LabeledArray<double >> cutsV0{" cutsV0daughter" , {hf_cuts_v0_daughter::cuts[0 ], hf_cuts_v0_daughter::nBinsPt, hf_cuts_v0_daughter::nCutVars, hf_cuts_v0_daughter::labelsPt, hf_cuts_v0_daughter::labelsCutVar}, " V0 daughter selections" };
83+ Configurable<std::vector<double >> binsPtV0{" binsPtV0" , std::vector<double >{hf_cuts_v0_daughter::vecBinsPt}, " pT bin limits for V0 daughter cuts" };
7684
7785 using reducedDWithMl = soa::Join<aod::HfRed3PrNoTrks, aod::HfRed3ProngsMl>;
7886
@@ -82,15 +90,14 @@ struct HfCandidateCreatorCharmResoReduced {
8290
8391 Preslice<aod::HfRedVzeros> candsV0PerCollision = aod::hf_track_index_reduced::hfRedCollisionId;
8492 Preslice<aod::HfRed3PrNoTrks> candsDPerCollision = hf_track_index_reduced::hfRedCollisionId;
85- // aod::HfRedVzeros
93+
8694 // Useful constants
8795 double massK0{0 .};
8896 double massLambda{0 .};
8997 double massDplus{0 .};
9098 double massDstar{0 .};
9199 double massD0{0 .};
92100
93- // Histogram registry: if task make it with a THNsparse with all variables you want to save
94101 HistogramRegistry registry{" registry" };
95102
96103 void init (InitContext const &)
@@ -101,7 +108,7 @@ struct HfCandidateCreatorCharmResoReduced {
101108 LOGP (fatal, " Only one process function should be enabled! Please check your configuration!" );
102109 }
103110 // histograms
104- const AxisSpec axisPt{(std::vector<double >)vecBins , " #it{p}_{T} (GeV/#it{c})" };
111+ const AxisSpec axisPt{(std::vector<double >)vecBinsPt , " #it{p}_{T} (GeV/#it{c})" };
105112 registry.add (" hMassDs1" , " Ds1 candidates;m_{Ds1} (GeV/#it{c}^{2});entries" , {HistType::kTH2F , {{100 , 2.4 , 2.7 }, {(std::vector<double >)binsPt, " #it{p}_{T} (GeV/#it{c})" }}});
106113 registry.add (" hMassDs2Star" , " Ds^{*}2 candidates; m_Ds^{*}2 (GeV/#it{c}^{2}) ;entries" , {HistType::kTH2F , {{100 , 2.4 , 2.7 }, {(std::vector<double >)binsPt, " #it{p}_{T} (GeV/#it{c})" }}});
107114 registry.add (" hMassXcRes" , " XcRes candidates; m_XcRes (GeV/#it{c}^{2}) ;entries" , {HistType::kTH2F , {{100 , 2.9 , 3.3 }, {(std::vector<double >)binsPt, " #it{p}_{T} (GeV/#it{c})" }}});
@@ -131,21 +138,33 @@ struct HfCandidateCreatorCharmResoReduced {
131138 template <DecayChannel channel, typename DRedTable>
132139 bool isDSelected (DRedTable const & candD)
133140 {
134- float massD{0 .};
135141 float invMassD{0 .};
142+ float ptD = candD.pt ();
143+ int ptBin = findBin (binsPtD, ptD);
144+ if (ptBin == -1 ) {
145+ return false ;
146+ }
136147 // slection on D candidate mass
137148 if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) {
138- massD = massDplus;
139149 invMassD = candD.invMassDplus ();
140150 } else if (channel == DecayChannel::Ds1ToDstarK0s) {
141- massD = massDstar - massD0;
142151 if (candD.dType () > 0 )
143152 invMassD = candD.invMassDstar ();
144153 else
145154 invMassD = candD.invMassAntiDstar ();
146155 }
147- if (std::fabs (invMassD - massD) > invMassWindowD) {
148- return false ;
156+ // invariant mass selection
157+ if (!keepSideBands) {
158+ if (invMassD < cutsD->get (ptBin, " invMassSignalLow" ) || invMassD > cutsD->get (ptBin, " invMassSignalHigh" )) {
159+ return false ;
160+ }
161+ } else {
162+ if ((invMassD < cutsD->get (ptBin, " invMassLeftSBLow" )) ||
163+ (invMassD > cutsD->get (ptBin, " invMassLeftSBHigh" ) && invMassD < cutsD->get (ptBin, " invMassSignalLow" )) ||
164+ (invMassD > cutsD->get (ptBin, " invMassSignalHigh" ) && invMassD < cutsD->get (ptBin, " invMassRightSBLow" )) ||
165+ (invMassD > cutsD->get (ptBin, " invMassRightSBHigh" ))) {
166+ return false ;
167+ }
149168 }
150169 return true ;
151170 }
@@ -159,6 +178,11 @@ struct HfCandidateCreatorCharmResoReduced {
159178 {
160179 float massV0{0 .};
161180 float invMassV0{0 .};
181+ float ptV0 = candV0.pt ();
182+ int ptBin = findBin (binsPtV0, ptV0);
183+ if (ptBin == -1 ) {
184+ return false ;
185+ }
162186 if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::Ds1ToDstarK0s) {
163187 massV0 = massK0;
164188 invMassV0 = candV0.invMassK0s ();
@@ -175,12 +199,17 @@ struct HfCandidateCreatorCharmResoReduced {
175199 invMassV0 = candV0.invMassAntiLambda ();
176200 targetV0Type = V0Type::AntiLambda;
177201 }
202+ // check skimming cuts
178203 if (!TESTBIT (candV0.v0Type (), targetV0Type)) {
179204 return false ;
180205 }
181206 }
182- // slection on V0 candidate mass
183- if (std::fabs (invMassV0 - massV0) > invMassWindowV0) {
207+ // selection on V0 candidate mass
208+ if ((invMassV0 - massV0) > cutsV0->get (ptBin, " invMassLow" ) && (massV0 - invMassV0) < cutsV0->get (ptBin, " invMassLow" )) {
209+ return false ;
210+ }
211+ // selection on kinematics and topology
212+ if (candV0.dca () > cutsV0->get (ptBin, " dcaMax" ) || candV0.cpa () < cutsV0->get (ptBin, " cpaMin" ) || candV0.v0Radius () < cutsV0->get (ptBin, " radiusMin" )) {
184213 return false ;
185214 }
186215 return true ;
@@ -211,7 +240,7 @@ struct HfCandidateCreatorCharmResoReduced {
211240 if (candD.dType () == -2 )
212241 invMassD = candD.invMassAntiDstar ();
213242 std::array<float , 3 > pVecD = {candD.px (), candD.py (), candD.pz ()};
214- float ptD = RecoDecay::pt (pVecD) ;
243+ std::array< int , 3 > dDaughtersIds = {candD. prong0Id (), candD. prong1Id (), candD. prong2Id ()} ;
215244 ;
216245 // loop on V0 candidates
217246 bool alreadyCounted{false };
@@ -233,7 +262,6 @@ struct HfCandidateCreatorCharmResoReduced {
233262 float invMassReso{0 .};
234263 float invMassV0{0 .};
235264 std::array<float , 3 > pVecV0 = {candV0.px (), candV0.py (), candV0.pz ()};
236- float ptV0 = RecoDecay::pt (pVecV0);
237265 float ptReso = RecoDecay::pt (RecoDecay::sumOfVec (pVecV0, pVecD));
238266 switch (channel) {
239267 case DecayChannel::Ds1ToDstarK0s:
@@ -269,15 +297,14 @@ struct HfCandidateCreatorCharmResoReduced {
269297 }
270298 // Filling Output table
271299 rowCandidateReso (collision.globalIndex (),
300+ pVecD[0 ], pVecD[1 ], pVecD[2 ],
301+ pVecV0[0 ], pVecV0[1 ], pVecV0[2 ],
272302 invMassReso,
273- ptReso,
274303 invMassD,
275- ptD,
276304 invMassV0,
277- ptV0,
278305 candV0.cpa (),
279306 candV0.dca (),
280- candV0.v0radius ());
307+ candV0.v0Radius ());
281308 if constexpr (fillMl) {
282309 mlScores (candD.mlScoreBkgMassHypo0 (), candD.mlScorePromptMassHypo0 (), candD.mlScoreNonpromptMassHypo0 ());
283310 }
0 commit comments