HiggsAnalysis-KITHiggsToTauTau
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
RecoilCorrector.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <TFile.h>
5 #include <TH1.h>
6 #include <TF1.h>
7 #include <TString.h>
8 #include <TRandom.h>
9 #include <TMath.h>
10 #include <assert.h>
11 
13 
14  public:
15  RecoilCorrector(TString fileName);
17 
18  void Correct(float MetPx,
19  float MetPy,
20  float genZPx,
21  float genZPy,
22  float diLepPx,
23  float diLepPy,
24  int njets,
25  float & MetCorrPx,
26  float & MetCorrPy);
27 
28  void CorrectByMeanResolution(float MetPx,
29  float MetPy,
30  float genZPx,
31  float genZPy,
32  float diLepPx,
33  float diLepPy,
34  int njets,
35  float & MetCorrPx,
36  float & MetCorrPy);
37 
38 
39  private:
40 
41  int binNumber(float x, const std::vector<float> bins) const
42  {
43  for (size_t iB=0; iB<bins.size(); ++iB)
44  if (x>=bins[iB]&&x<bins[iB+1])
45  return iB;
46  return 0;
47  }
48 
49  int binNumber(float x, int nbins, const float * bins) {
50 
51  int binN = 0;
52 
53  for (int iB=0; iB<nbins; ++iB) {
54  if (x>=bins[iB]&&x<bins[iB+1]) {
55  binN = iB;
56  break;
57  }
58  }
59 
60  return binN;
61 
62  }
63 
64  TString _fileName;
65 
66  void InitMEtWeights(TFile * file,
67  TString _perpZStr,
68  TString _paralZStr,
69  int nZPtBins,
70  float * ZPtBins,
71  TString * _ZPtStr,
72  int nJetsBins,
73  TString * _nJetsStr);
74 
75  void InitMEtWeights(TFile * file,
76  const std::vector<float>& ZPtBins,
77  const std::string _perpZStr,
78  const std::string _paralZStr,
79  const std::vector<std::string>& _ZPtStr,
80  const std::vector<std::string>& _nJetsStr);
81 
82  void CalculateU1U2FromMet(float MetPx,
83  float MetPy,
84  float genZPx,
85  float genZPy,
86  float diLepPx,
87  float diLepPy,
88  float & U1,
89  float & U2,
90  float & metU1,
91  float & metU2);
92 
93  void CalculateMetFromU1U2(float U1,
94  float U2,
95  float genZPx,
96  float genZPy,
97  float diLepPx,
98  float diLepPy,
99  float & metPx,
100  float & metPy);
101 
102  void U1U2CorrectionsByWidth(float & U1, float & U2,
103  int nZptBin,
104  int njets);
105 
106  float CorrectionsBySampling(float x, TF1 * funcMC, TF1 * funcData);
107 
108  float rescale(float x,
109  float meanData,
110  float meanMC,
111  float resolutionData,
112  float resolutionMC);
113 
114 
115  //float * _ZPtBins;
116  std::vector<float> _ZPtBins;
117 
118  Double_t _epsrel;
119  Double_t _epsabs;
120  Double_t _error;
121  float _range;
122 
123  int _nZPtBins;
124  int _nJetsBins;
125 
126  TF1 * _metZParalData[5][3];
127  TF1 * _metZPerpData[5][3];
128  TF1 * _metZParalMC[5][3];
129  TF1 * _metZPerpMC[5][3];
130 
131  TH1F * _metZParalDataHist[5][3];
132  TH1F * _metZPerpDataHist[5][3];
133  TH1F * _metZParalMCHist[5][3];
134  TH1F * _metZPerpMCHist[5][3];
135 
136  float _meanMetZParalData[5][3];
137  float _meanMetZParalMC[5][3];
138  float _meanMetZPerpData[5][3];
139  float _meanMetZPerpMC[5][3];
140 
141  float _rmsMetZParalData[5][3];
142  float _rmsLeftMetZParalData[5][3];
143  float _rmsRightMetZParalData[5][3];
144 
145  float _rmsMetZParalMC[5][3];
146  float _rmsLeftMetZParalMC[5][3];
147  float _rmsRightMetZParalMC[5][3];
148 
149  float _rmsMetZPerpData[5][3];
150  float _rmsLeftMetZPerpData[5][3];
151  float _rmsRightMetZPerpData[5][3];
152 
153  float _rmsMetZPerpMC[5][3];
154  float _rmsLeftMetZPerpMC[5][3];
155  float _rmsRightMetZPerpMC[5][3];
156 
157  float _xminMetZPerp[5][3];
158  float _xmaxMetZPerp[5][3];
159 
160  float _xminMetZPerpData[5][3];
161  float _xmaxMetZPerpData[5][3];
162 
163  float _xminMetZPerpMC[5][3];
164  float _xmaxMetZPerpMC[5][3];
165 
166  float _xminMetZParal[5][3];
167  float _xmaxMetZParal[5][3];
168 
169  float _xminMetZParalData[5][3];
170  float _xmaxMetZParalData[5][3];
171 
172  float _xminMetZParalMC[5][3];
173  float _xmaxMetZParalMC[5][3];
174 
175 };
tuple bins
Definition: makePlots_rocCurves.py:125
void Correct(float MetPx, float MetPy, float genZPx, float genZPy, float diLepPx, float diLepPy, int njets, float &MetCorrPx, float &MetCorrPy)
Definition: RecoilCorrector.cc:214
tuple x
Test the formatting of numbers with uncertainty.
Definition: test_uncertainties.py:1222
RecoilCorrector(TString fileName)
Definition: RecoilCorrector.cc:3
~RecoilCorrector()
Definition: RecoilCorrector.cc:73
nbins
Definition: makePlots_datacardsSMHtt_nDim.py:106
tuple file
Definition: makePlots_datacardsCPStudies_projection.py:222
void CorrectByMeanResolution(float MetPx, float MetPy, float genZPx, float genZPy, float diLepPx, float diLepPy, int njets, float &MetCorrPx, float &MetCorrPy)
Definition: RecoilCorrector.cc:342
Definition: RecoilCorrector.h:12