@@ -50,11 +50,6 @@ enum Daughtertype {
5050 kPosdaugh ,
5151 kNegdaugh
5252};
53-
54- enum ResoMothers {
55- kPhi ,
56- kKStar
57- };
5853} // namespace femto_dream_reso_selection
5954
6055class FemtoDreamResoSelection
@@ -70,7 +65,7 @@ class FemtoDreamResoSelection
7065 virtual ~FemtoDreamResoSelection () = default ;
7166
7267 template <typename V>
73- uint32_t getType (V const & track1, V const & track2);
68+ uint32_t getType (V const & track1, V const & track2, bool resoIsNotAnti );
7469
7570 // / assigns value from configurbale to private class member
7671 template <typename V>
@@ -104,21 +99,19 @@ class FemtoDreamResoSelection
10499 bool daughterSelectionNeg (V const & track2);
105100
106101 template <typename V, typename T>
107- bool isSelectedMinimalPIDPos (V const & track1, T const & pids );
102+ bool isSelectedMinimalPIDPos (V const & track1, T const & pidVector );
108103
109104 template <typename V, typename T>
110- bool isSelectedMinimalPIDNeg (V const & track2, T const & pids );
105+ bool isSelectedMinimalPIDNeg (V const & track2, T const & pidVector );
111106
112107 template <typename cutContainerType, typename V>
113108 std::array<cutContainerType, 5 > getCutContainer (V const & track1, V const & track2, float sign);
114109
115- template <typename T>
116- std::pair<bool , bool > checkCombination (T const & PosTrack, T const & NegTrack, femto_dream_reso_selection::ResoMothers mother);
117-
118- std::pair<o2::track::PID::ID, o2::track::PID::ID> getPIDPairFromMother (femto_dream_reso_selection::ResoMothers mother);
110+ template <typename T, typename V>
111+ std::pair<bool , bool > checkCombination (T const & PosTrack, T const & NegTrack, V const & pidVector, float massDiff, float massDiffAnti, bool useMassDiff);
119112
120- template <typename T>
121- bool checkPID (T const & Track, float nSigTPC, float nSigTOF , float nSig2TPC, float nSig2TOF, float PTPCThrvalue );
113+ template <typename T, typename V >
114+ float getNSigTotal (T const & track, V const & pid , float const & threshold );
122115
123116 void updateThreshold ()
124117 {
@@ -149,8 +142,6 @@ class FemtoDreamResoSelection
149142 }
150143 }
151144
152- std::pair<float , float > getMassDaughters (femto_dream_reso_selection::ResoMothers mother);
153-
154145 // / The following functions might not be needed, as right now there is only one ResoSel (sign).
155146 // / However all the other selections are implemented this way (also in the CutCulator).
156147 // / So for now this is implemented analogous (migth also be beneficial if further ResoSels want to be implemented).
@@ -227,18 +218,28 @@ class FemtoDreamResoSelection
227218}; // namespace femtoDream
228219
229220template <typename V>
230- uint32_t FemtoDreamResoSelection::getType (V const & track1, V const & track2)
221+ uint32_t FemtoDreamResoSelection::getType (V const & track1, V const & track2, bool resoIsNotAnti )
231222{
232- if (track1.pt () <= mDaughPTPCThr [0 ] && track2.pt () <= mDaughPTPCThr [1 ]) {
223+ float posThresh = 0 .;
224+ float negThresh = 0 .;
225+ if (resoIsNotAnti) {
226+ posThresh = mDaughPTPCThr [0 ];
227+ negThresh = mDaughPTPCThr [1 ];
228+ } else {
229+ posThresh = mDaughPTPCThr [1 ];
230+ negThresh = mDaughPTPCThr [0 ];
231+ }
232+
233+ if (track1.pt () <= posThresh && track2.pt () <= negThresh) {
233234 return aod::femtodreamparticle::kResoPosdaughTPC_NegdaughTPC ;
234235 }
235- if (track1.pt () <= mDaughPTPCThr [ 0 ] && track2.pt () > mDaughPTPCThr [ 1 ] ) {
236+ if (track1.pt () <= posThresh && track2.pt () > negThresh ) {
236237 return aod::femtodreamparticle::kResoPosdaughTPC_NegdaughTOF ;
237238 }
238- if (track1.pt () > mDaughPTPCThr [ 0 ] && track2.pt () <= mDaughPTPCThr [ 1 ] ) {
239+ if (track1.pt () > posThresh && track2.pt () <= negThresh ) {
239240 return aod::femtodreamparticle::kResoPosdaughTOF_NegdaughTPC ;
240241 }
241- if (track1.pt () > mDaughPTPCThr [ 0 ] && track2.pt () > mDaughPTPCThr [ 1 ] ) {
242+ if (track1.pt () > posThresh && track2.pt () > negThresh ) {
242243 return aod::femtodreamparticle::kResoPosdaughTOF_NegdaughTOF ;
243244 }
244245 return 255 ; // as error filler
@@ -321,101 +322,94 @@ bool FemtoDreamResoSelection::daughterSelectionNeg(V const& track2)
321322}
322323
323324template <typename V, typename T>
324- bool FemtoDreamResoSelection::isSelectedMinimalPIDPos (V const & track1, T const & pid )
325+ bool FemtoDreamResoSelection::isSelectedMinimalPIDPos (V const & track1, T const & pidVector )
325326{
326- float pidTPC = posDaughTrack.getNsigmaTPC (track1, pid); // pids[0] for pos track
327- float pidTOF = posDaughTrack.getNsigmaTOF (track1, pid);
328-
329- bool pass = false ;
330- if (track1.pt () < mDaughPTPCThr [0 ]) {
331- pass = std::fabs (pidTPC) < mSigmaPIDMax ;
332- } else {
333- pass = std::sqrt (pidTPC * pidTPC + pidTOF * pidTOF) < mSigmaPIDMax ;
327+ int pidVecSize = pidVector.size ();
328+ for (int i = 0 ; i < pidVecSize; i++) {
329+ const float pidTPC = posDaughTrack.getNsigmaTPC (track1, pidVector[i]);
330+ const float pidTOF = posDaughTrack.getNsigmaTOF (track1, pidVector[i]);
331+
332+ if (track1.pt () < mDaughPTPCThr [i]) {
333+ if (std::fabs (pidTPC) < mSigmaPIDMax ) {
334+ return true ;
335+ }
336+ } else if ((std::sqrt (pidTPC * pidTPC + pidTOF * pidTOF) < mSigmaPIDMax )) {
337+ return true ;
338+ }
334339 }
335-
336- return pass;
340+ return false ;
337341}
338342
339343template <typename V, typename T>
340- bool FemtoDreamResoSelection::isSelectedMinimalPIDNeg (V const & track2, T const & pid )
344+ bool FemtoDreamResoSelection::isSelectedMinimalPIDNeg (V const & track2, T const & pidVector )
341345{
342- float pidTPC = negDaughTrack.getNsigmaTPC (track2, pid); // pids[1] for neg track
343- float pidTOF = negDaughTrack.getNsigmaTOF (track2, pid);
344-
345- bool pass = false ;
346- if (track2.pt () < mDaughPTPCThr [1 ]) {
347- pass = std::fabs (pidTPC) < mSigmaPIDMax ;
348- } else {
349- pass = std::sqrt (pidTPC * pidTPC + pidTOF * pidTOF) < mSigmaPIDMax ;
346+ int pidVecSize = pidVector.size ();
347+ for (int i = 0 ; i < pidVecSize; i++) {
348+ const float pidTPC = negDaughTrack.getNsigmaTPC (track2, pidVector[i]);
349+ const float pidTOF = negDaughTrack.getNsigmaTOF (track2, pidVector[i]);
350+
351+ if (track2.pt () < mDaughPTPCThr [i]) {
352+ if (std::fabs (pidTPC) < mSigmaPIDMax ) {
353+ return true ;
354+ }
355+ } else if ((std::sqrt (pidTPC * pidTPC + pidTOF * pidTOF) < mSigmaPIDMax )) {
356+ return true ;
357+ }
350358 }
351-
352- return pass;
359+ return false ;
353360}
354361
355- template <typename T>
356- std::pair<bool , bool > FemtoDreamResoSelection::checkCombination (T const & PosTrack, T const & NegTrack, femto_dream_reso_selection::ResoMothers mother )
362+ template <typename T, typename V >
363+ std::pair<bool , bool > FemtoDreamResoSelection::checkCombination (T const & PosTrack, T const & NegTrack, V const & pidVector, float massDiff, float massDiffAnti, bool useMassDiff )
357364{
358- // / first bool: normal or anti
365+ // / first bool: true ( normal resonance) / false ( anti resonance)
359366 // / second bool: is not a valid combination
360367
361- auto [part1, part2] = getPIDPairFromMother (mother);
368+ const auto part1 = pidVector[0 ]; // / particle type 1
369+ const auto part2 = pidVector[1 ]; // / particle type 2
370+
371+ float nSigPosPart1Total = getNSigTotal (PosTrack, part1, mDaughPTPCThr [0 ]); // / Total propability that PosTrack is of particle type 1
372+ float nSigPosPart2Total = getNSigTotal (PosTrack, part2, mDaughPTPCThr [1 ]); // / Total propability that PosTrack is of particle type 2
373+ float nSigNegPart1Total = getNSigTotal (NegTrack, part1, mDaughPTPCThr [0 ]);
374+ float nSigNegPart2Total = getNSigTotal (NegTrack, part2, mDaughPTPCThr [1 ]);
375+
376+ // check if PosTrack is more likely to be part1 than part2 (and vice versa for NegTrack) -> normal resonance
377+ bool couldBeNormal = nSigPosPart1Total < nSigPosPart2Total && nSigNegPart2Total < nSigNegPart1Total;
378+ // check if PosTrack is more likely to be part2 than part1 (and vice versa for NegTrack) -> anti resonance
379+ bool couldBeAnti = nSigPosPart2Total < nSigPosPart1Total && nSigNegPart1Total < nSigNegPart2Total;
362380
363- float nSigPosTPC1 = o2::aod::pidutils::tpcNSigma (part1, PosTrack) - mPIDoffsetTPC ;
364- float nSigPosTOF1 = posDaughTrack.getNsigmaTOF (PosTrack, part1) - mPIDoffsetTOF ; // / for TOF use function in TrackSelection, because it also checks hasTOF()
365- float nSigPosTPC2 = o2::aod::pidutils::tpcNSigma (part2, PosTrack) - mPIDoffsetTPC ;
366- float nSigPosTOF2 = posDaughTrack.getNsigmaTOF (PosTrack, part2) - mPIDoffsetTOF ;
367- float nSigNegTPC1 = o2::aod::pidutils::tpcNSigma (part1, NegTrack) - mPIDoffsetTPC ;
368- float nSigNegTOF1 = negDaughTrack.getNsigmaTOF (NegTrack, part1) - mPIDoffsetTOF ;
369- float nSigNegTPC2 = o2::aod::pidutils::tpcNSigma (part2, NegTrack) - mPIDoffsetTPC ;
370- float nSigNegTOF2 = negDaughTrack.getNsigmaTOF (NegTrack, part2) - mPIDoffsetTOF ;
381+ if (useMassDiff) {
382+ couldBeNormal = couldBeNormal && massDiff < massDiffAnti;
383+ couldBeAnti = couldBeAnti && massDiffAnti < massDiff;
384+ }
371385
372- if (checkPID (PosTrack, nSigPosTPC1, nSigPosTOF1, nSigPosTPC2, nSigPosTOF2, mDaughPTPCThr [ 0 ]) && checkPID (NegTrack, nSigNegTPC2, nSigNegTOF2, nSigNegTPC1, nSigNegTOF1, mDaughPTPCThr [ 1 ]) ) {
386+ if (couldBeNormal && !couldBeAnti ) {
373387 return {true , false };
374- } else if (checkPID (PosTrack, nSigPosTPC2, nSigPosTOF2, nSigPosTPC1, nSigPosTOF1, mDaughPTPCThr [0 ]) && checkPID (NegTrack, nSigNegTPC1, nSigNegTOF1, nSigNegTPC2, nSigNegTOF2, mDaughPTPCThr [1 ])) {
388+ }
389+ if (!couldBeNormal && couldBeAnti) {
375390 return {false , false };
376- } else {
377- return {false , true };
378391 }
392+ // if ambiguous (both true) or invalid (both false)
393+ return {false , true };
379394}
380395
381- template <typename T>
382- bool FemtoDreamResoSelection::checkPID (T const & Track, float nSig1TPC, float nSig1TOF , float nSig2TPC, float nSig2TOF, float PTPCThrvalue )
396+ template <typename T, typename V >
397+ float FemtoDreamResoSelection::getNSigTotal (T const & track, V const & pid , float const & threshold )
383398{
384- if (Track.pt () < PTPCThrvalue) {
385- return (std::abs (nSig1TPC) <= std::abs (nSig2TPC));
386- } else {
387- return (std::sqrt (nSig1TPC * nSig1TPC + nSig1TOF * nSig1TOF) <= std::sqrt (nSig2TPC * nSig2TPC + nSig2TOF * nSig2TOF));
388- }
389- }
399+ float nSigTPC = o2::aod::pidutils::tpcNSigma (pid, track);
400+ float pTtrack = track.pt ();
390401
391- std::pair<o2::track::PID::ID, o2::track::PID::ID> FemtoDreamResoSelection::getPIDPairFromMother (femto_dream_reso_selection::ResoMothers mother)
392- {
393- // / return is structured this way:
394- // / The mother particle is assumed to be normal (not antiparticle). Then:
395- // / 1. return value is positive daughter
396- // / 2. return value is negative daughter
397- switch (mother) {
398- case (femto_dream_reso_selection::kPhi ):
399- return {o2::track::PID::Kaon, o2::track::PID::Kaon};
400- case (femto_dream_reso_selection::kKStar ):
401- return {o2::track::PID::Kaon, o2::track::PID::Pion};
402- default :
403- LOG (warn) << " MotherPID not implemented in femto_dream_reso_selection.getPIDPairFromMother" ;
404- return {o2::track::PID::Kaon, o2::track::PID::Kaon};
402+ if (pTtrack < threshold) {
403+ return std::abs (nSigTPC);
405404 }
406- }
407405
408- std::pair<float , float > FemtoDreamResoSelection::getMassDaughters (femto_dream_reso_selection::ResoMothers mother)
409- {
410- switch (mother) {
411- case (femto_dream_reso_selection::kPhi ):
412- return {o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus};
413- case (femto_dream_reso_selection::kKStar ):
414- return {o2::constants::physics::MassKPlus, o2::constants::physics::MassPiPlus};
415- default :
416- LOG (warn) << " MotherPID not implemented in femto_dream_reso_selection.getMassDauhters" ;
417- return {o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus};
406+ float nSigTOF = 0 .;
407+ if (!track.hasTOF ()) {
408+ nSigTOF = 999 .f ;
409+ } else {
410+ nSigTOF = o2::aod::pidutils::tofNSigma (pid, track);
418411 }
412+ return std::sqrt (nSigTPC * nSigTPC + nSigTOF * nSigTOF);
419413}
420414
421415// // new getCutContainer
0 commit comments