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

Public Member Functions

 MuScleFitMuonProducer (const edm::ParameterSet &)
 
 ~MuScleFitMuonProducer ()
 
- 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

template<class T >
std::auto_ptr< TapplyCorrection (const edm::Handle< T > &allMuons)
 
virtual void beginJob () override
 
virtual void endJob () override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

boost::shared_ptr
< MomentumScaleCorrector
corrector_
 
edm::ESHandle< MuScleFitDBobjectdbObject_
 
unsigned long long dbObjectCacheId_
 
std::string dbObjectLabel_
 
bool patMuons_
 
edm::InputTag theMuonLabel_
 
edm::EDGetTokenT
< pat::MuonCollection
thePatMuonToken_
 
edm::EDGetTokenT
< reco::MuonCollection
theRecoMuonToken_
 

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

Produce a new muon collection with corrected Pt.
It is also possible to apply a smearing to the muons Pt.

Definition at line 47 of file MuScleFitMuonProducer.cc.

Constructor & Destructor Documentation

MuScleFitMuonProducer::MuScleFitMuonProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 68 of file MuScleFitMuonProducer.cc.

References patMuons_.

68  :
69  theMuonLabel_( iConfig.getParameter<edm::InputTag>( "MuonLabel" ) ),
70  thePatMuonToken_( mayConsume<pat::MuonCollection>( theMuonLabel_ ) ),
71  theRecoMuonToken_( mayConsume<reco::MuonCollection>( theMuonLabel_ ) ),
72  patMuons_( iConfig.getParameter<bool>( "PatMuons" ) ),
73  dbObjectLabel_( iConfig.getUntrackedParameter<std::string>("DbObjectLabel", "") ),
75 {
76  if ( patMuons_ == true ) {
77  produces<pat::MuonCollection>();
78  } else {
79  produces<reco::MuonCollection>();
80  }
81 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned long long dbObjectCacheId_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
MuScleFitMuonProducer::~MuScleFitMuonProducer ( )

Definition at line 84 of file MuScleFitMuonProducer.cc.

85 {
86 }

Member Function Documentation

template<class T >
std::auto_ptr< T > MuScleFitMuonProducer::applyCorrection ( const edm::Handle< T > &  allMuons)
private

Definition at line 90 of file MuScleFitMuonProducer.cc.

References eta(), trackingTruthProducerFastSim_cfi::muon, phi, and RecoTauCleanerPlugins::pt.

Referenced by produce().

91 {
92  std::auto_ptr<T> pOut(new T);
93 
94  // Apply the correction and produce the new muons
95  for( typename T::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
96 
97  //std::cout << "Pt before correction = " << muon->pt() << std::endl;
98  double pt = (*corrector_)(*muon);
99  //std::cout << "Pt after correction = " << pt << std::endl;
100  double eta = muon->eta();
101  double phi = muon->phi();
102 
103  typename T::value_type * newMuon = muon->clone();
104  newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
105 
106  pOut->push_back(*newMuon);
107  }
108  return pOut;
109 }
T eta() const
Container::value_type value_type
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:29
long double T
Definition: DDAxes.h:10
void MuScleFitMuonProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 164 of file MuScleFitMuonProducer.cc.

165 {
166 }
void MuScleFitMuonProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 170 of file MuScleFitMuonProducer.cc.

171 {
172 }
void MuScleFitMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 112 of file MuScleFitMuonProducer.cc.

References allMuons_cfi::allMuons, applyCorrection(), corrector_, dbObject_, dbObjectCacheId_, dbObjectLabel_, edm::EventSetup::get(), edm::Event::getByToken(), patMuons_, edm::ESHandle< class >::product(), edm::Event::put(), thePatMuonToken_, and theRecoMuonToken_.

113 {
114  unsigned long long dbObjectCacheId = iSetup.get<MuScleFitDBobjectRcd>().cacheIdentifier();
115  if ( dbObjectCacheId != dbObjectCacheId_ ) {
116  if ( dbObjectLabel_ != "" ) {
118  } else {
119  iSetup.get<MuScleFitDBobjectRcd>().get(dbObject_);
120  }
121  }
122 
123  //std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
124  //std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;
125 
126  // Create the corrector and set the parameters
128 
129  if( patMuons_ == true ) {
131  iEvent.getByToken(thePatMuonToken_, allMuons);
132  iEvent.put(applyCorrection(allMuons));
133  }
134  else {
136  iEvent.getByToken(theRecoMuonToken_, allMuons);
137  iEvent.put(applyCorrection(allMuons));
138  }
139 
140  // put into the Event
141  // iEvent.put(pOut);
142  // iEvent.put(applyCorrection(allMuons));
143 
144 /* std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
145 
146  // Apply the correction and produce the new muons
147  for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
148 
149  double pt = (*corrector_)(*muon);
150  double eta = muon->eta();
151  double phi = muon->phi();
152 
153  reco::Muon * newMuon = muon->clone();
154  newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
155 
156  pOut->push_back(*newMuon);
157  }
158 */
159 
160 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::ESHandle< MuScleFitDBobject > dbObject_
tuple allMuons
Definition: allMuons_cfi.py:3
std::auto_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
boost::shared_ptr< MomentumScaleCorrector > corrector_
unsigned long long dbObjectCacheId_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_

Member Data Documentation

boost::shared_ptr<MomentumScaleCorrector> MuScleFitMuonProducer::corrector_
private

Definition at line 65 of file MuScleFitMuonProducer.cc.

Referenced by produce().

edm::ESHandle<MuScleFitDBobject> MuScleFitMuonProducer::dbObject_
private

Definition at line 62 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 64 of file MuScleFitMuonProducer.cc.

Referenced by produce().

std::string MuScleFitMuonProducer::dbObjectLabel_
private

Definition at line 63 of file MuScleFitMuonProducer.cc.

Referenced by produce().

bool MuScleFitMuonProducer::patMuons_
private

Definition at line 61 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 58 of file MuScleFitMuonProducer.cc.

edm::EDGetTokenT<pat::MuonCollection> MuScleFitMuonProducer::thePatMuonToken_
private

Definition at line 59 of file MuScleFitMuonProducer.cc.

Referenced by produce().

edm::EDGetTokenT<reco::MuonCollection> MuScleFitMuonProducer::theRecoMuonToken_
private

Definition at line 60 of file MuScleFitMuonProducer.cc.

Referenced by produce().