CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

boost::shared_ptr< MomentumScaleCorrectorcorrector_
 
edm::ESHandle< MuScleFitDBobjectdbObject_
 
unsigned long long dbObjectCacheId_
 
std::string dbObjectLabel_
 
bool patMuons_
 
edm::InputTag theMuonLabel_
 
edm::EDGetTokenT< pat::MuonCollectionthePatMuonToken_
 
edm::EDGetTokenT< reco::MuonCollectiontheRecoMuonToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 ( )
override

Definition at line 84 of file MuScleFitMuonProducer.cc.

85 {
86 }

Member Function Documentation

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

Definition at line 90 of file MuScleFitMuonProducer.cc.

References PVValHelper::eta, metsig::muon, phi, and EnergyCorrector::pt.

Referenced by produce().

91 {
92  std::unique_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 }
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
long double T
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.

References DEFINE_FWK_MODULE.

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

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< T >::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(std::move(pOut));
142  // iEvent.put(applyCorrection(allMuons);
143 
144 /* std::unique_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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::unique_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
edm::ESHandle< MuScleFitDBobject > dbObject_
boost::shared_ptr< MomentumScaleCorrector > corrector_
unsigned long long dbObjectCacheId_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
T const * product() const
Definition: ESHandle.h:86

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().