@@ -55,13 +55,14 @@ struct Alice3Lepton {
5555 kCe = 0 ,
5656 kBe = 1 ,
5757 kBCe = 2 ,
58- kPPi0 = 4 ,
58+ kPPi0 = 3 ,
59+ kHFE = 4 ,
5960 };
6061
6162 Service<o2::framework::O2DatabasePDG> inspdg;
6263
6364 Configurable<int > pdg{" pdg" , 11 , " pdg code for analysis. dielectron:11, dimuon:13" };
64- Configurable<int > requireHFE{" requireHFE" , -1 , " -1: no selection, 0: charm, 1: direct beauty, 2: beauty->charm->e, 3: HFE , 4: promptPi0 " };
65+ Configurable<int > requireHFE{" requireHFE" , -1 , " -1: no selection, 0: charm, 1: direct beauty, 2: beauty->charm->e, 3: promptPi0 , 4: HFE " };
6566 Configurable<float > ptMin{" ptMin" , 0 .f , " Lower limit in pT" };
6667 Configurable<float > ptMax{" ptMax" , 5 .f , " Upper limit in pT" };
6768 Configurable<float > etaMin{" etaMin" , -5 .f , " Lower limit in eta" };
@@ -92,7 +93,7 @@ struct Alice3Lepton {
9293 const AxisSpec axisTrackLengthOuterTOF{300 , 0 ., 300 ., " Track length (cm)" };
9394 const AxisSpec axisEta{1000 , -5 , 5 , " #it{#eta}" };
9495 const AxisSpec axisDCAxysigma{1000 , -20 , 20 , " DCA_{xy} (#sigma)" };
95- const AxisSpec axisDCAxy{1000 , -1000 , 1000 , " DCA_{xy} (#micro m)" };
96+ const AxisSpec axisDCAxy{1200 , -300 , 300 , " DCA_{xy} (#micro m)" };
9697 const AxisSpec axisPhi{360 , 0 , TMath::TwoPi (), " #it{#varphi} (rad.)" };
9798 const AxisSpec axisProdx{2000 , -100 , 100 , " Prod. Vertex X (cm)" };
9899 const AxisSpec axisPrody{2000 , -100 , 100 , " Prod. Vertex Y (cm)" };
@@ -162,8 +163,9 @@ struct Alice3Lepton {
162163 template <typename TMCParticle1, typename TMCParticles>
163164 int IsHF (TMCParticle1 const & p1, TMCParticles const & mcparticles)
164165 {
165- if (!p1.has_mothers ())
166+ if (!p1.has_mothers ()) {
166167 return HFType::kUndef ;
168+ }
167169
168170 int motherid_p1 = p1.mothersIds ()[0 ];
169171 if (motherid_p1 > -1 ) {
@@ -285,15 +287,12 @@ struct Alice3Lepton {
285287 continue ;
286288 }
287289 }
288- if (std::abs (mcParticle.pdgCode ()) != pdg) {
289- continue ;
290- }
291290 if (requireHFE > -1 ) {
292291 int typehfe = IsHF (mcParticle, mcParticles);
293- if (requireHFE < 3 && typehfe != requireHFE) {
292+ if (requireHFE < HFType:: kHFE && typehfe != requireHFE) {
294293 continue ;
295294 }
296- if (requireHFE == 3 && typehfe == HFType::kUndef ) {
295+ if (requireHFE == HFType:: kHFE && ( typehfe == HFType::kUndef || typehfe == kPPi0 ) ) {
297296 continue ;
298297 }
299298 }
@@ -431,10 +430,10 @@ struct Alice3Lepton {
431430 }
432431 if (requireHFE > -1 ) {
433432 int typehfe = IsHF (mcParticle, mcParticles);
434- if (requireHFE < 3 && typehfe != requireHFE) {
433+ if (requireHFE < HFType:: kHFE && typehfe != requireHFE) {
435434 continue ;
436435 }
437- if (requireHFE == 3 && typehfe == HFType::kUndef ) {
436+ if (requireHFE == HFType:: kHFE && ( typehfe == HFType::kUndef || typehfe == kPPi0 ) ) {
438437 continue ;
439438 }
440439 }
@@ -528,7 +527,8 @@ struct Alice3Dilepton {
528527 SliceCache cache_rec;
529528
530529 Configurable<int > pdg{" pdg" , 11 , " pdg code for analysis. dielectron:11, dimuon:13" };
531- Configurable<bool > requireHFEid{" requireHFEid" , true , " Require HFE identification for both leptons" };
530+ Configurable<bool > requireHFEid{" requireHFEid" , true , " Require HFE identification" };
531+ Configurable<bool > contamination{" contamination" , false , " Fill only pairs with one misidentifixed electrons" };
532532 Configurable<float > ptMin{" ptMin" , 0 .f , " Lower limit in pT" };
533533 Configurable<float > ptMax{" ptMax" , 5 .f , " Upper limit in pT" };
534534 Configurable<float > etaMin{" etaMin" , -5 .f , " Lower limit in eta" };
@@ -629,13 +629,40 @@ struct Alice3Dilepton {
629629 }
630630 }
631631
632+ template <typename TTrack, typename TMCParticles>
633+ bool IsHF (TTrack const & track, TMCParticles const & mcparticles)
634+ {
635+ if (!track.has_mcParticle ()) {
636+ return false ;
637+ }
638+ const auto p1 = track.template mcParticle_as <aod::McParticles>();
639+ if (!p1.has_mothers ()) {
640+ return false ;
641+ }
642+ int motherId = p1.mothersIds ()[0 ];
643+ while (motherId > -1 ) {
644+ auto mp = mcparticles.rawIteratorAt (motherId);
645+ if (((500 < std::abs (mp.pdgCode ()) && std::abs (mp.pdgCode ()) < 599 ) || (5000 < std::abs (mp.pdgCode ()) && std::abs (mp.pdgCode ()) < 5999 )) || ((400 < std::abs (mp.pdgCode ()) && std::abs (mp.pdgCode ()) < 499 ) || (4000 < std::abs (mp.pdgCode ()) && std::abs (mp.pdgCode ()) < 4999 ))) {
646+ return true ;
647+ }
648+ if (mp.has_mothers ()) {
649+ motherId = mp.mothersIds ()[0 ];
650+ } else {
651+ motherId = -999 ;
652+ }
653+ }
654+ return false ;
655+ }
656+
632657 template <typename TMCParticle1, typename TMCParticle2, typename TMCParticles>
633658 int IsSameMother (TMCParticle1 const & p1, TMCParticle2 const & p2, TMCParticles const & mcparticles)
634659 {
635- if (!p1.has_mothers ())
660+ if (!p1.has_mothers ()) {
636661 return -1 ;
637- if (!p2.has_mothers ())
662+ }
663+ if (!p2.has_mothers ()) {
638664 return -1 ;
665+ }
639666
640667 int motherid1 = p1.mothersIds ()[0 ];
641668 auto mother1 = mcparticles.iteratorAt (motherid1);
@@ -645,10 +672,12 @@ struct Alice3Dilepton {
645672 auto mother2 = mcparticles.iteratorAt (motherid2);
646673 int mother2_pdg = mother2.pdgCode ();
647674
648- if (motherid1 != motherid2)
675+ if (motherid1 != motherid2) {
649676 return -1 ;
650- if (mother1_pdg != mother2_pdg)
677+ }
678+ if (mother1_pdg != mother2_pdg) {
651679 return -1 ;
680+ }
652681
653682 if (std::abs (mother1_pdg) != PDG_t::kGamma // photon
654683 && std::abs (mother1_pdg) != PDG_t::kPi0 // pi0
@@ -674,10 +703,12 @@ struct Alice3Dilepton {
674703 // 1. b->e- and bbar->e+ (different b and bbar)
675704 // 2. b->c->e+ and bbar->cbar->e- (different b and bbar)
676705 // 3. b->c->e+ and b->e- (1 same b (or bbar))
677- if (!p1.has_mothers ())
706+ if (!p1.has_mothers ()) {
678707 return HFllType::kUndef ;
679- if (!p2.has_mothers ())
708+ }
709+ if (!p2.has_mothers ()) {
680710 return HFllType::kUndef ;
711+ }
681712
682713 int motherid_p1 = p1.mothersIds ()[0 ];
683714 int motherid_p2 = p2.mothersIds ()[0 ];
@@ -727,10 +758,12 @@ struct Alice3Dilepton {
727758 {
728759 // in total, 1 case for LS pairs
729760 // 4. b->c->e+ and bbar->e+
730- if (!p1.has_mothers ())
761+ if (!p1.has_mothers ()) {
731762 return HFllType::kUndef ;
732- if (!p2.has_mothers ())
763+ }
764+ if (!p2.has_mothers ()) {
733765 return HFllType::kUndef ;
766+ }
734767
735768 int motherid_p1 = p1.mothersIds ()[0 ];
736769 int motherid_p2 = p2.mothersIds ()[0 ];
@@ -788,13 +821,27 @@ struct Alice3Dilepton {
788821 }
789822
790823 template <bool isWithSmearing, PairType pairtype, typename TTracks>
791- void FillPairRecAll (TTracks const & tracks1, TTracks const & tracks2)
824+ void FillPairRecAll (TTracks const & tracks1, TTracks const & tracks2, const aod::McParticles& mcParticles )
792825 {
793826 if constexpr (pairtype == PairType::kULS ) {
794827 for (const auto & [t1, t2] : combinations (soa::CombinationsFullIndexPolicy (tracks1, tracks2))) {
795828 if (!IsInAcceptance<isWithSmearing>(t1) || !IsInAcceptance<isWithSmearing>(t2)) {
796829 continue ;
797830 }
831+ if (contamination) {
832+ if (t1.has_mcParticle () && t2.has_mcParticle ()) {
833+ auto mct1 = t1.template mcParticle_as <aod::McParticles>();
834+ auto mct2 = t2.template mcParticle_as <aod::McParticles>();
835+ if (std::abs (mct1.pdgCode ()) == pdg && std::abs (mct2.pdgCode ()) == pdg) {
836+ continue ;
837+ }
838+ }
839+ }
840+ if (requireHFEid) {
841+ if (!IsHF (t1, mcParticles) && !IsHF (t2, mcParticles)) {
842+ continue ;
843+ }
844+ }
798845 float pair_dca_xy = 999 .f ;
799846 ROOT ::Math::PtEtaPhiMVector v12 = buildPairDCA<isWithSmearing>(t1, t2, pair_dca_xy);
800847
@@ -811,6 +858,20 @@ struct Alice3Dilepton {
811858 if (!IsInAcceptance<isWithSmearing>(t1) || !IsInAcceptance<isWithSmearing>(t2)) {
812859 continue ;
813860 }
861+ if (contamination) {
862+ if (t1.has_mcParticle () && t2.has_mcParticle ()) {
863+ auto mct1 = t1.template mcParticle_as <aod::McParticles>();
864+ auto mct2 = t2.template mcParticle_as <aod::McParticles>();
865+ if (std::abs (mct1.pdgCode ()) == pdg && std::abs (mct2.pdgCode ()) == pdg) {
866+ continue ;
867+ }
868+ }
869+ }
870+ if (requireHFEid) {
871+ if (!IsHF (t1, mcParticles) && !IsHF (t2, mcParticles)) {
872+ continue ;
873+ }
874+ }
814875 float pair_dca_xy = 999 .f ;
815876 ROOT ::Math::PtEtaPhiMVector v12 = buildPairDCA<isWithSmearing>(t1, t2, pair_dca_xy);
816877
@@ -1084,7 +1145,7 @@ struct Alice3Dilepton {
10841145
10851146 void processRecAll (MyFilteredAlice3Collision const & collisions,
10861147 MyFilteredTracksMC const &,
1087- const aod::McParticles&)
1148+ const aod::McParticles& mcParticles )
10881149 {
10891150 for (const auto & collision : collisions) {
10901151 registry.fill (HIST (" Reconstructed/Event/VtxZ" ), collision.posZ ());
@@ -1125,9 +1186,9 @@ struct Alice3Dilepton {
11251186 registry.fill (HIST (" Reconstructed/Track/Pre" ), track.isTrackPrefilter ());
11261187 }
11271188
1128- FillPairRecAll<false , PairType::kULS >(negTracks_coll, posTracks_coll);
1129- FillPairRecAll<false , PairType::kLSpp >(posTracks_coll, posTracks_coll);
1130- FillPairRecAll<false , PairType::kLSnn >(negTracks_coll, negTracks_coll);
1189+ FillPairRecAll<false , PairType::kULS >(negTracks_coll, posTracks_coll, mcParticles );
1190+ FillPairRecAll<false , PairType::kLSpp >(posTracks_coll, posTracks_coll, mcParticles );
1191+ FillPairRecAll<false , PairType::kLSnn >(negTracks_coll, negTracks_coll, mcParticles );
11311192
11321193 } // end of collision loop
11331194 } // end of processRec
@@ -1150,7 +1211,7 @@ struct Alice3Dilepton {
11501211
11511212 void processRecAllWithSmearing (MyFilteredAlice3Collision const & collisions,
11521213 MyFilteredTracksWithSmearing const &,
1153- const aod::McParticles&)
1214+ const aod::McParticles& mcParticles )
11541215 {
11551216 for (const auto & collision : collisions) {
11561217 registry.fill (HIST (" Reconstructed/Event/VtxZ" ), collision.posZ ());
@@ -1191,9 +1252,9 @@ struct Alice3Dilepton {
11911252 registry.fill (HIST (" Reconstructed/Track/Pre" ), track.isTrackPrefilter ());
11921253 }
11931254
1194- FillPairRecAll<true , PairType::kULS >(negTracks_coll, posTracks_coll);
1195- FillPairRecAll<true , PairType::kLSpp >(posTracks_coll, posTracks_coll);
1196- FillPairRecAll<true , PairType::kLSnn >(negTracks_coll, negTracks_coll);
1255+ FillPairRecAll<true , PairType::kULS >(negTracks_coll, posTracks_coll, mcParticles );
1256+ FillPairRecAll<true , PairType::kLSpp >(posTracks_coll, posTracks_coll, mcParticles );
1257+ FillPairRecAll<true , PairType::kLSnn >(negTracks_coll, negTracks_coll, mcParticles );
11971258
11981259 } // end of collision loop
11991260 } // end of processRec
0 commit comments