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::ProductRegistryHelper

Public Member Functions

 DistortedMuonProducerFromDB (const edm::ParameterSet &)
 
 ~DistortedMuonProducerFromDB ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

Private Attributes

std::string dbDataResolutionLabel_
 
std::string dbMCResolutionLabel_
 
std::string dbScaleLabel_
 
edm::InputTag genMatchMapTag_
 
std::auto_ptr
< MomentumScaleCorrector
momCorrector_
 
std::auto_ptr< ResolutionFunctionmomResolutionData_
 
std::auto_ptr< ResolutionFunctionmomResolutionMC_
 
edm::InputTag muonTag_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 13 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(), and muonTag_.

51  {
52 
53  // What is being produced
54  produces<std::vector<reco::Muon> >();
55 
56  // Input products
57  muonTag_ = 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
DistortedMuonProducerFromDB::~DistortedMuonProducerFromDB ( )

Definition at line 65 of file DistortedMuonProducerFromDB.cc.

65  {
66 }

Member Function Documentation

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

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:62
std::auto_ptr< ResolutionFunction > momResolutionMC_
void DistortedMuonProducerFromDB::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 88 of file DistortedMuonProducerFromDB.cc.

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

Implements edm::EDProducer.

Definition at line 92 of file DistortedMuonProducerFromDB.cc.

References reco::Muon::clone(), reco::LeafCandidate::eta(), edm::Event::getByLabel(), i, edm::EventBase::isRealData(), LogTrace, reco::LeafCandidate::mass(), momResolutionData_, momResolutionMC_, RPCpg::mu, muonTag_, 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.getByLabel(muonTag_, 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
std::auto_ptr< ResolutionFunction > momResolutionData_
virtual void setP4(const LorentzVector &p4)
set 4-momentum
bool isRealData() const
Definition: EventBase.h:60
virtual double eta() const
momentum pseudorapidity
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
virtual double mass() const
mass
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
const int mu
Definition: Constants.h:23
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
Muon * clone() const
create a clone
Definition: Muon.cc:40
virtual double pt() const
transverse momentum
std::auto_ptr< ResolutionFunction > momResolutionMC_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:27
static unsigned int const shift
virtual double phi() const
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

std::string DistortedMuonProducerFromDB::dbDataResolutionLabel_
private

Definition at line 27 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

std::string DistortedMuonProducerFromDB::dbMCResolutionLabel_
private

Definition at line 28 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

std::string DistortedMuonProducerFromDB::dbScaleLabel_
private

Definition at line 26 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and DistortedMuonProducerFromDB().

edm::InputTag DistortedMuonProducerFromDB::genMatchMapTag_
private

Definition at line 24 of file DistortedMuonProducerFromDB.cc.

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

Definition at line 30 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun().

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

Definition at line 31 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

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

Definition at line 32 of file DistortedMuonProducerFromDB.cc.

Referenced by beginRun(), and produce().

edm::InputTag DistortedMuonProducerFromDB::muonTag_
private

Definition at line 23 of file DistortedMuonProducerFromDB.cc.

Referenced by DistortedMuonProducerFromDB(), and produce().