CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual 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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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(), muonToken_, neutralHadronIsoVeto_, pfToken_, trackIsoVeto_, and usePfMuonsOnly_.

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

Definition at line 67 of file MuonWithPFIsoProducer.cc.

67  {
68 }

Member Function Documentation

void MuonWithPFIsoProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 71 of file MuonWithPFIsoProducer.cc.

71  {
72 }
void MuonWithPFIsoProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 75 of file MuonWithPFIsoProducer.cc.

75  {
76 }
void MuonWithPFIsoProducer::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 79 of file MuonWithPFIsoProducer.cc.

References reco::Muon::clone(), 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, i, reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), j, reco::LeafCandidate::momentum(), RPCpg::mu, reco::PFCandidate::mu, muonToken_, neutralHadronIsoVeto_, MuonAlignmentFromReference_cff::newmuons, reco::MuonIsolation::nTracks, reco::PFCandidate::particleId(), 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().

79  {
80 
81  // Initialize pointer to new output muon collection
82  std::auto_ptr<reco::MuonCollection> newmuons (new reco::MuonCollection);
83 
84  // Get Muon collection
85  edm::Handle<edm::View<reco::Muon> > muonCollection;
86  if (!ev.getByToken(muonToken_, muonCollection)) {
87  edm::LogError("") << ">>> Muon collection does not exist !!!";
88  ev.put(newmuons);
89  return;
90  }
91 
92  // Get PFCandidate collection
94  if (!ev.getByToken(pfToken_, pfCollection)) {
95  edm::LogError("") << ">>> PFCandidate collection does not exist !!!";
96  ev.put(newmuons);
97  return;
98  }
99 
100  // Loop over Pf candidates to find muons and collect deposits in veto,
101  // dR<0.3 and dR<0.5 cones. Interpret "track" as charged particles (e,mu,
102  // chraged hadrons). Interpret "em" as photons and also as electromagnetic
103  // energy in HF. Interpret "had" as neutral hadrons and also as hadronic
104  // energy in HF. Apply weights if requested at input level.
105  // HO energies are not filled. Ditto for jet energies around the muon.
106  unsigned int muonCollectionSize = muonCollection->size();
107  unsigned int pfCollectionSize = pfCollection->size();
108  for (unsigned int i=0; i<muonCollectionSize; i++) {
109  edm::RefToBase<reco::Muon> mu = muonCollection->refAt(i);
110 
111  // Ask for PfMuon consistency if requested
112  bool muonFound = false;
113 
114  // Starting bycloning this muon
115  reco::Muon* newmu = mu->clone();
116  reco::TrackRef tk = mu->innerTrack();
117 
118  // Set isolations
119  reco::MuonIsolation iso03;
120  reco::MuonIsolation iso05;
121  // Loop on all candidates
122  for (unsigned int j=0; j<pfCollectionSize; j++) {
123  edm::RefToBase<reco::PFCandidate> pf = pfCollection->refAt(j);
124 
125  // Check the muon is in the PF collection when required
126  bool thisIsTheMuon = false;
127  if (tk.isNonnull() && pf->trackRef()==tk) {
128  thisIsTheMuon = true;
129  muonFound = true;
130  }
131 
132  // Get dR. Nothing to add if dR>0.5
133  double deltaR = Geom::deltaR(mu->momentum(),pf->momentum());
134  if (deltaR>0.5) continue;
135 
136  // Fill "tracker" components
137  if ( pf->particleId()==reco::PFCandidate::h
139  || pf->particleId()==reco::PFCandidate::mu ) {
140  if (deltaR<trackIsoVeto_ || thisIsTheMuon) {
141  iso05.trackerVetoPt += pf->pt();
142  iso03.trackerVetoPt += pf->pt();
143  } else {
144  iso05.sumPt += pf->pt();
145  iso05.nTracks++;
146  if (deltaR<0.3) {
147  iso03.sumPt += pf->pt();
148  iso03.nTracks++;
149  }
150  }
151  // Fill "em" components
152  } else if ( pf->particleId()==reco::PFCandidate::gamma
154  if (deltaR<gammaIsoVeto_) {
155  iso05.emVetoEt += pf->pt();
156  iso03.emVetoEt += pf->pt();
157  } else {
158  iso05.emEt += pf->pt();
159  if (deltaR<0.3) iso03.emEt += pf->pt();
160  }
161  // Fill "had" components
162  } else if ( pf->particleId()==reco::PFCandidate::h0
164  if (deltaR<neutralHadronIsoVeto_) {
165  iso05.hadVetoEt += pf->pt();
166  iso03.hadVetoEt += pf->pt();
167  } else {
168  iso05.hadEt += pf->pt();
169  if (deltaR<0.3) iso03.hadEt += pf->pt();
170  }
171  }
172  }
173 
174  // Do not take this muon (under explicit request) if it is not a PfMuon
175  if (usePfMuonsOnly_ && (!muonFound)) continue;
176 
177  // Set this isolation information in the new muon
178  newmu->setIsolation(iso03,iso05);
179 
180  // Add new muon to output collection
181  newmuons->push_back(*newmu);
182 
183  }
184 
185  // Add output collection to event
186  ev.put(newmuons);
187 }
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
int i
Definition: DBlmapReader.cc:9
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
float hadVetoEt
hcal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:15
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
Definition: Muon.cc:805
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:429
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
int j
Definition: DBlmapReader.cc:9
const int mu
Definition: Constants.h:22
int nTracks
number of tracks in the cone (excluding veto region)
Definition: MuonIsolation.h:11
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Muon * clone() const
create a clone
Definition: Muon.cc:44
float emVetoEt
ecal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:14
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfToken_
virtual Vector momentum() const GCC11_FINAL
spatial momentum vector
virtual ParticleType particleId() const
Definition: PFCandidate.h:355
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
virtual float pt() const GCC11_FINAL
transverse momentum
float trackerVetoPt
(sum-)pt inside the veto region in r-phi
Definition: MuonIsolation.h:13

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