Main Page
Namespaces
Classes
Package Documentation
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
()
override
;
51
52
private
:
53
void
beginJob
()
override
;
54
void
produce
(
edm::Event
&,
const
edm::EventSetup
&)
override
;
55
void
endJob
()
override
;
56
template
<
class
T> std::unique_ptr<T>
applyCorrection
(
const
edm::Handle<T>
&
allMuons
);
57
58
edm::InputTag
theMuonLabel_
;
59
edm::EDGetTokenT<pat::MuonCollection>
thePatMuonToken_
;
60
edm::EDGetTokenT<reco::MuonCollection>
theRecoMuonToken_
;
61
bool
patMuons_
;
62
edm::ESHandle<MuScleFitDBobject>
dbObject_
;
63
std::string
dbObjectLabel_
;
64
unsigned
long
long
dbObjectCacheId_
;
65
boost::shared_ptr<MomentumScaleCorrector>
corrector_
;
66
};
67
68
MuScleFitMuonProducer::MuScleFitMuonProducer
(
const
edm::ParameterSet
& iConfig) :
69
theMuonLabel_
( iConfig.getParameter<
edm
::InputTag>(
"MuonLabel"
) ),
70
thePatMuonToken_
(
mayConsume
<
pat
::
MuonCollection
>(
theMuonLabel_
) ),
71
theRecoMuonToken_
(
mayConsume
<
reco
::
MuonCollection
>(
theMuonLabel_
) ),
72
patMuons_
( iConfig.getParameter<
bool
>(
"PatMuons"
) ),
73
dbObjectLabel_
( iConfig.getUntrackedParameter<
std
::
string
>(
"DbObjectLabel"
,
""
) ),
74
dbObjectCacheId_
(0)
75
{
76
if
(
patMuons_
==
true
) {
77
produces<pat::MuonCollection>();
78
}
else
{
79
produces<reco::MuonCollection>();
80
}
81
}
82
83
84
MuScleFitMuonProducer::~MuScleFitMuonProducer
()
85
{
86
}
87
88
89
template
<
class
T>
90
std::unique_ptr<T>
MuScleFitMuonProducer::applyCorrection
(
const
edm::Handle<T>
&
allMuons
)
91
{
92
std::unique_ptr<T> pOut(
new
T
);
93
94
// Apply the correction and produce the new muons
95
for
(
typename
T::const_iterator
muon
= allMuons->begin();
muon
!= allMuons->end(); ++
muon
) {
96
97
//std::cout << "Pt before correction = " << muon->pt() << std::endl;
98
double
pt
= (*corrector_)(*muon);
99
//std::cout << "Pt after correction = " << pt << std::endl;
100
double
eta
= muon->eta();
101
double
phi
= muon->phi();
102
103
typename
T::value_type
* newMuon = muon->clone();
104
newMuon->setP4(
reco::Particle::PolarLorentzVector
( pt, eta, phi, muon->mass() ) );
105
106
pOut->push_back(*newMuon);
107
}
108
return
pOut;
109
}
110
111
// ------------ method called to produce the data ------------
112
void
MuScleFitMuonProducer::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
113
{
114
unsigned
long
long
dbObjectCacheId = iSetup.
get
<
MuScleFitDBobjectRcd
>().cacheIdentifier();
115
if
( dbObjectCacheId !=
dbObjectCacheId_
) {
116
if
(
dbObjectLabel_
!=
""
) {
117
iSetup.
get
<
MuScleFitDBobjectRcd
>().
get
(
dbObjectLabel_
,
dbObject_
);
118
}
else
{
119
iSetup.
get
<
MuScleFitDBobjectRcd
>().
get
(
dbObject_
);
120
}
121
}
122
123
//std::cout << "identifiers size from dbObject = " << dbObject_->identifiers.size() << std::endl;
124
//std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;;
125
126
// Create the corrector and set the parameters
127
corrector_
.reset(
new
MomentumScaleCorrector
(
dbObject_
.
product
() ) );
128
129
if
(
patMuons_
==
true
) {
130
edm::Handle<pat::MuonCollection>
allMuons
;
131
iEvent.
getByToken
(
thePatMuonToken_
, allMuons);
132
iEvent.
put
(
applyCorrection
(allMuons));
133
}
134
else
{
135
edm::Handle<reco::MuonCollection>
allMuons
;
136
iEvent.
getByToken
(
theRecoMuonToken_
, allMuons);
137
iEvent.
put
(
applyCorrection
(allMuons));
138
}
139
140
// put into the Event
141
// iEvent.put(std::move(pOut));
142
// iEvent.put(applyCorrection(allMuons);
143
144
/* std::unique_ptr<reco::MuonCollection> pOut(new reco::MuonCollection);
145
146
// Apply the correction and produce the new muons
147
for( std::vector<reco::Muon>::const_iterator muon = allMuons->begin(); muon != allMuons->end(); ++muon ) {
148
149
double pt = (*corrector_)(*muon);
150
double eta = muon->eta();
151
double phi = muon->phi();
152
153
reco::Muon * newMuon = muon->clone();
154
newMuon->setP4( reco::Particle::PolarLorentzVector( pt, eta, phi, muon->mass() ) );
155
156
pOut->push_back(*newMuon);
157
}
158
*/
159
160
}
161
162
// ------------ method called once each job just before starting event loop ------------
163
void
164
MuScleFitMuonProducer::beginJob
()
165
{
166
}
167
168
// ------------ method called once each job just after ending the event loop ------------
169
void
170
MuScleFitMuonProducer::endJob
()
171
{
172
}
173
174
//define this as a plug-in
175
DEFINE_FWK_MODULE
(
MuScleFitMuonProducer
);
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:136
MuScleFitDBobjectRcd.h
MuScleFitMuonProducer
Definition:
MuScleFitMuonProducer.cc:47
MuScleFitMuonProducer::endJob
void endJob() override
Definition:
MuScleFitMuonProducer.cc:170
LeafCandidate.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:519
MuScleFitMuonProducer::dbObjectLabel_
std::string dbObjectLabel_
Definition:
MuScleFitMuonProducer.cc:63
MuScleFitMuonProducer::applyCorrection
std::unique_ptr< T > applyCorrection(const edm::Handle< T > &allMuons)
Definition:
MuScleFitMuonProducer.cc:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
Event.h
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:47
EventSetup.h
MuScleFitMuonProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
MuScleFitMuonProducer.cc:112
MuScleFitDBobject.h
PVValHelper::eta
Definition:
PVValidationHelpers.h:65
std
Definition:
JetResolutionObject.h:76
muon
Definition:
MuonCocktails.h:17
EnergyCorrector.pt
pt
Definition:
EnergyCorrector.py:45
edm::EDGetTokenT< pat::MuonCollection >
Frameworkfwd.h
DDAxes::phi
edm::EDProducer
Definition:
EDProducer.h:35
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition:
MuonFwd.h:9
MuonFwd.h
pat
Definition:
HeavyIon.h:7
ParameterSet.h
MuScleFitMuonProducer::~MuScleFitMuonProducer
~MuScleFitMuonProducer() override
Definition:
MuScleFitMuonProducer.cc:84
MomentumScaleCorrector.h
iEvent
int iEvent
Definition:
GenABIO.cc:230
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
MuScleFitMuonProducer::dbObject_
edm::ESHandle< MuScleFitDBobject > dbObject_
Definition:
MuScleFitMuonProducer.cc:62
edm::ESHandle< MuScleFitDBobject >
ESHandle.h
edm::EventSetup
Definition:
EventSetup.h:48
Muon.h
MuScleFitMuonProducer::beginJob
void beginJob() override
Definition:
MuScleFitMuonProducer.cc:164
MuScleFitMuonProducer::corrector_
boost::shared_ptr< MomentumScaleCorrector > corrector_
Definition:
MuScleFitMuonProducer.cc:65
electrons_cff.bool
bool
Definition:
electrons_cff.py:231
EDProducer.h
MuScleFitMuonProducer::dbObjectCacheId_
unsigned long long dbObjectCacheId_
Definition:
MuScleFitMuonProducer.cc:64
CompositeCandidate.h
metsig::muon
Definition:
SignAlgoResolutions.h:40
MuScleFitMuonProducer::theRecoMuonToken_
edm::EDGetTokenT< reco::MuonCollection > theRecoMuonToken_
Definition:
MuScleFitMuonProducer.cc:60
MuScleFitMuonProducer::theMuonLabel_
edm::InputTag theMuonLabel_
Definition:
MuScleFitMuonProducer.cc:58
edm::EventSetup::get
const T & get() const
Definition:
EventSetup.h:59
MuScleFitDBobjectRcd
Definition:
MuScleFitDBobjectRcd.h:6
allMuons_cfi.allMuons
allMuons
Definition:
allMuons_cfi.py:3
Muon.h
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:43
edm
HLT enums.
Definition:
AlignableModifier.h:17
edm::InputTag
Definition:
InputTag.h:15
InputTag.h
reco::Particle::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition:
Particle.h:23
MuScleFitMuonProducer::patMuons_
bool patMuons_
Definition:
MuScleFitMuonProducer.cc:61
MuScleFitMuonProducer::MuScleFitMuonProducer
MuScleFitMuonProducer(const edm::ParameterSet &)
Definition:
MuScleFitMuonProducer.cc:68
edm::ParameterSet
Definition:
ParameterSet.h:36
MuScleFitMuonProducer::thePatMuonToken_
edm::EDGetTokenT< pat::MuonCollection > thePatMuonToken_
Definition:
MuScleFitMuonProducer.cc:59
MomentumScaleCorrector
Definition:
MomentumScaleCorrector.h:25
edm::Event
Definition:
Event.h:69
Track.h
T
long double T
Definition:
Basic3DVectorLD.h:66
edm::EDConsumerBase::mayConsume
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:120
edm::ESHandle::product
T const * product() const
Definition:
ESHandle.h:86
Functions.h
Generated for CMSSW Reference Manual by
1.8.11