Main Page
Namespaces
Classes
Package Documentation
GIT Directory
WorkBook
Offline Guide
Release schedule
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
MuonAnalysis
MomentumScaleCalibration
plugins
MuScleFitMuonProducer.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: MuScleFitMuonProducer
4
// Class: MuScleFitMuonProducer
5
//
10
//
11
// Original Author: Marco De Mattia,40 3-B32,+41227671551,
12
// Created: Tue Jun 22 13:50:22 CEST 2010
13
//
14
//
15
16
// system include files
17
#include <memory>
18
#include <string>
19
20
// user include files
21
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
22
#include "
FWCore/Framework/interface/EDProducer.h
"
23
24
#include "
FWCore/Framework/interface/Event.h
"
25
#include "
FWCore/Framework/interface/MakerMacros.h
"
26
27
#include "
FWCore/Utilities/interface/InputTag.h
"
28
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
29
30
#include "
DataFormats/MuonReco/interface/Muon.h
"
31
#include "
DataFormats/MuonReco/interface/MuonFwd.h
"
32
#include "
DataFormats/Candidate/interface/LeafCandidate.h
"
33
34
#include "
DataFormats/TrackReco/interface/Track.h
"
35
#include "
DataFormats/PatCandidates/interface/Muon.h
"
36
#include "
DataFormats/PatCandidates/interface/CompositeCandidate.h
"
37
38
#include "
MuonAnalysis/MomentumScaleCalibration/interface/Functions.h
"
39
40
#include "
CondFormats/RecoMuonObjects/interface/MuScleFitDBobject.h
"
41
#include "
CondFormats/DataRecord/interface/MuScleFitDBobjectRcd.h
"
42
43
#include "
FWCore/Framework/interface/EventSetup.h
"
44
#include "
FWCore/Framework/interface/ESHandle.h
"
45
#include "
MuonAnalysis/MomentumScaleCalibration/interface/MomentumScaleCorrector.h
"
46
47
class
MuScleFitMuonProducer
:
public
edm::EDProducer
{
48
public
:
49
explicit
MuScleFitMuonProducer
(
const
edm::ParameterSet
&);
50
~MuScleFitMuonProducer
();
51
52
private
:
53
virtual
void
beginJob
()
override
;
54
virtual
void
produce
(
edm::Event
&,
const
edm::EventSetup
&)
override
;
55
virtual
void
endJob
()
override
;
56
template
<
class
T> std::auto_ptr<T>
applyCorrection
(
const
edm::Handle<T>
&
allMuons
);
57
58
edm::InputTag
theMuonLabel_
;
59
bool
patMuons_
;
60
edm::ESHandle<MuScleFitDBobject>
dbObject_
;
61
std::string
dbObjectLabel_
;
62
unsigned
long
long
dbObjectCacheId_
;
63
boost::shared_ptr<MomentumScaleCorrector>
corrector_
;
64
};
65
66
MuScleFitMuonProducer::MuScleFitMuonProducer
(
const
edm::ParameterSet
& iConfig) :
67
theMuonLabel_( iConfig.getParameter<edm::InputTag>(
"MuonLabel"
) ),
68
patMuons_( iConfig.getParameter<bool>(
"PatMuons"
) ),
69
dbObjectLabel_( iConfig.getUntrackedParameter<std::
string
>(
"DbObjectLabel"
,
""
) ),
70
dbObjectCacheId_(0)
71
{
72
if
(
patMuons_
==
true
) {
73
produces<pat::MuonCollection>();
74
}
else
{
75
produces<reco::MuonCollection>();
76
}
77
}
78
79
80
MuScleFitMuonProducer::~MuScleFitMuonProducer
()
81
{
82
}
83
84
85
template
<
class
T>
86
std::auto_ptr<T>
MuScleFitMuonProducer::applyCorrection
(
const
edm::Handle<T>
&
allMuons
)
87
{
88
std::auto_ptr<T> pOut(
new
T
);
89
90
// Apply the correction and produce the new muons
91
for
(
typename
T::const_iterator
muon
= allMuons->begin();
muon
!= allMuons->end(); ++
muon
) {
92
93
//std::cout << "Pt before correction = " << muon->pt() << std::endl;
94
double
pt
= (*corrector_)(*muon);
95
//std::cout << "Pt after correction = " << pt << std::endl;
96
double
eta
= muon->eta();
97
double
phi
= muon->phi();
98
99
typename
T::value_type
* newMuon = muon->clone();
100
newMuon->setP4(
reco::Particle::PolarLorentzVector
( pt, eta, phi, muon->mass() ) );
101
102
pOut->push_back(*newMuon);
103
}
104
return
pOut;
105
}
106
107
// ------------ method called to produce the data ------------
108
void
MuScleFitMuonProducer::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
109
{
110
unsigned
long
long
dbObjectCacheId = iSetup.
get
<
MuScleFitDBobjectRcd
>().cacheIdentifier();
111
if
( dbObjectCacheId !=
dbObjectCacheId_
) {
112
if
(
dbObjectLabel_
!=
""
) {
113
iSetup.
get
<
MuScleFitDBobjectRcd
>().
get
(
dbObjectLabel_
,
dbObject_
);
114
}
else
{
115
iSetup.
get
<
MuScleFitDBobjectRcd
>().
get
(
dbObject_
);
116
}
117
}
118
119
//std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
120
//std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;
121
122
// Create the corrector and set the parameters
123
corrector_
.reset(
new
MomentumScaleCorrector
(
dbObject_
.
product
() ) );
124
125
if
(
patMuons_
==
true
) {
126
edm::Handle<pat::MuonCollection>
allMuons
;
127
iEvent.
getByLabel
(
theMuonLabel_
, allMuons);
128
iEvent.
put
(
applyCorrection
(allMuons));
129
}
130
else
{
131
edm::Handle<reco::MuonCollection>
allMuons
;
132
iEvent.
getByLabel
(
theMuonLabel_
, allMuons);
133
iEvent.
put
(
applyCorrection
(allMuons));
134
}
135
136
// put into the Event
137
// iEvent.put(pOut);
138
// iEvent.put(applyCorrection(allMuons));
139
140
/* std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
141
142
// Apply the correction and produce the new muons
143
for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
144
145
double pt = (*corrector_)(*muon);
146
double eta = muon->eta();
147
double phi = muon->phi();
148
149
reco::Muon * newMuon = muon->clone();
150
newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
151
152
pOut->push_back(*newMuon);
153
}
154
*/
155
156
}
157
158
// ------------ method called once each job just before starting event loop ------------
159
void
160
MuScleFitMuonProducer::beginJob
()
161
{
162
}
163
164
// ------------ method called once each job just after ending the event loop ------------
165
void
166
MuScleFitMuonProducer::endJob
()
167
{
168
}
169
170
//define this as a plug-in
171
DEFINE_FWK_MODULE
(
MuScleFitMuonProducer
);
MuScleFitDBobjectRcd.h
MuScleFitMuonProducer
Definition:
MuScleFitMuonProducer.cc:47
MuScleFitMuonProducer::endJob
virtual void endJob() override
Definition:
MuScleFitMuonProducer.cc:166
LeafCandidate.h
MuScleFitMuonProducer::dbObjectLabel_
std::string dbObjectLabel_
Definition:
MuScleFitMuonProducer.cc:61
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
Event.h
MakerMacros.h
EventSetup.h
MuScleFitMuonProducer::produce
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition:
MuScleFitMuonProducer.cc:108
MuScleFitDBobject.h
eta
T eta() const
Definition:
Basic3DVectorLD.h:179
edm::Handle
Definition:
AssociativeIterator.h:47
Frameworkfwd.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
edm::EDProducer
Definition:
EDProducer.h:30
MuScleFitMuonProducer::~MuScleFitMuonProducer
~MuScleFitMuonProducer()
Definition:
MuScleFitMuonProducer.cc:80
MuonFwd.h
ParameterSet.h
MomentumScaleCorrector.h
iEvent
int iEvent
Definition:
GenABIO.cc:243
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:116
MuScleFitMuonProducer::dbObject_
edm::ESHandle< MuScleFitDBobject > dbObject_
Definition:
MuScleFitMuonProducer.cc:60
RecoTauCleanerPlugins.pt
tuple pt
Definition:
RecoTauCleanerPlugins.py:53
edm::ESHandle< MuScleFitDBobject >
ESHandle.h
allMuons_cfi.allMuons
tuple allMuons
Definition:
allMuons_cfi.py:3
edm::EventSetup
Definition:
EventSetup.h:44
Muon.h
cond::ecalcond::value_type
Container::value_type value_type
Definition:
EcalChannelStatusPyWrapper.cc:33
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:390
MuScleFitMuonProducer::applyCorrection
std::auto_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
Definition:
MuScleFitMuonProducer.cc:86
MuScleFitMuonProducer::beginJob
virtual void beginJob() override
Definition:
MuScleFitMuonProducer.cc:160
MuScleFitMuonProducer::corrector_
boost::shared_ptr< MomentumScaleCorrector > corrector_
Definition:
MuScleFitMuonProducer.cc:63
EDProducer.h
MuScleFitMuonProducer::dbObjectCacheId_
unsigned long long dbObjectCacheId_
Definition:
MuScleFitMuonProducer.cc:62
CompositeCandidate.h
metsig::muon
Definition:
SignAlgoResolutions.h:40
MuScleFitMuonProducer::theMuonLabel_
edm::InputTag theMuonLabel_
Definition:
MuScleFitMuonProducer.cc:58
edm::EventSetup::get
const T & get() const
Definition:
EventSetup.h:55
edm::ESHandle::product
T const * product() const
Definition:
ESHandle.h:62
MuScleFitDBobjectRcd
Definition:
MuScleFitDBobjectRcd.h:6
Muon.h
edm::InputTag
Definition:
InputTag.h:17
InputTag.h
reco::Particle::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition:
Particle.h:29
MuScleFitMuonProducer::patMuons_
bool patMuons_
Definition:
MuScleFitMuonProducer.cc:59
MuScleFitMuonProducer::MuScleFitMuonProducer
MuScleFitMuonProducer(const edm::ParameterSet &)
Definition:
MuScleFitMuonProducer.cc:66
edm::ParameterSet
Definition:
ParameterSet.h:35
MomentumScaleCorrector
Definition:
MomentumScaleCorrector.h:25
edm::Event
Definition:
Event.h:62
Track.h
T
long double T
Definition:
Basic3DVectorLD.h:59
Functions.h
phi
Definition:
DDAxes.h:10
Generated for CMSSW Reference Manual by
1.8.5