-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmk_Zones.C
499 lines (431 loc) · 21.5 KB
/
mk_Zones.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
#include "TFile.h"
#include "TH2D.h"
#include "TCanvas.h"
#include "TMath.h"
#include "tdrstyle_mod18.C"
#include "TError.h"
#include "settings.h"
void ZeroBinsToVal(TH2D *h2, double val) {
for (int idxeta = 1; idxeta < h2->GetNbinsX()+1; ++idxeta) { // Loop over HCAL eta strips.
for (int idxphi = 1; idxphi < h2->GetNbinsY()+1; ++idxphi) {
if (h2->GetBinContent(idxeta,idxphi)==0.0) {
h2->SetBinContent(idxeta,idxphi,val);
}
}
}
}
void Shift(TH2D *h2, double shift) {
for (int i = 1, Nx = h2->GetNbinsX(); i <= Nx; ++i) {
for (int j = 1, Ny = h2->GetNbinsY(); j <= Ny; ++j) {
h2->SetBinContent(i,j, h2->GetBinContent(i,j) + shift);
}
}
}
TH2D *Span(TH2D *h2, const char *name, double min, double max) {
TH2D* h2nu = static_cast<TH2D*>(h2->Clone(name));
double cmin = h2nu->GetMinimum();
double cmax = h2nu->GetMaximum();
Shift(h2nu, -cmin);
h2nu->Scale( (max-min)/(cmax-cmin) );
Shift(h2nu, min);
h2nu->Scale(100000);
return h2nu;
}
// Draw 2D plot of jet rates in (eta,phi) to spot issues
void mk_Zones(bool quick = true, string overlayName = "") {
const double minsig = 3.0; // For a single trigger, how many sigmas are interpreted as a significant deviation?
bool phidep = false;
string yrtag = "16"; // default
if (jp::yid==1) yrtag = "17";
else if (jp::yid==2) yrtag = "17 LowPU";
else if (jp::yid==3) yrtag = "18";
const char *yeartag = yrtag.c_str();
//string savedir = "rootfiles";
string savedir = ".";
vector<const char*> types = {"","_cef","_muf","_nef","_chf","_puf","_nhf"};
// Eta ranges where different counts of triggers are considered
const array<vector<double>,jp::yrs> etalims_ = {{
{4.2,4.0,3.8,3.4,3.0,2.6},
{4.899,4.538,4.191,3.489,3.139,2.65,2.5},
{4.899,4.538,4.191,3.489,3.139,2.65,2.5},
{4.899,4.538,4.191,3.489,3.139,2.65,2.5}
}};
// Counts of triggers in each eta range
const vector<double> etalims = etalims_.at(jp::yid);
const array<vector<int>,jp::yrs> etatrgs_ = {{
{2,3,4,5,6,10},
{1,2,4,6,8,9,11},
{1,2,4,6,8,9,11},
{1,2,4,6,8,9,11}
}};
const vector<int> etatrgs = etatrgs_.at(jp::yid);
assert(etatrgs.size()==etalims.size());
map<string,const char*> trgNames = {
{"jt0" ,"ZeroBias"},
{"jt40" ,"PFJet40"},
{"jt60" ,"PFJet60"},
{"jt80" ,"PFJet80"},
{"jt140","PFJet140"},
{"jt200","PFJet200"},
{"jt260","PFJet260"},
{"jt320","PFJet320"},
{"jt400","PFJet400"},
{"jt450","PFJet450"},
{"jt500","PFJet500"},
{"jt550","PFJet550"}
};
const vector<string> modes = {"dt","mc","hw","ht"};
TDirectory *curdir = gDirectory;
setTDRStyle();
gStyle->SetOptTitle();
gStyle->SetPalette(1);
//gStyle->SetPalette(kLightTemperature);
TFile *fd = new TFile("./output-DATA-2a.root","READ");
TH2D *h2s[jp::notrigs], *h2as[jp::notrigs], *h2bs[jp::notrigs], *h2hots[jp::notrigs], *h2colds[jp::notrigs];
TH2D *h2template = 0;
TH2D *h2hotNew = 0;
// Further overlay settings
if (overlayName=="") overlayName = Form("hotjets-%srun%s.root",yeartag,jp::run.c_str());
TFile *hotmap = new TFile(overlayName.c_str());
if (!hotmap->IsZombie()) {
h2hotNew = static_cast<TH2D*>(static_cast<TH2D*>(hotmap->Get("h2hotfilter"))->Clone("newmap"));
assert(h2hotNew && !h2hotNew->IsZombie());
} else {
cout << "Overlay file " << overlayName << " not found!" << endl;
}
for (size_t imode = 0; imode < modes.size(); ++imode) {
TFile *f = 0;
const string mode = modes[imode];
if (imode==0) {
f = fd;
} else {
if (quick) break;
string mctag = mode=="mc" ? "MC" : (mode=="hw" ? "HW" : (mode=="ht" ? "HT" : ""));
f = new TFile(Form("./output-%sNU-2a.root",mctag.c_str()),"READ");
}
if (!f or f->IsZombie()) continue;
bool enterdir = f->cd("FullEta_Reco");
assert(enterdir);
TDirectory *din = gDirectory;
string nametag = (imode==0) ? "data" : mode;
string roottag = (imode==0) ? "" : mode;
TFile *phifile = phidep ? new TFile("pdf/phifile.root","RECREATE") : 0;
TH2D *h2hotComb(0), *h2hotComb2(0);
TFile *fouthot = new TFile(Form("%s/hotjets%s-%srun%s.root" ,savedir.c_str(),roottag.c_str(),yeartag,jp::run.c_str()),"RECREATE");
TFile *foutcold = new TFile(Form("%s/coldjets%s-%srun%s.root",savedir.c_str(),roottag.c_str(),yeartag,jp::run.c_str()),"RECREATE");
for (auto &type : types) {
for (int itrg = 0; itrg < jp::notrigs; ++itrg) {
din->cd();
const char *ctrg = jp::triggers[itrg];
bool enterdir2 = gDirectory->cd(ctrg);
assert(enterdir2);
TDirectory *d = gDirectory;
TH2D *h2 = (TH2D*)d->Get(Form("hetaphi%s",type));
assert(h2);
// Create an empty histogram for cloning purposes
TH2D *h2empty = (TH2D*)h2->Clone(Form("h2empty%s",ctrg));
for (int idxeta = 1; idxeta != h2->GetNbinsX()+1; ++idxeta) {
for (int idxphi = 1; idxphi != h2->GetNbinsY()+1; ++idxphi) {
h2empty->SetBinContent (idxeta, idxphi, 0);
h2empty->SetBinError (idxeta, idxphi, 0);
} // for j
} // for i
if (h2hotComb==0) h2hotComb = static_cast<TH2D*>(h2empty->Clone("h2hot")); // Combined filtered variations
if (h2hotComb2==0) h2hotComb2 = static_cast<TH2D*>(h2empty->Clone("h2hotfilter")); // Combined filtered variations
// Hot and cold mappings
TH2D *h2a = static_cast<TH2D*>(h2empty->Clone(Form("h2a%s",ctrg))); // Fluctuation w.r.t. variance
TH2D *h2b = static_cast<TH2D*>(h2empty->Clone(Form("h2b%s",ctrg))); // Fluctuation w.r.t. mean
TH2D *h2hot = static_cast<TH2D*>(h2empty->Clone(Form("h2hot%s",ctrg))); // Filtered upwards fluctuations in h2a
TH2D *h2cold = static_cast<TH2D*>(h2empty->Clone(Form("h2cold%s",ctrg))); // Filtered downwards fluctuations in h2a
// Extract eta and phi binnning
vector<double> xbins, ybins;
for (unsigned idxeta = 1u; idxeta <= h2->GetNbinsX(); ++idxeta) xbins.push_back(h2->GetXaxis()->GetBinLowEdge(idxeta));
xbins.push_back(h2->GetXaxis()->GetBinUpEdge(h2->GetNbinsX()));
for (unsigned idxphi = 1u; idxphi <= h2->GetNbinsY(); ++idxphi) ybins.push_back(h2->GetYaxis()->GetBinLowEdge(idxphi));
ybins.push_back(h2->GetYaxis()->GetBinUpEdge(h2->GetNbinsY()));
// Eta histograms
TH1D *hvar = new TH1D(Form("hvar%s",type),"#sigma/#mu for #eta -strip;#eta_{jet};#sigma/#mu",xbins.size()-1,&xbins[0]);
TH1D *hvar2 = new TH1D(Form("hvar2%s",type),"Expected #sigma/#mu for #eta -strip;#eta_{jet};Expected #sigma/#mu",xbins.size()-1,&xbins[0]);
for (int idxeta = 1; idxeta < h2->GetNbinsX()+1; ++idxeta) { // Loop over HCAL eta strips.
// 1. Calculate mean bin content and sample variance in the current eta strip
int NPhi = h2->GetNbinsY();
double Sum = 0, SumPow2 = 0;
for (int idxphi = 1; idxphi <= NPhi; ++idxphi) {
double val = h2->GetBinContent(idxeta,idxphi);
Sum += val;
SumPow2 += pow(val,2);
}
double Mean = Sum/NPhi;
double Var = sqrt( (SumPow2/NPhi-pow(Mean,2))/(1.0-1.0/NPhi) );
// 2. Recalculate mean bin content and sample variance in the current eta strip by excluding bins over three sigmas away from mean.
int NPhiGood = 0, NPhiNonZero = 0;
double SumGood = 0, SumPow2Good = 0;
for (int idxphi = 1; idxphi < h2->GetNbinsY()+1; ++idxphi) {
// Accept only bins where fluctuations are under three sigmas away
double val = h2->GetBinContent(idxeta,idxphi);
if (fabs(val-Mean)/Var < 3.0) {
SumGood += val;
SumPow2Good += pow(val,2);
++NPhiGood;
if (val>0) ++NPhiNonZero;
}
}
double MeanGood = NPhiGood==0 ? 0.0 : SumGood/NPhiGood;
double VarGood = NPhiGood<=1 ? 0.0 : sqrt( (SumPow2Good/NPhiGood-pow(MeanGood,2))/(1.0-1.0/NPhiGood) );
// Eta-histograms for relative variance.
// For MC, the scale of hvar2 might be off due to event weighting
hvar ->SetBinContent(idxeta, MeanGood>0 ? VarGood/MeanGood : 0.0);
hvar2->SetBinContent(idxeta, MeanGood>0 ? 1./sqrt(MeanGood) : 0.0);
TH1D *hphi = phidep ? new TH1D(Form("hphi%s%s_%.2f",ctrg,type,h2->GetXaxis()->GetBinCenter(idxeta)),Form("Fluctuation w.r.t. #eta -strip mean (%s);#phi_{jet};Fluctuation/#mu",trgNames[ctrg]),ybins.size()-1,&ybins[0]) : 0;
// Eta-phi -histograms for complete binwise (HCAL-towerwise) fluctuations
for (int idxphi = 1; idxphi < h2->GetNbinsY()+1; ++idxphi) {
bool GoodThreshold = (NPhi/5.0 < NPhiNonZero);
double diff = GoodThreshold ? h2->GetBinContent(idxeta,idxphi)-MeanGood : 0.0;
// Fluctuation w.r.t. variance
double aval = (GoodThreshold and VarGood>0) ? diff/VarGood : 0.0;
h2a ->SetBinContent(idxeta, idxphi, aval );
h2hot ->SetBinContent(idxeta, idxphi, aval>= minsig ? aval : 0.0); // When it is over 3 sigma upwards
h2cold->SetBinContent(idxeta, idxphi, aval<=-minsig ? -aval : 0.0); // When it is over 3 sigma downwards
// Fluctuation w.r.t. mean
double bval = (GoodThreshold and MeanGood>VarGood) ? diff/MeanGood : 0.0;
h2b->SetBinContent(idxeta, idxphi, 1.+bval);
if (hphi) hphi->SetBinContent(idxphi, bval);
} // for idxphi
if (hphi and phifile) {
phifile->cd();
TCanvas *cphi = new TCanvas(Form("cphi%s%s_%.2f",ctrg,type,h2->GetXaxis()->GetBinCenter(idxeta)),"",600,600);
gPad->SetTopMargin(0.10);
hphi->SetLineColor(kRed);
hphi->Draw();
hphi->Write();
d->cd();
//cphi->SaveAs(Form("pdf/phi/%s_DiffPerMean_%s_%.2f.pdf",nametag.c_str(),ctrg,h2->GetXaxis()->GetBinCenter(idxeta)));
}
} // for idxeta
// Store current histograms
h2template = h2empty; // Only one template needed - pick it whenever
h2s [itrg] = h2;
h2as [itrg] = h2a;
h2bs [itrg] = h2b;
h2hots [itrg] = h2hot;
h2colds[itrg] = h2cold;
TCanvas *cvar = new TCanvas(Form("cvar%s%s",ctrg,type),"",600,600);
gPad->SetTopMargin(0.10);
hvar->SetLineColor(kRed);
hvar->Draw();
hvar2->SetLineColor(kBlue);
hvar2->Draw("SAME");
if (!quick) cvar->SaveAs(Form("pdf/%s_VarPerMean%s_%s.pdf",nametag.c_str(),type,ctrg));
} // itrg
assert(h2template);
// Create sum histograms
TH2D *h2cumul = (TH2D*)h2template->Clone("h2cumul"); // Completely unfiltered sum of h2as
TH2D *h2pcumul = (TH2D*)h2template->Clone("h2pcumul"); // Completely unfiltered sum of h2as
TH2D *h2ncumul = (TH2D*)h2template->Clone("h2ncumul"); // Completely unfiltered sum of h2as
TH2D *h2hot = (TH2D*)h2template->Clone("h2hot"); // Unfiltered sum of h2hot
TH2D *h2hot2 = (TH2D*)h2template->Clone("h2hot2"); // Filtered sum of h2hot
TH2D *h2cold = (TH2D*)h2template->Clone("h2cold"); // Unfiltered sum of h2cold
TH2D *h2cold2 = (TH2D*)h2template->Clone("h2cold2"); // Filtered sum of h2cold
for (int idxeta = 1; idxeta <= h2hot->GetNbinsX(); ++idxeta) { // Loop over HCAL eta strips.
// We check which triggers are in a usable form in this eta region. Triggers ordered from the most inclusive (ZeroBias) to the least inclusive (JetHT500)
double abseta = fabs(h2hot->GetXaxis()->GetBinCenter(idxeta));
int breaker = etalims.size();
for (auto ie = 0u; ie < etalims.size(); ++ie) {
if (abseta>etalims[ie]) {
breaker = ie;
break;
}
}
breaker -= 1;
cout << "Eta: " << abseta;
if (breaker>=0) { // Only do something if the eta strip is activated
const int NTrgs = etatrgs[breaker];
cout << " No trgs: " << NTrgs << endl;
for (int idxphi = 1; idxphi < h2hot->GetNbinsY()+1; ++idxphi) {
// Sum over all triggers, taking weight into account
double cumulsum = 0, hotsum = 0, coldsum = 0;
for (int itrg = 0; itrg < NTrgs; ++itrg) {
cumulsum += h2as[itrg]->GetBinContent(idxeta,idxphi); // This counter includes everything
hotsum += h2hots[itrg]->GetBinContent(idxeta,idxphi); // A sum of over 3-sigma fluctuations upwards
coldsum += h2colds[itrg]->GetBinContent(idxeta,idxphi); // A sum of over 3-sigma fluctuations downwards
} // for itrg
double scale = 1.0/NTrgs;
if (NTrgs==1) scale /= 4.0;
else if (NTrgs<4) scale /= 3.0;
else if (NTrgs<7) scale /= 2.0;
else if (NTrgs<9) scale /= 1.5;
cumulsum *= scale; hotsum *= scale; coldsum *= scale;
// Unfiltered histograms
h2cumul->SetBinContent(idxeta,idxphi, cumulsum);
if (cumulsum>1.0) h2pcumul->SetBinContent(idxeta,idxphi, cumulsum);
else if (cumulsum<-1.0) h2ncumul->SetBinContent(idxeta,idxphi, -cumulsum);
h2hot ->SetBinContent(idxeta,idxphi, hotsum);
h2cold ->SetBinContent(idxeta,idxphi, coldsum);
// Filter maps for hot and cold zones (saved in a .root file): required one sigma per trigger.
h2hot2 ->SetBinContent(idxeta,idxphi,hotsum >=1.0 ? 10 : 0);
h2cold2->SetBinContent(idxeta,idxphi,coldsum>=1.0 ? 10 : 0);
} // for idxphi
} else {
cout << endl;
}
} // for idxeta
if (h2hotNew==0) h2hotNew = static_cast<TH2D*>(h2hot2->Clone("newmap"));
h2hotNew->SetFillStyle(0);
h2hotNew->SetLineColor(kBlack);
h2hotNew->GetZaxis()->SetRangeUser(0,10);
TLine *l = new TLine();
l->SetLineColor(kBlack);
for (int itrg = 0; itrg != jp::notrigs; ++itrg) {
h2hots[itrg]->SetFillStyle(0);
h2hots[itrg]->SetLineColor(kBlack);
h2hots[itrg]->GetZaxis()->SetRangeUser(0,10);
h2colds[itrg]->SetFillStyle(0);
h2colds[itrg]->SetLineColor(kWhite);
h2colds[itrg]->GetZaxis()->SetRangeUser(0,10);
const char *ctrg = jp::triggers[itrg];
TCanvas *c1 = new TCanvas(Form("c1%s%s",ctrg,type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2s[itrg]->SetTitle("Number of jets;#eta_{jet};#phi_{jet}");
c1->SetLogz();
h2s[itrg]->Draw("COLZ");
Span(h2hots[itrg], "h2ashot", h2s[itrg]->GetMinimum(), h2s[itrg]->GetMaximum())->Draw("SAMEBOX");
Span(h2colds[itrg], "h2ashot", h2s[itrg]->GetMinimum(), h2s[itrg]->GetMaximum())->Draw("SAMEBOX");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
gErrorIgnoreLevel = kWarning;
if (!quick) c1->SaveAs(Form("pdf/%s_njet%s_%s.pdf",nametag.c_str(),type,ctrg));
TCanvas *c2a = new TCanvas(Form("c2a%s%s",ctrg,type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
// For drawing, mark deficit <-8 as -8 (so blue box instead of white)
h2as[itrg]->SetTitle(Form("Fluctuation w.r.t. #eta -strip #sigma (%s);#eta_{jet};#phi_{jet}",trgNames[ctrg]));
h2as[itrg]->SetMinimum(-5);
h2as[itrg]->SetMaximum(+5);
ZeroBinsToVal(h2as[itrg],-10);
h2as[itrg]->Draw("COLZ");
Span(h2hotNew, "h2ashot", h2as[itrg]->GetMinimum(), h2as[itrg]->GetMaximum())->Draw("SAMEBOX");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
TCanvas *c2b = new TCanvas(Form("c2b%s%s",ctrg,type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2bs[itrg]->SetTitle(Form("Value w.r.t. #eta -strip mean (%s);#eta_{jet};#phi_{jet}",trgNames[ctrg]));
h2bs[itrg]->SetMinimum(0);
h2bs[itrg]->SetMaximum(2);
ZeroBinsToVal(h2bs[itrg],-2);
h2bs[itrg]->Draw("COLZ");
Span(h2hotNew, "h2bshot", h2bs[itrg]->GetMinimum(), h2bs[itrg]->GetMaximum())->Draw("SAMEBOX");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
if (!quick) c2a->SaveAs(Form("pdf/%s_DiffPerVar%s_%s.pdf",nametag.c_str(),type,ctrg));
if (!quick) c2b->SaveAs(Form("pdf/%s_DiffPerMean%s_%s.pdf",nametag.c_str(),type,ctrg));
}
TCanvas *c0 = new TCanvas(Form("c0%s",type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2cumul->SetTitle("Cumulative sum of fluctuations;#eta_{jet};#phi_{jet}");
h2cumul->SetMinimum(-5);
h2cumul->SetMaximum(+5);
h2cumul->Draw("COLZ");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
Span(h2hotNew, "h2cumulhot", h2cumul->GetMinimum(), h2cumul->GetMaximum())->Draw("SAMEBOX");
TCanvas *c0p = new TCanvas(Form("c0p%s",type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2pcumul->SetTitle("Cumulative sum of positive fluctuations;#eta_{jet};#phi_{jet}");
h2pcumul->SetMinimum(1.0);
c0p->SetLogz();
h2pcumul->Draw("COLZ");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
Span(h2hotNew, "h2pcumulhot", h2pcumul->GetMinimum(), h2pcumul->GetMaximum())->Draw("SAMEBOX");
TCanvas *c0n = new TCanvas(Form("c0n%s",type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2ncumul->SetTitle("Cumulative sum of negative fluctuations;#eta_{jet};#phi_{jet}");
c0n->SetLogz();
h2ncumul->Draw("COLZ");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
Span(h2hotNew, "h2ncumulhot", h2ncumul->GetMinimum(), h2ncumul->GetMaximum())->Draw("SAMEBOX");
TCanvas *c0hot = new TCanvas(Form("c0hot%s",type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2hot->SetTitle("Cumulative weighted sum of 3#sigma+ up fluctuations;#eta_{jet};#phi_{jet}");
h2ncumul->SetMinimum(1.0);
c0hot->SetLogz();
h2hot->Draw("COLZ");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
Span(h2hotNew, "h2hot", h2hot->GetMinimum(), h2hot->GetMaximum())->Draw("SAMEBOX");
TCanvas *c0cold = new TCanvas(Form("c0cold%s",type),"",600,600);
gPad->SetLeftMargin(0.10);
gPad->SetRightMargin(0.15);
gPad->SetTopMargin(0.10);
gPad->SetBottomMargin(0.10);
h2cold->SetTitle("Cumulative weighted sum of 3#sigma+ down fluctuations;#eta_{jet};#phi_{jet}");
c0cold->SetLogz();
h2cold->Draw("COLZ");
l->DrawLine(1.305,-TMath::Pi(),1.305,TMath::Pi());
l->DrawLine(2.964,-TMath::Pi(),2.964,TMath::Pi());
l->DrawLine(-1.305,-TMath::Pi(),-1.305,TMath::Pi());
l->DrawLine(-2.964,-TMath::Pi(),-2.964,TMath::Pi());
Span(h2hotNew, "h2cold", h2cold->GetMinimum(), h2cold->GetMaximum())->Draw("SAMEBOX");
if (!quick) c0 ->SaveAs(Form("pdf/%s%s_cumulation.pdf",nametag.c_str(),type));
if (!quick) c0p ->SaveAs(Form("pdf/%s%s_hotcumulation.pdf",nametag.c_str(),type));
if (!quick) c0n ->SaveAs(Form("pdf/%s%s_coldcumulation.pdf",nametag.c_str(),type));
if (!quick) c0hot ->SaveAs(Form("pdf/%s%s_hots.pdf",nametag.c_str(),type));
if (!quick) c0cold->SaveAs(Form("pdf/%s%s_colds.pdf",nametag.c_str(),type));
string typestring = type;
const char* dirname = typestring=="" ? "all" : string(type).substr(1).c_str();
fouthot->mkdir(dirname);
fouthot->cd(dirname);
h2hot->Write(Form("h2hot%s",type));
h2hot2->Write(Form("h2hotfilter%s",type));
foutcold->mkdir(dirname);
foutcold->cd(dirname);
h2cold->Write(Form("h2cold%s",type));
h2cold2->Write(Form("h2hole%s",type));
if (typestring=="" or typestring=="_chf" or typestring=="_nhf") {
h2hotComb ->Add(h2hot);
h2hotComb2->Add(h2hot2);
}
} // type
if (phifile) phifile->Close();
fouthot->cd();
h2hotComb->Write("h2hot");
h2hotComb2->Write("h2hotfilter");
fouthot->Close();
foutcold->Close();
} // Sample (data/mc/herwig)
}