CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FML3PtSmearer.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 
6 
7 //
8 // Static data member definition
9 //
10 double FML3PtSmearer::MuonMassSquared_ = 0.10565837*0.10565837;
11 
12 
14  : random(engine)
15 { }
16 
18 
20  double ptSim = std::sqrt(simP4.perp2());
21  double invPtSim;
22  if (ptSim>0.) invPtSim = 1./ptSim;
23  else {
24  // Better if we throw an exception here...
25  simP4.SetPx(recP3.X());
26  simP4.SetPy(recP3.Y());
27  simP4.SetPz(recP3.Z());
28  double muonEnergy=std::sqrt(simP4.P()*simP4.P()+MuonMassSquared_);
29  simP4.SetE(muonEnergy);
30  return simP4;
31  }
32  double etaSim = simP4.eta();
33  double invPtNew = random->gaussShoot(invPtSim,error(ptSim,etaSim));
34  invPtNew /= ( 1. + shift(ptSim,etaSim)*invPtNew);
35  if (invPtNew>0.) {
36  double invPtRec = std::sqrt(recP3.perp2());
37  if (invPtRec>0) invPtRec = 1./invPtRec; else invPtRec=invPtSim;
38  simP4.SetPx(recP3.x()*invPtRec/invPtNew);
39  simP4.SetPy(recP3.y()*invPtRec/invPtNew);
40  simP4.SetPz(recP3.z()*invPtRec/invPtNew);
41  double muonEnergy=std::sqrt(simP4.P()*simP4.P()+MuonMassSquared_);
42  simP4.SetE(muonEnergy);
43  }
44  else {
45  simP4.SetPx(recP3.x());
46  simP4.SetPy(recP3.y());
47  simP4.SetPz(recP3.z());
48  double muonEnergy=std::sqrt(simP4.P()*simP4.P()+MuonMassSquared_);
49  simP4.SetE(muonEnergy);
50  }
51  return simP4;
52 }
53 
54 double FML3PtSmearer::error(double thePt, double theEta) const {
55  return funSigma(fabs(theEta),thePt)/thePt;
56 }
57 
58 double FML3PtSmearer::shift(double thePt, double theEta) const {
59  return funShift(fabs(theEta));
60 }
61 
62 double FML3PtSmearer::funShift(double x) const {
63  if (x<1.305) return 7.90897e-04;
64  else if (x<1.82 ) return 9.52662e-02-1.12262e-01*x+3.05410e-02*x*x;
65  else return -7.9e-03;
66  }
67 
68 double FML3PtSmearer::funSigma(double eta , double pt) const {
69  double sigma = funSigmaPt(pt) * funSigmaEta(eta);
70  return sigma;
71 }
72 
73 double FML3PtSmearer::funSigmaPt(double x) const {
74  if (x<444.) return 3.13349e-01+2.77853e-03*x+4.94289e-06*x*x-9.63359e-09*x*x*x;
75  else return 9.26294e-01+1.64896e-03*x;
76 }
77 
78 double FML3PtSmearer::funSigmaEta(double x) const {
79  if (x<0.94) return 2.27603e-02+1.23995e-06*exp(9.30755*x);
80  else return 2.99467e-02+1.86770e-05*exp(3.52319*x);
81 }
double funShift(double x) const
FML3PtSmearer(const RandomEngine *engine)
Constructor.
double funSigmaEta(double x) const
const RandomEngine * random
Definition: FML3PtSmearer.h:37
double funSigmaPt(double x) const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
TRandom random
Definition: MVATrainer.cc:138
T eta() const
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
double funSigma(double eta, double pt) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
T sqrt(T t)
Definition: SSEVec.h:28
math::XYZTLorentzVector smear(math::XYZTLorentzVector simP4, math::XYZVector recP3) const
smear the transverse momentum of a reco::Muon
double error(double thePt, double theEta) const
smear the transverse momentum of a SimplL3MuGMTCand
static double MuonMassSquared_
Definition: FML3PtSmearer.h:35
~FML3PtSmearer()
Destructor.
double shift(double thePt, double theEta) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31