-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReweight.cc
130 lines (108 loc) · 3.43 KB
/
Reweight.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef Reweight_h
#define Reweight_h
#include <stdio.h>
#include <iostream>
#include "TFile.h"
#include "TH1D.h"
#include "TH1F.h"
class ReweightPU {
public:
ReweightPU(TString filenameData) {
fileData_ = 0;
fileData_ = new TFile(filenameData, "READ");
if (!fileData_) {
cout << "\n\n Data file of the Nvtx reweighting could not be opened!" << endl;
}
h_Data_ = 0;
h_Data_ = (TH1D*)fileData_->Get("pileup");
if (!h_Data_) cout << "Can't open PU data reweight histo";
// Distribution used for Summer2012 MC.
Double_t Summer2012_S10[60] = {
2.560E-06,
5.239E-06,
1.420E-05,
5.005E-05,
1.001E-04,
2.705E-04,
1.999E-03,
6.097E-03,
1.046E-02,
1.383E-02,
1.685E-02,
2.055E-02,
2.572E-02,
3.262E-02,
4.121E-02,
4.977E-02,
5.539E-02,
5.725E-02,
5.607E-02,
5.312E-02,
5.008E-02,
4.763E-02,
4.558E-02,
4.363E-02,
4.159E-02,
3.933E-02,
3.681E-02,
3.406E-02,
3.116E-02,
2.818E-02,
2.519E-02,
2.226E-02,
1.946E-02,
1.682E-02,
1.437E-02,
1.215E-02,
1.016E-02,
8.400E-03,
6.873E-03,
5.564E-03,
4.457E-03,
3.533E-03,
2.772E-03,
2.154E-03,
1.656E-03,
1.261E-03,
9.513E-04,
7.107E-04,
5.259E-04,
3.856E-04,
2.801E-04,
2.017E-04,
1.439E-04,
1.017E-04,
7.126E-05,
4.948E-05,
3.405E-05,
2.322E-05,
1.570E-05,
5.005E-06};
h_MCmod_ = (TH1D*)h_Data_->Clone("h_MCmod_");
for (Int_t i = 1; i < 61; i++) {
h_MCmod_->SetBinContent(i, Summer2012_S10[i-1]);
}
double int_MC_ = h_MCmod_->Integral();
double int_Data_ = h_Data_->Integral();
h_Data_->Divide(h_MCmod_);
h_Data_->Scale(int_MC_ / int_Data_);
/*
cout << endl;
for (Int_t i = 1; i < 61; i++)
cout << h_Data_->GetBinContent(i) <<endl;
*/
}
~ReweightPU() {
delete fileData_;
delete h_MCmod_;
delete h_Data_;
}
double GetWeight(double nvtx) {
return h_Data_->GetBinContent( h_Data_->FindBin(nvtx) );
}
private:
TFile* fileData_;
TH1D* h_MCmod_;
TH1D* h_Data_;
};
#endif