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
MuonWithPFIsoProducerCopy Class Reference
Inheritance diagram for MuonWithPFIsoProducerCopy:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonWithPFIsoProducerCopy (const edm::ParameterSet &)
 
 ~MuonWithPFIsoProducerCopy ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 ()
 
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
 
- 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 12 of file MuonWithPFIsoProducerCopy.cc.

Constructor & Destructor Documentation

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

Definition at line 44 of file MuonWithPFIsoProducerCopy.cc.

References gammaIsoVeto_, edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::InputTag, 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
MuonWithPFIsoProducerCopy::~MuonWithPFIsoProducerCopy ( )

Definition at line 66 of file MuonWithPFIsoProducerCopy.cc.

66  {
67 }

Member Function Documentation

void MuonWithPFIsoProducerCopy::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonWithPFIsoProducerCopy.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 74 of file MuonWithPFIsoProducerCopy.cc.

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

Implements edm::EDProducer.

Definition at line 78 of file MuonWithPFIsoProducerCopy.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::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(), RPCpg::mu, reco::PFCandidate::mu, muonTag_, neutralHadronIsoVeto_, MuonAlignmentFromReference_cff::newmuons, 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_.

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
84  edm::Handle<edm::View<reco::Muon> > muonCollection;
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
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
virtual TrackRef innerTrack() const
Definition: Muon.h:48
virtual Vector momentum() const
spatial momentum vector
float hadVetoEt
hcal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:15
virtual double pt() const
transverse momentum
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
int j
Definition: DBlmapReader.cc:9
const int mu
Definition: Constants.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
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
float emVetoEt
ecal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:14
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
Muon * clone() const
create a clone
float trackerVetoPt
(sum-)pt inside the veto region in r-phi
Definition: MuonIsolation.h:13

Member Data Documentation

double MuonWithPFIsoProducerCopy::gammaIsoVeto_
private

Definition at line 28 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().

edm::InputTag MuonWithPFIsoProducerCopy::muonTag_
private

Definition at line 22 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().

double MuonWithPFIsoProducerCopy::neutralHadronIsoVeto_
private

Definition at line 29 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().

edm::InputTag MuonWithPFIsoProducerCopy::pfTag_
private

Definition at line 23 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().

double MuonWithPFIsoProducerCopy::trackIsoVeto_
private

Definition at line 27 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().

bool MuonWithPFIsoProducerCopy::usePfMuonsOnly_
private

Definition at line 25 of file MuonWithPFIsoProducerCopy.cc.

Referenced by MuonWithPFIsoProducerCopy(), and produce().