-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdrawSummary.C
executable file
·2815 lines (2367 loc) · 89.7 KB
/
drawSummary.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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Purpose: Draw publication quality summary plots of analysis
// Author: [email protected]
// Created: April 21, 2010
// Updated: April 21, 2010
#include "TFile.h"
#include "TDirectory.h"
#include "TList.h"
#include "TKey.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TLatex.h"
#include "TLegend.h"
#include "TF1.h"
#include "TGraphErrors.h"
#include "TGraphAsymmErrors.h"
#include "TLine.h"
#include "TROOT.h"
#include "TMath.h"
#include "TProfile.h"
#include "TBox.h"
#include <iostream>
#include <fstream>
#include <string>
#include "tools.h"
#include "tdrstyle_mod18.C"
using namespace std;
// ranges for drawing
#include "settings.h"
const bool _final = false; // cmsFinal
const int kRightHatch = 3654;
const int kLeftHatch = 3645;
const int kVertHatch = 3699;
const int kHorizHatch = 3600;
const int kCrossHatch = 3644;
// possible commands
void drawEtaSpectra(string type);
void drawDataTheoryRatioLog();
void drawDataTheoryRatio();
void drawDataTheoryRatio3x2();//bool ak7 = false, bool v38x = false);
void drawTheoryDataRatio(bool ak7 = false, bool v38x = false);
void drawUnfoldSummary(string type, string algo="PF");
void drawJetIDSummary(string type, string idtype = "JetID");
void drawNPCorr(string type);
// helper functions
//void GetPoint(TGraphErrors *g, int n, double &x, double &y,
// double &ex, double &ey);
//void SetPoint(TGraphErrors *g, int n, double x, double y,
// double ex, double ey);
void scaleGraph(TGraphErrors *g, double scale);
void offsetGraph(TGraphErrors *g, double offset);
void offsetGraph(TH1D *g, double offset);
void ratioGraph(TGraphErrors *g, TF1 *f);
void ratioGraph(TGraphErrors *g, TH1D *h);
void pruneGraph(TGraphErrors *g, double errmax, double ymin=0.,
double xmin=-1e10, double xmax=1e10);
void rangeGraph(TGraph *g, double xmin, double xmax);
TGraphErrors *makeBand(TGraph *f, const TH1D *epl, const TH1D *emn,
double xmin, double xmax, bool hist = false);
TGraphErrors *makeBand(TF1 *f, const TH1D *epl, const TH1D *emn,
double xmin, double xmax);
void drawEtaSpectra(string type) {
TDirectory *curdir = gDirectory;
const char *t = type.c_str();
// Unfolded data
// TFile *fin = new TFile(Form("output-%s-3.root",t),"READ");
TFile *fin = new TFile(Form("output-%s-2c.root",t),"READ"); // unfolded data
assert(fin && !fin->IsZombie());
assert(fin->cd("Standard"));
TDirectory *din = gDirectory;
// Uncertainties
// TFile *fin2 = new TFile(Form("output-%s-4.root",t),"READ");
// assert(fin2 && !fin2->IsZombie());
// assert(fin2->cd("Standard"));
// TDirectory *din2 = gDirectory;
// Theory
TFile *fnlo = new TFile(Form("output-%s-2c.root",t),"READ");
assert(fnlo && !fnlo->IsZombie());
assert(fnlo->cd("Standard"));
TDirectory *dnlo = gDirectory;
vector<string> etas;
etas.push_back("Eta_0.0-0.5");
etas.push_back("Eta_0.5-1.0");
etas.push_back("Eta_1.0-1.5");
etas.push_back("Eta_1.5-2.0");
etas.push_back("Eta_2.0-2.5");
etas.push_back("Eta_2.5-3.0");
double c = 10;
double scale[] = {pow(c,5),pow(c,4),pow(c,3),pow(c,2),pow(c,1),pow(c,0.)};
int marker[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare,
kFullTriangleUp, kOpenTriangleUp};
TCanvas *c1 = new TCanvas("c1","c1",600,600);
c1->SetLogx();
c1->SetLogy();
double xmaxeta = jp::xmax;
TH1D *h = new TH1D("h","",int(xmaxeta-jp::xmin),jp::xmin,xmaxeta);
h->SetMinimum(1.0001e-4);
h->SetMaximum(5e11);
h->GetYaxis()->SetTitle("d^{2}#sigma/dp_{T}dy (pb/GeV)");
h->GetYaxis()->SetTitleOffset(1.15);// for ^{2}
h->GetXaxis()->SetTitle("p_{T} (GeV)");
h->GetXaxis()->SetMoreLogLabels();
h->GetXaxis()->SetNoExponent();
h->Draw("AXIS");
TLegend *leg = new TLegend(0.58,0.69,0.90,0.93,"","brNDC");
leg->SetFillStyle(kNone);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
leg->Draw();
TLegend *leg2 = new TLegend(0.19,0.22,0.53,0.30,"","brNDC");
leg2->SetFillStyle(kNone);
leg2->SetBorderSize(0);
leg2->SetTextSize(0.04);
leg2->Draw();
TLatex *tjet = new TLatex(0.19,0.18,Form("Anti-k_{T} R=%1.1f",
string(jp::algo)=="AK7" ? 0.7 : 0.5));
tjet->SetTextSize(0.04);
tjet->SetNDC();
tjet->Draw();
//cmsPrel(jp::isdt ? jp::lumi : 0);
vector<TH1D*> vhnlo(etas.size());
vector<TGraphErrors*> vnlo(etas.size());
vector<TGraphErrors*> vnloup(etas.size());
vector<TGraphErrors*> vnlodw(etas.size());
vector<TGraphErrors*> vgerr(etas.size());
vector<TH1D*> vheup(etas.size());
vector<TH1D*> vhedw(etas.size());
vector<TGraphErrors*> vdata(etas.size());
for (unsigned int i = 0; i != etas.size(); ++i) {
assert(din->cd(etas[i].c_str()));
TDirectory *d = gDirectory;
assert(dnlo->cd(etas[i].c_str()));
TDirectory *dt = gDirectory;
// assert(din2->cd(etas[i].c_str()));
//TDirectory *d2 = gDirectory;
float etamin, etamax;
assert(sscanf(etas[i].c_str(),"Eta_%f-%f",&etamin,&etamax)==2);
// Load and scale central values
// TGraphErrors *g = (TGraphErrors*)d->Get("gcorrpt"); assert(g);
//scaleGraph(g, scale[i]);
TF1 *f = (TF1*)d->Get("fus"); assert(f);
f->SetParameter(0, f->GetParameter(0)*scale[i]);
vdata[i] = g;
// Load theory prediction
TH1D *htheory = (TH1D*)dt->Get("hnlo"); assert(htheory);
TH1D *hthup = (TH1D*)dt->Get("hsysup"); assert(hthup);
TH1D *hthdw = (TH1D*)dt->Get("hsysdw"); assert(hthdw);
TGraphErrors *gnlo = new TGraphErrors(0);
TGraphErrors *gnloup = new TGraphErrors(0);
TGraphErrors *gnlodw = new TGraphErrors(0);
for (int j = 0; j != g->GetN(); ++j) {
double x = g->GetX()[j];
if (x >= jp::xmin) {//jp::xminpas) {
double y = htheory->GetBinContent(htheory->FindBin(x));
int n = gnlo->GetN();
gnlo->SetPoint(n, x, y * scale[i]);
double yup = hthup->GetBinContent(hthup->FindBin(x));
gnloup->SetPoint(n, x, y * (1 + yup) * scale[i]);
double ydw = hthdw->GetBinContent(hthdw->FindBin(x));
gnlodw->SetPoint(n, x, y * (1 + ydw) * scale[i]);
}
}
htheory->GetXaxis()->SetRangeUser(g->GetX()[0],g->GetX()[g->GetN()-1]);
htheory->SetLineWidth(2);
htheory->SetLineColor(kRed);
htheory->Scale(scale[i]);
vhnlo[i] = htheory;
gnlo->SetLineWidth(2);
gnlo->SetLineColor(kRed);
gnloup->SetLineColor(kRed);
gnlodw->SetLineColor(kRed);
vnlo[i] = gnlo;
vnloup[i] = gnloup;
vnlodw[i] = gnlodw;
// Find last entry
double ptmax, yptmax;
g->GetPoint(g->GetN()-1, ptmax, yptmax);
// Produce uncertainty band around ansatz fit
// TH1D *hpl = (TH1D*)d2->Get("htot_pl"); assert(hpl);
//TH1D *hmn = (TH1D*)d2->Get("htot_mn"); assert(hmn);
// ptmax = hpl->GetBinLowEdge(hpl->FindBin(ptmax)+1);
// TGraphErrors *gerr = (jp::centerOnAnsatz ? makeBand(f, hpl, hmn, jp::xmin, jp::xmax) :
// makeBand(g, hpl, hmn, jp::xmin, jp::xmax));
//vgerr[i] = gerr;
// vheup[i] = hpl;
// vhedw[i] = hmn;
// Find reasonable upper range for fit
// at 1 TeV range, we require 1 event in a bin of O(100 GeV) width
// => update to ptmax
//f->SetRange(1., 3500./cosh(etamin));
//double x = f->GetX(scale[i]*1./100.);
f->SetRange(jp::xmin, ptmax);//x);
g->SetMarkerStyle(marker[i]);
// gerr->SetFillStyle(1001);
// gerr->SetFillColor(kYellow+1);
f->SetLineColor(kRed);
// gerr->Draw(jp::centerOnAnsatz ? "SAME E3" : "SAME E3");
if (gnlo) gnlo->Draw("SAME L");
else f->Draw("SAME");
if (gnloup) gnloup->Draw("SAME L");
if (gnlodw) gnlodw->Draw("SAME L");
g->Draw("SAMEP");
const char *seta = (etamin==0 ? Form("|y|<%1.2g ",etamax) :
Form("%1.2g#leq|y|<%1.2g",etamin,etamax));
//const char *smult = (scale[i]==1 ? "" : Form(" (#times%1.0f)",scale[i]));
const char *smult = Form(" (#times %1.0f^{%1.0f})",c,log(scale[i])/log(c));
leg->AddEntry(g,Form("%s%s",seta,smult),"P");
if (i==0) {
assert(gnlo);
leg2->AddEntry(gnlo, "NLO#otimesNP theory", "L"); // cmsFinal
// leg2->AddEntry(gerr, "Exp. uncertainty", "F");
}
} // for i
cout << endl;
for (unsigned int i = 0; i != etas.size(); ++i) {
assert(din->cd(etas[i].c_str()));
TDirectory *d = gDirectory;
float etamin, etamax;
assert(sscanf(etas[i].c_str(),"Eta_%f-%f",&etamin,&etamax)==2);
// Print ansatz fits
TF1 *fs = (TF1*)d->Get("fs"); assert(fs);
TF1 *f = (TF1*)d->Get("fus"); assert(f);
if (fs) {
cout << "fs:" << endl;
cout << Form("$%1.1f<|y|<%1.1f$ & %1.1f$\\pm$%1.1f & %1.2f$\\pm$%1.2f &"
" %1.1f$\\pm$%1.1f & %1.2f$\\pm$%1.2f & "
" %1.1f / %d \\\\", etamin, etamax,
fs->GetParameter(1)/1e12, fs->GetParError(1)/1e12,
fs->GetParameter(3), fs->GetParError(3),
fs->GetParameter(4), fs->GetParError(4),
fs->GetParameter(2), fs->GetParError(2),
fs->GetChisquare(), fs->GetNDF())
<< endl;
cout << "fus:" << endl;
cout << Form("$%1.1f<|y|<%1.1f$ & %1.1f$\\pm$%1.1f & %1.2f$\\pm$%1.2f &"
" %1.1f$\\pm$%1.1f & %1.2f$\\pm$%1.2f & "
" %1.1f / %d \\\\", etamin, etamax,
f->GetParameter(1)/1e12, f->GetParError(1)/1e12,
f->GetParameter(3), f->GetParError(3),
f->GetParameter(4), f->GetParError(4),
f->GetParameter(2), f->GetParError(2),
f->GetChisquare(), f->GetNDF())
<< endl;
}
} // for i
cout << endl;
for (unsigned int i = 0; i != etas.size(); ++i) {
assert(din->cd(etas[i].c_str()));
TDirectory *d = gDirectory;
float etamin, etamax;
assert(sscanf(etas[i].c_str(),"Eta_%f-%f",&etamin,&etamax)==2);
// Print ansatz fits
TF1 *fs = (TF1*)d->Get("fs"); assert(fs);
cout << Form(" {%1.3g, %1.3g, %1.3g, %1.3g}, // %1.2g<|y|<%1.2g:"
" %1.1f/%d", fs->GetParameter(1),
fs->GetParameter(3), fs->GetParameter(4),
fs->GetParameter(2), etamin, etamax,
fs->GetChisquare(), fs->GetNDF()) << endl;
} // for i
const char *a = string(jp::algo).c_str();
//if(_eps) c1->SaveAs(Form("eps/summaryEtaSpectra_%s_%s.eps",a,t));
if(jp::pdf) c1->SaveAs(Form("pdf/summaryEtaSpectra_%s_%s.pdf",a,t));
//if(_gif) c1->SaveAs(Form("gif/summaryEtaSpectra_%s_%s.gif",a,t));
//if(_png) c1->SaveAs(Form("png/summaryEtaSpectra_%s_%s.png",a,t));
///////////////////////////////////////////////////////////////
// for PAS, cut the NLO line at pT>18 GeV, color band yellow
for (unsigned int i = 0; i != vnlo.size(); ++i) {
pruneGraph(vnlo[i],1e10,-1e10,jp::xminpas,1e10);
pruneGraph(vnloup[i],1e10,-1e10,jp::xminpas,1e10);
pruneGraph(vnlodw[i],1e10,-1e10,jp::xminpas,1e10);
pruneGraph(vgerr[i],1e10,-1e10,jp::xminpas,1e10);
vgerr[i]->SetFillColor(kYellow+1);
} // for i
//h->SetMaximum(5e11);
//h->SetMaximum(0.99999e11);
h->SetMaximum(1e11);
h->SetMinimum(1e-7);
h->GetXaxis()->SetRangeUser(jp::xminpas,xmaxeta);
// Redraw fully
h->Draw("AXIS");
for (unsigned int i = 0; i != vgerr.size(); ++i) vgerr[i]->Draw("SAME E3");
for (unsigned int i = 0; i != vhnlo.size(); ++i) vhnlo[i]->Draw("SAME HIST][");
//for (unsigned int i = 0; i != vnlo.size(); ++i) vnlo[i]->Draw("SAME L");
for (unsigned int i = 0; i != vdata.size(); ++i) vdata[i]->DrawClone("SAME Pz");
leg->Draw();
leg2->Draw();
tjet->Draw();
TLatex *tex = new TLatex();
//tex->SetTextSize(0.045);
tex->SetTextSize(0.04);
tex->SetNDC();
//tex->DrawLatex(0.19,0.33+0.03,"#mu_{R} = #mu_{F} = p_{T}");
tex->DrawLatex(0.19,0.30+0.03,"#mu_{R} = #mu_{F} = p_{T}");
//if (jp::isdt and _final) cmsFinal(jp::lumi);
//else cmsPrel(jp::isdt ? jp::lumi : 0);
gPad->RedrawAxis();
// Save the histograms for redrawing PAS plots (here, so pT<30 GeV clipped)
// if (_pas) {
// TDirectory *curdirpas = gDirectory;
// TFile *fpas = new TFile("comparisons/pasPF.root", "UPDATE");
// for (unsigned int i = 0; i != etas.size(); ++i) {
// TGraphErrors *gnlo = (TGraphErrors*)vnlo[i]->Clone();
// scaleGraph(gnlo, 1./scale[i]);
// if (gnlo) gnlo->Write(Form("fig6_%d_gnlo",i),TObject::kOverwrite);
// delete gnlo;
// TGraphErrors *g = (TGraphErrors*)vdata[i]->Clone();
// scaleGraph(g, 1./scale[i]);
// if (g) g->Write(Form("fig6_%d_gpt",i),TObject::kOverwrite);
// delete g;
// }
// fpas->Close();
// curdirpas->cd();
// } // _pas
//if(_eps) c1->SaveAs(Form("eps/summaryEtaSpectraPAS_%s_%s.eps",a,t));
if(jp::pdf) c1->SaveAs(Form("pdf/summaryEtaSpectraPAS_%s_%s.pdf",a,t));
//if(_gif) c1->SaveAs(Form("gif/summaryEtaSpectraPAS_%s_%s.gif",a,t));
//if(_png) c1->SaveAs(Form("png/summaryEtaSpectraPAS_%s_%s.png",a,t));
// Print out the Durham tables
gROOT->ProcessLine(".! mkdir txt");
for (unsigned int i = 0; i != vdata.size(); ++i) {
ofstream fout(Form("txt/CMS_incjet_y%1.1f_%1.1f_%s.txt",0.5*i,0.5*(i+1),
jp::algo),ios::out);
fout << Form("Inclusive jet double-differential cross sections in the |rapidity| range %1.1f to %1.1f, using a jet resolution R value of %1.1f.",0.5*i,0.5*(i+1),string(jp::algo)=="AK7" ? 0.7 : 0.5) << endl;
fout << "RE : P P --> JET X" << endl;
fout << Form("ABS(YRAP) : %1.1f TO %1.1f",0.5*i,0.5*(i+1)) << endl;
fout << Form("R : %1.1f",string(jp::algo)=="AK7" ? 0.7 : 0.5) << endl;
fout << "SQRT(S) : 7 TeV" << endl;
fout << "x-axis header: PT IN GEV" << endl;
fout << "y-axis header: D2(SIG)/DPT/DYRAP IN PB/GEV" << endl;
fout << endl;
fout << Form(" %-6s %-5s %-5s %-10s %-21s %-21s",
"x","xlow","xhigh","y","dy(stat)","dy(sys)") << endl;
fout << endl;
TGraphErrors *g = vdata[i];
TH1D *hup = vheup[i];
TH1D *hdw = vhedw[i];
for (int j = 0; j != g->GetN(); ++j) {
double x = g->GetX()[j];
if (x>18) {
int ibin = hup->FindBin(x);
double xminb = hup->GetBinLowEdge(ibin);
double xmaxb = hup->GetBinLowEdge(ibin+1);
double y = g->GetY()[j];
double ey = g->GetEY()[j] / y * 100.;
double sysup = hup->GetBinContent(ibin)*100.;
double sysdw = hdw->GetBinContent(ibin)*100.;
fout << Form("%6.1f %5.0f %5.0f %10.3g %+5.1f %+5.1f (percent)"
" %+5.1f %+5.1f (percent)",
x, xminb, xmaxb, y/scale[i], ey, -ey, sysup, sysdw)
<< endl;
}
} // for j
fout.close();
} // for i
if (gROOT->IsBatch()) delete c1;
curdir->cd();
} // drawEtaSpectra
void drawDataTheoryRatioLog() {
TDirectory *curdir = gDirectory;
TFile *fin = new TFile("output-DATA-4c.root","READ");
assert(fin && !fin->IsZombie());
assert(fin->cd("Standard"));
TDirectory *din = gDirectory;
TFile *fin2 = new TFile("output-DATA-4.root","READ");
assert(fin2 && !fin2->IsZombie());
assert(fin2->cd("Standard"));
TDirectory *din2 = gDirectory;
TFile *fnlo = new TFile("output-DATA-5.root","READ");
assert(fnlo && !fnlo->IsZombie());
assert(fnlo->cd("Standard"));
TDirectory *dnlo = gDirectory;
TFile *finmc = new TFile("output-MC-4c.root","READ");
assert(finmc && !finmc->IsZombie());
assert(finmc->cd("Standard"));
TDirectory *dinmc = gDirectory;
vector<string> etas;
etas.push_back("Eta_0.0-0.5");
etas.push_back("Eta_0.5-1.0");
etas.push_back("Eta_1.0-1.5");
etas.push_back("Eta_1.5-2.0");
etas.push_back("Eta_2.0-2.5");
etas.push_back("Eta_2.5-3.0");
double c = 10.;
double scale[] = {pow(c,5),pow(c,4),pow(c,3),pow(c,2),pow(c,1),pow(c,0.)};
int marker[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare,
kFullTriangleUp, kOpenTriangleUp};
TCanvas *c1 = new TCanvas("c1","c1",600,600);
c1->SetLogx();
c1->SetLogy();
TH1D *h = new TH1D("h","",int(jp::xmax-jp::xmin),jp::xmin,jp::xmax);
h->SetMinimum(pow(c,-1.5));
h->SetMaximum(pow(c,6));
h->GetYaxis()->SetTitle("Data / NLO theory");
h->GetYaxis()->SetTitleOffset(1.1);
h->GetXaxis()->SetTitle("p_{T} (GeV)");
h->GetXaxis()->SetMoreLogLabels();
h->GetXaxis()->SetNoExponent();
h->Draw("AXIS");
TLegend *leg = new TLegend(11.,0.5,50.,8e5,"","br");
leg->SetFillStyle(kNone);
leg->SetBorderSize(0);
leg->SetTextSize(0.033);
TLegend *leg2 = new TLegend(100.,0.04,400.,0.7,"","br");
leg2->SetFillStyle(kNone);
leg2->SetBorderSize(0);
leg2->SetTextSize(0.033);
double ymin = 0.5;
double ymax = 5e5;
TLine *lptmin = new TLine(50.,ymin,50.,ymax);
lptmin->SetLineStyle(kDashed);
lptmin->SetLineColor(kBlue);
lptmin->Draw();
TLatex *tptmin = new TLatex(1.1*50., 0.9*ymax,"p_{T} > 50 GeV");
tptmin->SetTextSize(0.033);
tptmin->SetTextColor(kBlue);
tptmin->Draw("SAME");
TLine *lxmin = new TLine(50./980.*4000.,ymin,50./980.*4000.,ymax);
lxmin->SetLineStyle(kDotted);
lxmin->SetLineColor(kBlue);
lxmin->Draw();
TLatex *txmin = new TLatex(1.1*50./980.*4000, 0.9*ymax,"x > 0.0051");
txmin->SetTextSize(0.033);
txmin->SetTextColor(kBlue);
txmin->Draw();
//cmsPrel(jp::lumi);
TLatex *tjet = new TLatex(0.17,0.22,"Anti-k_{T} R=0.5");// PF");
tjet->SetTextSize(0.045);
tjet->SetNDC();
tjet->Draw();
vector<TF1*> vnlo(etas.size());
//vector<TH1D*> verr(etas.size());
vector<TGraphErrors*> vgerr(etas.size());
vector<TGraphErrors*> vmc(etas.size());
vector<TGraphErrors*> vdt(etas.size());
vector<TH1D*> hpas(etas.size());
for (unsigned int i = 0; i != etas.size(); ++i) {
assert(din->cd(etas[i].c_str()));
TDirectory *d = gDirectory;
assert(din2->cd(etas[i].c_str()));
TDirectory *d2 = gDirectory;
assert(dnlo->cd(etas[i].c_str()));
TDirectory *dt = gDirectory;
assert(dinmc->cd(etas[i].c_str()));
TDirectory *dmc = gDirectory;
float etamin, etamax;
assert(sscanf(etas[i].c_str(),"Eta_%f-%f",&etamin,&etamax)==2);
// Load central values
TGraphErrors *g = (TGraphErrors*)d->Get("gcorrpt"); assert(g);
TGraphErrors *gmc = (TGraphErrors*)dmc->Get("gcorrpt"); assert(gmc);
// Load theory
TF1 *fus = (TF1*)d->Get("fus"); assert(fus);
TH1D *htheory = (TH1D*)dt->Get("hnlo"); assert(htheory);
// For PAS: evaluate ratio of ansatz and theory
TH1D *hdtoth = (TH1D*)htheory->Clone(Form("fig7_%d_dataovertheory",i));
for (int j = 1; j != hdtoth->GetNbinsX()+1; ++j) {
double xminb = hdtoth->GetBinLowEdge(j);
double xmaxb = min(4000./cosh(0.5*i), hdtoth->GetBinLowEdge(j+1));
double y = htheory->GetBinContent(j);
if (xminb*cosh(0.5*i) < 4000. && y) {
double fy = fus->Integral(xminb, xmaxb) / (xmaxb - xminb);
hdtoth->SetBinContent(j, fy / y);
hdtoth->SetBinError(j, 0.);
}
else {
hdtoth->SetBinContent(j ,0.);
hdtoth->SetBinError(j, 0.);
}
}
hpas[i] = hdtoth;
if (htheory) ratioGraph(g, htheory);
else ratioGraph(g, fus);
scaleGraph(g, scale[i]);
if (htheory) ratioGraph(gmc, htheory);
else ratioGraph(gmc, fus);
scaleGraph(gmc, scale[i]);
pruneGraph(gmc, 0.50, 0., 10., jp::xmax);
gmc->SetLineWidth(2);
gmc->SetLineStyle(kDashed);
// Produce uncertainty band around ansatz fit
TH1D *hpl = (TH1D*)d2->Get("htot_pl"); assert(hpl);
TH1D *hmn = (TH1D*)d2->Get("htot_mn"); assert(hmn);
TF1 *f = new TF1(Form("f%d",i),"[0]", jp::xmin, jp::xmax);
f->SetParameter(0, scale[i]);
TGraphErrors *gerr = (jp::centerOnAnsatz ?
makeBand(f, hpl, hmn, jp::xmin, f->GetXmax()) :
makeBand(g, hpl, hmn, jp::xmin, f->GetXmax()));
g->SetMarkerStyle(marker[i]);
gmc->SetMarkerStyle(marker[i]);
gmc->SetMarkerColor(kBlue);
gmc->SetLineColor(kBlue);
gerr->SetFillStyle(1001);
gerr->SetFillColor(kYellow+1);
f->SetLineColor(kRed);
gerr->Draw(jp::centerOnAnsatz ? "SAME E3" : "SAME E3");
f->Draw("SAME");
gmc->Draw("SAMEL");
g->Draw("SAMEP");
const char *seta = (etamin==0 ? Form("|y| < %1.2g",etamax) :
Form("%1.2g #leq |y| < %1.2g",etamin,etamax));
const char *smult = (scale[i]==1 ? "" : Form(" (#times%1.0f^{%1.0f})", c,
log(scale[i])/log(c)));
leg->AddEntry(g,Form("%s%s",seta,smult),"P");
leg->AddEntry(gmc," ","");
if (i==0) {
if (htheory) leg2->AddEntry(f, "NLO theory", "L");
else leg2->AddEntry(f, "ansatz fit to data", "L");
leg2->AddEntry(gmc,"Pythia D6T QCD", "L");
leg2->AddEntry(gerr, "Exp. uncertainty", "F");
}
assert(gmc->GetN());
vnlo[i] = f;
vgerr[i] = gerr;
vmc[i] = gmc;
vdt[i] = g;
} // for i
// Get the tick marks on top of the bands
h->Draw("AXIS SAME");
leg->Draw();
leg2->Draw();
//if(_eps) c1->SaveAs("eps/summaryDataTheoryRatioLog.eps");
if(jp::pdf) c1->SaveAs("pdf/summaryDataTheoryRatioLog.pdf");
//if(_gif) c1->SaveAs("gif/summaryDataTheoryRatioLog.gif");
//if(_png) c1->SaveAs("png/summaryDataTheoryRatioLog.png");
/////////////////////////////////////////////////////
// for PAS, cut at pT>30 GeV, color error band yellow
h->GetXaxis()->SetRangeUser(30,jp::xmax);
h->SetMinimum(2e-2);
h->Draw("AXIS");
for (unsigned int i = 0; i != etas.size(); ++i) {
vgerr[i]->SetFillColor(kYellow+1);
vgerr[i]->Draw(jp::centerOnAnsatz ? "SAME E3" : "SAME E3");
vnlo[i]->Draw("SAME");
vmc[i]->Draw("SAME L");
vdt[i]->Draw("SAME P");
}
h->Draw("AXIS SAME");
tjet->Draw();
leg->Draw();
leg2->Draw();
//if(_eps) c1->SaveAs("eps/summaryDataTheoryRatioLogPAS.eps");
if(jp::pdf) c1->SaveAs("pdf/summaryDataTheoryRatioLogPAS.pdf");
//if(_gif) c1->SaveAs("gif/summaryDataTheoryRatioLogPAS.gif");
//if(_png) c1->SaveAs("png/summaryDataTheoryRatioLogPAS.png");
if (gROOT->IsBatch()) delete c1;
curdir->cd();
} // drawDataTheoryRatioLog
void drawDataTheoryRatio() {
TDirectory *curdir = gDirectory;
TFile *fin = new TFile("output-DATA-4c.root","READ");
assert(fin && !fin->IsZombie());
assert(fin->cd("Standard"));
TDirectory *din = gDirectory;
TFile *fin2 = new TFile("output-DATA-4.root","READ");
assert(fin2 && !fin2->IsZombie());
assert(fin2->cd("Standard"));
TDirectory *din2 = gDirectory;
TFile *fnlo = new TFile("output-DATA-5.root","READ");
assert(fnlo && !fnlo->IsZombie());
assert(fnlo->cd("Standard"));
TDirectory *dnlo = gDirectory;
//TFile *finmc = new TFile("output-MC-3a.root","READ");
TFile *finmc = new TFile("output-MC-4c.root","READ");
assert(finmc && !finmc->IsZombie());
assert(finmc->cd("Standard"));
TDirectory *dinmc = gDirectory;
vector<string> etas;
etas.push_back("Eta_0.0-0.5");
etas.push_back("Eta_0.5-1.0");
etas.push_back("Eta_1.0-1.5");
etas.push_back("Eta_1.5-2.0");
etas.push_back("Eta_2.0-2.5");
etas.push_back("Eta_2.5-3.0");
double off = 1.;
double offset[] = {5*off, 4*off, 3*off, 2*off, off, 0.};
int marker[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare,
kFullTriangleUp, kOpenTriangleUp};
TCanvas *c1 = new TCanvas("c1","c1",600,600);
c1->SetLogx();
TH1D *h = new TH1D("h","",int(jp::xmax-jp::xmin),jp::xmin,jp::xmax);
h->SetMinimum(0.0);
h->SetMaximum(9.0*off);
h->GetYaxis()->SetTitle("Data / NLO theory");
h->GetXaxis()->SetTitle("p_{T} (GeV)");
h->GetXaxis()->SetMoreLogLabels();
h->GetXaxis()->SetNoExponent();
h->GetYaxis()->SetNdivisions(0,int(9*off)*2,0);
h->Draw("AXIS");
TLegend *leg = new TLegend(0.58,0.70,0.93,0.93,"","brNDC");
leg->SetFillStyle(kNone);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);//0.045);
TLegend *leg2 = new TLegend(0.18,0.78,0.48,0.93,"","brNDC");
leg2->SetFillStyle(kNone);
leg2->SetBorderSize(0);
leg2->SetTextSize(0.045);
TLatex *ta = new TLatex();
ta->SetTextFont(42);
ta->SetTextSize(0.04);
vector<TF1*> vnlo(etas.size());
vector<TGraphErrors*> vgerr(etas.size());
vector<TGraphErrors*> vmc2(etas.size());
vector<TGraphErrors*> vgnlo(etas.size());
vector<TGraphErrors*> vdt(etas.size());
TLatex *t = new TLatex();
t->SetTextSize(0.05);
t->SetTextFont(42);
t->SetTextAlign(31); // align right
for (unsigned int i = 0; i != etas.size(); ++i) {
assert(din->cd(etas[i].c_str()));
TDirectory *d = gDirectory;
assert(din2->cd(etas[i].c_str()));
TDirectory *d2 = gDirectory;
assert(dnlo->cd(etas[i].c_str()));
TDirectory *dt = gDirectory;
assert(dinmc->cd(etas[i].c_str()));
TDirectory *dmc = gDirectory;
float etamin, etamax;
assert(sscanf(etas[i].c_str(),"Eta_%f-%f",&etamin,&etamax)==2);
// Load central values
TGraphErrors *g = (TGraphErrors*)d->Get("gcorrpt"); assert(g);
TGraphErrors *gmc = (TGraphErrors*)dmc->Get("gcorrpt"); assert(gmc);
// Load theory
TF1 *fus = (TF1*)d->Get("fus"); assert(fus);
TH1D *htheory = (TH1D*)dt->Get("hnlo"); assert(htheory);
TGraphErrors *gtheory = (TGraphErrors*)dt->Get("gnlofit"); assert(gtheory);
TF1 *ftheory = (TF1*)dt->Get("fnlo"); assert(ftheory);
// Ansatz ratio to theory
TF1 *fdt = new TF1(Form("fdt%d",i),"[0]*exp([1]/x)*pow(x,[2])"
"*pow(1-x*cosh([4])/4000.,[3]) / "
"([5]*exp([6]/x)*pow(x,[7]+[9]*log(0.01*x))"
"*pow(1-x*cosh([4])/4000.,[8]))+[10]", jp::xmin, jp::xmax);
fdt->SetParameters(fus->GetParameter(0), fus->GetParameter(1),
fus->GetParameter(2), fus->GetParameter(3),
fus->GetParameter(4),
ftheory->GetParameter(0), ftheory->GetParameter(1),
ftheory->GetParameter(2), ftheory->GetParameter(3),
ftheory->GetParameter(5));
fdt->SetParameter(10, 0.);
offsetGraph(gtheory, offset[i]);
if (ftheory) ratioGraph(g, ftheory);
else ratioGraph(g, fus);
offsetGraph(g, offset[i]);
if (ftheory) ratioGraph(gmc, ftheory);
else ratioGraph(gmc, fus);
offsetGraph(gmc, offset[i]);
gmc->SetLineWidth(2);
gmc->SetLineStyle(kDashed);
// Produce uncertainty band around ansatz fit
TH1D *hpl = (TH1D*)d2->Get("htot_pl"); assert(hpl);
TH1D *hmn = (TH1D*)d2->Get("htot_mn"); assert(hmn);
TF1 *f = new TF1(Form("f%d",i),"[0]", jp::xmin, jp::xmax);
f->SetParameter(0, 1+offset[i]);
TGraphErrors *gerr = (jp::centerOnAnsatz ?
makeBand(fdt, hpl,hmn, jp::xmin,g->GetX()[g->GetN()-1]) :
makeBand(g, hpl,hmn, jp::xmin,g->GetX()[g->GetN()-1]));
fdt->SetParameter(10, offset[i]);
offsetGraph(gerr, offset[i]);
g->SetMarkerStyle(marker[i]);
gmc->SetMarkerStyle(marker[i]);
gmc->SetMarkerColor(kBlue);
gmc->SetLineColor(kBlue+2);
gtheory->SetLineColor(kRed+2);
gtheory->SetLineWidth(2);
gerr->SetFillStyle(1001);
gerr->SetFillColor(kYellow+1);
f->SetLineWidth(2);
f->SetLineColor(kRed);
//TLine *line = new TLine(xmin, offset[i]+off, bxmax, offset[i]+off);
TLine *line = new TLine(jp::xmin, offset[i]+off, jp::xmax, offset[i]+off);
if (i!=0) line->Draw();
gerr->Draw(jp::centerOnAnsatz ? "SAME E3" : "SAME E3");
f->Draw("SAME");
gmc->Draw("SAMEL");
g->Draw("SAMEP");
const char *seta = (etamin==0 ? Form("|y| < %1.2g",etamax) :
Form("%1.2g #leq |y| < %1.2g",etamin,etamax));
leg->AddEntry(g,seta,"P");
leg->AddEntry(gmc," ","");
if (i==0) {
if (htheory) leg2->AddEntry(f, "NLO", "L");
else leg2->AddEntry(f, "ansatz fit to data", "L");
leg2->AddEntry(gmc,"Pythia D6T", "L");
leg2->AddEntry(gerr, "Exp. uncertainty", "F");
}
assert(gmc->GetN());
vnlo[i] = f;
vgnlo[i] = gtheory;
vgerr[i] = gerr;
vmc2[i] = gmc;
vdt[i] = g;
} // for i
// Get the tick marks on top of the bands
h->Draw("AXIS SAME");
leg->Draw();
leg2->Draw();
// Theory scale uncertainty band
TLine *lup = new TLine();
lup->SetLineColor(kRed); lup->SetLineStyle(kDotted);
lup->DrawLineNDC(0.19,0.92,0.245,0.92);
lup->DrawLineNDC(0.19,0.89,0.245,0.89);
//if(_eps) c1->SaveAs("eps/summaryDataTheoryRatio.eps");
if(jp::pdf) c1->SaveAs("pdf/summaryDataTheoryRatio.pdf");
//if(_gif) c1->SaveAs("gif/summaryDataTheoryRatio.gif");
//if(_png) c1->SaveAs("png/summaryDataTheoryRatio.png");
/////////////////////////////////////////////////////
// for PAS, cut at pT>20 GeV, color error band yellow
TH1D *hpas = (TH1D*)h->DrawClone("AXIS");
hpas->GetXaxis()->SetRangeUser(jp::xmin, jp::xmax);
const int nylab = 12;
const double ylabels[nylab] = {0, 1, 2, 1, 2, 1, 0, 1, 2, 3, 4, 5};
for (int i = 0; i != nylab; ++i)
t->DrawTextNDC(0.14, 0.135+0.0665*i, Form("%1.0f",ylabels[i]));
for (unsigned int i = 0; i != etas.size(); ++i) {
vgerr[i]->SetFillColor(kYellow+1);
vgerr[i]->Draw(jp::centerOnAnsatz ? "SAME E3" : "SAME E3");
}
for (unsigned int i = 0; i != etas.size(); ++i) {
//TLine *line = new TLine(jp::xminpas, offset[i]+off, bxmax, offset[i]+off);
TLine *line = new TLine(jp::xminpas, offset[i]+off, jp::xmax, offset[i]+off);
if (i!=0) line->Draw();
vnlo[i]->Draw("SAME");
TGraphErrors *gmc = vmc2[i];
for (int j = 0; j != gmc->GetN(); ++j)
gmc->SetPointError(j, 0., 0.);
gmc->SetLineColor(kBlue);
gmc->Draw("SAME L");
vdt[i]->Draw("SAME P");
}
hpas->Draw("AXIS SAME");
//cmsPrel(jp::lumi);
leg->Draw();
leg2->Draw();
if (jp::centerOnAnsatz)
ta->DrawTextNDC(leg2->GetX1NDC()+0.07, leg2->GetY1NDC()-0.04,//0.02,
"(centered on ansatz)");
lup->DrawLineNDC(0.19,0.92,0.245,0.92);
lup->DrawLineNDC(0.19,0.89,0.245,0.89);
//if(_eps) c1->SaveAs("eps/summaryDataTheoryRatioPAS.eps");
if(jp::pdf) c1->SaveAs("pdf/summaryDataTheoryRatioPAS.pdf");
//if(_gif) c1->SaveAs("gif/summaryDataTheoryRatioPAS.gif");
//if(_png) c1->SaveAs("png/summaryDataTheoryRatioPAS.png");
if (gROOT->IsBatch()) delete c1;
curdir->cd();
} // drawDataTheoryRatio
void drawDataTheoryRatio3x2() {//bool ak7, bool v38x) {
//bool _usejpt = true;
bool _ak7 = (string(jp::algo)=="AK7");
TDirectory *curdir = gDirectory;
TFile *fin = new TFile("output-DATA-4c.root","READ");
assert(fin && !fin->IsZombie());
assert(fin->cd("Standard"));
TDirectory *din = gDirectory;
TFile *fin2 = new TFile("output-DATA-4.root","READ");
assert(fin2 && !fin2->IsZombie());
assert(fin2->cd("Standard"));
TDirectory *din2 = gDirectory;
// EXTRA
//TFile *fin2010 = new TFile("../pfjet/output-DATA-4c.root","READ");
/*
TFile *fin2010 = new TFile("fastnlo/data2010.root");
assert(fin2010 && !fin2010->IsZombie());
assert(fin2010->cd("Standard"));
TDirectory *din2010 = gDirectory;
*/
//TFile *fin2010t = new TFile("../pfjet/output-DATA-5.root","READ");
//assert(fin2010t && !fin2010t->IsZombie());
//assert(fin2010t->cd("Standard"));
//TDirectory *din2010t = gDirectory;
//EXTRA
// EXTRA2
//TFile *fin2011 = new TFile("backup/oct26/output-DATA-4c.root","READ");
//TFile *fin2011 = new TFile("fastnlo/data2011v2.root","READ");
//TFile *fin2011 = new TFile("GRV23_AK5/output-DATA-4c.root","READ");
/*
TFile *fin2011 = new TFile("GRV23_AK5_42x_v4/output-DATA-4c.root","READ");
assert(fin2011 && !fin2011->IsZombie());
assert(fin2011->cd("Standard"));
TDirectory *din2011 = gDirectory;
*/
//TFile *fin2011t = new TFile("backup/oct26/output-DATA-5.root","READ");
//assert(fin2011t && !fin2011t->IsZombie());
//assert(fin2011t->cd("Standard"));
//TDirectory *din2011t = gDirectory;
//EXTRA
TFile *fmc = new TFile("output-MC-2a.root","READ");
assert(fmc && !fmc->IsZombie());
assert(fmc->cd("Standard"));
TDirectory *dinmc = gDirectory;
TFile *fnlo = new TFile("output-DATA-5.root","READ");
assert(fnlo && !fnlo->IsZombie());
assert(fnlo->cd("Standard"));
TDirectory *dnlo = gDirectory;
/*
TFile *fnlo11 = new TFile("GRV23_AK5_42x_v4/output-DATA-5.root","READ");
assert(fnlo11 && !fnlo11->IsZombie());
assert(fnlo11->cd("Standard"));
TDirectory *dnlo11 = gDirectory;
*/
TFile *fout = new TFile("comparisons/graphsDataNLORatio.root","RECREATE");
assert(fout && !fout->IsZombie());
curdir->cd();
vector<string> etas;
etas.push_back("Eta_0.0-0.5");
etas.push_back("Eta_0.5-1.0");
etas.push_back("Eta_1.0-1.5");
etas.push_back("Eta_1.5-2.0");
etas.push_back("Eta_2.0-2.5");
etas.push_back("Eta_2.5-3.0");
//string ssak7 = (ak7 ? "_AK7" : "");
//string ssv38x = (v38x ? "_38X" : "");
//string ssid = ssak7 + ssv38x;
const char *sid = "";//ssid.c_str();
//bool _ak7 = (string(jp::algo)=="AK7");
TCanvas *c1a = new TCanvas("c1a","c1a",1800,1200);
c1a->SetTopMargin(0.10);
c1a->Divide(3,2,-1,-1);
TCanvas *c1 = new TCanvas("c1","c1",1800,1200);
c1->SetTopMargin(0.10);
c1->Divide(3,2,-1,-1);
TCanvas *c2a = new TCanvas("c2a","c2a",600,600);
TCanvas *c2b = new TCanvas("c2b","c2b",1800,1200);
c2b->SetTopMargin(0.10);
c2b->Divide(3,2,-1,-1);
TCanvas *c2 = new TCanvas("c2","c2",600,600);
TH1D *h = new TH1D("h","",int(jp::xmax-jp::xmin),jp::xmin,jp::xmax);
h->SetMinimum(0.0001);
h->SetMaximum(1.7999);
//h->GetYaxis()->SetTitle("Data / NLO#otimesNP (PDF4LHC)"); // cmsFinal
h->GetYaxis()->SetTitle("Data / NLO#otimesNP (CT10)"); // cmsFinal
if (jp::herapdf) h->GetYaxis()->SetTitle("Data / NLO#otimesNP (HERAPDF1.5)");
h->GetXaxis()->SetTitle("p_{T} (GeV)");
h->GetXaxis()->SetMoreLogLabels();