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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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  }

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

◆ ~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.

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 }

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

◆ produce()

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

Definition at line 55 of file PackedCandidateMuonSelectorProducer.cc.

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 }

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

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().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
pat::PackedCandidateMuonSelectorProducer::muonToken_
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
Definition: PackedCandidateMuonSelectorProducer.cc:43
muon
Definition: MuonCocktails.h:17
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
pat::PackedCandidateMuonSelectorProducer::muonSelectors_
const std::vector< std::string > muonSelectors_
Definition: PackedCandidateMuonSelectorProducer.cc:48
edm::RefVector
Definition: EDProductfwd.h:27
alignCSCRings.s
s
Definition: alignCSCRings.py:92
muon::isGoodMuon
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
Definition: MuonSelectors.cc:649
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
muon::selectionTypeFromString
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
pat::PackedCandidateMuonSelectorProducer::muonIDMap_
std::map< std::string, std::unique_ptr< StringCutObjectSelector< reco::Muon > > > muonIDMap_
Definition: PackedCandidateMuonSelectorProducer.cc:50
cand
Definition: decayParser.h:32
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PackedCandidateMuonSelectorProducer::candidate2PFToken_
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > candidate2PFToken_
Definition: PackedCandidateMuonSelectorProducer.cc:46
edm::Association
Definition: Association.h:18
pat::PackedCandidateMuonSelectorProducer::candidateToken_
const edm::EDGetTokenT< pat::PackedCandidateCollection > candidateToken_
Definition: PackedCandidateMuonSelectorProducer.cc:44
pat::PackedCandidateMuonSelectorProducer::muonIDs_
const std::vector< std::string > muonIDs_
Definition: PackedCandidateMuonSelectorProducer.cc:49
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
pat::PackedCandidateMuonSelectorProducer::track2LostTrackToken_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > track2LostTrackToken_
Definition: PackedCandidateMuonSelectorProducer.cc:47
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55048
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
edm::InputTag
Definition: InputTag.h:15
pat::PackedCandidateRef
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
Definition: PackedCandidate.h:1131