CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

std::string dbDataResolutionLabel_
 
std::string dbMCResolutionLabel_
 
std::string dbScaleLabel_
 
std::auto_ptr
< MomentumScaleCorrector
momCorrector_
 
std::auto_ptr< ResolutionFunctionmomResolutionData_
 
std::auto_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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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

Definition at line 16 of file DistortedMuonProducerFromDB.cc.

Constructor & Destructor Documentation

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

Definition at line 51 of file DistortedMuonProducerFromDB.cc.

References dbDataResolutionLabel_, dbMCResolutionLabel_, dbScaleLabel_, edm::ParameterSet::getUntrackedParameter(), muonToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

51  {
52 
53  // What is being produced
54  produces<std::vector<reco::Muon> >();
55 
56  // Input products
57  muonToken_ = 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 
62 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
DistortedMuonProducerFromDB::~DistortedMuonProducerFromDB ( )

Definition at line 65 of file DistortedMuonProducerFromDB.cc.

65  {
66 }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 69 of file DistortedMuonProducerFromDB.cc.

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

69  {
71  iSetup.get<MuScleFitDBobjectRcd>().get(dbScaleLabel_,dbObject1);
72  momCorrector_.reset(new MomentumScaleCorrector(dbObject1.product()));
73 
74  LogTrace("") << ">>> Using database for momentum scale corrections !!";
75 
77  iSetup.get<MuScleFitDBobjectRcd>().get(dbDataResolutionLabel_, dbObject2);
78  momResolutionData_.reset(new ResolutionFunction(dbObject2.product()));
79 
81  iSetup.get<MuScleFitDBobjectRcd>().get(dbMCResolutionLabel_, dbObject3);
82  momResolutionMC_.reset(new ResolutionFunction(dbObject3.product()));
83 
84  LogTrace("") << ">>> Using database for momentum resolution corrections !!";
85 }
std::auto_ptr< MomentumScaleCorrector > momCorrector_
std::auto_ptr< ResolutionFunction > momResolutionData_
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::auto_ptr< ResolutionFunction > momResolutionMC_
void DistortedMuonProducerFromDB::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 88 of file DistortedMuonProducerFromDB.cc.

88  {
89 }
void DistortedMuonProducerFromDB::produce ( edm::Event ev,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 92 of file DistortedMuonProducerFromDB.cc.

References reco::Muon::clone(), reco::LeafCandidate::eta(), edm::Event::getByToken(), i, edm::EventBase::isRealData(), LogTrace, reco::LeafCandidate::mass(), momResolutionData_, momResolutionMC_, RPCpg::mu, muonToken_, MuonAlignmentFromReference_cff::newmuons, reco::LeafCandidate::phi(), funct::pow(), reco::LeafCandidate::pt(), edm::Event::put(), reco::LeafCandidate::setP4(), edm::shift, and mathSSE::sqrt().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

92  {
93 
94  if (ev.isRealData()) return;
95 
96  // Muon collection
97  edm::Handle<edm::View<reco::Muon> > muonCollection;
98  if (!ev.getByToken(muonToken_, muonCollection)) {
99  edm::LogError("") << ">>> Muon collection does not exist !!!";
100  return;
101  }
102  unsigned int muonCollectionSize = muonCollection->size();
103 
104  std::auto_ptr<reco::MuonCollection> newmuons (new reco::MuonCollection);
105 
106  for (unsigned int i=0; i<muonCollectionSize; i++) {
107  edm::RefToBase<reco::Muon> mu = muonCollection->refAt(i);
108 
109  // Set shift
110  double shift = (*momCorrector_)(*mu) - mu->pt();
111  LogTrace("") << "\tmomentumScaleShift= " << shift << " [GeV]";
112 
113  // Set resolutions
114  double sigma = pow(momResolutionData_->sigmaPt(*mu),2) -
115  pow(momResolutionMC_->sigmaPt(*mu),2);
116  if (sigma>0.) sigma = sqrt(sigma); else sigma = 0.;
117  LogTrace("") << "\tPt additional smearing= " << sigma << " [GeV]";
118 
119  // Gaussian Random number for smearing
120  double rndg = CLHEP::RandGauss::shoot();
121 
122  // New muon
123  double ptmu = mu->pt();
124  ptmu += shift + sigma*rndg;
125  reco::Muon* newmu = mu->clone();
126  newmu->setP4 (
128  ptmu, mu->eta(), mu->phi(), mu->mass()
129  )
130  );
131  newmuons->push_back(*newmu);
132 
133  }
134 
135  ev.put(newmuons);
136 }
int i
Definition: DBlmapReader.cc:9
virtual float pt() const
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual float phi() const
momentum azimuthal angle
std::auto_ptr< ResolutionFunction > momResolutionData_
virtual void setP4(const LorentzVector &p4)
set 4-momentum
bool isRealData() const
Definition: EventBase.h:60
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual float eta() const
momentum pseudorapidity
T sqrt(T t)
Definition: SSEVec.h:48
const int mu
Definition: Constants.h:22
#define LogTrace(id)
Muon * clone() const
create a clone
Definition: Muon.cc:44
std::auto_ptr< ResolutionFunction > momResolutionMC_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:29
static unsigned int const shift
virtual float mass() const
mass
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_

Member Data Documentation

std::string DistortedMuonProducerFromDB::dbDataResolutionLabel_
private

Definition at line 29 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

std::string DistortedMuonProducerFromDB::dbMCResolutionLabel_
private

Definition at line 30 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

std::string DistortedMuonProducerFromDB::dbScaleLabel_
private

Definition at line 28 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

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

Definition at line 32 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun().

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

Definition at line 33 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

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

Definition at line 34 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

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

Definition at line 26 of file DistortedMuonProducerFromDB.cc.

Referenced by DistortedMuonProducerFromDB(), and produce().