CMS 3D CMS Logo

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< MomentumScaleCorrectorcorrector_
 
edm::ESHandle< MuScleFitDBobjectdbObject_
 
unsigned long long dbObjectCacheId_
 
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcdmuToken_
 
const bool patMuons_
 
const edm::InputTag theMuonLabel_
 
const edm::EDGetTokenT< pat::MuonCollectionthePatMuonToken_
 
const edm::EDGetTokenT< reco::MuonCollectiontheRecoMuonToken_
 

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::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 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
const edm::InputTag theMuonLabel_
unsigned long long dbObjectCacheId_
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_

◆ ~MuScleFitMuonProducer()

MuScleFitMuonProducer::~MuScleFitMuonProducer ( )
overridedefault

Member Function Documentation

◆ applyCorrection()

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

Definition at line 77 of file MuScleFitMuonProducer.cc.

References allMuons_cfi::allMuons, PVValHelper::eta, HLT_2024v13_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

◆ produce()

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::EventSetup::getHandle(), iEvent, muToken_, patMuons_, edm::ESHandle< T >::product(), 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);
113  } else {
115  iEvent.getByToken(theRecoMuonToken_, 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 }
const edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
std::unique_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< MuScleFitDBobject > dbObject_
T get() const
Definition: EventSetup.h:79
const edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
unsigned long long dbObjectCacheId_
std::shared_ptr< MomentumScaleCorrector > corrector_
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_

Member Data Documentation

◆ corrector_

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

Definition at line 57 of file MuScleFitMuonProducer.cc.

Referenced by produce().

◆ dbObject_

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

Definition at line 55 of file MuScleFitMuonProducer.cc.

Referenced by produce().

◆ dbObjectCacheId_

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 56 of file MuScleFitMuonProducer.cc.

Referenced by produce().

◆ muToken_

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

Definition at line 49 of file MuScleFitMuonProducer.cc.

Referenced by produce().

◆ patMuons_

const bool MuScleFitMuonProducer::patMuons_
private

Definition at line 53 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

◆ theMuonLabel_

const edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 50 of file MuScleFitMuonProducer.cc.

◆ thePatMuonToken_

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

Definition at line 51 of file MuScleFitMuonProducer.cc.

Referenced by produce().

◆ theRecoMuonToken_

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

Definition at line 52 of file MuScleFitMuonProducer.cc.

Referenced by produce().