CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonWithPFIsoProducer Class Reference
Inheritance diagram for MuonWithPFIsoProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonWithPFIsoProducer (const edm::ParameterSet &)
 
 ~MuonWithPFIsoProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double gammaIsoVeto_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
 
double neutralHadronIsoVeto_
 
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfToken_
 
double trackIsoVeto_
 
bool usePfMuonsOnly_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file MuonWithPFIsoProducer.cc.

Constructor & Destructor Documentation

◆ MuonWithPFIsoProducer()

MuonWithPFIsoProducer::MuonWithPFIsoProducer ( const edm::ParameterSet pset)
explicit

Definition at line 45 of file MuonWithPFIsoProducer.cc.

45  {
46  // What is being produced
47  produces<std::vector<reco::Muon> >();
48 
49  // Muon collection
50  muonToken_ =
51  consumes<edm::View<reco::Muon> >(pset.getUntrackedParameter<edm::InputTag>("MuonTag", edm::InputTag("muons")));
52 
53  // PF candidate collection
54  pfToken_ = consumes<edm::View<reco::PFCandidate> >(
55  pset.getUntrackedParameter<edm::InputTag>("PFTag", edm::InputTag("particleFlow")));
56 
57  // Use only PF muons to get exact consistency with PfMET
58  usePfMuonsOnly_ = pset.getUntrackedParameter<bool>("UsePfMuonsOnly", false);
59 
60  // Veto cone
61  trackIsoVeto_ = pset.getUntrackedParameter<double>("TrackIsoVeto", 0.01);
62  gammaIsoVeto_ = pset.getUntrackedParameter<double>("GammaIsoVeto", 0.07);
63  neutralHadronIsoVeto_ = pset.getUntrackedParameter<double>("NeutralHadronIsoVeto", 0.1);
64 }

References gammaIsoVeto_, HLT_FULL_cff::InputTag, muonToken_, neutralHadronIsoVeto_, pfToken_, muonDTDigis_cfi::pset, trackIsoVeto_, and usePfMuonsOnly_.

◆ ~MuonWithPFIsoProducer()

MuonWithPFIsoProducer::~MuonWithPFIsoProducer ( )
override

Definition at line 67 of file MuonWithPFIsoProducer.cc.

67 {}

Member Function Documentation

◆ beginJob()

void MuonWithPFIsoProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonWithPFIsoProducer.cc.

70 {}

◆ endJob()

void MuonWithPFIsoProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file MuonWithPFIsoProducer.cc.

73 {}

◆ produce()

void MuonWithPFIsoProducer::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 76 of file MuonWithPFIsoProducer.cc.

76  {
77  // Initialize pointer to new output muon collection
78  std::unique_ptr<reco::MuonCollection> newmuons(new reco::MuonCollection);
79 
80  // Get Muon collection
82  if (!ev.getByToken(muonToken_, muonCollection)) {
83  edm::LogError("") << ">>> Muon collection does not exist !!!";
84  ev.put(std::move(newmuons));
85  return;
86  }
87 
88  // Get PFCandidate collection
90  if (!ev.getByToken(pfToken_, pfCollection)) {
91  edm::LogError("") << ">>> PFCandidate collection does not exist !!!";
92  ev.put(std::move(newmuons));
93  return;
94  }
95 
96  // Loop over Pf candidates to find muons and collect deposits in veto,
97  // dR<0.3 and dR<0.5 cones. Interpret "track" as charged particles (e,mu,
98  // chraged hadrons). Interpret "em" as photons and also as electromagnetic
99  // energy in HF. Interpret "had" as neutral hadrons and also as hadronic
100  // energy in HF. Apply weights if requested at input level.
101  // HO energies are not filled. Ditto for jet energies around the muon.
102  unsigned int muonCollectionSize = muonCollection->size();
103  unsigned int pfCollectionSize = pfCollection->size();
104  for (unsigned int i = 0; i < muonCollectionSize; i++) {
106 
107  // Ask for PfMuon consistency if requested
108  bool muonFound = false;
109 
110  // Starting bycloning this muon
111  reco::Muon* newmu = mu->clone();
112  reco::TrackRef tk = mu->innerTrack();
113 
114  // Set isolations
115  reco::MuonIsolation iso03;
116  reco::MuonIsolation iso05;
117  // Loop on all candidates
118  for (unsigned int j = 0; j < pfCollectionSize; j++) {
119  edm::RefToBase<reco::PFCandidate> pf = pfCollection->refAt(j);
120 
121  // Check the muon is in the PF collection when required
122  bool thisIsTheMuon = false;
123  if (tk.isNonnull() && pf->trackRef() == tk) {
124  thisIsTheMuon = true;
125  muonFound = true;
126  }
127 
128  // Get dR. Nothing to add if dR>0.5
129  double deltaR = Geom::deltaR(mu->momentum(), pf->momentum());
130  if (deltaR > 0.5)
131  continue;
132 
133  // Fill "tracker" components
134  if (pf->particleId() == reco::PFCandidate::h || pf->particleId() == reco::PFCandidate::e ||
135  pf->particleId() == reco::PFCandidate::mu) {
136  if (deltaR < trackIsoVeto_ || thisIsTheMuon) {
137  iso05.trackerVetoPt += pf->pt();
138  iso03.trackerVetoPt += pf->pt();
139  } else {
140  iso05.sumPt += pf->pt();
141  iso05.nTracks++;
142  if (deltaR < 0.3) {
143  iso03.sumPt += pf->pt();
144  iso03.nTracks++;
145  }
146  }
147  // Fill "em" components
148  } else if (pf->particleId() == reco::PFCandidate::gamma || pf->particleId() == reco::PFCandidate::egamma_HF) {
149  if (deltaR < gammaIsoVeto_) {
150  iso05.emVetoEt += pf->pt();
151  iso03.emVetoEt += pf->pt();
152  } else {
153  iso05.emEt += pf->pt();
154  if (deltaR < 0.3)
155  iso03.emEt += pf->pt();
156  }
157  // Fill "had" components
158  } else if (pf->particleId() == reco::PFCandidate::h0 || pf->particleId() == reco::PFCandidate::h_HF) {
160  iso05.hadVetoEt += pf->pt();
161  iso03.hadVetoEt += pf->pt();
162  } else {
163  iso05.hadEt += pf->pt();
164  if (deltaR < 0.3)
165  iso03.hadEt += pf->pt();
166  }
167  }
168  }
169 
170  // Do not take this muon (under explicit request) if it is not a PfMuon
171  if (usePfMuonsOnly_ && (!muonFound))
172  continue;
173 
174  // Set this isolation information in the new muon
175  newmu->setIsolation(iso03, iso05);
176 
177  // Add new muon to output collection
178  newmuons->push_back(*newmu);
179  }
180 
181  // Add output collection to event
182  ev.put(std::move(newmuons));
183 }

References PbPb_ZMuSkimMuonDPG_cff::deltaR, reco::PFCandidate::e, reco::PFCandidate::egamma_HF, reco::MuonIsolation::emEt, reco::MuonIsolation::emVetoEt, ev, reco::PFCandidate::gamma, gammaIsoVeto_, reco::PFCandidate::h, reco::PFCandidate::h0, reco::PFCandidate::h_HF, reco::MuonIsolation::hadEt, reco::MuonIsolation::hadVetoEt, mps_fire::i, edm::Ref< C, T, F >::isNonnull(), dqmiolumiharvest::j, eostools::move(), amptDefaultParameters_cff::mu, reco::PFCandidate::mu, pdwgLeptonRecoSkim_cfi::muonCollection, muonToken_, neutralHadronIsoVeto_, MuonAlignmentFromReference_cff::newmuons, reco::MuonIsolation::nTracks, packedPFCandidateRefMixer_cfi::pf, pfToken_, reco::Muon::setIsolation(), reco::MuonIsolation::sumPt, reco::MuonIsolation::trackerVetoPt, trackIsoVeto_, and usePfMuonsOnly_.

Member Data Documentation

◆ gammaIsoVeto_

double MuonWithPFIsoProducer::gammaIsoVeto_
private

Definition at line 32 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

◆ muonToken_

edm::EDGetTokenT<edm::View<reco::Muon> > MuonWithPFIsoProducer::muonToken_
private

Definition at line 26 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

◆ neutralHadronIsoVeto_

double MuonWithPFIsoProducer::neutralHadronIsoVeto_
private

Definition at line 33 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

◆ pfToken_

edm::EDGetTokenT<edm::View<reco::PFCandidate> > MuonWithPFIsoProducer::pfToken_
private

Definition at line 27 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

◆ trackIsoVeto_

double MuonWithPFIsoProducer::trackIsoVeto_
private

Definition at line 31 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

◆ usePfMuonsOnly_

bool MuonWithPFIsoProducer::usePfMuonsOnly_
private

Definition at line 29 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

MuonAlignmentFromReference_cff.newmuons
newmuons
Definition: MuonAlignmentFromReference_cff.py:26
MuonWithPFIsoProducer::gammaIsoVeto_
double gammaIsoVeto_
Definition: MuonWithPFIsoProducer.cc:32
mps_fire.i
i
Definition: mps_fire.py:428
reco::PFCandidate::e
Definition: PFCandidate.h:47
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
reco::MuonIsolation::emEt
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
reco::PFCandidate::h
Definition: PFCandidate.h:46
reco::PFCandidate::h_HF
Definition: PFCandidate.h:51
edm::Handle
Definition: AssociativeIterator.h:50
reco::Muon::setIsolation
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
reco::MuonIsolation
Definition: MuonIsolation.h:5
reco::Muon
Definition: Muon.h:27
edm::Ref< TrackCollection >
reco::MuonIsolation::sumPt
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
reco::PFCandidate::mu
Definition: PFCandidate.h:48
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
MuonWithPFIsoProducer::muonToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
Definition: MuonWithPFIsoProducer.cc:26
MuonWithPFIsoProducer::pfToken_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfToken_
Definition: MuonWithPFIsoProducer.cc:27
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
reco::MuonIsolation::hadVetoEt
float hadVetoEt
hcal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:14
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
MuonWithPFIsoProducer::trackIsoVeto_
double trackIsoVeto_
Definition: MuonWithPFIsoProducer.cc:31
reco::PFCandidate::egamma_HF
Definition: PFCandidate.h:52
reco::PFCandidate::gamma
Definition: PFCandidate.h:49
reco::MuonIsolation::nTracks
int nTracks
number of tracks in the cone (excluding veto region)
Definition: MuonIsolation.h:10
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
pdwgLeptonRecoSkim_cfi.muonCollection
muonCollection
Definition: pdwgLeptonRecoSkim_cfi.py:7
reco::MuonIsolation::emVetoEt
float emVetoEt
ecal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:13
MuonWithPFIsoProducer::neutralHadronIsoVeto_
double neutralHadronIsoVeto_
Definition: MuonWithPFIsoProducer.cc:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::MuonIsolation::hadEt
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
reco::PFCandidate::h0
Definition: PFCandidate.h:50
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
reco::MuonIsolation::trackerVetoPt
float trackerVetoPt
(sum-)pt inside the veto region in r-phi
Definition: MuonIsolation.h:12
edm::RefToBase
Definition: AssociativeIterator.h:54
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15
MuonWithPFIsoProducer::usePfMuonsOnly_
bool usePfMuonsOnly_
Definition: MuonWithPFIsoProducer.cc:29
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27