@@ -78,7 +78,7 @@ using MyElectron = MyElectrons::iterator;
7878using FilteredMyElectrons = soa::Filtered<MyElectrons>;
7979using FilteredMyElectron = FilteredMyElectrons::iterator;
8080
81- using MyMuons = soa::Join<aod::EMPrimaryMuons, aod::EMPrimaryMuonEMEventIds, aod::EMAmbiguousMuonSelfIds>;
81+ using MyMuons = soa::Join<aod::EMPrimaryMuons, aod::EMPrimaryMuonEMEventIds, aod::EMAmbiguousMuonSelfIds, aod::EMGlobalMuonSelfIds >;
8282using MyMuon = MyMuons::iterator;
8383using FilteredMyMuons = soa::Filtered<MyMuons>;
8484using FilteredMyMuon = FilteredMyMuons::iterator;
@@ -771,8 +771,8 @@ struct Dilepton {
771771 }
772772 }
773773
774- template <int ev_id, typename TCollision, typename TTrack1, typename TTrack2, typename TCut>
775- bool fillPairInfo (TCollision const & collision, TTrack1 const & t1, TTrack2 const & t2, TCut const & cut)
774+ template <int ev_id, typename TCollision, typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks >
775+ bool fillPairInfo (TCollision const & collision, TTrack1 const & t1, TTrack2 const & t2, TCut const & cut, TAllTracks const & tracks )
776776 {
777777 if constexpr (ev_id == 1 ) {
778778 if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron ) {
@@ -813,6 +813,13 @@ struct Dilepton {
813813 if (!cut.template IsSelectedTrack <false >(t1) || !cut.template IsSelectedTrack <false >(t2)) {
814814 return false ;
815815 }
816+
817+ if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch (t1, cut, tracks)) {
818+ return false ;
819+ }
820+ if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch (t2, cut, tracks)) {
821+ return false ;
822+ }
816823 }
817824 }
818825
@@ -1112,8 +1119,8 @@ struct Dilepton {
11121119 std::vector<std::pair<int , int >> used_trackIds;
11131120 int ndf = 0 ;
11141121
1115- template <bool isTriggerAnalysis, typename TCollisions, typename TLeptons, typename TPresilce, typename TCut>
1116- void runPairing (TCollisions const & collisions, TLeptons const & posTracks, TLeptons const & negTracks, TPresilce const & perCollision, TCut const & cut)
1122+ template <bool isTriggerAnalysis, typename TCollisions, typename TLeptons, typename TPresilce, typename TCut, typename TAllTracks >
1123+ void runPairing (TCollisions const & collisions, TLeptons const & posTracks, TLeptons const & negTracks, TPresilce const & perCollision, TCut const & cut, TAllTracks const & tracks )
11171124 {
11181125 for (auto & collision : collisions) {
11191126 initCCDB<isTriggerAnalysis>(collision);
@@ -1190,19 +1197,19 @@ struct Dilepton {
11901197
11911198 int nuls = 0 , nlspp = 0 , nlsmm = 0 ;
11921199 for (auto & [pos, neg] : combinations (CombinationsFullIndexPolicy (posTracks_per_coll, negTracks_per_coll))) { // ULS
1193- bool is_pair_ok = fillPairInfo<0 >(collision, pos, neg, cut);
1200+ bool is_pair_ok = fillPairInfo<0 >(collision, pos, neg, cut, tracks );
11941201 if (is_pair_ok) {
11951202 nuls++;
11961203 }
11971204 }
11981205 for (auto & [pos1, pos2] : combinations (CombinationsStrictlyUpperIndexPolicy (posTracks_per_coll, posTracks_per_coll))) { // LS++
1199- bool is_pair_ok = fillPairInfo<0 >(collision, pos1, pos2, cut);
1206+ bool is_pair_ok = fillPairInfo<0 >(collision, pos1, pos2, cut, tracks );
12001207 if (is_pair_ok) {
12011208 nlspp++;
12021209 }
12031210 }
12041211 for (auto & [neg1, neg2] : combinations (CombinationsStrictlyUpperIndexPolicy (negTracks_per_coll, negTracks_per_coll))) { // LS--
1205- bool is_pair_ok = fillPairInfo<0 >(collision, neg1, neg2, cut);
1212+ bool is_pair_ok = fillPairInfo<0 >(collision, neg1, neg2, cut, tracks );
12061213 if (is_pair_ok) {
12071214 nlsmm++;
12081215 }
@@ -1282,25 +1289,25 @@ struct Dilepton {
12821289
12831290 for (auto & pos : selected_posTracks_in_this_event) { // ULS mix
12841291 for (auto & neg : negTracks_from_event_pool) {
1285- fillPairInfo<1 >(collision, pos, neg, cut);
1292+ fillPairInfo<1 >(collision, pos, neg, cut, tracks );
12861293 }
12871294 }
12881295
12891296 for (auto & neg : selected_negTracks_in_this_event) { // ULS mix
12901297 for (auto & pos : posTracks_from_event_pool) {
1291- fillPairInfo<1 >(collision, neg, pos, cut);
1298+ fillPairInfo<1 >(collision, neg, pos, cut, tracks );
12921299 }
12931300 }
12941301
12951302 for (auto & pos1 : selected_posTracks_in_this_event) { // LS++ mix
12961303 for (auto & pos2 : posTracks_from_event_pool) {
1297- fillPairInfo<1 >(collision, pos1, pos2, cut);
1304+ fillPairInfo<1 >(collision, pos1, pos2, cut, tracks );
12981305 }
12991306 }
13001307
13011308 for (auto & neg1 : selected_negTracks_in_this_event) { // LS-- mix
13021309 for (auto & neg2 : negTracks_from_event_pool) {
1303- fillPairInfo<1 >(collision, neg1, neg2, cut);
1310+ fillPairInfo<1 >(collision, neg1, neg2, cut, tracks );
13041311 }
13051312 }
13061313 } // end of loop over mixed event pool
@@ -1315,8 +1322,8 @@ struct Dilepton {
13151322
13161323 } // end of DF
13171324
1318- template <typename TCollision, typename TTrack1, typename TTrack2, typename TCut>
1319- bool isPairOK (TCollision const & collision, TTrack1 const & t1, TTrack2 const & t2, TCut const & cut)
1325+ template <typename TCollision, typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks >
1326+ bool isPairOK (TCollision const & collision, TTrack1 const & t1, TTrack2 const & t2, TCut const & cut, TAllTracks const & tracks )
13201327 {
13211328 if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron ) {
13221329 if (dielectroncuts.cfg_pid_scheme == static_cast <int >(DielectronCut::PIDSchemes::kPIDML )) {
@@ -1332,6 +1339,13 @@ struct Dilepton {
13321339 if (!cut.IsSelectedTrack (t1) || !cut.IsSelectedTrack (t2)) {
13331340 return false ;
13341341 }
1342+
1343+ if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch (t1, cut, tracks)) {
1344+ return false ;
1345+ }
1346+ if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch (t2, cut, tracks)) {
1347+ return false ;
1348+ }
13351349 }
13361350
13371351 if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron ) {
@@ -1398,17 +1412,17 @@ struct Dilepton {
13981412 auto negTracks_per_coll = negTracks.sliceByCached (perCollision, collision.globalIndex (), cache);
13991413
14001414 for (auto & [pos, neg] : combinations (CombinationsFullIndexPolicy (posTracks_per_coll, negTracks_per_coll))) { // ULS
1401- if (isPairOK (collision, pos, neg, cut)) {
1415+ if (isPairOK (collision, pos, neg, cut, tracks )) {
14021416 passed_pairIds.emplace_back (std::make_pair (pos.globalIndex (), neg.globalIndex ()));
14031417 }
14041418 }
14051419 for (auto & [pos1, pos2] : combinations (CombinationsStrictlyUpperIndexPolicy (posTracks_per_coll, posTracks_per_coll))) { // LS++
1406- if (isPairOK (collision, pos1, pos2, cut)) {
1420+ if (isPairOK (collision, pos1, pos2, cut, tracks )) {
14071421 passed_pairIds.emplace_back (std::make_pair (pos1.globalIndex (), pos2.globalIndex ()));
14081422 }
14091423 }
14101424 for (auto & [neg1, neg2] : combinations (CombinationsStrictlyUpperIndexPolicy (negTracks_per_coll, negTracks_per_coll))) { // LS--
1411- if (isPairOK (collision, neg1, neg2, cut)) {
1425+ if (isPairOK (collision, neg1, neg2, cut, tracks )) {
14121426 passed_pairIds.emplace_back (std::make_pair (neg1.globalIndex (), neg2.globalIndex ()));
14131427 }
14141428 }
@@ -1457,13 +1471,13 @@ struct Dilepton {
14571471 if (cfgApplyWeightTTCA) {
14581472 fillPairWeightMap<false >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut , electrons);
14591473 }
1460- runPairing<false >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut );
1474+ runPairing<false >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut , electrons );
14611475 } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon ) {
14621476 auto muons = std::get<0 >(std::tie (args...));
14631477 if (cfgApplyWeightTTCA) {
14641478 fillPairWeightMap<false >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut , muons);
14651479 }
1466- runPairing<false >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut );
1480+ runPairing<false >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut , muons );
14671481 }
14681482 map_weight.clear ();
14691483 ndf++;
@@ -1478,13 +1492,13 @@ struct Dilepton {
14781492 if (cfgApplyWeightTTCA) {
14791493 fillPairWeightMap<true >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut , electrons);
14801494 }
1481- runPairing<true >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut );
1495+ runPairing<true >(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut , electrons );
14821496 } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon ) {
14831497 auto muons = std::get<0 >(std::tie (args...));
14841498 if (cfgApplyWeightTTCA) {
14851499 fillPairWeightMap<true >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut , muons);
14861500 }
1487- runPairing<true >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut );
1501+ runPairing<true >(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut , muons );
14881502 }
14891503 map_weight.clear ();
14901504 ndf++;
0 commit comments