Skip to content

Commit e872c7a

Browse files
authored
[PWGEM/Dilepton] update dimuon producer (#15680)
1 parent 1c0a232 commit e872c7a

File tree

2 files changed

+27
-55
lines changed

2 files changed

+27
-55
lines changed

PWGEM/Dilepton/Core/DileptonProducer.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "Common/CCDB/RCTSelectionFlags.h"
2828
#include "Common/DataModel/Centrality.h"
2929
#include "Common/DataModel/EventSelection.h"
30+
#include "Common/DataModel/PIDResponseTPC.h"
3031
#include "Common/DataModel/TrackSelectionTables.h"
3132

3233
#include <CCDB/BasicCCDBManager.h>
@@ -57,10 +58,8 @@
5758
#include <cstddef>
5859
#include <cstdint>
5960
#include <map>
60-
#include <random>
6161
#include <string>
62-
#include <string_view>
63-
#include <tuple>
62+
#include <unordered_map>
6463
#include <utility>
6564
#include <vector>
6665

@@ -272,9 +271,7 @@ struct DileptonProducer {
272271
float d_bz;
273272

274273
o2::framework::HistogramRegistry fRegistry{"output", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject, false, false};
275-
static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"};
276274

277-
std::mt19937 engine;
278275
float leptonM1 = 0.f;
279276
float leptonM2 = 0.f;
280277

@@ -289,9 +286,6 @@ struct DileptonProducer {
289286
ccdb->setFatalWhenNull(false);
290287
rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value);
291288

292-
std::random_device seed_gen;
293-
engine = std::mt19937(seed_gen());
294-
295289
DefineEMEventCut();
296290
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
297291
DefineDielectronCut();
@@ -461,7 +455,7 @@ struct DileptonProducer {
461455
}
462456

463457
template <typename TCollision, typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks>
464-
bool fillPairInfo(TCollision const&, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks)
458+
bool fillPairInfo(TCollision const&, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&)
465459
{
466460
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
467461
if (dielectroncuts.cfg_pid_scheme == static_cast<int>(DielectronCut::PIDSchemes::kPIDML)) {
@@ -477,13 +471,16 @@ struct DileptonProducer {
477471
if (!cut.template IsSelectedTrack<false>(t1) || !cut.template IsSelectedTrack<false>(t2)) {
478472
return false;
479473
}
480-
481-
if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) {
482-
return false;
483-
}
484-
if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) {
474+
if (!map_best_match_globalmuon[t1.globalIndex()] || !map_best_match_globalmuon[t2.globalIndex()]) {
485475
return false;
486476
}
477+
478+
// if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) {
479+
// return false;
480+
// }
481+
// if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) {
482+
// return false;
483+
// }
487484
}
488485

489486
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
@@ -539,6 +536,7 @@ struct DileptonProducer {
539536
o2::framework::SliceCache cache;
540537
o2::framework::Preslice<MyElectrons> perCollision_electron = o2::aod::emprimaryelectron::emeventId;
541538
o2::framework::expressions::Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz;
539+
o2::framework::expressions::Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl;
542540
o2::framework::expressions::Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true);
543541
o2::framework::expressions::Filter prefilter_derived_electron = ifnode(dielectroncuts.cfg_apply_cuts_from_prefilter_derived.node() && dielectroncuts.cfg_prefilter_bits_derived.node() >= static_cast<uint16_t>(1),
544542
ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast<uint16_t>(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) > static_cast<uint16_t>(0), (o2::aod::emprimaryelectron::pfbderived & static_cast<uint16_t>(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) <= static_cast<uint16_t>(0), true) &&
@@ -571,7 +569,6 @@ struct DileptonProducer {
571569
o2::framework::Partition<FilteredMyMuons> positive_muons = o2::aod::emprimarymuon::sign > int8_t(0);
572570
o2::framework::Partition<FilteredMyMuons> negative_muons = o2::aod::emprimarymuon::sign < int8_t(0);
573571

574-
int ndf = 0;
575572
template <bool isTriggerAnalysis, typename TCollisions, typename TLeptons, typename TPresilce, typename TCut, typename TAllTracks>
576573
void runPairing(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks)
577574
{
@@ -628,7 +625,7 @@ struct DileptonProducer {
628625
} // end of DF
629626

630627
template <typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks>
631-
bool isPairOK(TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks)
628+
bool isPairOK(TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&)
632629
{
633630
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
634631
if (dielectroncuts.cfg_pid_scheme == static_cast<int>(DielectronCut::PIDSchemes::kPIDML)) {
@@ -644,13 +641,16 @@ struct DileptonProducer {
644641
if (!cut.IsSelectedTrack(t1) || !cut.IsSelectedTrack(t2)) {
645642
return false;
646643
}
647-
648-
if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) {
649-
return false;
650-
}
651-
if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) {
644+
if (!map_best_match_globalmuon[t1.globalIndex()] || !map_best_match_globalmuon[t2.globalIndex()]) {
652645
return false;
653646
}
647+
648+
// if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) {
649+
// return false;
650+
// }
651+
// if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) {
652+
// return false;
653+
// }
654654
}
655655

656656
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
@@ -742,6 +742,8 @@ struct DileptonProducer {
742742
passed_pairIds.shrink_to_fit();
743743
}
744744

745+
std::unordered_map<int, bool> map_best_match_globalmuon;
746+
745747
void processAnalysis(FilteredMyCollisions const& collisions, Types const&... args)
746748
{
747749
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
@@ -752,13 +754,14 @@ struct DileptonProducer {
752754
runPairing<false>(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons);
753755
} else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) {
754756
auto muons = std::get<0>(std::tie(args...));
757+
map_best_match_globalmuon = o2::aod::pwgem::dilepton::utils::emtrackutil::findBestMatchMap(muons, fDimuonCut);
755758
if (cfgApplyWeightTTCA) {
756759
fillPairWeightMap<false>(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons);
757760
}
758761
runPairing<false>(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons);
759762
}
760763
map_weight.clear();
761-
ndf++;
764+
map_best_match_globalmuon.clear();
762765
}
763766
PROCESS_SWITCH(DileptonProducer, processAnalysis, "run dilepton analysis", true);
764767

PWGEM/Dilepton/Utils/EMTrackUtilities.h

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool isBestMatch(TTrack const& track, TCut const& cut, TTracks const& tracks)
162162
for (const auto& glmuonId : track.globalMuonsWithSameMFTIds()) {
163163
auto candidate = tracks.rawIteratorAt(glmuonId);
164164
if (candidate.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && candidate.emeventId() == track.emeventId() && candidate.mchtrackId() != track.mchtrackId()) {
165-
if (cut.template IsSelectedTrack<true>(candidate)) {
165+
if (cut.template IsSelectedTrack<false>(candidate)) {
166166
map_chi2MCHMFT[candidate.globalIndex()] = candidate.chi2MatchMCHMFT();
167167
}
168168
}
@@ -181,7 +181,7 @@ bool isBestMatch(TTrack const& track, TCut const& cut, TTracks const& tracks)
181181
for (const auto& glmuonId : track.globalMuonsWithSameMCHMIDIds()) {
182182
auto candidate = tracks.rawIteratorAt(glmuonId);
183183
if (candidate.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && candidate.emeventId() == track.emeventId() && candidate.mfttrackId() != track.mfttrackId()) {
184-
if (cut.template IsSelectedTrack<true>(candidate)) {
184+
if (cut.template IsSelectedTrack<false>(candidate)) {
185185
map_chi2MCHMFT[candidate.globalIndex()] = candidate.chi2MatchMCHMFT();
186186
}
187187
}
@@ -211,36 +211,5 @@ std::unordered_map<int, bool> findBestMatchMap(TTracks const& tracks, TCut const
211211
return map;
212212
}
213213
//_______________________________________________________________________
214-
// template <typename T>
215-
// float sigmaPt(T const& track)
216-
// {
217-
// return std::sqrt(track.c1Pt21Pt2()) / std::pow(track.signed1Pt(), 2); // pT resolution
218-
// }
219-
// //_______________________________________________________________________
220-
// template <typename T>
221-
// float sigmaPhi(T const& track)
222-
// {
223-
// return std::sqrt(track.cSnpSnp()) / std::sqrt(1.f - std::pow(track.snp(), 2)); // phi resolution
224-
// }
225-
// //_______________________________________________________________________
226-
// template <typename T>
227-
// float sigmaTheta(T const& track)
228-
// {
229-
// return std::sqrt(track.cTglTgl()) / (1.f + std::pow(track.tgl(), 2)); // theta resolution = lambda resolution. // lambda = pi/2 - theta. theta is polar angle.
230-
// }
231-
// //_______________________________________________________________________
232-
// template <typename T>
233-
// float sigmaEta(T const& track)
234-
// {
235-
// return std::sqrt(track.cTglTgl()) / std::sqrt(1.f + std::pow(track.tgl(), 2));
236-
// }
237-
// //_______________________________________________________________________
238-
// template <typename T>
239-
// float sigmaP(T const& track)
240-
// {
241-
// // p = 1/1/pT x 1/cos(lambda);
242-
// return std::sqrt(std::pow(1.f / track.signed1Pt(), 4) * ((1.f + std::pow(track.tgl(), 2)) * track.c1Pt21Pt2() + 1.f / (1.f + std::pow(track.tgl(), 2)) * std::pow(track.signed1Pt() * track.tgl(), 2) * track.cTglTgl() - 2.f * track.signed1Pt() * track.tgl() * track.c1PtTgl()));
243-
// }
244-
//_______________________________________________________________________
245214
} // namespace o2::aod::pwgem::dilepton::utils::emtrackutil
246215
#endif // PWGEM_DILEPTON_UTILS_EMTRACKUTILITIES_H_

0 commit comments

Comments
 (0)