CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DistortedMuonProducerFromDB Class Reference
Inheritance diagram for DistortedMuonProducerFromDB:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DistortedMuonProducerFromDB (const edm::ParameterSet &)
 
 ~DistortedMuonProducerFromDB () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string dbDataResolutionLabel_
 
std::string dbMCResolutionLabel_
 
std::string dbScaleLabel_
 
std::unique_ptr< MomentumScaleCorrectormomCorrector_
 
std::unique_ptr< ResolutionFunctionmomResolutionData_
 
std::unique_ptr< ResolutionFunctionmomResolutionMC_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
 

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
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file DistortedMuonProducerFromDB.cc.

Constructor & Destructor Documentation

◆ DistortedMuonProducerFromDB()

DistortedMuonProducerFromDB::DistortedMuonProducerFromDB ( const edm::ParameterSet pset)
explicit

Definition at line 51 of file DistortedMuonProducerFromDB.cc.

51  {
52  // What is being produced
53  produces<std::vector<reco::Muon> >();
54 
55  // Input products
56  muonToken_ =
57  consumes<edm::View<reco::Muon> >(pset.getUntrackedParameter<edm::InputTag>("MuonTag", edm::InputTag("muons")));
58  dbScaleLabel_ = pset.getUntrackedParameter<std::string>("DBScaleLabel", "scale");
59  dbDataResolutionLabel_ = pset.getUntrackedParameter<std::string>("DBDataResolutionLabel", "datareso");
60  dbMCResolutionLabel_ = pset.getUntrackedParameter<std::string>("DBMCResolutionLabel", "mcreso");
61 }

References dbDataResolutionLabel_, dbMCResolutionLabel_, dbScaleLabel_, HLT_FULL_cff::InputTag, muonToken_, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~DistortedMuonProducerFromDB()

DistortedMuonProducerFromDB::~DistortedMuonProducerFromDB ( )
override

Definition at line 64 of file DistortedMuonProducerFromDB.cc.

64 {}

Member Function Documentation

◆ beginRun()

void DistortedMuonProducerFromDB::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 67 of file DistortedMuonProducerFromDB.cc.

67  {
69  iSetup.get<MuScleFitDBobjectRcd>().get(dbScaleLabel_, dbObject1);
70  momCorrector_ = std::make_unique<MomentumScaleCorrector>(dbObject1.product());
71 
72  LogTrace("") << ">>> Using database for momentum scale corrections !!";
73 
75  iSetup.get<MuScleFitDBobjectRcd>().get(dbDataResolutionLabel_, dbObject2);
76  momResolutionData_ = std::make_unique<ResolutionFunction>(dbObject2.product());
77 
79  iSetup.get<MuScleFitDBobjectRcd>().get(dbMCResolutionLabel_, dbObject3);
80  momResolutionMC_ = std::make_unique<ResolutionFunction>(dbObject3.product());
81 
82  LogTrace("") << ">>> Using database for momentum resolution corrections !!";
83 }

References dbDataResolutionLabel_, dbMCResolutionLabel_, dbScaleLabel_, edm::EventSetup::get(), get, LogTrace, momCorrector_, momResolutionData_, momResolutionMC_, and edm::ESHandle< T >::product().

◆ endJob()

void DistortedMuonProducerFromDB::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 86 of file DistortedMuonProducerFromDB.cc.

86 {}

◆ produce()

void DistortedMuonProducerFromDB::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 89 of file DistortedMuonProducerFromDB.cc.

89  {
90  if (ev.isRealData())
91  return;
92 
93  // Muon collection
95  if (!ev.getByToken(muonToken_, muonCollection)) {
96  edm::LogError("") << ">>> Muon collection does not exist !!!";
97  return;
98  }
99  unsigned int muonCollectionSize = muonCollection->size();
100 
101  std::unique_ptr<reco::MuonCollection> newmuons(new reco::MuonCollection);
102 
103  for (unsigned int i = 0; i < muonCollectionSize; i++) {
105 
106  // Set shift
107  double shift = (*momCorrector_)(*mu) - mu->pt();
108  LogTrace("") << "\tmomentumScaleShift= " << shift << " [GeV]";
109 
110  // Set resolutions
111  double sigma = pow(momResolutionData_->sigmaPt(*mu), 2) - pow(momResolutionMC_->sigmaPt(*mu), 2);
112  if (sigma > 0.)
113  sigma = sqrt(sigma);
114  else
115  sigma = 0.;
116  LogTrace("") << "\tPt additional smearing= " << sigma << " [GeV]";
117 
118  // Gaussian Random number for smearing
119  double rndg = CLHEP::RandGauss::shoot();
120 
121  // New muon
122  double ptmu = mu->pt();
123  ptmu += shift + sigma * rndg;
124  reco::Muon* newmu = mu->clone();
125  newmu->setP4(reco::Particle::PolarLorentzVector(ptmu, mu->eta(), mu->phi(), mu->mass()));
126  newmuons->push_back(*newmu);
127  }
128 
129  ev.put(std::move(newmuons));
130 }

References ev, mps_fire::i, LogTrace, momResolutionData_, momResolutionMC_, eostools::move(), amptDefaultParameters_cff::mu, pdwgLeptonRecoSkim_cfi::muonCollection, muonToken_, MuonAlignmentFromReference_cff::newmuons, funct::pow(), reco::LeafCandidate::setP4(), edm::shift, and mathSSE::sqrt().

Member Data Documentation

◆ dbDataResolutionLabel_

std::string DistortedMuonProducerFromDB::dbDataResolutionLabel_
private

Definition at line 29 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

◆ dbMCResolutionLabel_

std::string DistortedMuonProducerFromDB::dbMCResolutionLabel_
private

Definition at line 30 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

◆ dbScaleLabel_

std::string DistortedMuonProducerFromDB::dbScaleLabel_
private

Definition at line 28 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

◆ momCorrector_

std::unique_ptr<MomentumScaleCorrector> DistortedMuonProducerFromDB::momCorrector_
private

Definition at line 32 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun().

◆ momResolutionData_

std::unique_ptr<ResolutionFunction> DistortedMuonProducerFromDB::momResolutionData_
private

Definition at line 33 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

◆ momResolutionMC_

std::unique_ptr<ResolutionFunction> DistortedMuonProducerFromDB::momResolutionMC_
private

Definition at line 34 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

◆ muonToken_

edm::EDGetTokenT<edm::View<reco::Muon> > DistortedMuonProducerFromDB::muonToken_
private

Definition at line 26 of file DistortedMuonProducerFromDB.cc.

Referenced by DistortedMuonProducerFromDB(), and produce().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
MuonAlignmentFromReference_cff.newmuons
newmuons
Definition: MuonAlignmentFromReference_cff.py:26
mps_fire.i
i
Definition: mps_fire.py:428
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
DistortedMuonProducerFromDB::dbScaleLabel_
std::string dbScaleLabel_
Definition: DistortedMuonProducerFromDB.cc:28
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
MuScleFitDBobjectRcd
Definition: MuScleFitDBobjectRcd.h:6
DistortedMuonProducerFromDB::dbMCResolutionLabel_
std::string dbMCResolutionLabel_
Definition: DistortedMuonProducerFromDB.cc:30
edm::Handle
Definition: AssociativeIterator.h:50
reco::Muon
Definition: Muon.h:27
DistortedMuonProducerFromDB::dbDataResolutionLabel_
std::string dbDataResolutionLabel_
Definition: DistortedMuonProducerFromDB.cc:29
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DistortedMuonProducerFromDB::muonToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
Definition: DistortedMuonProducerFromDB.cc:26
edm::ESHandle< MuScleFitDBobject >
DistortedMuonProducerFromDB::momResolutionData_
std::unique_ptr< ResolutionFunction > momResolutionData_
Definition: DistortedMuonProducerFromDB.cc:33
reco::Particle::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
DistortedMuonProducerFromDB::momResolutionMC_
std::unique_ptr< ResolutionFunction > momResolutionMC_
Definition: DistortedMuonProducerFromDB.cc:34
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
pdwgLeptonRecoSkim_cfi.muonCollection
muonCollection
Definition: pdwgLeptonRecoSkim_cfi.py:7
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::RefToBase
Definition: AssociativeIterator.h:54
DistortedMuonProducerFromDB::momCorrector_
std::unique_ptr< MomentumScaleCorrector > momCorrector_
Definition: DistortedMuonProducerFromDB.cc:32
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27