CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleZSPJPTJetCorrector.cc
Go to the documentation of this file.
1 //
2 // Original Author: Fedor Ratnikov Dec 27, 2006
3 //
4 // ZSP Jet Corrector
5 //
7 
8 #include <vector>
9 #include <iostream>
10 #include <fstream>
11 #include <sstream>
12 
13 #include "Math/PtEtaPhiE4D.h"
14 #include "Math/LorentzVector.h"
15 typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiE4D<double> > PtEtaPhiELorentzVectorD;
16 typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > XYZTLorentzVectorD;
17 
18 using namespace std;
19 
20 
22 { debug_=false;}
23 
25 {
26  debug_=false;
27  mParameters = new JetCorrectorParameters (fDataFile,"");
28 
29  //std::cout<<" Formula "<<((mParameters->definitions()).formula()).c_str()<<std::endl;
30 
31  mFunc = new TFormula("function",((mParameters->definitions()).formula()).c_str());
32 
33 // Read parameters
34  if (debug_) {
35  std::cout<<" Size of parameters as read by SimpleJetCorrectorParameters "<<mParameters->size()<<std::endl;
36  for(unsigned int i = 0; i<mParameters->size(); i++){
37  const std::vector<float> p = mParameters->record (i).parameters ();
38  for(std::vector<float>::const_iterator j=p.begin(); j<p.end(); j++) {
39  std::cout<<" Parameter number "<<mParameters->record (i).xMin(0)<<" "<<mParameters->record (i).xMax(0)<<" "<<(*j)<<std::endl;
40  }
41  }
42  } // debug
43 }
44 
46 }
47 
48 double SimpleZSPJPTJetCorrector::correctionPtEtaPhiE (double fPt, double fEta, double fPhi, double fE) const {
49  double costhetainv = cosh (fEta);
50  return correctionEtEtaPhiP (fE/costhetainv, fEta, fPhi, fPt*costhetainv);
51 }
52 
53 double SimpleZSPJPTJetCorrector::correctionEtEtaPhiP (double fEt, double fEta, double fPhi, double fP) const {
54 
55  double et=fEt;
56  double eta=fabs (fEta);
57  double factor = 1.;
58 
59 // Define Eta bin for parametrization
60  std::vector<float> xx; xx.push_back(eta);
61  int band = mParameters->binIndex(xx);
62 
63  if(band < 0) return factor;
64 
65  const std::vector<float> p = mParameters->record (band).parameters ();
66 
67  // Set parameters
68  for(unsigned int i=0; i<p.size();i++) {
69  mFunc->SetParameter(i,p[i]);
70  }
71 
72  if (debug_) {
73  cout<<" Et and eta of jet "<<et<<" "<<eta<<" bin "<<band<<" "<<p[1]<<" "<<p[2]<<" "<<p[3]<<
74  " "<<p[4]<<" "<<p[5]<<endl;
75  }
76 
77 // double koef = 1. - p[2]*exp(p[3]*et)-p[4]*exp(p[5]*et);
78 
79  double koef = 1. - mFunc->Eval(et);
80 
81 // If et calojet less then some value - use correction on the boundary
82 
83  if( et < p[0] ) koef = 1. - mFunc->Eval(p[0]);
84 
85 //
86  if(koef <= 0.000001)
87  {
88  if (debug_) std::cout<<"SimpleZSPJPTJetCorrector::Problem with ZSP corrections "<<koef<<std::endl;
89  koef = 1.;
90  }
91 
92  double etnew = et/koef;
93 
94  if (debug_) cout<<" The new energy found "<<etnew<<" "<<et<<" "<<koef<<endl;
95 
96  return etnew/et;
97 }
98 
99 double SimpleZSPJPTJetCorrector::correctionPUEtEtaPhiP (double fEt, double fEta, double fPhi, double fP) const {
100 
101  double et=fEt;
102  double eta=fabs (fEta);
103  double factor = 1.;
104 
105 // Define Eta bin for parametrization
106  std::vector<float> xx; xx.push_back(eta);
107  int band = mParameters->binIndex(xx);
108 
109  if(band < 0) return factor;
110 
111  const std::vector<float> p = mParameters->record (band).parameters ();
112 
113  if (debug_) {
114  cout<<" Et and eta of jet "<<et<<" "<<eta<<" bin "<<band<<std::endl;
115  }
116 
117  double koef = (et-p[2])/et;
118  double etnew = et/koef;
119 
120  if (debug_) cout<<" The new energy found "<<etnew<<" "<<et<<endl;
121 
122  return etnew/et;
123 }
124 
125 
126 
int i
Definition: DBlmapReader.cc:9
virtual double correctionPtEtaPhiE(double fPt, double fEta, double fPhi, double fE) const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiE4D< double > > PtEtaPhiELorentzVectorD
int j
Definition: DBlmapReader.cc:9
virtual double correctionPUEtEtaPhiP(double fEt, double fEta, double fPhi, double fP) const
virtual double correctionEtEtaPhiP(double fEt, double fEta, double fPhi, double fP) const
tuple cout
Definition: gather_cfg.py:121