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
//
13
//
14
// Original Author: Marco De Mattia,40 3-B32,+41227671551,
15
// Created: Tue Jun 22 13:50:22 CEST 2010
16
// $Id: MuScleFitMuonProducer.cc,v 1.1 2010/06/22 17:25:39 demattia Exp $
17
//
18
//
19
20
21
// system include files
22
#include <memory>
23
24
// user include files
25
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
26
#include "
FWCore/Framework/interface/EDProducer.h
"
27
28
#include "
FWCore/Framework/interface/Event.h
"
29
#include "
FWCore/Framework/interface/MakerMacros.h
"
30
31
#include "
FWCore/Utilities/interface/InputTag.h
"
32
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
33
34
#include "
DataFormats/MuonReco/interface/Muon.h
"
35
#include "
DataFormats/MuonReco/interface/MuonFwd.h
"
36
#include "
DataFormats/Candidate/interface/LeafCandidate.h
"
37
38
#include "
DataFormats/TrackReco/interface/Track.h
"
39
#include "
DataFormats/PatCandidates/interface/Muon.h
"
40
#include "
DataFormats/PatCandidates/interface/CompositeCandidate.h
"
41
42
#include "
MuonAnalysis/MomentumScaleCalibration/interface/Functions.h
"
43
44
class
MuScleFitMuonProducer
:
public
edm::EDProducer
{
45
public
:
46
explicit
MuScleFitMuonProducer
(
const
edm::ParameterSet
&);
47
~MuScleFitMuonProducer
();
48
49
private
:
50
virtual
void
beginJob
() ;
51
virtual
void
produce
(
edm::Event
&,
const
edm::EventSetup
&);
52
virtual
void
endJob
() ;
53
54
edm::InputTag
theMuonLabel_
;
55
// Contains the numbers taken from the J/Psi
56
// smearFunctionType7 smearFunction;
57
};
58
59
MuScleFitMuonProducer::MuScleFitMuonProducer
(
const
edm::ParameterSet
& iConfig) :
60
theMuonLabel_( iConfig.getParameter<edm::InputTag>(
"MuonLabel"
) )
61
{
62
produces<reco::MuonCollection>();
63
}
64
65
66
MuScleFitMuonProducer::~MuScleFitMuonProducer
()
67
{
68
}
69
70
// ------------ method called to produce the data ------------
71
void
MuScleFitMuonProducer::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
72
{
73
edm::Handle<reco::MuonCollection>
allMuons
;
74
iEvent.
getByLabel
(
theMuonLabel_
, allMuons);
75
76
std::auto_ptr<reco::MuonCollection> pOut(
new
reco::MuonCollection
);
77
78
// Apply any bias and/or smearing to the events
79
for
( std::vector<reco::Muon>::const_iterator
muon
= allMuons->begin();
muon
!= allMuons->end(); ++
muon
) {
80
81
double
pt
=
muon
->pt();
82
83
// Biasing the MC such that it reproduces the data + the residual error
84
double
a_0 = 1.0039;
85
// double a_1 = 0.;
86
// // The miscalibration can be applied only for pt < 626 GeV/c
87
// if( pt < -a_0*a_0/(4*a_1) ) {
88
// pt = (-a_0 + sqrt(a_0*a_0 + 4*a_1*pt))/(2*a_1);
89
// }
90
pt = a_0*
pt
;
91
92
// Smearing
93
// std::cout << "smearing muon" << std::endl;
94
// std::vector<double> par;
95
// double * y = 0;
96
TF1 G(
"G"
,
"[0]*exp(-0.5*pow(x,2)/[1])"
, -5., 5.);
97
double
sigma
= 0.00014;
// converted from TeV^-1 to GeV^-1
98
double
norm
= 1/(
sqrt
(2*
TMath::Pi
()));
99
G.SetParameter(0,norm);
100
G.SetParameter(1,1);
101
// std::cout << "old pt = " << pt;
102
pt = 1/(1/pt + sigma*G.GetRandom());
103
// pt' = pt + sigma pt^2
104
// pt = pt*(1-G.GetRandom());
105
double
eta
=
muon
->eta();
106
double
phi
=
muon
->phi();
107
// smearFunction.smear(pt, eta, phi, y, par);
108
// std::cout << " new pt = " << pt << std::endl;
109
110
reco::Muon
* newMuon =
muon
->clone();
111
newMuon->
setP4
(
reco::Particle::PolarLorentzVector
( pt, eta, phi,
muon
->mass() ) );
112
113
pOut->push_back(*newMuon);
114
}
115
116
// put into the Event
117
// std::auto_ptr<reco::MuonCollection> pOut(new reco::MuonCollection(*allMuons));
118
iEvent.
put
(pOut);
119
}
120
121
// ------------ method called once each job just before starting event loop ------------
122
void
123
MuScleFitMuonProducer::beginJob
()
124
{
125
}
126
127
// ------------ method called once each job just after ending the event loop ------------
128
void
129
MuScleFitMuonProducer::endJob
()
130
{
131
}
132
133
//define this as a plug-in
134
DEFINE_FWK_MODULE
(
MuScleFitMuonProducer
);
ExpressReco_HICollisions_FallBack.sigma
tuple sigma
Definition:
ExpressReco_HICollisions_FallBack.py:4426
Pi
const double Pi
Definition:
CosmicMuonParameters.h:18
MuScleFitMuonProducer::beginJob
virtual void beginJob()
Definition:
MuScleFitMuonProducer.cc:123
MuScleFitMuonProducer
Definition:
MuScleFitMuonProducer.cc:44
LeafCandidate.h
MuScleFitMuonProducer::endJob
virtual void endJob()
Definition:
MuScleFitMuonProducer.cc:129
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:71
Event.h
MakerMacros.h
reco::LeafCandidate::setP4
virtual void setP4(const LorentzVector &p4)
set 4-momentum
Definition:
LeafCandidate.h:149
edm::Handle< reco::MuonCollection >
eta
T eta() const
Definition:
newBasic3DVector.h:122
Frameworkfwd.h
edm::EDProducer
Definition:
EDProducer.h:21
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition:
MuonFwd.h:9
MuScleFitMuonProducer::~MuScleFitMuonProducer
~MuScleFitMuonProducer()
Definition:
MuScleFitMuonProducer.cc:66
MuonFwd.h
ParameterSet.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:84
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:28
lumiNorm.norm
tuple norm
Definition:
lumiNorm.py:78
allMuons_cfi.allMuons
tuple allMuons
Definition:
allMuons_cfi.py:3
edm::EventSetup
Definition:
EventSetup.h:44
Muon.h
reco::Muon
Definition:
Muon.h:25
ExpressReco_HICollisions_FallBack.pt
tuple pt
Definition:
ExpressReco_HICollisions_FallBack.py:1070
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:359
EDProducer.h
CompositeCandidate.h
metsig::muon
Definition:
SignAlgoResolutions.h:40
MuScleFitMuonProducer::theMuonLabel_
edm::InputTag theMuonLabel_
Definition:
MuScleFitMuonProducer.cc:54
Muon.h
edm::InputTag
Definition:
InputTag.h:12
InputTag.h
reco::Particle::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition:
Particle.h:28
MuScleFitMuonProducer::MuScleFitMuonProducer
MuScleFitMuonProducer(const edm::ParameterSet &)
Definition:
MuScleFitMuonProducer.cc:59
edm::ParameterSet
Definition:
ParameterSet.h:31
edm::Event
Definition:
Event.h:49
Track.h
Functions.h
phi
Definition:
DDAxes.h:10
Generated for CMSSW Reference Manual by
1.8.5