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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file MuonWithPFIsoProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file MuonWithPFIsoProducer.cc.

References gammaIsoVeto_, edm::ParameterSet::getUntrackedParameter(), HLT_2018_cff::InputTag, muonToken_, neutralHadronIsoVeto_, pfToken_, trackIsoVeto_, and usePfMuonsOnly_.

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 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
MuonWithPFIsoProducer::~MuonWithPFIsoProducer ( )
override

Definition at line 67 of file MuonWithPFIsoProducer.cc.

67 {}

Member Function Documentation

void MuonWithPFIsoProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonWithPFIsoProducer.cc.

70 {}
void MuonWithPFIsoProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file MuonWithPFIsoProducer.cc.

73 {}
void MuonWithPFIsoProducer::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 76 of file MuonWithPFIsoProducer.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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++) {
105  edm::RefToBase<reco::Muon> mu = muonCollection->refAt(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
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
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) {
159  if (deltaR < neutralHadronIsoVeto_) {
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 }
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
virtual TrackRef innerTrack() const
Definition: Muon.h:45
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
float hadVetoEt
hcal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:14
double pt() const final
transverse momentum
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
Vector momentum() const final
spatial momentum vector
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
int nTracks
number of tracks in the cone (excluding veto region)
Definition: MuonIsolation.h:10
float emVetoEt
ecal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:13
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfToken_
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
virtual ParticleType particleId() const
Definition: PFCandidate.h:366
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
Muon * clone() const override
create a clone
float trackerVetoPt
(sum-)pt inside the veto region in r-phi
Definition: MuonIsolation.h:12
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double MuonWithPFIsoProducer::gammaIsoVeto_
private

Definition at line 32 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

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

Definition at line 26 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

double MuonWithPFIsoProducer::neutralHadronIsoVeto_
private

Definition at line 33 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

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

Definition at line 27 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

double MuonWithPFIsoProducer::trackIsoVeto_
private

Definition at line 31 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

bool MuonWithPFIsoProducer::usePfMuonsOnly_
private

Definition at line 29 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().