-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonCutsPureROOT.h
3484 lines (2969 loc) · 98.3 KB
/
CommonCutsPureROOT.h
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
#ifndef COMMONCUTSPUREROOT_H
#define COMMONCUTSPUREROOT_H
#include <TLine.h>
#include <TLatex.h>
#include <TColor.h>
#include <TString.h>
#include <TPaveStats.h>
#include <TH1.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TH3F.h>
#include <TLegend.h>
#include <THStack.h>
#include <TList.h>
#include <TStyle.h>
#include <TROOT.h>
#include <TVector3.h>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TChain.h>
#include <TLorentzVector.h>
#include <TCanvas.h>
#include <TParticle.h>
#include <TClonesArray.h>
#include <TGraphErrors.h>
#include <TPad.h>
#include <vector>
#include <RooRealVar.h>
#include <TImage.h>
#include <TF1.h>
#include <TCutG.h>
#include <RooDataSet.h>
#include <TMath.h>
#include <TRandom3.h>
using namespace RooFit;
const Double_t PDGmassE = 0.510998928E-3;
const Double_t PDGmassP = 938.272046E-3;
const Double_t PDGmassN = 939.565379E-3;
const Double_t PDGKs0Mass = 0.497614;
const Double_t PDGKPlusMass = 0.493677;
const Double_t PDGPiPlusMass = 0.13957018;
const Double_t PDGKStar892PMMass = 0.89166;
const Double_t PDGKStar8920Mass = 0.896;
const Double_t PDGKChiC0Mass = 3.41476;
const Double_t PDGPi0Mass = 0.1349766;
Bool_t FillTH1F(Double_t fin, TH1 *histtmp,Double_t w=1.0){
if(histtmp->GetXaxis()->GetXmin()<= fin && fin <histtmp->GetXaxis()->GetXmax()){
histtmp->Fill(fin,w);
return true;
}else return false;
}
Bool_t FillTH1(Double_t fin, TH1 *histtmp,Double_t w=1.0){
if(histtmp->GetXaxis()->GetXmin()<= fin && fin <histtmp->GetXaxis()->GetXmax()){
histtmp->Fill(fin,w);
return true;
}else return false;
}
Bool_t FillTH1F(Float_t fin, TH1 *histtmp,Float_t w=1.0){
if(histtmp->GetXaxis()->GetXmin()<= fin && fin <histtmp->GetXaxis()->GetXmax()){
histtmp->Fill(fin,w);
return true;
}else return false;
}
Bool_t FillTH2F(Double_t finx,Double_t finy, TH2F *histtmp){
if(!(histtmp->GetXaxis()->GetXmin()<= finx && finx <histtmp->GetXaxis()->GetXmax())) return false;
if(!(histtmp->GetYaxis()->GetXmin()<= finy && finy <histtmp->GetYaxis()->GetXmax())) return false;
histtmp->Fill(finx,finy);
return true;
}
Bool_t FillTH3(Double_t finx,Double_t finy,Double_t finz, TH3 *histtmp){
if(!(histtmp->GetXaxis()->GetXmin()<= finx && finx <histtmp->GetXaxis()->GetXmax())) return false;
if(!(histtmp->GetYaxis()->GetXmin()<= finy && finy <histtmp->GetYaxis()->GetXmax())) return false;
if(!(histtmp->GetZaxis()->GetXmin()<= finz && finz <histtmp->GetZaxis()->GetXmax())) return false;
histtmp->Fill(finx,finy,finz);
return true;
}
Bool_t FillTH3(Float_t finx,Float_t finy,Float_t finz, TH1 *histtmp){
Double_t x = finx;
Double_t y = finy;
Double_t z = finz;
return FillTH3(x,y,z,histtmp);
}
TCanvas* prepareCanvas(Char_t name[]="c1",Int_t xL = 600, Int_t yL=400){
gROOT->SetStyle("Plain");
TStyle *Sty = new TStyle("MyStyle","My Style");
Sty->SetFrameBorderMode(0);
Sty->SetCanvasBorderMode(0);
Sty->SetPadBorderMode(0);
Sty->SetPadColor(0);
Sty->SetCanvasColor(0);
Sty->SetTitleColor(1);
Sty->SetStatColor(0);
Sty->SetTitleFont(22,"X");
Sty->SetTitleFont(22,"Y");
Sty->SetTitleFont(22,"Z");
Sty->SetTitleFont(22,"title");
Sty->SetLabelFont(22,"X");
Sty->SetLabelFont(22,"Y");
Sty->SetLabelFont(22,"X");
Sty->SetOptStat(1110);
Sty->SetStatFont(22);
Sty->SetStatColor(10);
Sty->SetCanvasColor(10);
Sty->SetTitleColor(10,"title");
Sty->SetFillColor(10);
Sty->SetStatX(0.99);
// Sty->SetStatW(0.5);
// Sty->SetStatH(0.4);
Sty->SetStatY(0.99);
// Sty->SetOptDate(11);
Sty->cd();
// gROOT->SetStyle("MyStyle");
// gROOT->ForceStyle();
// return;
//for more beautiful
const Int_t NRGBs = 5;
const Int_t NCont = 99;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
if(gROOT->GetVersionDate()>20090000){
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //rootv5.16 or late
}else{
//gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //root v.515 or before
}
gStyle->SetNumberContours(NCont);
delete gROOT->FindObject(name);
TCanvas *c1 = new TCanvas(name,"",xL,yL);
c1->SetFillColor(10);
c1->SetLeftMargin(0.12);
c1->SetRightMargin(0.099);
c1->SetTopMargin(0.05);
gROOT->SetStyle("MyStyle");
gROOT->ForceStyle();
return c1;
}
void prepareCanvasBigStat(){
gROOT->SetStyle("Plain");
delete gROOT->FindObject("c1");
TCanvas *c1 = new TCanvas("c1","");
c1->SetFillColor(10);
c1->SetLeftMargin(0.12);
c1->SetRightMargin(0.099);
c1->SetTopMargin(0.05);
TStyle *Sty = new TStyle("MyStyle","My Style");
Sty->SetFrameBorderMode(0);
Sty->SetCanvasBorderMode(0);
Sty->SetPadBorderMode(0);
Sty->SetPadColor(0);
Sty->SetCanvasColor(0);
Sty->SetTitleColor(1);
Sty->SetStatColor(0);
Sty->SetTitleFont(22,"X");
Sty->SetTitleFont(22,"Y");
Sty->SetTitleFont(22,"Z");
Sty->SetTitleFont(22,"title");
Sty->SetLabelFont(22,"X");
Sty->SetLabelFont(22,"Y");
Sty->SetOptStat(1110);
Sty->SetStatFont(22);
Sty->SetStatColor(10);
Sty->SetCanvasColor(10);
Sty->SetTitleColor(10,"title");
Sty->SetFillColor(10);
Sty->SetStatX(0.99);
Sty->SetStatW(0.5);
Sty->SetStatH(0.4);
Sty->SetStatY(0.99);
Sty->SetOptDate(11);
Sty->cd();
gROOT->SetStyle("MyStyle");
// return;
//for more beautiful
const Int_t NRGBs = 5;
const Int_t NCont = 99;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
if(gROOT->GetVersionDate()>20090000){
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //rootv5.16 or late
}else{
// gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //root v.515 or before
}
gStyle->SetNumberContours(NCont);
gROOT->ForceStyle();
}
void prepareCanvasV(){
gROOT->SetStyle("Plain");
delete gROOT->FindObject("c1");
TCanvas *c1 = new TCanvas("c1","",0,0,600,720);
c1->SetFillColor(10);
c1->SetLeftMargin(0.12);
c1->SetRightMargin(0.099);
c1->SetTopMargin(0.05);
TStyle *Sty = new TStyle("MyStyle","My Style");
Sty->SetFrameBorderMode(0);
Sty->SetCanvasBorderMode(0);
Sty->SetPadBorderMode(0);
Sty->SetPadColor(0);
Sty->SetCanvasColor(0);
Sty->SetTitleColor(1);
Sty->SetStatColor(0);
Sty->SetTitleFont(22,"X");
Sty->SetTitleFont(22,"Y");
Sty->SetTitleFont(22,"Z");
Sty->SetTitleFont(22,"title");
Sty->SetLabelFont(22,"X");
Sty->SetLabelFont(22,"Y");
Sty->SetOptStat(1110);
Sty->SetStatFont(22);
Sty->SetStatColor(10);
Sty->SetCanvasColor(10);
Sty->SetTitleColor(10,"title");
Sty->SetTitleX(0.1);
Sty->SetFillColor(10);
Sty->SetStatX(0.99);
Sty->SetStatW(0.43);
Sty->SetStatH(0.2);
Sty->SetStatY(0.99);
Sty->SetOptDate(11);
Sty->cd();
gROOT->SetStyle("MyStyle");
// return;
//for more beautiful
const Int_t NRGBs = 5;
const Int_t NCont = 99;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
if(gROOT->GetVersionDate()>20090000){
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //rootv5.16 or late
}else{
// gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //root v.515 or before
}
gStyle->SetNumberContours(NCont);
gROOT->ForceStyle();
}
void prepareCanvasZoom1(){
gROOT->SetStyle("Plain");
delete gROOT->FindObject("c1");
TCanvas *c1 = new TCanvas("c1","");
c1->SetFillColor(0);
c1->SetLeftMargin(0.12);
c1->SetRightMargin(0.099);
c1->SetTopMargin(0.05);
c1->SetTickx(1);
c1->SetTicky(1);
TStyle *Sty = new TStyle("MyStyle","My Style");
Sty->SetTitleFont(22,"xyz");
Sty->SetTitleFont(22,"title");
Sty->SetLabelFont(22,"X");
Sty->SetLabelFont(22,"Y");
Sty->SetOptStat(1110);
Sty->SetStatFont(22);
Sty->SetStatColor(10);
Sty->SetCanvasColor(10);
Sty->SetTitleColor(10,"title");
Sty->SetFillColor(10);
Sty->SetStatX(0.99);
Sty->SetStatY(0.99);
Sty->SetOptDate(11);
Sty->SetOptTitle(1);
Sty->SetOptStat(1);
Sty->SetOptFit(0);
// put tick marks on top and RHS of plots
Sty->SetPadTickX(1);
Sty->SetPadTickY(1);
Sty->SetNdivisions(509); // default root value is 510
gROOT->SetStyle("MyStyle");
// return;
//for more beautiful
const Int_t NRGBs = 20;
const Int_t NCont = 99;
Double_t red[NRGBs] = { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.25,0.50, 0.75, 1.00, 1.00, 1.00, 0.95, 0.85, 0.70, 0.55, 0.30 };
Double_t green[NRGBs] = { 0.00, 0.00, 0.00, 0.00, 0.00, 0.25, 0.50, 0.75, 1.00, 1.00,1.00, 1.00, 1.00, 0.85, 0.75, 0.50, 0.10, 0.00, 0.00, 0.00 };
Double_t blue[NRGBs] = { 0.30, 0.55, 0.70, 0.85, 0.95, 1.00, 1.00, 1.00, 1.00, 0.75, 0.25, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 };
Double_t stops[NRGBs] = { 0.00, 0.2, 0.4, 0.6, 0.80, 0.82, 0.84, 0.86, 0.88, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00 };
/* Double_t stops[NRGBs] = { 0.00, 0.90, 0.95, 0.98, 1.00 }; */
/* Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; */
/* Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; */
/* Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; */
if(gROOT->GetVersionDate()>20090000){
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //rootv5.16 or late
}else{
// gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //root v.515 or before
}
gStyle->SetNumberContours(NCont);
gROOT->ForceStyle();
}
Bool_t MassInRange(Double_t mass, Double_t LMass, Double_t HMass){
if(mass<HMass && mass>LMass) return true;
return false;
}
Bool_t MassInRange(Double_t mass, Double_t LMass[], Double_t HMass[],Int_t n){
for(Int_t i=0; i<n; i++){
if(mass<HMass[i] && mass>=LMass[i]) return true;
}
return false;
}
void LineY(Double_t atY, Int_t iColor=kRed,Char_t canvasName[]="c1"){
TCanvas *ctmp =(TCanvas *)gROOT->GetListOfCanvases()->FindObject(canvasName);
if(ctmp){
ctmp->Modified();
ctmp->Update();
TLine *l1 = new TLine(gPad->GetUxmin(),atY,gPad->GetUxmax(),atY);
l1->SetLineColor(iColor);
l1->Draw();
}else{
TLine *l1 = new TLine(gPad->GetUxmin(),atY,gPad->GetUxmax(),atY);
l1->SetLineColor(iColor);
l1->Draw();
}
}
void LineTH1FX(Double_t atX, Int_t iColor=kRed,Char_t canvasName[]="c1"){
TCanvas *ctmp =(TCanvas *)gROOT->GetListOfCanvases()->FindObject(canvasName);
if(ctmp){
ctmp->Modified();
ctmp->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}else{
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}
}
void LineX1(Double_t atX,Int_t iColor=kRed,Int_t iStyle=1,Double_t iWidth=1){
gPad->Modified();
gPad->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->SetLineStyle(iStyle);
l1->SetLineWidth((Width_t)iWidth);
l1->Draw();
}
void LineY1(Double_t atY,Int_t iColor=kRed,Int_t iStyle=1,Double_t iWidth=1){
gPad->Modified();
gPad->Update();
TLine *l1 = new TLine(gPad->GetUxmin(),atY,gPad->GetUxmax(),atY);
l1->SetLineColor(iColor);
l1->SetLineStyle(iStyle);
l1->SetLineWidth((Width_t)iWidth);
l1->Draw();
}
void LineX(Double_t atX, Int_t iColor=kRed,Char_t canvasName[]="c1"){
TCanvas *ctmp =(TCanvas *)gROOT->GetListOfCanvases()->FindObject(canvasName);
if(ctmp){
ctmp->Modified();
ctmp->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}else{
gPad->Modified();
gPad->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}
}
void LineX(Double_t atX, Int_t iColor=kRed,Double_t LineW=0.02,Char_t canvasName[]="c1"){
TCanvas *ctmp =(TCanvas *)gROOT->GetListOfCanvases()->FindObject(canvasName);
if(ctmp){
ctmp->Modified();
ctmp->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->SetLineWidth(TMath::Nint(LineW));
l1->Draw();
}else{
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->SetLineWidth(TMath::Nint(LineW));
l1->Draw();
}
}
void LineTH1FX(TH1F *hist,Double_t atX, Int_t iColor=kRed,Char_t canvasName[]="c1"){
printf("draw Line at %.1f on %s\n",atX,hist->GetName());
TCanvas *ctmp =(TCanvas *)gROOT->GetListOfCanvases()->FindObject(canvasName);
if(ctmp){
ctmp->Modified();
ctmp->Update();
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}else{
TLine *l1 = new TLine(atX,gPad->GetUymin(),atX,gPad->GetUymax());
l1->SetLineColor(iColor);
l1->Draw();
}
}
void LineTH1FX(TH1F *hist,Double_t atX, Char_t canvasName[]){
LineTH1FX(hist,atX,kRed,canvasName);
}
void LineTH1FX(TH1F *hist,Double_t atX, TCanvas *c1){
Char_t str[100];
sprintf(str,"%s",c1->GetName());
LineTH1FX(hist,atX,kRed,str);
}
void DrawText(Double_t posX = 0., Double_t posY = 0., const char* text = "",
Double_t size=0.08, Int_t col=1
// Int_t align=0, Double_t angle=0.,
// Int_t font, Bool_t bNDC=kTRUE
)
{
// Drawing some text
TLatex* pText=new TLatex(posX,posY,text);
pText->SetNDC(kTRUE);
// pText->SetNDC(bNDC);
pText->SetTextColor(col); pText->SetTextSize(size);
// pText->SetTextAngle(angle);
// pText->SetTextFont(font); pText->SetTextAlign(align);
pText->Draw();
}
void DrawNice2DHisto(TH2* h,const char* opt="",double range = 10.)
{
// Draw a 2D histo with the rainbow colors and the palette besides
TString options = "colz"; options += opt;
if(gPad->GetLogz() == 0 && h->GetMaximum()<range) h->SetAxisRange(0.,range,"Z");
h->SetStats(kFALSE);
h->SetTitleOffset(0.8,"T");
gPad->SetRightMargin(0.16);
h->DrawCopy(options.Data());
}
void set_nicer_2d_plot_style()
{
const Int_t NRGBs = 5;
const Int_t NCont = 255;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
if(gROOT->GetVersionDate()>20090000){
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //rootv5.16 or late
}else{
//gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); //root v.515 or before
}
// TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
// gStyle->CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
}
void BetterStatBox( TPad* pad ){
/// Vorgehensweise:
/// * Histogramme in ein TPad zeichnen (1. Histogramm: Draw(), ntes Histogramm:
/// Draw("sames"))
/// * die Update() Funktion vom Canvas aufrufen (die Statistikboxen werden erst
/// erzeugt, wenn das Histogramm wirklich gezeichnet wird)
/// * der Funktion das aktuelle TPad uebergeben
/// (z.B.: TPad* p=(TPad*)gPad; BetterStatBox(p);)
int entries = pad->GetListOfPrimitives()->GetEntries();
TString name = "";
TPaveStats *st;
int obj = 1;
for(int i=0; i<entries; i++){
name = pad->GetListOfPrimitives()->At(i)->IsA()->GetName();
if( name.Contains("TH1") ){
TH1* hist = (TH1*)pad->GetListOfPrimitives()->At(i);
st = (TPaveStats*)hist->GetListOfFunctions()->FindObject("stats");
if(st){
st->SetOptStat(1);
st->SetX1NDC(0.80);
st->SetY1NDC(1-0.16*obj) ;
st->SetY2NDC( st->GetY1NDC()+0.15 ) ;
st->SetTextColor( hist->GetLineColor() );
st->SetLineColor( hist->GetLineColor() );
st->Draw("same");
obj++;
}
}
}
}
// TLegend* BuildLegend_THStack( THStack* stack, float x1, float y1, float x2, float y2 ){
//
// TLegend* legend = new TLegend(x1,y1,x2,y2);
// TList* list = stack->GetHists();
// TIter next( list );
// TH1* hist;
//
// while ( hist = (TH1*)next() ) legend->AddEntry(hist,"","F");
//
// return legend;
// }
void LoadPandaStyle(void)
{
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: PBase.C,v 1.8 2006/09/22 12:04:13 kliemt Exp $
//
// Description:
// Initialization code executed at the start of a ROOT session.
// Set up the Panda style for approved plots.
//
// Environment:
// Software developed for the PANDA Detector at GSI, Darmstadt
//
// Author List:
// Sergey Ganzhur Original Author
//
// Copyright Information:
// Copyright (C) 2001-2002 Ruhr Universitaet Bochum
//
//------------------------------------------------------------------------
// use the 'plain' style for plots (white backgrounds, etc)
//cout << "...using style 'Plain'" << endl;
gROOT->SetStyle("Plain");
// Create the 'PANDA' style for approved plots. Note that this style may need
// some fine tuning in your macro depending on what you are plotting, e.g.
//
// gStyle->SetMarkerSize(0.75); // use smaller markers in a histogram with many bins
// gStyle->SetTitleOffset(0.65,"y"); // bring y axis label closer to narrow values
// Ralf Kliemt:
// Ok I changed a bit for myself here
TStyle *pandaStyle= new TStyle("PANDA","PANDA approved plots style");
// use plain black on white colors
pandaStyle->SetFrameBorderMode(0);
pandaStyle->SetCanvasBorderMode(0);
pandaStyle->SetPadBorderMode(0);
pandaStyle->SetPadColor(0);
pandaStyle->SetCanvasColor(0);
pandaStyle->SetTitleColor(1);
pandaStyle->SetStatColor(0);
// pandaStyle->SetFillColor(0);// conflict with 2D plots
// pandaStyle->SetPalette(1);
// set the paper & margin sizes
pandaStyle->SetPaperSize(20,26);
pandaStyle->SetPadTopMargin(0.05);
pandaStyle->SetPadRightMargin(0.05);
pandaStyle->SetPadBottomMargin(0.1);
pandaStyle->SetPadLeftMargin(0.12);
// use large Times-Roman fonts
/* pandaStyle->SetTextFont(132); */
/* pandaStyle->SetLabelFont(132,"x"); */
/* pandaStyle->SetLabelFont(132,"y"); */
/* pandaStyle->SetLabelFont(132,"z"); */
pandaStyle->SetTextFont(22);//changed to bold (R.K.)
pandaStyle->SetTextSize(0.08);
pandaStyle->SetLabelFont(22,"x");//changed to bold (R.K.)
pandaStyle->SetLabelFont(22,"y");//changed to bold (R.K.)
pandaStyle->SetLabelFont(22,"z");//changed to bold (R.K.)
pandaStyle->SetLabelSize(0.05,"x");
pandaStyle->SetTitleSize(0.06,"x");
pandaStyle->SetLabelSize(0.05,"y");
pandaStyle->SetTitleSize(0.06,"y");
pandaStyle->SetLabelSize(0.05,"z");
pandaStyle->SetTitleSize(0.06,"z");
// use bold lines and markers
pandaStyle->SetMarkerStyle(8);
pandaStyle->SetHistLineWidth(2);//1.85);
pandaStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
// do not display any of the standard histogram decorations
pandaStyle->SetOptTitle(1);
pandaStyle->SetOptStat(1);
pandaStyle->SetOptFit(0);
// put tick marks on top and RHS of plots
pandaStyle->SetPadTickX(1);
pandaStyle->SetPadTickY(1);
//R.K. avoid clumsy axis lables
pandaStyle->SetNdivisions(509); // default root value is 510
//cout <<" For approved plots use: gROOT->SetStyle(\"PANDA\");"<< endl;
// pandaStyle->SetOptDate(11);
pandaStyle->cd();
gROOT->ForceStyle();
set_nicer_2d_plot_style();//[R.K.] use nicer 2D plots
}//void PBase::LoadPandaStyle(void)
Double_t GetVR(TVector3 VTrk, TVector3 VBeamPos){
Double_t fVRX = VTrk.X() - VBeamPos.X();
Double_t fVRY = VTrk.Y() - VBeamPos.Y();
return TMath::Sqrt(fVRX*fVRX + fVRY*fVRY);
}
Double_t GetVZ(TVector3 VTrk, TVector3 VBeamPos){
return VTrk.Z() - VBeamPos.Z();
}
Bool_t InVR(TVector3 VTrk, TVector3 VBeamPos,Double_t fCut){
Double_t fR = GetVR(VTrk, VBeamPos);
if( fR<= fCut) return kTRUE;
else return kFALSE;
}
Bool_t InVZ(TVector3 VTrk, TVector3 VBeamPos,Double_t fCut){
Double_t fZ = GetVZ(VTrk, VBeamPos);
if( TMath::Abs(fZ) <= fCut) return kTRUE;
else return kFALSE;
}
Double_t GetVR(TVector3 VTrk){
return VTrk.Pt();
}
Double_t GetVZ(TVector3 VTrk){
return VTrk.Z();
}
Bool_t InVR(TVector3 VTrk,Double_t fCut){
Double_t fR = GetVR(VTrk);
if( fR<= fCut) return kTRUE;
else return kFALSE;
}
Bool_t InVZ(TVector3 VTrk,Double_t fCut){
Double_t fZ = GetVZ(VTrk);
if( TMath::Abs(fZ) <= fCut) return kTRUE;
else return kFALSE;
}
Bool_t IsInRange(Double_t Val, Double_t RangeL, Double_t RangeH){
return (Val<RangeH && Val>RangeL)? kTRUE:kFALSE;
}
Bool_t IsInRange(Double_t Val, Double_t fRange){
return (Val< fRange && Val>-fRange)? kTRUE:kFALSE;
}
Bool_t IsInRange(Double_t Val, Double_t RangeL, Double_t RangeH,Double_t Obs,TH1 *hValAll,TH1 *hValPass,TH1 *hObsAll, TH1 *hObsPass, TH1 *hObsFall){
Bool_t judge = (Val<RangeH && Val>RangeL)? kTRUE:kFALSE;
FillTH1F(Val,hValAll);
FillTH1F(Obs,hObsAll);
if(judge){
FillTH1F(Val,hValPass);
FillTH1F(Obs,hObsPass);
}else{
FillTH1F(Obs,hObsFall);
}
return judge;
}
Double_t GetMassInClonesArray(Int_t j, TClonesArray *pclone){
TLorentzVector *pLV = (TLorentzVector *)pclone->At(j);
return pLV->M();
}
Double_t GetMassInClonesArrayTPartile(Int_t j, TClonesArray *pclone){
TParticle *part1 = (TParticle *)pclone->At(j);
TLorentzVector LVtmp;
part1 -> Momentum(LVtmp);
return LVtmp.M();
}
Double_t GetRecMassInClonesArrayTPartile(Int_t j, TClonesArray *pclone1,TClonesArray *pclone2){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1 -> Momentum(LVtmp1);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2 -> Momentum(LVtmp2);
TLorentzVector LVtmp12 = LVtmp1 + LVtmp2;
return LVtmp12.M();
}
TLorentzVector GetRec4MomentumForceInvMass1InClonesArrayTPartile(Int_t j, TClonesArray *pclone1,Double_t forceMass,TClonesArray *pclone2){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1 -> Momentum(LVtmp1);
TLorentzVector LVtmp1ChangeMass;
LVtmp1ChangeMass.SetXYZM(LVtmp1.Px(),LVtmp1.Py(),LVtmp1.Pz(),forceMass);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2 -> Momentum(LVtmp2);
TLorentzVector LVtmp12 = LVtmp1ChangeMass + LVtmp2;
return LVtmp12;
}
TLorentzVector GetLVInClonesArrayTPartile(Int_t j, TClonesArray *pclone1){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1 -> Momentum(LVtmp1);
return LVtmp1;
}
TLorentzVector GetRec4MomentumForceInvMass12InClonesArrayTPartile(Int_t j, TClonesArray *pclone1,Double_t forceMass1,TClonesArray *pclone2,Double_t forceMass2){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1 -> Momentum(LVtmp1);
TLorentzVector LVtmp1ChangeMass1;
LVtmp1ChangeMass1.SetXYZM(LVtmp1.Px(),LVtmp1.Py(),LVtmp1.Pz(),forceMass1);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2 -> Momentum(LVtmp2);
TLorentzVector LVtmp2ChangeMass2;
LVtmp2ChangeMass2.SetXYZM(LVtmp2.Px(),LVtmp2.Py(),LVtmp2.Pz(),forceMass2);
TLorentzVector LVtmp12 = LVtmp1ChangeMass1 + LVtmp2ChangeMass2;
return LVtmp12;
}
Double_t GetRecMassForceInvMass12InClonesArrayTPartile(Int_t j, TClonesArray *pclone1,Double_t forceMass1,TClonesArray *pclone2,Double_t forceMass2){
TLorentzVector LVtmp = GetRec4MomentumForceInvMass12InClonesArrayTPartile(j,pclone1,forceMass1,pclone2,forceMass2);
return LVtmp.M();
}
Double_t GetRecMassForceInvMass1InClonesArrayTPartile(Int_t j, TClonesArray *pclone1,Double_t forceMass,TClonesArray *pclone2){
TLorentzVector LVtmp = GetRec4MomentumForceInvMass1InClonesArrayTPartile(j,pclone1,forceMass,pclone2);
return LVtmp.M();
}
Int_t GetPdgCodeInClonesArrayTPartile(Int_t j, TClonesArray *pclone){
if(j>=pclone->GetEntries()) {
printf("Error: nEntries=%d but you want the idx=%d\n",pclone->GetEntries(),j);
return -999;
}
TParticle *part1 = (TParticle *)pclone->At(j);
return part1->GetPdgCode();
}
Double_t GetMassIn2ClonesArray(Int_t j, TClonesArray *pclone1, TClonesArray *pclone2){
TLorentzVector *pLV1 = (TLorentzVector *)pclone1->At(j);
TLorentzVector *pLV2 = (TLorentzVector *)pclone2->At(j);
TLorentzVector pLV12 = (*pLV1) + (*pLV2);
return pLV12.M();
}
Double_t GetPtInClonesArray(Int_t j, TClonesArray *pclone){
TLorentzVector *pLV = (TLorentzVector *)pclone->At(j);
return pLV->Pt();
}
Double_t GetPtInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part1 = (TParticle *)pclone->At(j);
return part1->Pt();
}
Double_t GetPzInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part1 = (TParticle *)pclone->At(j);
return part1->Pz();
}
TLorentzVector GetTotaMomentumInClonesArrayTParticle(Int_t j, TClonesArray *pclone1,TClonesArray *pclone2,TClonesArray *pclone3){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1->Momentum(LVtmp1);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2->Momentum(LVtmp2);
TParticle *part3 = (TParticle *)pclone3->At(j);
TLorentzVector LVtmp3;
part3->Momentum(LVtmp3);
return LVtmp1 + LVtmp2 + LVtmp3;
}
TLorentzVector GetTotalMomentumInClonesArrayTParticle(Int_t j, TClonesArray *pclone1,Double_t fMass1,TClonesArray *pclone2,TClonesArray *pclone3){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1p;
part1->Momentum(LVtmp1p);
TLorentzVector LVtmp1;
LVtmp1.SetXYZM(LVtmp1p.Px(),LVtmp1p.Py(),LVtmp1p.Pz(),fMass1);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2->Momentum(LVtmp2);
TParticle *part3 = (TParticle *)pclone3->At(j);
TLorentzVector LVtmp3;
part3->Momentum(LVtmp3);
return LVtmp1 + LVtmp2 + LVtmp3;
}
Double_t GetPInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part1 = (TParticle *)pclone->At(j);
return part1->P();
}
Double_t GetCosThetaInClonesArray(Int_t j, TClonesArray *pclone){
if(j<pclone->GetEntries()){
TLorentzVector *pLV = (TLorentzVector *)pclone->At(j);
return pLV->CosTheta();
}else{
printf("In GetCosThetaInClonesArray Error: Nentry=%d but j=%d\n",pclone->GetEntries(),j);
return -999;
}
}
Double_t GetCosThetaInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
if(j<pclone->GetEntries()){
TParticle *part1 = (TParticle *)pclone->At(j);
TLorentzVector LVtmp;
part1->Momentum(LVtmp);
//return LVtmp.Pz()/LVtmp.P();
return LVtmp.CosTheta();
}else{
printf("In GetCosThetaInClonesArrayTParticle(Int_t j, TClonesArray *pclone) Error: Nentry=%d but j=%d\n",pclone->GetEntries(),j);
return -999;
}
}
Double_t GetCosThetaOf2TrackInClonesArrayTParticle(Int_t j, TClonesArray *pclone1 , TClonesArray *pclone2){
if(j<pclone1->GetEntries()){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1->Momentum(LVtmp1);
TParticle *part2 = (TParticle *)pclone2->At(j);
TLorentzVector LVtmp2;
part2->Momentum(LVtmp2);
return TMath::Cos( LVtmp1.Angle(LVtmp2.Vect()));
}else{
printf("In GetCosThetaOf2TrackInClonesArrayTParticle(Int_t j, TClonesArray *pclone1 , TClonesArray *pclone2)\n");
return -999;
}
}
Double_t GetCosThetaOf2TLorentzVector(TLorentzVector *lv1, TLorentzVector *lv2){
return TMath::Cos( lv1->Angle(lv2->Vect()));
}
Double_t GetCosThetaOf2TrackInClonesArrayTParticle(Int_t j, TClonesArray *pclone1 , TLorentzVector *LVtmp2){
if(j<pclone1->GetEntries()){
TParticle *part1 = (TParticle *)pclone1->At(j);
TLorentzVector LVtmp1;
part1->Momentum(LVtmp1);
return TMath::Cos( LVtmp1.Angle(LVtmp2->Vect()));
}else{
printf("In GetCosThetaOf2TrackInClonesArrayTParticle(Int_t j, TClonesArray *pclone1 , TClonesArray *pclone2)\n");
return -999;
}
}
Double_t GetRInClonesArray(Int_t j, TClonesArray *pclone){
TVector3 *pV = (TVector3 *)pclone->At(j);
return pV->Perp();
}
Double_t GetRInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
TVector3 LVpro3 = LVpro.Vect();
return LVpro3.Perp();
}
Double_t GetVyInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
return LVpro.Y();
}
Double_t GetVxInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
return LVpro.X();
}
Double_t GetRInClonesArrayTParticle(Int_t j, TClonesArray *pclone,TVector3 BeamV){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
TVector3 LVpro3 = LVpro.Vect() - BeamV;
return LVpro3.Perp();
}
Double_t GetZInClonesArrayTParticle(Int_t j, TClonesArray *pclone){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
TVector3 LVpro3 = LVpro.Vect();
return LVpro3.Z();
}
Double_t GetZInClonesArrayTParticle(Int_t j, TClonesArray *pclone,TVector3 BeamV){
TParticle *part = (TParticle *)pclone->At(j);
TLorentzVector LVpro;
part->ProductionVertex(LVpro);
TVector3 LVpro3 = LVpro.Vect() - BeamV;
return LVpro3.Z();
}
Double_t GetDeltaRInClonesArray(Int_t j, TClonesArray *pclone1,TClonesArray *pclone2){
TVector3 *pV1 = (TVector3 *)pclone1->At(j);
TVector3 *pV2 = (TVector3 *)pclone2->At(j);
Double_t x1 = pV1->X();
Double_t y1 = pV1->Y();
Double_t x2 = pV2->X();
Double_t y2 = pV2->Y();
Double_t xx12 = x1 - x2;
Double_t yy12 = y1 - y2;
return TMath::Sqrt(xx12 * xx12 + yy12 * yy12);
}