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
PATMuonMerger Class Reference
Inheritance diagram for PATMuonMerger:
edm::stream::EDProducer<>

Public Member Functions

 PATMuonMerger (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATMuonMerger () override
 
- 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 &descriptions)
 

Private Attributes

edm::InputTag lostTrack_
 
StringCutObjectSelector
< pat::PackedCandidate, false > 
lostTrackCut_
 
edm::EDGetTokenT< std::vector
< pat::PackedCandidate > > 
lostTrackToken_
 
edm::InputTag muons_
 
StringCutObjectSelector
< pat::Muon, false > 
muonsCut_
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
muonToken_
 
edm::InputTag pfCandidate_
 
StringCutObjectSelector
< pat::PackedCandidate, false > 
pfCandidateCut_
 
edm::EDGetTokenT< std::vector
< pat::PackedCandidate > > 
pfCandToken_
 

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 21 of file PATMuonMerger.cc.

Constructor & Destructor Documentation

PATMuonMerger::PATMuonMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 42 of file PATMuonMerger.cc.

References lostTrack_, lostTrackToken_, muons_, muonToken_, pfCandidate_, and pfCandToken_.

43  : muons_(iConfig.getParameter<edm::InputTag>("muons")),
44  muonsCut_(iConfig.getParameter<std::string>("muonCut")),
45  pfCandidate_(iConfig.getParameter<edm::InputTag>("pfCandidates")),
46  pfCandidateCut_(iConfig.getParameter<std::string>("pfCandidatesCut")),
47  lostTrack_(iConfig.getParameter<edm::InputTag>("otherTracks")),
48  lostTrackCut_(iConfig.getParameter<std::string>("lostTrackCut")) {
49  muonToken_ = consumes<std::vector<pat::Muon>>(muons_);
50  pfCandToken_ = consumes<std::vector<pat::PackedCandidate>>(pfCandidate_);
51  lostTrackToken_ = consumes<std::vector<pat::PackedCandidate>>(lostTrack_);
52  produces<std::vector<pat::Muon>>();
53 }
StringCutObjectSelector< pat::PackedCandidate, false > pfCandidateCut_
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pfCandToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::InputTag pfCandidate_
edm::InputTag lostTrack_
StringCutObjectSelector< pat::Muon, false > muonsCut_
StringCutObjectSelector< pat::PackedCandidate, false > lostTrackCut_
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > lostTrackToken_
edm::InputTag muons_
PATMuonMerger::~PATMuonMerger ( )
inlineoverride

Definition at line 24 of file PATMuonMerger.cc.

24 {}

Member Function Documentation

void PATMuonMerger::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 55 of file PATMuonMerger.cc.

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

55  {
56  // mergedMuons
58  desc.add<std::string>("muonCut", "");
59  desc.add<edm::InputTag>("otherTracks", edm::InputTag("lostTracks"));
60  desc.add<edm::InputTag>("pfCandidates", edm::InputTag("packedPFCandidates"));
61  desc.add<std::string>("pfCandidatesCut", "");
62  desc.add<edm::InputTag>("muons", edm::InputTag("slimmedMuons"));
63  desc.add<std::string>("lostTrackCut", "");
64  descriptions.add("mergedMuonsNoCuts", desc);
65 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATMuonMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 67 of file PATMuonMerger.cc.

References funct::abs(), relval_parameters_module::energy, edm::Event::getByToken(), mps_fire::i, edm::Ptr< T >::isNonnull(), lostTrackCut_, lostTracks_cfi::lostTracks, lostTrackToken_, eostools::move(), RPCpg::mu, HLT_FULL_cff::muon, patZpeak::muons, muonsCut_, muonToken_, dqmiodumpmetadata::n, submitPVResolutionJobs::out, pfCandidateCut_, pfCandToken_, edm::Event::put(), and mathSSE::sqrt().

67  {
71 
72  iEvent.getByToken(muonToken_, muons);
73  iEvent.getByToken(pfCandToken_, pfCands);
74  iEvent.getByToken(lostTrackToken_, lostTracks);
75 
76  auto out = std::make_unique<std::vector<pat::Muon>>();
77  out->reserve(muons->size() + pfCands->size() + lostTracks->size());
78 
79  // copy all muons
80  for (auto& muon : *muons) {
81  if (!muonsCut_(muon))
82  continue;
83  out->push_back(muon);
84  }
85 
86  // add other pfCandidates, removing duplicates
87  for (unsigned int pf = 0; pf < pfCands->size(); ++pf) {
88  auto pfCand = pfCands->at(pf);
89  if (!pfCandidateCut_(pfCand))
90  continue;
91  reco::CandidatePtr pfCandPtr(pfCands, pf);
92  bool isPFMuon = false;
93  for (auto& muon : *muons) {
94  for (unsigned int i = 0, n = muon.numberOfSourceCandidatePtrs(); i < n; ++i) {
95  reco::CandidatePtr ptr = muon.sourceCandidatePtr(i);
96  if (ptr.isNonnull() && ptr == pfCandPtr) {
97  isPFMuon = true;
98  break;
99  }
100  }
101  if (isPFMuon)
102  break;
103  }
104  if (isPFMuon) {
105  continue;
106  }
107 
108  // now make a reco::Muon and recast to pat::Muon
109  double energy = sqrt(pfCand.p() * pfCand.p() + 0.011163691);
110  math::XYZTLorentzVector p4(pfCand.px(), pfCand.py(), pfCand.pz(), energy);
111  reco::Muon mu(pfCand.charge(), p4, pfCand.vertex());
112  pat::Muon aMu(mu);
113  out->push_back(aMu);
114  }
115 
116  // adding now lost tracks, removing duplicates
117  for (auto& lostTrack : *lostTracks) {
118  if (!lostTrackCut_(lostTrack))
119  continue;
120  if (std::abs(lostTrack.pdgId()) == 13)
121  continue;
122 
123  // now make a reco::Muon and recast to pat::Muon
124  double energy = sqrt(lostTrack.p() * lostTrack.p() + 0.011163691);
125  math::XYZTLorentzVector p4(lostTrack.px(), lostTrack.py(), lostTrack.pz(), energy);
126  reco::Muon mu(lostTrack.charge(), p4, lostTrack.vertex());
127  pat::Muon aMu(mu);
128  out->push_back(aMu);
129  }
130  iEvent.put(std::move(out));
131 }
StringCutObjectSelector< pat::PackedCandidate, false > pfCandidateCut_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pfCandToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonToken_
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
tuple muons
Definition: patZpeak.py:39
StringCutObjectSelector< pat::Muon, false > muonsCut_
StringCutObjectSelector< pat::PackedCandidate, false > lostTrackCut_
Analysis-level muon class.
Definition: Muon.h:51
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > lostTrackToken_

Member Data Documentation

edm::InputTag PATMuonMerger::lostTrack_
private

Definition at line 34 of file PATMuonMerger.cc.

Referenced by PATMuonMerger().

StringCutObjectSelector<pat::PackedCandidate, false> PATMuonMerger::lostTrackCut_
private

Definition at line 35 of file PATMuonMerger.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<pat::PackedCandidate> > PATMuonMerger::lostTrackToken_
private

Definition at line 39 of file PATMuonMerger.cc.

Referenced by PATMuonMerger(), and produce().

edm::InputTag PATMuonMerger::muons_
private

Definition at line 30 of file PATMuonMerger.cc.

Referenced by PATMuonMerger().

StringCutObjectSelector<pat::Muon, false> PATMuonMerger::muonsCut_
private

Definition at line 31 of file PATMuonMerger.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<pat::Muon> > PATMuonMerger::muonToken_
private

Definition at line 37 of file PATMuonMerger.cc.

Referenced by PATMuonMerger(), and produce().

edm::InputTag PATMuonMerger::pfCandidate_
private

Definition at line 32 of file PATMuonMerger.cc.

Referenced by PATMuonMerger().

StringCutObjectSelector<pat::PackedCandidate, false> PATMuonMerger::pfCandidateCut_
private

Definition at line 33 of file PATMuonMerger.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<pat::PackedCandidate> > PATMuonMerger::pfCandToken_
private

Definition at line 38 of file PATMuonMerger.cc.

Referenced by PATMuonMerger(), and produce().