CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::PackedCandidateCollection
candidateToken_
 
const edm::EDGetTokenT
< pat::PackedCandidateCollection
lostTrackToken_
 
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::MuonCollection
muonToken_
 
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

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  }
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_
pat::PackedCandidateMuonSelectorProducer::~PackedCandidateMuonSelectorProducer ( )
overridedefault

Member Function Documentation

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

Definition at line 120 of file PackedCandidateMuonSelectorProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void pat::PackedCandidateMuonSelectorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 55 of file PackedCandidateMuonSelectorProducer.cc.

References candidate2PFToken_, HLT_FULL_cff::candidates, candidateToken_, edm::Event::get(), edm::Event::getHandle(), mps_fire::i, muon::isGoodMuon(), eostools::move(), HLT_FULL_cff::muon, muonIDMap_, muonIDs_, patZpeak::muons, muonSelectors_, muonToken_, edm::Event::put(), 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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
std::map< std::string, std::unique_ptr< StringCutObjectSelector< reco::Muon > > > muonIDMap_
def move
Definition: eostools.py:511
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
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
tuple muons
Definition: patZpeak.py:39
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_

Member Data Documentation

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

Definition at line 46 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

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

Definition at line 44 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

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

Definition at line 45 of file PackedCandidateMuonSelectorProducer.cc.

std::map<std::string, std::unique_ptr<StringCutObjectSelector<reco::Muon> > > pat::PackedCandidateMuonSelectorProducer::muonIDMap_
private
const std::vector<std::string> pat::PackedCandidateMuonSelectorProducer::muonIDs_
private
const std::vector<std::string> pat::PackedCandidateMuonSelectorProducer::muonSelectors_
private
const edm::EDGetTokenT<reco::MuonCollection> pat::PackedCandidateMuonSelectorProducer::muonToken_
private

Definition at line 43 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().

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

Definition at line 47 of file PackedCandidateMuonSelectorProducer.cc.

Referenced by produce().