CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PackedCandidateMuonSelectorProducer Class Reference
Inheritance diagram for pat::PackedCandidateMuonSelectorProducer:
edm::stream::EDProducer<>

Public Member Functions

 PackedCandidateMuonSelectorProducer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PackedCandidateMuonSelectorProducer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Attributes

const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectioncandidateToken_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionlostTrackToken_
 
std::map< std::string, std::unique_ptr< StringCutObjectSelector< reco::Muon > > > muonIDMap_
 
const std::vector< std::string > muonIDs_
 
const std::vector< std::string > muonSelectors_
 
const edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 15 of file PackedCandidateMuonSelectorProducer.cc.

Constructor & Destructor Documentation

◆ PackedCandidateMuonSelectorProducer()

pat::PackedCandidateMuonSelectorProducer::PackedCandidateMuonSelectorProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 17 of file PackedCandidateMuonSelectorProducer.cc.

References muonIDMap_, muonIDs_, muonSelectors_, and EgammaValidation_Wenu_cff::sel.

18  : muonToken_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
19  candidateToken_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("candidates"))),
21  iConfig.getParameter<edm::InputTag>("candidates"))),
23  iConfig.getParameter<edm::InputTag>("lostTracks"))),
24  muonSelectors_(iConfig.getParameter<std::vector<std::string>>("muonSelectors")),
25  muonIDs_(iConfig.getParameter<std::vector<std::string>>("muonIDs")) {
26  for (const auto& sel : muonSelectors_) {
27  produces<pat::PackedCandidateRefVector>("lostTracks" + sel);
28  produces<pat::PackedCandidateRefVector>("pfCandidates" + sel);
29  }
30  for (const auto& sel : muonIDs_) {
31  muonIDMap_[sel] = std::make_unique<StringCutObjectSelector<reco::Muon>>("passed('" + sel + "')");
32  produces<pat::PackedCandidateRefVector>("lostTracks" + sel);
33  produces<pat::PackedCandidateRefVector>("pfCandidates" + sel);
34  }
35  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
std::map< std::string, std::unique_ptr< StringCutObjectSelector< reco::Muon > > > muonIDMap_
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_

◆ ~PackedCandidateMuonSelectorProducer()

pat::PackedCandidateMuonSelectorProducer::~PackedCandidateMuonSelectorProducer ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

void pat::PackedCandidateMuonSelectorProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 120 of file PackedCandidateMuonSelectorProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

120  {
122  desc.add<edm::InputTag>("muons", edm::InputTag("muons"))->setComment("muon input collection");
123  desc.add<edm::InputTag>("candidates", edm::InputTag("packedPFCandidates"))
124  ->setComment("packed PF candidate input collection");
125  desc.add<edm::InputTag>("lostTracks", edm::InputTag("lostTracks"))->setComment("lost track input collection");
126  desc.add<std::vector<std::string>>("muonSelectors", {"AllTrackerMuons", "TMOneStationTight"})
127  ->setComment("muon selectors");
128  desc.add<std::vector<std::string>>("muonIDs", {})->setComment("muon IDs");
129  descriptions.add("packedCandidateMuonID", desc);
130 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void pat::PackedCandidateMuonSelectorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 55 of file PackedCandidateMuonSelectorProducer.cc.

References candidate2PFToken_, HLT_2024v12_cff::candidates, candidateToken_, mps_fire::i, iEvent, muon::isGoodMuon(), eostools::move(), muonIDMap_, muonIDs_, DiMuonV_cfg::muons, muonSelectors_, muonToken_, push_back(), reco::TrackBase::qualityByName(), alignCSCRings::s, EgammaValidation_Wenu_cff::sel, muon::selectionTypeFromString(), and track2LostTrackToken_.

55  {
56  const auto& muons = iEvent.get(muonToken_);
57  const auto& candidates = iEvent.getHandle(candidateToken_);
58  const auto& candidate2PF = iEvent.get(candidate2PFToken_);
59  const auto& track2LostTrack = iEvent.get(track2LostTrackToken_);
60 
61  std::map<std::string, std::unique_ptr<pat::PackedCandidateRefVector>> lostTrackMap, candMap;
62  for (const auto& sel : muonSelectors_) {
63  lostTrackMap.emplace(sel, new pat::PackedCandidateRefVector());
64  candMap.emplace(sel, new pat::PackedCandidateRefVector());
65  }
66  for (const auto& sel : muonIDs_) {
67  lostTrackMap.emplace(sel, new pat::PackedCandidateRefVector());
68  candMap.emplace(sel, new pat::PackedCandidateRefVector());
69  }
70 
71  // loop over muons
72  for (const auto& muon : muons) {
73  const auto& muonTrack = muon.innerTrack();
74  // ignore muons without high purity inner track
75  if (muonTrack.isNull() || !muonTrack->quality(reco::TrackBase::qualityByName("highPurity")))
76  continue;
77 
78  // find lost track associated to muon
79  const auto& lostTrack = track2LostTrack[muonTrack];
80  if (lostTrack.isNonnull()) {
81  for (const auto& sel : muonSelectors_) {
83  lostTrackMap[sel]->push_back(lostTrack);
84  }
85  for (const auto& sel : muonIDs_) {
86  if ((*muonIDMap_.at(sel))(muon))
87  lostTrackMap[sel]->push_back(lostTrack);
88  }
89  continue;
90  }
91 
92  // find PF candidate associated to muon
93  for (size_t i = 0; i < candidates->size(); i++) {
94  const auto& cand = pat::PackedCandidateRef(candidates, i);
95  const auto& candTrack = candidate2PF[cand]->trackRef();
96  // check if candidate and muon are compatible
97  if (candTrack.isNonnull() && muonTrack == candTrack) {
98  for (const auto& sel : muonSelectors_) {
100  candMap[sel]->push_back(cand);
101  }
102  for (const auto& sel : muonIDs_) {
103  if ((*muonIDMap_.at(sel))(muon))
104  candMap[sel]->push_back(cand);
105  }
106  break;
107  }
108  }
109  }
110 
111  for (auto& s : lostTrackMap) {
112  iEvent.put(std::move(s.second), "lostTracks" + s.first);
113  }
114  for (auto& s : candMap) {
115  iEvent.put(std::move(s.second), "pfCandidates" + s.first);
116  }
117 }
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
int iEvent
Definition: GenABIO.cc:224
std::map< std::string, std::unique_ptr< StringCutObjectSelector< reco::Muon > > > muonIDMap_
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ candidate2PFToken_

const edm::EDGetTokenT<edm::Association<reco::PFCandidateCollection> > pat::PackedCandidateMuonSelectorProducer::candidate2PFToken_
private

Definition at line 46 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

◆ candidateToken_

const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PackedCandidateMuonSelectorProducer::candidateToken_
private

Definition at line 44 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

◆ lostTrackToken_

const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PackedCandidateMuonSelectorProducer::lostTrackToken_
private

Definition at line 45 of file PackedCandidateMuonSelectorProducer.cc.

◆ muonIDMap_

std::map<std::string, std::unique_ptr<StringCutObjectSelector<reco::Muon> > > pat::PackedCandidateMuonSelectorProducer::muonIDMap_
private

◆ muonIDs_

const std::vector<std::string> pat::PackedCandidateMuonSelectorProducer::muonIDs_
private

◆ muonSelectors_

const std::vector<std::string> pat::PackedCandidateMuonSelectorProducer::muonSelectors_
private

◆ muonToken_

const edm::EDGetTokenT<reco::MuonCollection> pat::PackedCandidateMuonSelectorProducer::muonToken_
private

Definition at line 43 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

◆ track2LostTrackToken_

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PackedCandidateMuonSelectorProducer::track2LostTrackToken_
private

Definition at line 47 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().