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::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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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

std::shared_ptr
< MomentumScaleCorrector
corrector_
 
edm::ESHandle< MuScleFitDBobjectdbObject_
 
unsigned long long dbObjectCacheId_
 
std::string dbObjectLabel_
 
bool patMuons_
 
edm::InputTag theMuonLabel_
 
edm::EDGetTokenT
< pat::MuonCollection
thePatMuonToken_
 
edm::EDGetTokenT
< reco::MuonCollection
theRecoMuonToken_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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

References patMuons_.

70  : theMuonLabel_(iConfig.getParameter<edm::InputTag>("MuonLabel")),
71  thePatMuonToken_(mayConsume<pat::MuonCollection>(theMuonLabel_)),
72  theRecoMuonToken_(mayConsume<reco::MuonCollection>(theMuonLabel_)),
73  patMuons_(iConfig.getParameter<bool>("PatMuons")),
74  dbObjectLabel_(iConfig.getUntrackedParameter<std::string>("DbObjectLabel", "")),
75  dbObjectCacheId_(0) {
76  if (patMuons_ == true) {
77  produces<pat::MuonCollection>();
78  } else {
79  produces<reco::MuonCollection>();
80  }
81 }
T getUntrackedParameter(std::string const &, T const &) const
unsigned long long dbObjectCacheId_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
MuScleFitMuonProducer::~MuScleFitMuonProducer ( )
override

Definition at line 83 of file MuScleFitMuonProducer.cc.

83 {}

Member Function Documentation

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

Definition at line 86 of file MuScleFitMuonProducer.cc.

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

Referenced by produce().

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

Reimplemented from edm::EDProducer.

Definition at line 154 of file MuScleFitMuonProducer.cc.

154 {}
void MuScleFitMuonProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 157 of file MuScleFitMuonProducer.cc.

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

Implements edm::EDProducer.

Definition at line 106 of file MuScleFitMuonProducer.cc.

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

106  {
107  unsigned long long dbObjectCacheId = iSetup.get<MuScleFitDBobjectRcd>().cacheIdentifier();
108  if (dbObjectCacheId != dbObjectCacheId_) {
109  if (!dbObjectLabel_.empty()) {
111  } else {
112  iSetup.get<MuScleFitDBobjectRcd>().get(dbObject_);
113  }
114  }
115 
116  //std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
117  //std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;
118 
119  // Create the corrector and set the parameters
121 
122  if (patMuons_ == true) {
124  iEvent.getByToken(thePatMuonToken_, allMuons);
125  iEvent.put(applyCorrection(allMuons));
126  } else {
128  iEvent.getByToken(theRecoMuonToken_, allMuons);
129  iEvent.put(applyCorrection(allMuons));
130  }
131 
132  // put into the Event
133  // iEvent.put(std::move(pOut));
134  // iEvent.put(applyCorrection(allMuons);
135 
136  /* std::unique_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
137 
138  // Apply the correction and produce the new muons
139  for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
140 
141  double pt = (*corrector_)(*muon);
142  double eta = muon->eta();
143  double phi = muon->phi();
144 
145  reco::Muon * newMuon = muon->clone();
146  newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
147 
148  pOut->push_back(*newMuon);
149  }
150 */
151 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
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
unsigned long long dbObjectCacheId_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
T const * product() const
Definition: ESHandle.h:86
std::shared_ptr< MomentumScaleCorrector > corrector_
T get() const
Definition: EventSetup.h:88
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_

Member Data Documentation

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

Definition at line 66 of file MuScleFitMuonProducer.cc.

Referenced by produce().

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

Definition at line 63 of file MuScleFitMuonProducer.cc.

Referenced by produce().

unsigned long long MuScleFitMuonProducer::dbObjectCacheId_
private

Definition at line 65 of file MuScleFitMuonProducer.cc.

Referenced by produce().

std::string MuScleFitMuonProducer::dbObjectLabel_
private

Definition at line 64 of file MuScleFitMuonProducer.cc.

Referenced by produce().

bool MuScleFitMuonProducer::patMuons_
private

Definition at line 62 of file MuScleFitMuonProducer.cc.

Referenced by MuScleFitMuonProducer(), and produce().

edm::InputTag MuScleFitMuonProducer::theMuonLabel_
private

Definition at line 59 of file MuScleFitMuonProducer.cc.

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

Definition at line 60 of file MuScleFitMuonProducer.cc.

Referenced by produce().

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

Definition at line 61 of file MuScleFitMuonProducer.cc.

Referenced by produce().