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