-
Notifications
You must be signed in to change notification settings - Fork 0
/
pTDistri.C
647 lines (561 loc) · 23.1 KB
/
pTDistri.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
#include "TFile.h"
#include <iostream>
#include <vector>
#include "TChain.h"
#include "TTree.h"
#include "TSystem.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TF1.h"
#include "TGraphErrors.h"
#include "TGraphAsymmErrors.h"
#include "TLorentzVector.h"
#include "TClonesArray.h"
#include "TROOT.h"
#include "TMath.h"
#include "TStyle.h"
#include "TColor.h"
#include "TLegend.h"
#include "TPad.h"
#include "TLine.h"
#include "TH1F.h"
//#include "TRatioPlot.h"
#include "../../plugins/CosmicSplittingResolutionNtuple.h"
//you first decalre all the varaibles you are goingt o pick from the tree and use in this code. Be careful that the type of the varaible (Int, Float etc) have to be the same that when it was filled in the tree maker
//my interesting variables
float pt[n_tracks][n_track_pos];
short charge[n_tracks][n_track_pos];
float unprop_pt[n_tracks][n_track_pos];
short unprop_charge[n_tracks][n_track_pos];
ushort pixel_hits[n_tracks][n_track_pos];
ushort strip_layers[n_tracks][n_track_pos];
ushort muon_hits[n_tracks][n_track_pos];
////////////////////////////////////////////////////////////////////////////////
float bins[]={50,100,200,300,400,600,2000};
int binnum = 6;
//Declaration of hitsogramm i plan to plot with this code
TH1F *pthistoGlbUP =new TH1F("pthistoGlb","",binnum,bins);
TH1F *pthistoGlbLOW =new TH1F("pthistoGlbLOW","",binnum,bins);
TH1F *pthistoTkonlyUP =new TH1F("pthistoTkonly","",binnum,bins);
TH1F *pthistoTkonlyLOW =new TH1F("pthistoTkonlyLOW","",binnum,bins);
TH1F *pthistoTpfmsUP =new TH1F("pthistoTpfms","",binnum,bins);
TH1F *pthistoTpfmsLOW =new TH1F("pthistoTpfmsLOW","",binnum,bins);
TH1F *pthistoPickyUP =new TH1F("pthistoPicky","",binnum,bins);
TH1F *pthistoPickyLOW =new TH1F("pthistoPickyLOW","",binnum,bins);
TH1F *pthistoDYTUP =new TH1F("pthistoDYT","",binnum,bins);
TH1F *pthistoDYTLOW =new TH1F("pthistoDYTLOW","",binnum,bins);
TH1F *pthistoTunePUP =new TH1F("pthistoTuneP","",binnum,bins);
TH1F *pthistoTunePLOW =new TH1F("pthistoTunePLOW","",binnum,bins);
//Begining of teh function
void pTDistri(){
//
//
//
// the next line is to link the tree you have - DATA
TChain *treedata = new TChain("UTpickedTracks/t");
// this is the root file you have input with your tree inside
treedata->Add("ROOT_Files/cosmic_data_2016_2017/cosmic_data_16_17.root");
//treedata->Add("ROOT_Files/MC2016/MC_2016_P500.root");
//treedata->Add("ROOT_Files/MC2016/cosmic_MC_2016.root");
// the following lines are to extract the branch of the trees, when there is a & it means that there is only one entry per event, like for run, lumi, event, dilepton mass in my case for DY events.
treedata->SetBranchAddress("charge",charge);
treedata->SetBranchAddress("pt",pt);
treedata->SetBranchAddress("unprop_charge",unprop_charge);
treedata->SetBranchAddress("unprop_pt",unprop_pt);
treedata->SetBranchAddress("pixel_hits",pixel_hits);
treedata->SetBranchAddress("strip_layers",strip_layers);
treedata->SetBranchAddress("muon_hits",muon_hits);
// This will get the numbers of entries of the tree.
Long64_t nentries = treedata->GetEntries();
//Decalaration of variable not in the tree that i use for the results
Float_t sameCharge = 0.;
Float_t goodMuon = 0.;
for ( int p=0; p<nentries ;p++){
// this loop over all the events in your tree
treedata->GetEntry(p);
//apply some quality cuts to select the entries that we think are interesting
//
//selection cuts
if (pixel_hits[8][0]>=1 && strip_layers[8][0]>=5 && pixel_hits[8][1]>=1 && strip_layers[8][1]>=5 && unprop_pt[8][1]>30.){
if (unprop_pt[8][1]>10 && unprop_pt[8][1]<100){
//Algorithm choice
//
//global
pthistoGlbUP->Fill(unprop_pt[0][0]);
pthistoGlbLOW->Fill(unprop_pt[0][1]);
//Tkonly
pthistoTkonlyUP->Fill(unprop_pt[2][0]);
pthistoTkonlyLOW->Fill(unprop_pt[2][1]);
//Tpfms
pthistoTpfmsUP->Fill(unprop_pt[3][0]);
pthistoTpfmsLOW->Fill(unprop_pt[3][1]);
//Picky
pthistoPickyUP->Fill(unprop_pt[4][0]);
pthistoPickyLOW->Fill(unprop_pt[4][1]);
//DYT
pthistoDYTUP->Fill(unprop_pt[5][0]);
pthistoDYTLOW->Fill(unprop_pt[5][1]);
//TuneP
pthistoTunePUP->Fill(unprop_pt[8][0]);
pthistoTunePLOW->Fill(unprop_pt[8][1]);
}
}
}// end loop p
TCanvas *c = new TCanvas("c", "canvas", 700, 600);
// Upper plot will be in pad5a
/*TPad *pad5a = new TPad("pad3a", "pad3a", 0, 0.19, 1, 1.0);
//pad5a->SetBottomMargin(0); // Upper and lower plot are joined
pad5a->SetGridx(); // Vertical grid
pad5a->Draw(); // Draw the upper pad: pad1
pad5a->cd(); // pad1 becomes the current pad*/
pthistoTunePLOW->SetStats(111); // No statistics on upper plot
pthistoTunePLOW->SetXTitle("p_{t} [GeV]-TuneP");
pthistoTunePLOW->SetTitle("2016+2017 data - P10");
pthistoTunePLOW->GetXaxis()->SetTitleSize(0.05);
pthistoTunePLOW->GetXaxis()->SetTitleOffset(0.93);
pthistoTunePLOW->SetLineColor(kBlue+1);
pthistoTunePLOW->SetLineWidth(2);
//pthistoTunePUP->Draw("E1");
// Draw h1
pthistoTunePLOW->Draw("E1"); // Draw h5 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
/*TLegend * leg5 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg5->SetHeader("TuneP-MC total");
leg5->SetFillColor(10);
leg5->AddEntry(pthistoTunePUP,"Upper leg ","l");
leg5->AddEntry(pthistoTunePLOW,"Lower leg","l");
leg5 -> Draw();*/
// lower plot will be in pad
/*c->cd(); // Go back to the main canvas before defining pad5b
TPad *pad5b = new TPad("pad5b", "pad5b", 0, 0, 1, 0.16);
pad5b->SetTopMargin(0);
pad5b->SetBottomMargin(0.2);
pad5b->SetGridx(); // vertical grid
pad5b->Draw();
pad5b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h5 = (TH1F*)pthistoTunePUP->Clone("h5");
h5->SetLineColor(kBlack);
h5->Sumw2();
h5->SetStats(0); // No statistics on lower plot
h5->Divide(pthistoTunePUP,pthistoTunePLOW ,1,1,"B");
h5->SetMarkerStyle(21);
h5->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoTunePUP->SetXTitle("p_{t} [GeV]-TuneP");
pthistoTunePUP->SetLineColor(kBlue+1);
pthistoTunePUP->SetLineWidth(2);
pthistoTunePUP->GetXaxis()->SetTitleSize(0.05);*/
// Y axis h1 plot settings
//pthistoTunePUP->GetYaxis()->SetTitleSize(20);
//pthistoTunePUP->GetYaxis()->SetTitleFont(43);
//pthistoTunePUP->GetYaxis()->SetTitleOffset(1.);
// h5 settings
pthistoTunePLOW->SetLineColor(kRed);
pthistoTunePLOW->SetLineWidth(2);
// Ratio plot (h5) settings
/*h5->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h5->GetYaxis()->SetTitle("up/low");
h5->GetYaxis()->SetNdivisions(505);
h5->GetYaxis()->SetTitleSize(20);
h5->GetYaxis()->SetTitleFont(43);
h5->GetYaxis()->SetTitleOffset(1.);
h5->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h5->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h5->GetXaxis()->SetTitleSize(20);
h5->GetXaxis()->SetTitleFont(43);
h5->GetXaxis()->SetTitleOffset(4.);
h5->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h5->GetXaxis()->SetLabelSize(15);
h5->SetStats(0); */ // No statistics on lower plot
//h5->GetYaxis()->SetRangeUser(-2,6);
// Define the Canvas
/*TCanvas *c = new TCanvas("c", "canvas", 1200, 800);
c->Divide(3,2);
c->cd(1);
// Upper plot will be in pad0a
TPad *pad0a = new TPad("pad0a", "pad0a", 0, 0.3, 1, 1.0);
//pad0a->SetBottomMargin(0); // Upper and lower plot are joined
pad0a->SetGridx(); // Vertical grid
pad0a->Draw(); // Draw the upper pad: pad1
pad0a->cd(); // pad1 becomes the current pad
//pthistoGlbUP->SetStats(0); // No statistics on upper plot
pthistoGlbUP->Draw("E1"); // Draw h1
pthistoGlbLOW->Draw("E1 same"); // Draw h2 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg0 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg0->SetHeader("Global fit");
leg0->SetFillColor(10);
leg0->AddEntry(pthistoGlbUP,"Upper leg ","l");
leg0->AddEntry(pthistoGlbLOW,"Lower leg","l");
leg0 -> Draw();
// lower plot will be in pad
c->cd(); // Go back to the main canvas before defining pad0b
TPad *pad0b = new TPad("pad0b", "pad0b", 0, 0.56, 0.33, 0.66);
pad0b->SetTopMargin(0);
pad0b->SetBottomMargin(0.2);
pad0b->SetGridx(); // vertical grid
pad0b->Draw();
pad0b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h0 = (TH1F*)pthistoGlbUP->Clone("h0");
h0->SetLineColor(kBlack);
h0->Sumw2();
h0->SetStats(0); // No statistics on lower plot
h0->Divide(pthistoGlbUP,pthistoGlbLOW ,1,1,"B");
h0->SetMarkerStyle(21);
h0->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoGlbUP->SetXTitle("p_t [GeV]");
pthistoGlbUP->SetLineColor(kBlue+1);
pthistoGlbUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoGlbUP->GetYaxis()->SetTitleSize(20);
pthistoGlbUP->GetYaxis()->SetTitleFont(43);
pthistoGlbUP->GetYaxis()->SetTitleOffset(1.55);
// h2 settings
pthistoGlbLOW->SetLineColor(kRed);
pthistoGlbLOW->SetLineWidth(2);
// Ratio plot (h0) settings
h0->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h0->GetYaxis()->SetTitle("up/low");
h0->GetYaxis()->SetNdivisions(505);
h0->GetYaxis()->SetTitleSize(20);
h0->GetYaxis()->SetTitleFont(43);
h0->GetYaxis()->SetTitleOffset(1.55);
h0->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h0->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h0->GetXaxis()->SetTitleSize(20);
h0->GetXaxis()->SetTitleFont(43);
h0->GetXaxis()->SetTitleOffset(4.);
h0->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h0->GetXaxis()->SetLabelSize(15);
h0->SetStats(0); // No statistics on lower plot
h0->GetYaxis()->SetRangeUser(-2,6);
c->cd(2);
// Upper plot will be in pad1a
TPad *pad1a = new TPad("pad1a", "pad1a", 0, 0.3, 1, 1.0);
//pad1a->SetBottomMargin(0); // Upper and lower plot are joined
pad1a->SetGridx(); // Vertical grid
pad1a->Draw(); // Draw the upper pad: pad1
pad1a->cd(); // pad1 becomes the current pad
//pthistoTkonlyUP->SetStats(0); // No statistics on upper plot
pthistoTkonlyUP->Draw("E1"); // Draw h1
pthistoTkonlyLOW->Draw("E1 same"); // Draw h2 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg1 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg1->SetHeader("Tkonly");
leg1->SetFillColor(10);
leg1->AddEntry(pthistoTkonlyUP,"Upper leg ","l");
leg1->AddEntry(pthistoTkonlyLOW,"Lower leg","l");
leg1 -> Draw();
// lower plot will be in pad
c->cd(); // Go back to the main canvas before defining pad1b
TPad *pad1b = new TPad("pad1b", "pad1b", 0.33, 0.56, 0.66,0.66);
pad1b->SetTopMargin(0);
pad1b->SetBottomMargin(0.2);
pad1b->SetGridx(); // vertical grid
pad1b->Draw();
pad1b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h1 = (TH1F*)pthistoTkonlyUP->Clone("h1");
h1->SetLineColor(kBlack);
h1->Sumw2();
h1->SetStats(0); // No statistics on lower plot
h1->Divide(pthistoTkonlyUP,pthistoTkonlyLOW ,1,1,"B");
h1->SetMarkerStyle(21);
h1->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoTkonlyUP->SetXTitle("p_t [GeV]");
pthistoTkonlyUP->SetLineColor(kBlue+1);
pthistoTkonlyUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoTkonlyUP->GetYaxis()->SetTitleSize(20);
pthistoTkonlyUP->GetYaxis()->SetTitleFont(43);
pthistoTkonlyUP->GetYaxis()->SetTitleOffset(1.55);
// h2 settings
pthistoTkonlyLOW->SetLineColor(kRed);
pthistoTkonlyLOW->SetLineWidth(2);
// Ratio plot (h1) settings
h1->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h1->GetYaxis()->SetTitle("up/low");
h1->GetYaxis()->SetNdivisions(505);
h1->GetYaxis()->SetTitleSize(20);
h1->GetYaxis()->SetTitleFont(43);
h1->GetYaxis()->SetTitleOffset(1.55);
h1->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h1->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h1->GetXaxis()->SetTitleSize(20);
h1->GetXaxis()->SetTitleFont(43);
h1->GetXaxis()->SetTitleOffset(4.);
h1->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h1->GetXaxis()->SetLabelSize(15);
h1->SetStats(0); // No statistics on lower plot
h1->GetYaxis()->SetRangeUser(-2,6);
c->cd(3);
// Upper plot will be in pad2ba
TPad *pad2a = new TPad("pad2a", "pad2a", 0, 0.3, 1, 1.0);
//pad2a->SetBottomMargin(0); // Upper and lower plot are joined
pad2a->SetGridx(); // Vertical grid
pad2a->Draw(); // Draw the upper pad: pad1
pad2a->cd(); // pad1 becomes the current pad
//pthistoTpfmsUP->SetStats(0); // No statistics on upper plot
pthistoTpfmsUP->Draw("E1"); // Draw h1
pthistoTpfmsLOW->Draw("E1 same"); // Draw h2 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg2 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg2->SetHeader("TPFMS");
leg2->SetFillColor(10);
leg2->AddEntry(pthistoTpfmsUP,"Upper leg ","l");
leg2->AddEntry(pthistoTpfmsLOW,"Lower leg","l");
leg2 -> Draw();
// lower plot will be in pad
c->cd(); // Go back to the main canvas before defining pad2b
TPad *pad2b = new TPad("pad2b", "pad2b", 0.66, 0.56, 1, 0.66);
pad2b->SetTopMargin(0);
pad2b->SetBottomMargin(0.2);
pad2b->SetGridx(); // vertical grid
pad2b->Draw();
pad2b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h2 = (TH1F*)pthistoTpfmsUP->Clone("h2");
h2->SetLineColor(kBlack);
h2->Sumw2();
h2->SetStats(0); // No statistics on lower plot
h2->Divide(pthistoTpfmsUP,pthistoTpfmsLOW ,1,1,"B");
h2->SetMarkerStyle(21);
h2->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoTpfmsUP->SetXTitle("p_t [GeV]");
pthistoTpfmsUP->SetLineColor(kBlue+1);
pthistoTpfmsUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoTpfmsUP->GetYaxis()->SetTitleSize(20);
pthistoTpfmsUP->GetYaxis()->SetTitleFont(43);
pthistoTpfmsUP->GetYaxis()->SetTitleOffset(1.55);
// h2 settings
pthistoTpfmsLOW->SetLineColor(kRed);
pthistoTpfmsLOW->SetLineWidth(2);
// Ratio plot (h2) settings
h2->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h2->GetYaxis()->SetTitle("up/low");
h2->GetYaxis()->SetNdivisions(505);
h2->GetYaxis()->SetTitleSize(20);
h2->GetYaxis()->SetTitleFont(43);
h2->GetYaxis()->SetTitleOffset(1.55);
h2->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h2->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h2->GetXaxis()->SetTitleSize(20);
h2->GetXaxis()->SetTitleFont(43);
h2->GetXaxis()->SetTitleOffset(4.);
h2->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h2->GetXaxis()->SetLabelSize(15);
h2->SetStats(0); // No statistics on lower plot
h2->GetYaxis()->SetRangeUser(-2,6);
c->cd(4);
// Upper plot will be in pad3a
TPad *pad3a = new TPad("pad3a", "pad3a",0, 0.3, 1, 1.0);
//pad3a->SetBottomMargin(0); // Upper and lower plot are joined
pad3a->SetGridx(); // Vertical grid
pad3a->Draw(); // Draw the upper pad: pad1
pad3a->cd(); // pad1 becomes the current pad
//pthistoPickyUP->SetStats(0); // No statistics on upper plot
pthistoPickyUP->Draw("E1"); // Draw h1
pthistoPickyLOW->Draw("E1 same"); // Draw h3 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg3 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg3->SetHeader("Picky fit");
leg3->SetFillColor(10);
leg3->AddEntry(pthistoPickyUP,"Upper leg ","l");
leg3->AddEntry(pthistoPickyLOW,"Lower leg","l");
leg3 -> Draw();
// lower plot will be in pad
c->cd(); // Go back to the main canvas before defining pad3b
TPad *pad3b = new TPad("pad3b", "pad3b", 0, 0.06, 0.33, 0.16);
pad3b->SetTopMargin(0);
pad3b->SetBottomMargin(0.2);
pad3b->SetGridx(); // vertical grid
pad3b->Draw();
pad3b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h3 = (TH1F*)pthistoPickyUP->Clone("h3");
h3->SetLineColor(kBlack);
h3->Sumw2();
h3->SetStats(0); // No statistics on lower plot
h3->Divide(pthistoPickyUP,pthistoPickyLOW ,1,1,"B");
h3->SetMarkerStyle(21);
h3->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoPickyUP->SetXTitle("p_t [GeV]");
pthistoPickyUP->SetLineColor(kBlue+1);
pthistoPickyUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoPickyUP->GetYaxis()->SetTitleSize(20);
pthistoPickyUP->GetYaxis()->SetTitleFont(43);
pthistoPickyUP->GetYaxis()->SetTitleOffset(1.55);
// h3 settings
pthistoPickyLOW->SetLineColor(kRed);
pthistoPickyLOW->SetLineWidth(2);
// Ratio plot (h3) settings
h3->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h3->GetYaxis()->SetTitle("up/low");
h3->GetYaxis()->SetNdivisions(505);
h3->GetYaxis()->SetTitleSize(20);
h3->GetYaxis()->SetTitleFont(43);
h3->GetYaxis()->SetTitleOffset(1.55);
h3->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h3->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h3->GetXaxis()->SetTitleSize(20);
h3->GetXaxis()->SetTitleFont(43);
h3->GetXaxis()->SetTitleOffset(4.);
h3->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h3->GetXaxis()->SetLabelSize(15);
h3->SetStats(0); // No statistics on lower plot
h3->GetYaxis()->SetRangeUser(-2,6);
c->cd(5);
// Upper plot will be in pad4a
TPad *pad4a = new TPad("pad4a", "pad4a", 0, 0.3, 1, 1.0);
//pad4a->SetBottomMargin(0); // Upper and lower plot are joined
pad4a->SetGridx(); // Vertical grid
pad4a->Draw(); // Draw the upper pad: pad1
pad4a->cd(); // pad1 becomes the current pad
//pthistoDYTUP->SetStats(0); // No statistics on upper plot
pthistoDYTUP->Draw("E1"); // Draw h1
pthistoDYTLOW->Draw("E1 same"); // Draw h4 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg4 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg4->SetHeader("DYT");
leg4->SetFillColor(10);
leg4->AddEntry(pthistoDYTUP,"Upper leg ","l");
leg4->AddEntry(pthistoDYTLOW,"Lower leg","l");
leg4 -> Draw();
// lower plot will be in pad
c->cd(); // Go ba to the main canvas before defining pad4b
TPad *pad4b = new TPad("pad4b", "pad4b", 0.33, 0.06, 0.66,0.16);
pad4b->SetTopMargin(0);
pad4b->SetBottomMargin(0.2);
pad4b->SetGridx(); // vertical grid
pad4b->Draw();
pad4b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h4 = (TH1F*)pthistoDYTUP->Clone("h4");
h4->SetLineColor(kBlack);
h4->Sumw2();
h4->SetStats(0); // No statistics on lower plot
h4->Divide(pthistoDYTUP,pthistoDYTLOW ,1,1,"B");
h4->SetMarkerStyle(21);
h4->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoDYTUP->SetXTitle("p_t [GeV]");
pthistoDYTUP->SetLineColor(kBlue+1);
pthistoDYTUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoDYTUP->GetYaxis()->SetTitleSize(20);
pthistoDYTUP->GetYaxis()->SetTitleFont(43);
pthistoDYTUP->GetYaxis()->SetTitleOffset(1.55);
// h4 settings
pthistoDYTLOW->SetLineColor(kRed);
pthistoDYTLOW->SetLineWidth(2);
// Ratio plot (h4) settings
h4->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h4->GetYaxis()->SetTitle("up/low");
h4->GetYaxis()->SetNdivisions(505);
h4->GetYaxis()->SetTitleSize(20);
h4->GetYaxis()->SetTitleFont(43);
h4->GetYaxis()->SetTitleOffset(1.55);
h4->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h4->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h4->GetXaxis()->SetTitleSize(20);
h4->GetXaxis()->SetTitleFont(43);
h4->GetXaxis()->SetTitleOffset(4.);
h4->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h4->GetXaxis()->SetLabelSize(15);
h4->SetStats(0); // No statistics on lower plot
h4->GetYaxis()->SetRangeUser(-2,6);
c->cd(6);
// Upper plot will be in pad5a
TPad *pad5a = new TPad("pad3a", "pad3a", 0, 0.3, 1, 1.0);
//pad5a->SetBottomMargin(0); // Upper and lower plot are joined
pad5a->SetGridx(); // Vertical grid
pad5a->Draw(); // Draw the upper pad: pad1
pad5a->cd(); // pad1 becomes the current pad
//pthistoTunePUP->SetStats(0); // No statistics on upper plot
pthistoTunePUP->Draw("E1"); // Draw h1
pthistoTunePLOW->Draw("E1 same"); // Draw h5 on top of h1
// Do not draw the Y axis label on the upper plot and redraw a small
// axis instead, in order to avoid the first label (0) to be clipped.
TLegend * leg5 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg5->SetHeader("TuneP");
leg5->SetFillColor(10);
leg5->AddEntry(pthistoTunePUP,"Upper leg ","l");
leg5->AddEntry(pthistoTunePLOW,"Lower leg","l");
leg5 -> Draw();
// lower plot will be in pad
c->cd(); // Go back to the main canvas before defining pad5b
TPad *pad5b = new TPad("pad5b", "pad5b", 0.66, 0.06, 1, 0.16);
pad5b->SetTopMargin(0);
pad5b->SetBottomMargin(0.2);
pad5b->SetGridx(); // vertical grid
pad5b->Draw();
pad5b->cd(); // pad2 becomes the current pad
// Define the ratio plot
TH1F *h5 = (TH1F*)pthistoTunePUP->Clone("h5");
h5->SetLineColor(kBlack);
h5->Sumw2();
h5->SetStats(0); // No statistics on lower plot
h5->Divide(pthistoTunePUP,pthistoTunePLOW ,1,1,"B");
h5->SetMarkerStyle(21);
h5->Draw("E1"); // Draw the ratio plot
// h1 settings
pthistoTunePUP->SetXTitle("p_t [GeV]");
pthistoTunePUP->SetLineColor(kBlue+1);
pthistoTunePUP->SetLineWidth(2);
// Y axis h1 plot settings
pthistoTunePUP->GetYaxis()->SetTitleSize(20);
pthistoTunePUP->GetYaxis()->SetTitleFont(43);
pthistoTunePUP->GetYaxis()->SetTitleOffset(1.55);
// h5 settings
pthistoTunePLOW->SetLineColor(kRed);
pthistoTunePLOW->SetLineWidth(2);
// Ratio plot (h5) settings
h5->SetTitle(""); // Remove the ratio title
// Y axis ratio plot settings
h5->GetYaxis()->SetTitle("up/low");
h5->GetYaxis()->SetNdivisions(505);
h5->GetYaxis()->SetTitleSize(20);
h5->GetYaxis()->SetTitleFont(43);
h5->GetYaxis()->SetTitleOffset(1.55);
h5->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h5->GetYaxis()->SetLabelSize(15);
// X axis ratio plot settings
h5->GetXaxis()->SetTitleSize(20);
h5->GetXaxis()->SetTitleFont(43);
h5->GetXaxis()->SetTitleOffset(4.);
h5->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
h5->GetXaxis()->SetLabelSize(15);
h5->SetStats(0); // No statistics on lower plot
h5->GetYaxis()->SetRangeUser(-2,6);*/
/*TFile *fout = new TFile("testpt.root ","RECREATE");
pthistoGlb->Write();
pthistoStalone->Write();
fout->Close();*/
}// end of function