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::ProductRegistryHelper

Public Member Functions

 MuonWithPFIsoProducer (const edm::ParameterSet &)
 
 ~MuonWithPFIsoProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

Private Attributes

double gammaIsoVeto_
 
edm::InputTag muonTag_
 
double neutralHadronIsoVeto_
 
edm::InputTag pfTag_
 
double trackIsoVeto_
 
bool usePfMuonsOnly_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 12 of file MuonWithPFIsoProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 44 of file MuonWithPFIsoProducer.cc.

References gammaIsoVeto_, edm::ParameterSet::getUntrackedParameter(), muonTag_, neutralHadronIsoVeto_, pfTag_, trackIsoVeto_, and usePfMuonsOnly_.

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

Definition at line 66 of file MuonWithPFIsoProducer.cc.

66  {
67 }

Member Function Documentation

void MuonWithPFIsoProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonWithPFIsoProducer.cc.

70  {
71 }
void MuonWithPFIsoProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 74 of file MuonWithPFIsoProducer.cc.

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

Implements edm::EDProducer.

Definition at line 78 of file MuonWithPFIsoProducer.cc.

References reco::Muon::clone(), deltaR(), Geom::deltaR(), reco::PFCandidate::e, reco::PFCandidate::egamma_HF, reco::MuonIsolation::emEt, reco::MuonIsolation::emVetoEt, reco::PFCandidate::gamma, gammaIsoVeto_, edm::Event::getByLabel(), 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(), reco::PFCandidate::mu, ExpressReco_HICollisions_FallBack::muonCollection, muonTag_, neutralHadronIsoVeto_, reco::MuonIsolation::nTracks, reco::PFCandidate::particleId(), pfTag_, reco::LeafCandidate::pt(), edm::Event::put(), reco::Muon::setIsolation(), reco::MuonIsolation::sumPt, reco::MuonIsolation::trackerVetoPt, trackIsoVeto_, reco::PFCandidate::trackRef(), and usePfMuonsOnly_.

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

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

Member Data Documentation

double MuonWithPFIsoProducer::gammaIsoVeto_
private

Definition at line 28 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

edm::InputTag MuonWithPFIsoProducer::muonTag_
private

Definition at line 22 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

double MuonWithPFIsoProducer::neutralHadronIsoVeto_
private

Definition at line 29 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

edm::InputTag MuonWithPFIsoProducer::pfTag_
private

Definition at line 23 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

double MuonWithPFIsoProducer::trackIsoVeto_
private

Definition at line 27 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

bool MuonWithPFIsoProducer::usePfMuonsOnly_
private

Definition at line 25 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().