forked from dapparu/massSpectrum_bckgPrediction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step2_backgroundPrediction.C
271 lines (213 loc) · 15.1 KB
/
step2_backgroundPrediction.C
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//************************************************************************************
// Usage:
// root -l -q -b step2_backgroundPrediction.C
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include "TRandom3.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TGraphErrors.h>
#include "./Regions.h"
using namespace std;
void step2_backgroundPrediction(){
ifstream infile;
infile.open("configFile_readHisto_toLaunch.txt");
std::string line;
std::string filename;
std::string st_sample;
std::string dirname;
int nPE, cutIndex;
int rebineta,rebinih,rebinp,rebinmass;
bool rebin;
bool corrTemplateIh, corrTemplateP;
int fitIh, fitP;
while(std::getline(infile,line)){
if(std::strncmp(line.c_str(),"#",1)==0) continue;
std::cout << line << std::endl;
std::stringstream ss(line);
ss >> filename >> st_sample >> dirname >> nPE >> cutIndex >> rebin >> rebineta >> rebinih >> rebinp >> rebinmass >> corrTemplateIh >> corrTemplateP >> fitIh >> fitP;
}
std::string commandDir = "mkdir -p "+dirname;
system(commandDir.c_str());
std::string outfilename_;
if(!rebin)outfilename_ = filename+"_cutIndex"+to_string(cutIndex)+"_analysed";
else outfilename_ = filename+"_cutIndex"+to_string(cutIndex)+"_rebinEta"+to_string(rebineta)+"_rebinIh"+to_string(rebinih)+"_rebinP"+to_string(rebinp)+"_rebinMass"+to_string(rebinmass);
if(corrTemplateIh) outfilename_ += "_corrTemplateIh";
if(corrTemplateP) outfilename_ += "_corrTemplateP";
if(fitIh==0) outfilename_ += "_fitIhDown";
if(fitIh==2) outfilename_ += "_fitIhUp";
if(fitP==0) outfilename_ += "_fitPDown";
if(fitP==2) outfilename_ += "_fitPUp";
outfilename_ += "_nPE"+to_string(nPE);
outfilename_ += "_test_v1";
std::cout << outfilename_ << std::endl;
bool bool_rebin=rebin;
TFile* ifile = new TFile((filename+".root").c_str());
// histograms used for the mass prediction
//------------
Region ra_ias50;
Region rc_ias50;
Region rb_50ias60;
Region rb_60ias70;
Region rb_70ias80;
Region rb_80ias90;
Region rb_50ias90;
Region rb_50ias99;
Region rb_50ias999;
Region rb_90ias100;
Region rb_99ias100;
Region rb_999ias100;
Region rd_50ias60;
Region rd_60ias70;
Region rd_70ias80;
Region rd_80ias90;
Region rd_50ias90;
Region rd_50ias99;
Region rd_50ias999;
Region rd_90ias100;
Region rd_99ias100;
Region rd_999ias100;
Region rbc_50ias60;
Region rbc_60ias70;
Region rbc_70ias80;
Region rbc_80ias90;
Region rbc_50ias90;
Region rbc_50ias99;
Region rbc_50ias999;
Region rbc_90ias100;
Region rbc_99ias100;
Region rbc_999ias100;
Region rb_true;
Region rc_true;
Region rb_true_50ias60;
Region rc_true_50ias60;
Region rb_true_60ias70;
Region rc_true_60ias70;
Region rb_true_70ias80;
Region rc_true_70ias80;
Region rb_true_80ias90;
Region rc_true_80ias90;
Region rb_true_50ias90;
Region rc_true_50ias90;
Region rb_true_90ias100;
Region rc_true_90ias100;
Region rbc_true_b;
Region rbc_true_c;
std::string Ext = "_testIhPt";
Ext = "";
// loading histograms used to validate the background estimate method in data --> base on Ias slices
// ------------------------------------------------------------------------------------------------------
std::cout << "loading..." << std::endl;
/*
loadHistograms(ra_ias50,ifile,"regionA_50",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionA_50");
loadHistograms(rc_ias50,ifile,"regionC_50",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionC_50");
loadHistograms(rb_50ias60,ifile,"regionB_50",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_50");
loadHistograms(rb_60ias70,ifile,"regionB_60",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_60");
loadHistograms(rb_70ias80,ifile,"regionB_70",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_70");
loadHistograms(rb_80ias90,ifile,"regionB_80",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_80");
loadHistograms(rb_50ias90,ifile,"regionB_50_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_50_90");
loadHistograms(rb_50ias99,ifile,"regionB_50_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_50_99");
loadHistograms(rb_50ias999,ifile,"regionB_50_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_50_999");
loadHistograms(rb_90ias100,ifile,"regionB_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_90_100");
loadHistograms(rb_99ias100,ifile,"regionB_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_99_100");
loadHistograms(rb_999ias100,ifile,"regionB_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionB_999_100");
loadHistograms(rd_50ias60,ifile,"regionD_50",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_50");
loadHistograms(rd_60ias70,ifile,"regionD_60",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_60");
loadHistograms(rd_70ias80,ifile,"regionD_70",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_70");
loadHistograms(rd_80ias90,ifile,"regionD_80",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_80");
loadHistograms(rd_50ias90,ifile,"regionD_50_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_50_90");
loadHistograms(rd_50ias99,ifile,"regionD_50_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_50_99");
loadHistograms(rd_50ias999,ifile,"regionD_50_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_50_999");
loadHistograms(rd_90ias100,ifile,"regionD_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_90_100");
loadHistograms(rd_99ias100,ifile,"regionD_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_99_100");
loadHistograms(rd_999ias100,ifile,"regionD_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionD_999_100");
loadHistograms(rbc_50ias60,ifile,"regionD_50",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_50");
loadHistograms(rbc_60ias70,ifile,"regionD_60",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_60");
loadHistograms(rbc_70ias80,ifile,"regionD_70",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_70");
loadHistograms(rbc_80ias90,ifile,"regionD_80",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_80");
loadHistograms(rbc_50ias90,ifile,"regionD_50_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_50_90");
loadHistograms(rbc_50ias99,ifile,"regionD_50_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_50_99");
loadHistograms(rbc_50ias999,ifile,"regionD_50_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_50_999");
loadHistograms(rbc_90ias100,ifile,"regionD_90",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_90_100");
loadHistograms(rbc_99ias100,ifile,"regionD_99",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_99_100");
loadHistograms(rbc_999ias100,ifile,"regionD_999",bool_rebin,rebineta,rebinp,rebinih,rebinmass,"regionBC_999_100");
*/
loadHistograms(ra_ias50,ifile,"regionA_ias50"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_ias50,ifile,"regionC_ias50"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_50ias60,ifile,"regionB_50ias60"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_60ias70,ifile,"regionB_60ias70"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_70ias80,ifile,"regionB_70ias80"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_80ias90,ifile,"regionB_80ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_50ias90,ifile,"regionB_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_90ias100,ifile,"regionB_90ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_99ias100,ifile,"regionB_99ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_999ias100,ifile,"regionB_999ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_50ias60,ifile,"regionD_50ias60"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_60ias70,ifile,"regionD_60ias70"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_70ias80,ifile,"regionD_70ias80"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_80ias90,ifile,"regionD_80ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_50ias90,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_90ias100,ifile,"regionD_90ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_99ias100,ifile,"regionD_99ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_999ias100,ifile,"regionD_999ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_50ias60,ifile,"regionD_50ias60"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_60ias70,ifile,"regionD_60ias70"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_70ias80,ifile,"regionD_70ias80"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_80ias90,ifile,"regionD_80ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_50ias90,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_90ias100,ifile,"regionD_90ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_99ias100,ifile,"regionD_99ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_999ias100,ifile,"regionD_999ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_50ias60,ifile,"regionD_50ias60"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_50ias60,ifile,"regionD_50ias60"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_60ias70,ifile,"regionD_60ias70"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_60ias70,ifile,"regionD_60ias70"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_70ias80,ifile,"regionD_70ias80"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_70ias80,ifile,"regionD_70ias80"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_80ias90,ifile,"regionD_80ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_80ias90,ifile,"regionD_80ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_50ias90,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_50ias90,ifile,"regionD_50ias90"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_true_90ias100,ifile,"regionD_90ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_true_90ias100,ifile,"regionD_90ias100"+Ext,bool_rebin,rebineta,rebinp,rebinih,rebinmass);
/* loadHistograms(ra_ias50,ifile,"regA_ias50",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rc_ias50,ifile,"regC_ias50",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_50ias60,ifile,"regB_50ias60",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_60ias70,ifile,"regB_60ias70",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_70ias80,ifile,"regB_70ias80",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_80ias90,ifile,"regB_80ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_50ias90,ifile,"regB_50ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rb_90ias100,ifile,"regB_90ias100",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_50ias60,ifile,"regD_50ias60",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_60ias70,ifile,"regD_60ias70",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_70ias80,ifile,"regD_70ias80",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_80ias90,ifile,"regD_80ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_50ias90,ifile,"regD_50ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rd_90ias100,ifile,"regD_90ias100",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_50ias60,ifile,"regD_50ias60",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_60ias70,ifile,"regD_60ias70",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_70ias80,ifile,"regD_70ias80",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_80ias90,ifile,"regD_80ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_50ias90,ifile,"regD_50ias90",bool_rebin,rebineta,rebinp,rebinih,rebinmass);
loadHistograms(rbc_90ias100,ifile,"regD_90ias100",bool_rebin,rebineta,rebinp,rebinih,rebinmass);*/
// ------------------------------------------------------------------------------------------------------
std::cout << "Regions loaded" << std::endl;
TFile* ofile = new TFile((outfilename_+".root").c_str(),"RECREATE");
std::cout << "background estimation... " << std::endl;
// estimate the background in different Ias slices, each containing 10% of the statistic
// ------------------------------------------------------------------------------------------------------
bckgEstimate(st_sample, dirname, rb_50ias60, rc_ias50, rbc_50ias60, ra_ias50, rd_50ias60, "50ias60", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
bckgEstimate(st_sample, dirname, rb_60ias70, rc_ias50, rbc_60ias70, ra_ias50, rd_60ias70, "60ias70", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
bckgEstimate(st_sample, dirname, rb_70ias80, rc_ias50, rbc_70ias80, ra_ias50, rd_70ias80, "70ias80", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
bckgEstimate(st_sample, dirname, rb_80ias90, rc_ias50, rbc_80ias90, ra_ias50, rd_80ias90, "80ias90", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
bckgEstimate(st_sample, dirname, rb_50ias90, rc_ias50, rbc_50ias90, ra_ias50, rd_50ias90, "50ias90", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
//bckgEstimate(st_sample, dirname, rb_90ias100, rc_ias50, rbc_90ias100, ra_ias50, rd_90ias100, "90ias100", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
//bckgEstimate(st_sample, dirname, rb_99ias100, rc_ias50, rbc_99ias100, ra_ias50, rd_99ias100, "99ias100", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
bckgEstimate(st_sample, dirname, rb_999ias100, rc_ias50, rbc_999ias100, ra_ias50, rd_999ias100, "999ias100", nPE, corrTemplateIh, corrTemplateP, fitIh, fitP, false);
delete ofile;
return;
}