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
 
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_
 

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 66 of file MuScleFitMuonProducer.cc.

References patMuons_.

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

Definition at line 80 of file MuScleFitMuonProducer.cc.

81 {
82 }

Member Function Documentation

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

Definition at line 86 of file MuScleFitMuonProducer.cc.

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

Referenced by produce().

87 {
88  std::auto_ptr<T> pOut(new T);
89 
90  // Apply the correction and produce the new muons
91  for( typename T::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
92 
93  //std::cout << "Pt before correction = " << muon->pt() << std::endl;
94  double pt = (*corrector_)(*muon);
95  //std::cout << "Pt after correction = " << pt << std::endl;
96  double eta = muon->eta();
97  double phi = muon->phi();
98 
99  typename T::value_type * newMuon = muon->clone();
100  newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
101 
102  pOut->push_back(*newMuon);
103  }
104  return pOut;
105 }
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 160 of file MuScleFitMuonProducer.cc.

161 {
162 }
void MuScleFitMuonProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 166 of file MuScleFitMuonProducer.cc.

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

Implements edm::EDProducer.

Definition at line 108 of file MuScleFitMuonProducer.cc.

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

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

Member Data Documentation

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

Definition at line 63 of file MuScleFitMuonProducer.cc.

Referenced by produce().

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

Definition at line 60 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 62 of file MuScleFitMuonProducer.cc.

Referenced by produce().

std::string MuScleFitMuonProducer::dbObjectLabel_
private

Definition at line 61 of file MuScleFitMuonProducer.cc.

Referenced by produce().

bool MuScleFitMuonProducer::patMuons_
private

Definition at line 59 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 58 of file MuScleFitMuonProducer.cc.

Referenced by produce().