CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuScleFitMuonProducer Class Reference
Inheritance diagram for MuScleFitMuonProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuScleFitMuonProducer (const edm::ParameterSet &)
 
 ~MuScleFitMuonProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

std::shared_ptr
< MomentumScaleCorrector
corrector_
 
edm::ESHandle< MuScleFitDBobjectdbObject_
 
unsigned long long dbObjectCacheId_
 
const edm::ESGetToken
< MuScleFitDBobject,
MuScleFitDBobjectRcd
muToken_
 
const bool patMuons_
 
const edm::InputTag theMuonLabel_
 
const edm::EDGetTokenT
< pat::MuonCollection
thePatMuonToken_
 
const edm::EDGetTokenT
< reco::MuonCollection
theRecoMuonToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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

Constructor & Destructor Documentation

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

Definition at line 60 of file MuScleFitMuonProducer.cc.

References patMuons_.

61  : muToken_(esConsumes(edm::ESInputTag("", iConfig.getUntrackedParameter<std::string>("DbObjectLabel", "")))),
62  theMuonLabel_(iConfig.getParameter<edm::InputTag>("MuonLabel")),
63  thePatMuonToken_(mayConsume<pat::MuonCollection>(theMuonLabel_)),
64  theRecoMuonToken_(mayConsume<reco::MuonCollection>(theMuonLabel_)),
65  patMuons_(iConfig.getParameter<bool>("PatMuons")),
66  dbObjectCacheId_(0) {
67  if (patMuons_ == true) {
68  produces<pat::MuonCollection>();
69  } else {
70  produces<reco::MuonCollection>();
71  }
72 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
const edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
const edm::InputTag theMuonLabel_
unsigned long long dbObjectCacheId_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MuScleFitMuonProducer::~MuScleFitMuonProducer ( )
overridedefault

Member Function Documentation

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

Definition at line 77 of file MuScleFitMuonProducer.cc.

References PVValHelper::eta, HLT_FULL_cff::muon, phi, and DiDispStaMuonMonitor_cfi::pt.

Referenced by produce().

77  {
78  std::unique_ptr<T> pOut(new T);
79 
80  // Apply the correction and produce the new muons
81  for (typename T::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon) {
82  //std::cout << "Pt before correction = " << muon->pt() << std::endl;
83  double pt = (*corrector_)(*muon);
84  //std::cout << "Pt after correction = " << pt << std::endl;
85  double eta = muon->eta();
86  double phi = muon->phi();
87 
88  typename T::value_type* newMuon = muon->clone();
89  newMuon->setP4(reco::Particle::PolarLorentzVector(pt, eta, phi, muon->mass()));
90 
91  pOut->push_back(*newMuon);
92  }
93  return pOut;
94 }
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
long double T
void MuScleFitMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 97 of file MuScleFitMuonProducer.cc.

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

97  {
98  unsigned long long dbObjectCacheId = iSetup.get<MuScleFitDBobjectRcd>().cacheIdentifier();
99  if (dbObjectCacheId != dbObjectCacheId_) {
100  dbObject_ = iSetup.getHandle(muToken_);
101  }
102 
103  //std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
104  //std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;
105 
106  // Create the corrector and set the parameters
108 
109  if (patMuons_ == true) {
111  iEvent.getByToken(thePatMuonToken_, allMuons);
112  iEvent.put(applyCorrection(allMuons));
113  } else {
115  iEvent.getByToken(theRecoMuonToken_, allMuons);
116  iEvent.put(applyCorrection(allMuons));
117  }
118 
119  // put into the Event
120  // iEvent.put(std::move(pOut));
121  // iEvent.put(applyCorrection(allMuons);
122 
123  /* std::unique_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
124 
125  // Apply the correction and produce the new muons
126  for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
127 
128  double pt = (*corrector_)(*muon);
129  double eta = muon->eta();
130  double phi = muon->phi();
131 
132  reco::Muon * newMuon = muon->clone();
133  newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
134 
135  pOut->push_back(*newMuon);
136  }
137 */
138 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::unique_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
edm::ESHandle< MuScleFitDBobject > dbObject_
tuple allMuons
Definition: allMuons_cfi.py:3
const edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
unsigned long long dbObjectCacheId_
T const * product() const
Definition: ESHandle.h:86
std::shared_ptr< MomentumScaleCorrector > corrector_
T get() const
Definition: EventSetup.h:82
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151

Member Data Documentation

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

Definition at line 57 of file MuScleFitMuonProducer.cc.

Referenced by produce().

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

Definition at line 55 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 56 of file MuScleFitMuonProducer.cc.

Referenced by produce().

const edm::ESGetToken<MuScleFitDBobject, MuScleFitDBobjectRcd> MuScleFitMuonProducer::muToken_
private

Definition at line 49 of file MuScleFitMuonProducer.cc.

Referenced by produce().

const bool MuScleFitMuonProducer::patMuons_
private

Definition at line 53 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

const edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 50 of file MuScleFitMuonProducer.cc.

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

Definition at line 51 of file MuScleFitMuonProducer.cc.

Referenced by produce().

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

Definition at line 52 of file MuScleFitMuonProducer.cc.

Referenced by produce().