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

Public Member Functions

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

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

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
 
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)
 
static void prevalidate (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

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

Definition at line 48 of file MuScleFitMuonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 67 of file MuScleFitMuonProducer.cc.

References patMuons_.

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

Definition at line 81 of file MuScleFitMuonProducer.cc.

82 {
83 }

Member Function Documentation

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

Definition at line 87 of file MuScleFitMuonProducer.cc.

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

Referenced by produce().

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

Reimplemented from edm::EDProducer.

Definition at line 161 of file MuScleFitMuonProducer.cc.

162 {
163 }
void MuScleFitMuonProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 167 of file MuScleFitMuonProducer.cc.

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

Implements edm::EDProducer.

Definition at line 109 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_.

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

Referenced by produce().

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

Definition at line 61 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 63 of file MuScleFitMuonProducer.cc.

Referenced by produce().

std::string MuScleFitMuonProducer::dbObjectLabel_
private

Definition at line 62 of file MuScleFitMuonProducer.cc.

Referenced by produce().

bool MuScleFitMuonProducer::patMuons_
private

Definition at line 60 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 59 of file MuScleFitMuonProducer.cc.

Referenced by produce().