-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotresi.h
1290 lines (1155 loc) · 45.9 KB
/
plotresi.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
#include <fstream>
#include <stdio.h>
#include <TMath.h>
#include <TStyle.h>
#include <TDirectory.h>
#include <TPad.h>
#include <TH1.h>
#include <TH2F.h>
#include <TF1.h>
#include <TPaveText.h>
#include <TPaveStats.h>
#include <TLegend.h>
#include <TGaxis.h>
// Global variables can be set by the program including resiplot.h
const char chend[4]="png"; // File extension for plots
char filename[255]; // prepended to plot file names
char plottitle[255]; // prepended to plot title
// ResiFitData is used to save fit parameters returned by various fit functions.
// To save ResiFitData to a file include statsfile.h and write out a stats file.
const int FITDATAMAX=20; //maximum number of possible fit items
Double_t ResiFitData[FITDATAMAX]; //filled by DrawGaus, DrawResi, DrawResiML, Drawh1h1, Drawh1h1h1
Double_t ResiFitData2[FITDATAMAX]; //filled by DrawResiML
// DrawResiParams = parameters for gaussian fit, used by DrawResi, DrawResiML
// DrawResiParams[0] => scale factor for residuals
// set to 1000 if residual plots are in mm.
// DrawResiParams[1] = 0 fit full range of plot
// > 0 number of RMSs for limit of DrawResi fit
// < 0 +-ranges of fit [mm]
Double_t DrawResiParams[2] = { 1., 5. };
//single gaussian fit of histogram
int DrawGaus( TH1 *hp );
TH1 *DrawGaus( const char *hname );
//check for 2 gaussians separated by 25ns in T0refit plot
TH1 *DrawT0refit( const char *hname );
int DrawT0refit( TH1 *hp );
// Double gaussian fit, 2 gaussians constrained to same mean
TH1 *DrawResi(const char *hname );
Double_t DrawResi( TH1 *hp );
// Double gaussian fit, 2 independent gaussians
TH1 *DrawResiInd(const char *hname);
int DrawResiInd( TH1 *hp );
// Gaussian functions for ROOT fits
Double_t DoubleG(Double_t *x,Double_t *par);
Double_t G1 (Double_t *x,Double_t *par);
Double_t G2 (Double_t *x,Double_t *par);
// Version for fitting 2 residual distributions and putting on same plot (e.g. to compare MLs)
int DrawResiML(const char *hname1, const char *hname2, const char *pname="", const char *fname="" );
int DrawResiML( TH1 *hp1, TH1 *hp2, const char *pname="", const char *fname="" );
// This just does the double gaussion fit, does not draw plot (used by DrawResiML)
int FitDoubleGaussian(TH1 *hp, Double_t values[FITDATAMAX]);
// print TH1F histogram
void Drawh1( const char *hname, const char *opt="", const char *stat="eMR");
// print 2 TH1F histogram2 overlaid (e.g. raw & seg or ML1 & ML2)
void Drawh1h1(const char *hname1, const char *hname2, const int iflag=1, const char *pname="", const char *fname="");
// print 3 TH1F histogram2 overlaid
void Drawh1h1h1(const char *hname1, const char *hname2, const char *hname3, const char *pname="" );
void Drawh1h1h1( TH1 *h1, TH1 *h2, const char *hname3, const char *pname="" );
// print TH2F histogram to file
TH2F* Drawh2(const char *hname, const char *chopt="", const char *xlab="", const char *ylab="", const char *chstat="" );
void Drawh2( TH2F *hp , const char *chopt="", const char *xlab="", const char *ylab="", const char *chstat="" );
// utility program to make a plot file from whatever has just been plotted on the current canvas
void makeplot(const char *pname="plot" );
/************************************************************
* DrawResiInd => Do double gaussian fit to a residual distribution, gaussians constrained to same mean
* Parameters:
* hp => Pointer to histogram
* DrawResiParams[0] => scale factor for residuals
* set to 1000 if residual plots are in mm.
* DrawResiParams[1] = 0 fit full range of plot
* > 0 number of RMSs for limit of DrawResi fit
* < 0 +-ranges of fit [mm]
* ResiFitData => Contains fit parameters, see below
************************************************************/
TH1 *DrawResi(const char *hname ) {
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp = (TH1 *) gDirectory->Get(hname);
if( hp == NULL ) {
printf("DrawResi ERROR: No histogram %s\n",hname);
return NULL;
}
DrawResi( hp );
return hp;
}
/************************************************************
* DrawResi => Do double gaussian fit to a residual distribution
* Version fiting 2 gaussians constrained to have the same mean
* ResiFitData[0] = Number of entries
* ResiFitData[1] = Histogram mean
* ResiFitData[2] = Error of mean = RMS/sqrt(entries)
* ResiFitData[3] = RMS
* ResiFitData[4] = Gaussian mean (G1+G2 common mean)
* ResiFitData[5] = Gaussian mean error
* ResiFitData[6] = Gaussian1 sigma (narrow)
* ResiFitData[7] = Gaussian1 sigma error (narrow)
* ResiFitData[8] = Gaussian2 sigma (wide)
* ResiFitData[9] = Gaussian2 sigma error (wide)
* ResiFitData[10] = Ratio of area of gaussians (narrow/wide)
* ResiFitData[11] = SigmaHM (==FWHM/2.3548 of the combined G1+G2 function)
************************************************************/
Double_t DrawResi(TH1 *hp) {
// Zero ResiFitData array
for( int i=0; i<FITDATAMAX; i++ ) ResiFitData[i] = 0.;
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp == NULL ) {
printf("DrawResi WARNING: histogram is NULL\n");
return -1;
}
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp->GetEntries() == 0 || hp->GetRMS() == 0 ) {
printf("DrawResi WARNING: histogram %s no entries, skipping plot\n", hp->GetName());
return -1;
}
printf("DrawResi: Fitting %s\n",hp->GetName());
// Rename histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
gStyle->SetOptStat("emr");
gStyle->SetOptFit(0);
// gStyle->SetTitleX(0.55);
// gStyle->SetTitleY(1.05);
// gStyle->SetTitleH(0.2);
// gStyle->SetTitleW(0.75);
gStyle->SetStatW(0.4);
gStyle->SetStatH(0.35);
gStyle->SetStatY(0.9);
// Set initial guesses of parameters
Int_t imax = hp->GetMaximumBin();
Double_t mean = hp->GetMean();
Float_t ampl = (hp->GetBinContent(imax-1)+hp->GetBinContent(imax)+hp->GetBinContent(imax+1))/3.;
Float_t rms = hp->GetRMS();
// Set fit limits according to param[1]
Double_t xmin=hp->GetXaxis()->GetBinLowEdge(1);
Double_t xmax=hp->GetXaxis()->GetBinUpEdge( hp->GetXaxis()->GetNbins() );
if( DrawResiParams[1] > 0. ) {
xmin = mean - DrawResiParams[1]*rms;
xmax = mean + DrawResiParams[1]*rms;
} else if( DrawResiParams[1] < 0. ) {
xmin = DrawResiParams[1];
xmax = -DrawResiParams[1];
}
TF1 *fun3 = new TF1("fun3",DoubleG,xmin,xmax,5);
fun3->SetParNames("Const1","Sigma1","Mean","Const2","Sigma2");
fun3->SetParameters(ampl,rms/4,mean,ampl/10.,rms*2); // constant,mean,sigma
hp->Fit("fun3","RQ");
// Check results of fit. If failed try again with restricted range
/* if( fun3->GetParError(1) > 2.*fun3->GetParameter(1) || */
/* fun3->GetParError(4) > 2.*fun3->GetParameter(4) ) { */
/* fun3->SetParameters(ampl,mean,rms/4,ampl/10.,mean,rms*2); //constant,mean,sigma */
/* hp->Fit("fun3","","",mean-2*rms,mean+2*rms); */
/* } */
// Determine SigmaHM. Do binary search to find half max points on both sides
Double_t Xmax = fun3->GetMaximumX(mean-rms,mean+rms);
Double_t Hmax = fun3->Eval(Xmax)/2; //GetMaximum(mean-rms,mean+rms);
Double_t X1 = Xmax-2*rms;
Double_t X2 = Xmax;
Double_t Xlo = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xlo) < Hmax ) X1 = Xlo;
else X2 = Xlo;
Xlo = (X1+X2)/2.;
}
X1 = Xmax;
X2 = Xmax+2*rms;
Double_t Xhi = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xhi) < Hmax ) X2 = Xhi;
else X1 = Xhi;
Xhi = (X1+X2)/2.;
}
Double_t sigmaHM = (Xhi-Xlo)/2.3548*DrawResiParams[0];
// Xmax *= DrawResiParams[0];
// printf("Xmax=%lf Hmax=%lf Xlo=%lf XloF=%lf\n",Xmax,Hmax,Xlo,fun3->Eval(Xlo));
// printf("Xhi=%lf XhiF=%lf sigma=%lf\n",Xhi,fun3->Eval(Xhi),sigmaHM);
// Draw fit results on plot
// TPaveText *sigpt = new TPaveText(0.1,0.5,0.38,0.9,"NDC");
TPaveText *sigpt = new TPaveText(0.1,0.4,0.38,0.9,"NDC");
sigpt->SetTextAlign(12);
Float_t sig1 = TMath::Abs(fun3->GetParameter(1))*DrawResiParams[0];
Float_t sig2 = TMath::Abs(fun3->GetParameter(4))*DrawResiParams[0];
Float_t mean1 = fun3->GetParameter(2)*DrawResiParams[0];
Float_t const1 = fun3->GetParameter(0);
Float_t const2 = fun3->GetParameter(3);
Float_t ratio = 0.;
if( sig1 < sig2 ) {
sigpt->AddText(Form("#sigma_{1}=%.1lf #mum",sig1));
sigpt->AddText(Form("#sigma_{2}=%.1lf #mum",sig2));
sigpt->AddText(Form("#mu=%.1lf #mum",mean1));
if( sig2 > 0. && const2 > 0. ) {
ratio = sig1*const1/sig2/const2;
sigpt->AddText(Form("A_{1}/A_{2}=%.3lf",ratio));
}
ResiFitData[6] = sig1;
ResiFitData[7] = fun3->GetParError(1)*DrawResiParams[0];
ResiFitData[8] = sig2;
ResiFitData[9] = fun3->GetParError(4)*DrawResiParams[0];
} else {
sigpt->AddText(Form("#sigma_{1}=%.1lf #mum",sig2));
sigpt->AddText(Form("#sigma_{2}=%.1lf #mum",sig1));
sigpt->AddText(Form("#mu=%.1lf #mum",mean1));
if( sig1 > 0. && const1 > 0. ) {
ratio = sig2*const2/sig1/const1;
sigpt->AddText(Form("A_{1}/A_{2}=%.3lf",ratio));
}
ResiFitData[6] = sig2;
ResiFitData[7] = fun3->GetParError(4)*DrawResiParams[0];
ResiFitData[8] = sig1;
ResiFitData[9] = fun3->GetParError(1)*DrawResiParams[0];
}
ResiFitData[0] = hp->GetEntries();
ResiFitData[1] = hp->GetMean()*DrawResiParams[0];
ResiFitData[3] = hp->GetRMS()*DrawResiParams[0];
if( ResiFitData[0] > 0. ) ResiFitData[2] = ResiFitData[3]/TMath::Sqrt(ResiFitData[0]);
ResiFitData[4] = mean1;
ResiFitData[5] = fun3->GetParError(2)*DrawResiParams[0];
ResiFitData[10] = ratio;
ResiFitData[11] = sigmaHM;
sigpt->AddText(Form("#sigma_{#epsilon}=%.1lf #mum",sigmaHM));
sigpt->Draw();
makeplot(hp->GetName());
return sigmaHM;
} //end DrawResi ==========================================================
/************************************************************
* DrawResiInd => Do double gaussian fit to a residual distribution, independent gaussians
* Parameters:
* hp => Pointer to histogram
* DrawResiParams[0] => scale factor for residuals
* set to 1000 if residual plots are in mm.
* DrawResiParams[1] = 0 fit full range of plot
* > 0 number of RMSs for limit of DrawResi fit
* < 0 +-ranges of fit [mm]
* ResiFitData => 2 versions, see below
************************************************************/
TH1 *DrawResiInd(const char *hname ) {
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp = (TH1 *) gDirectory->Get(hname);
if( hp == NULL ) {
printf("DrawResiInd ERROR: No histogram %s\n",hname);
return NULL;
}
DrawResiInd( hp );
return hp;
}
/************************************************************
* DrawResiInd => Do double gaussian fit to a residual distribution
* Version with two independent gaussians (NO FINAL dummy integer)
* ResiFitData[0] = Number of entries
* ResiFitData[1] = Histogram mean
* ResiFitData[2] = RMS
* ResiFitData[3] = Gaussian1 mean (narrow)
* ResiFitData[4] = Gaussian1 sigma (narrow)
* ResiFitData[5] = Gaussian2 mean (wide)
* ResiFitData[6] = Gaussian2 sigma (wide)
* ResiFitData[7] = Ratio of area of gaussians (narrow/wide)
* ResiFitData[8] = Error of mean = RMS/sqrt(entries)
* ResiFitData[9] = Gaussian1 mean error (narrow)
* ResiFitData[10] = Gaussian2 mean error (wide)
* ResiFitData[11] = Gaussian1 sigma error (narrow)
* ResiFitData[12] = Gaussian2 sigma error (wide)
* ResiFitData[13] = X value of maximum of combined function G1+G2
* ResiFitData[14] = SigmaHM (==FWHM/2.3548 of the combined G1+G2 function)
* ResiFitData[15] = X value of maximum of combined function G1+G2 error
* ResiFitData[16] = SigmaHM error
************************************************************/
int DrawResiInd(TH1 *hp) {
// Zero ResiFitData array
for( int i=0; i<FITDATAMAX; i++ ) ResiFitData[i] = 0.;
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp == NULL ) {
printf("DrawResiInd WARNING: histogram is NULL\n");
return -1;
}
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp->GetEntries() == 0 || hp->GetRMS() == 0 ) {
printf("DrawResiInd WARNING: histogram %s no entries, skipping plot\n",hp->GetName());
return -1;
}
printf("DrawResiInd: Fitting %s\n",hp->GetName());
// Rename histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
// printf("Create TF1\n");
TF1 *fun3=new TF1("fun3","gaus(0)+gaus(3)");
fun3->SetParNames("Const1","Mean1","Sigma1","Const2","Mean2","Sigma2");
// Set initial guesses of parameters
Int_t i = hp->GetMaximumBin();
Double_t mean = hp->GetMean();
Float_t ampl = (hp->GetBinContent(i-1) + hp->GetBinContent(i) + hp->GetBinContent(i+1))/3.;
Float_t rms = hp->GetRMS();
fun3->SetParameters(ampl,mean,rms/4,ampl/10.,mean,rms*2); //constant,mean,sigma
gStyle->SetOptStat("emr");
gStyle->SetOptFit(0);
gStyle->SetStatY(0.9);
// gStyle->SetTitleH(0.1);
// gStyle->SetTitleW(0.5);
gStyle->SetStatW(0.38);
gStyle->SetStatH(0.35);
// Set fit limits according to param[1]
if( DrawResiParams[1] > 0. ) hp->Fit("fun3","","",mean-DrawResiParams[1]*rms,mean+DrawResiParams[1]*rms);
else if( DrawResiParams[1] < 0. ) hp->Fit("fun3","","",DrawResiParams[1],-DrawResiParams[1]);
else hp->Fit("fun3");
// Check results of fit. If failed try again with restricted range
/* if( fun3->GetParError(1) > 2.*fun3->GetParameter(1) || */
/* fun3->GetParError(4) > 2.*fun3->GetParameter(4) ) { */
/* fun3->SetParameters(ampl,mean,rms/4,ampl/10.,mean,rms*2); //constant,mean,sigma */
/* hp->Fit("fun3","","",mean-2*rms,mean+2*rms); */
/* } */
// Determine SigmaHM. Do binary search to find half max points on both sides
Double_t Xmax = fun3->GetMaximumX(mean-rms,mean+rms);
Double_t Hmax = fun3->Eval(Xmax)/2; //GetMaximum(mean-rms,mean+rms);
Double_t X1 = Xmax-2*rms;
Double_t X2 = Xmax;
Double_t Xlo = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xlo) < Hmax ) X1 = Xlo;
else X2 = Xlo;
Xlo = (X1+X2)/2.;
}
X1 = Xmax;
X2 = Xmax+2*rms;
Double_t Xhi = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xhi) < Hmax ) X2 = Xhi;
else X1 = Xhi;
Xhi = (X1+X2)/2.;
}
Xmax *= DrawResiParams[0];
Double_t sigmaHM = (Xhi-Xlo)/2.3548*DrawResiParams[0];
// printf("Xmax=%lf Hmax=%lf Xlo=%lf XloF=%lf\n",Xmax,Hmax,Xlo,fun3->Eval(Xlo));
// printf("Xhi=%lf XhiF=%lf sigma=%lf\n",Xhi,fun3->Eval(Xhi),sigmaHM);
// Draw fit results on plot
// TPaveText *sigpt = new TPaveText(0.1,0.5,0.38,0.9,"NDC");
TPaveText *sigpt = new TPaveText(0.1,0.2,0.38,0.9,"NDC");
sigpt->SetTextAlign(12);
Float_t sig1 = TMath::Abs(fun3->GetParameter(2))*DrawResiParams[0];
Float_t sig2 = TMath::Abs(fun3->GetParameter(5))*DrawResiParams[0];
Float_t mean1 = fun3->GetParameter(1)*DrawResiParams[0];
Float_t mean2 = fun3->GetParameter(4)*DrawResiParams[0];
Float_t const1 = fun3->GetParameter(0);
Float_t const2 = fun3->GetParameter(3);
Float_t ratio = 0.;
if( sig1 < sig2 ) {
sigpt->AddText(Form("#sigma_{1}=%.1lf #mum",sig1));
sigpt->AddText(Form("#sigma_{2}=%.1lf #mum",sig2));
sigpt->AddText(Form("#mu_{1}=%.1lf #mum",mean1));
sigpt->AddText(Form("#mu_{2}=%.1lf #mum",mean2));
if( sig2 > 0. && const2 > 0. ) {
ratio = sig1*const1/sig2/const2;
sigpt->AddText(Form("A_{1}/A_{2}=%.3lf",ratio));
}
ResiFitData[3] = mean1;
ResiFitData[4] = sig1;
ResiFitData[5] = mean2;
ResiFitData[6] = sig2;
ResiFitData[7] = ratio;
ResiFitData[9] = fun3->GetParError(1)*DrawResiParams[0];
ResiFitData[10] = fun3->GetParError(4)*DrawResiParams[0];
ResiFitData[11] = fun3->GetParError(2)*DrawResiParams[0];
ResiFitData[12] = fun3->GetParError(5)*DrawResiParams[0];
} else {
sigpt->AddText(Form("#sigma_{1}=%.1lf #mum",sig2));
sigpt->AddText(Form("#sigma_{2}=%.1lf #mum",sig1));
sigpt->AddText(Form("#mu_{1}=%.1lf #mum",mean2));
sigpt->AddText(Form("#mu_{2}=%.1lf #mum",mean1));
if( sig1 > 0. && const1 > 0. ) {
ratio = sig2*const2/sig1/const1;
sigpt->AddText(Form("A_{1}/A_{2}=%.3lf",ratio));
}
ResiFitData[3] = mean2;
ResiFitData[4] = sig2;
ResiFitData[5] = mean1;
ResiFitData[6] = sig1;
ResiFitData[7] = ratio;
ResiFitData[9] = fun3->GetParError(4)*DrawResiParams[0];
ResiFitData[10] = fun3->GetParError(1)*DrawResiParams[0];
ResiFitData[11] = fun3->GetParError(5)*DrawResiParams[0];
ResiFitData[12] = fun3->GetParError(2)*DrawResiParams[0];
}
ResiFitData[0] = hp->GetEntries();
ResiFitData[1] = hp->GetMean()*DrawResiParams[0];
ResiFitData[2] = hp->GetRMS()*DrawResiParams[0];
if( ResiFitData[0] > 0. ) ResiFitData[8] = ResiFitData[2]/TMath::Sqrt(ResiFitData[0]);
ResiFitData[13] = Xmax;
ResiFitData[14] = sigmaHM;
// Xmax, sigmaHM errors are errors of G1+G2 added in quadrature
// These are too big. Just use narrow gaussian errors
// ResiFitData[15] = TMath::Sqrt(ResiFitData[9]*ResiFitData[9]+ResiFitData[10]*ResiFitData[10]);
// ResiFitData[16] = TMath::Sqrt(ResiFitData[11]*ResiFitData[11]+ResiFitData[12]*ResiFitData[12]);
ResiFitData[15] = ResiFitData[9];
ResiFitData[16] = ResiFitData[11];
sigpt->AddText(Form("#mu_{#epsilon}=%.1lf #mum",Xmax));
sigpt->AddText(Form("#sigma_{#epsilon}=%.1lf #mum",sigmaHM));
sigpt->Draw();
makeplot(hp->GetName());
return 0;
} //end DrawResiInd()
Double_t DoubleG(Double_t *x,Double_t *par) {
return G1(x,par)+G2(x,&par[2]);
} // DoubleG ================================================================
Double_t G1(Double_t *x,Double_t *par) {
// 0=peak 1=sigma 2=mean
Double_t t = (x[0]-par[2])/par[1];
return par[0]*TMath::Exp(-0.5*t*t);
} // G1 ================================================================
Double_t G2(Double_t *x,Double_t *par) {
// 0=mean 1=peak 2=sigma
Double_t t = (x[0]-par[0])/par[2];
return par[1]*TMath::Exp(-0.5*t*t);
} // G2 ================================================================
// Version to do fit 2 plots at once to display ML data
int DrawResiML(const char *hname1, const char *hname2, const char *pname, const char *fname ) {
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp1 = (TH1 *) gDirectory->Get(hname1);
if( hp1 == 0 ) {
printf("DrawResiML ERROR: No histogram %s\n",hname1);
return -1;
}
TH1 *hp2 = (TH1 *) gDirectory->Get(hname2);
if( hp2 == 0 ) {
printf("DrawResiML ERROR: No histogram %s\n",hname2);
return -1;
}
return DrawResiML( hp1, hp2, pname, fname );
}
// Version fiting 2 gaussians constrained to have the same mean
int DrawResiML(TH1 *hp1, TH1 *hp2, const char *pname, const char *fname ) {
// Zero ResiFitData array
for( int i=0; i<FITDATAMAX; i++ ) {
ResiFitData[i] = 0.;
ResiFitData2[i] = 0.;
}
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp1->GetEntries() == 0 || hp1->GetRMS() == 0 ) {
printf("DrawResi WARNING: histogram %s no entries, skipping plot\n",hp1->GetName());
return -1;
}
printf("DrawResi double fit: Fitting %s %s\n",hp1->GetName(),hp2->GetName());
// Add filename to title of histogram
// Rename histogram
if( plottitle[0] != '\0' ) {
if( pname[0] != '\0' ) {
hp1->SetTitle(Form("%s %s",plottitle,pname));
} else {
hp1->SetTitle(Form("%s %s",plottitle,hp1->GetTitle()));
}
} else if( pname[0] != '\0' ) {
hp1->SetTitle(pname);
}
gStyle->SetOptStat(0);
gStyle->SetOptFit(0);
// gStyle->SetTitleX(0.5);
// gStyle->SetTitleH(0.25);
// gStyle->SetTitleW(0.95);
// Reset hp1 maximum if hp2 max is larger so hp2 does not go offscale
if( hp2!=0 && hp1->GetMaximum() < hp2->GetMaximum() ) {
hp1->SetMaximum( 1.05*hp2->GetMaximum() );
}
// Do the double gaussian fits
FitDoubleGaussian(hp1,ResiFitData);
FitDoubleGaussian(hp2,ResiFitData2);
TF1 *fun = hp1->GetFunction("fun3");
fun->SetLineColor(kBlue);
hp1->SetLineColor(kBlue);
hp1->Draw();
TPaveText *sigpt1 = new TPaveText(0.1,0.53,0.40,0.9,"NDC");
sigpt1->SetTextAlign(12);
sigpt1->SetTextColor(kBlue);
sigpt1->AddText(Form("ML1 %.0lf",hp1->GetEntries()));
sigpt1->AddText(Form("#sigma_{1}=%.1lf #mum",ResiFitData[4]));
if( ResiFitData[6] > 1000. ) {
sigpt1->AddText(Form("#sigma_{2}=%.1lf mm",ResiFitData[6]/1000.));
} else {
sigpt1->AddText(Form("#sigma_{2}=%.1lf #mum",ResiFitData[6]));
}
sigpt1->AddText(Form("#mu=%.1lf #mum",ResiFitData[3]));
sigpt1->Draw();
if( hp2 && hp2->GetEntries() > 0. ) {
hp2->SetLineColor(kRed);
hp2->Draw("same");
TPaveText *sigpt2 = new TPaveText(0.64,0.53,0.94,0.9,"NDC");
sigpt2->SetTextAlign(12);
sigpt2->SetTextColor(kRed);
sigpt2->AddText(Form("ML2 %.0lf",hp2->GetEntries()));
sigpt2->AddText(Form("#sigma_{1}=%.1lf #mum",ResiFitData2[4]));
if( ResiFitData2[6] > 1000. ) {
sigpt1->AddText(Form("#sigma_{2}=%.1lf mm",ResiFitData2[6]/1000.));
} else {
sigpt2->AddText(Form("#sigma_{2}=%.1lf #mum",ResiFitData2[6]));
}
sigpt2->AddText(Form("#mu=%.1lf #mum",ResiFitData2[3]));
sigpt2->Draw();
}
// Print plot to file
if( filename[0] != '\0' ) {
if( fname[0] != '\0' ) {
gPad->Print(Form("%s_%s.png",filename,fname));
} else {
gPad->Print(Form("%s_%s.png",filename,hp1->GetTitle()));
}
} else if( fname[0] != '\0' ) {
gPad->Print(Form("%s.png",hp1->GetTitle()));
}
// if( fname[0] == '\0' ) gPad->Print(Form("%s.png",hp1->GetName()));
//else gPad->Print(Form("%s.png",fname));
return 0;
} //end DrawResiML
// Do a DoubleGaussian fit on a histogram. Mean of 2 gaussians constrained to be the same
int FitDoubleGaussian(TH1 *hp, Double_t values[FITDATAMAX]) {
if( hp == 0 ) return -1;
// Set initial guesses of parameters
Int_t imax = hp->GetMaximumBin();
Double_t mean = hp->GetMean();
Float_t ampl = (hp->GetBinContent(imax-1)+hp->GetBinContent(imax)+hp->GetBinContent(imax+1))/3.;
Float_t rms = hp->GetRMS();
// Set fit limits according to param[1]
Double_t xmin=hp->GetXaxis()->GetBinLowEdge(1);
Double_t xmax=hp->GetXaxis()->GetBinUpEdge( hp->GetXaxis()->GetNbins() );
if( DrawResiParams[1] > 0. ){
xmin=mean-DrawResiParams[1]*rms;
xmax=mean+DrawResiParams[1]*rms;
} else if( DrawResiParams[1] < 0. ){
xmin= DrawResiParams[1];
xmax=-DrawResiParams[1];
}
TF1 *fun3 = new TF1("fun3",DoubleG,xmin,xmax,5);
fun3->SetParNames("Const1","Sigma1","Mean","Const2","Sigma2");
fun3->SetParameters(ampl,rms/4,mean,ampl/10.,rms*2); // constant,mean,sigma
hp->Fit("fun3","RQ");
// Determine SigmaHM. Do binary search to find half max points on both sides
Double_t Xmax = fun3->GetMaximumX(mean-rms,mean+rms);
Double_t Hmax = fun3->Eval(Xmax)/2; //GetMaximum(mean-rms,mean+rms);
Double_t X1 = Xmax-2*rms;
Double_t X2 = Xmax;
Double_t Xlo = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xlo) < Hmax ) X1 = Xlo;
else X2 = Xlo;
Xlo = (X1+X2)/2.;
}
X1 = Xmax;
X2 = Xmax+2*rms;
Double_t Xhi = (X1+X2)/2.;
for( int ii=0; ii<25; ii++ ) {
if( fun3->Eval(Xhi) < Hmax ) X2 = Xhi;
else X1 = Xhi;
Xhi = (X1+X2)/2.;
}
Xmax *= DrawResiParams[0];
Double_t sigmaHM = (Xhi-Xlo)/2.3548*DrawResiParams[0];
Float_t sig1 = TMath::Abs(fun3->GetParameter(1))*DrawResiParams[0];
Float_t sig2 = TMath::Abs(fun3->GetParameter(4))*DrawResiParams[0];
Float_t mean1 = fun3->GetParameter(2)*DrawResiParams[0];
Float_t mean2 = fun3->GetParameter(2)*DrawResiParams[0];
Float_t const1 = fun3->GetParameter(0);
Float_t const2 = fun3->GetParameter(3);
if( sig1 < sig2 ) {
values[3] = mean1;
values[4] = sig1;
values[5] = mean2;
values[6] = sig2;
values[7] = sig1*const1/sig2/const2;
values[9] = fun3->GetParError(2)*DrawResiParams[0];
values[10] = fun3->GetParError(2)*DrawResiParams[0];
values[11] = fun3->GetParError(1)*DrawResiParams[0];
values[12] = fun3->GetParError(4)*DrawResiParams[0];
} else {
values[3] = mean2;
values[4] = sig2;
values[5] = mean1;
values[6] = sig1;
values[7] = sig2*const2/sig1/const1;
values[9] = fun3->GetParError(2)*DrawResiParams[0];
values[10] = fun3->GetParError(2)*DrawResiParams[0];
values[11] = fun3->GetParError(4)*DrawResiParams[0];
values[12] = fun3->GetParError(1)*DrawResiParams[0];
}
values[0] = hp->GetEntries();
values[1] = hp->GetMean()*DrawResiParams[0];
values[2] = hp->GetRMS()*DrawResiParams[0];
if( values[0] > 0. ) values[8] = values[2]/TMath::Sqrt(values[0]);
values[13] = Xmax;
values[14] = sigmaHM;
values[15] = values[9];
values[16] = values[11];
return 0;
} //end FitDoubleGaussian
/************************************************************
* Draw individual 1D histograms with a single Gaussian fit
* ResiFitData[0] = Number of entries
* ResiFitData[1] = Histogram mean
* ResiFitData[2] = RMS
* ResiFitData[3] = Gasssian mean;
* ResiFitData[4] = Gaussian sigma;
* ResiFitData[5] = Histogram mean error = rms/sqrt(n)
* ResiFitData[6] = Gaussian mean error
* ResiFitData[7] = Gaussian sigma error
************************************************************/
TH1 * DrawGaus(const char *hname ) {
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp = (TH1 *) gDirectory->Get(hname);
if( hp == NULL ) {
printf("DrawGaus ERROR: No histogram %s\n",hname);
return NULL;
}
DrawGaus( hp );
return hp;
}
int DrawGaus( TH1 *hp ) {
// Zero ResiFitData array
for( int i=0; i<FITDATAMAX; i++ ) ResiFitData[i] = 0.;
// By using TH1 this works for TH1F, TH1D, etc
if( hp == NULL ) {
printf("DrawGaus ERROR: Null histogram pointer passed\n");
return -1;
}
// Do not plot if no entries or if RMS=0
if( hp->GetEntries() == 0 || hp->GetRMS() == 0 ) {
printf("DrawGaus WARNING: histogram %s no entries, skipping plot\n",hp->GetName());
return -1;
}
printf("DrawGaus: Fitting %s\n",hp->GetName());
// Add filename to title of histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
gStyle->SetOptStat("emr");
// gStyle->SetStatX(1.0);
gStyle->SetStatW(0.4);
gStyle->SetStatH(0.35);
TF1 *fun1=new TF1("fun1","gaus");
fun1->SetParNames("Const","Mean","Sigma");
// Set initial guesses of parameters
Int_t i = hp->GetMaximumBin();
Double_t ampl = (hp->GetBinContent(i-1) + hp->GetBinContent(i) + hp->GetBinContent(i+1))/3.;
Double_t mean = hp->GetMean();
Double_t rms = hp->GetRMS();
Double_t peak = hp->GetBinCenter(hp->GetMaximumBin());
// Find narrow peak on a background.
Double_t lo, hi;
// Double_t halfmax = hp->GetMaximum()/3.; //set to half max
// lo = hp->GetBinCenter(1);
// hi = hp->GetBinCenter(hp->GetNbinsX()-1);
// Find lo
// for( int i=hp->GetMaximumBin(); i>0; i-- ) {
// if( hp->GetBinContent(i) < halfmax ) {
// lo = hp->GetBinCenter(i);
// break;
// }
// }
// Find hi
// for( int i=hp->GetMaximumBin(); i<hp->GetNbinsX(); i++ ) {
// if( hp->GetBinContent(i) < halfmax ) {
// hi = hp->GetBinCenter(i);
// break;
// }
// }
/* lo = mean-rms; */
/* hi = mean+rms; */
lo = peak-6;
hi = peak+6;
fun1->SetParameters(ampl,peak,rms); //constant,mean,sigma
hp->Fit("fun1","","",lo,hi);
// Draw fit results on plot
// TPaveText *sigpt = new TPaveText(0.16,0.79,0.45,0.99,"NDC"); //without histo title
// TPaveText *sigpt = new TPaveText(0.16,0.74,0.45,0.94,"NDC"); //with histo title
TPaveText *sigpt = new TPaveText(0.1,0.7,0.4,0.9,"NDC");
sigpt->SetFillColor(0);
sigpt->SetTextAlign(12);
Float_t mean1 = fun1->GetParameter(1);
Float_t sig1 = TMath::Abs(fun1->GetParameter(2));
// sigpt->AddText(Form("Peak=%.1lf ns",peak));
sigpt->AddText(Form("#mu=%.1lf ns",mean1));
sigpt->AddText(Form("#sigma=%.1lf ns",sig1));
sigpt->Draw();
makeplot(hp->GetName());
// We already know entries>0
ResiFitData[0] = hp->GetEntries();
ResiFitData[1] = mean;
ResiFitData[2] = rms;
if( ResiFitData[0] > 0. ) ResiFitData[5] = ResiFitData[2]/TMath::Sqrt(ResiFitData[0]);
// Make sure gaussian mean falls within limits of the histogram range
// i.e. check that fit is reasonable.
if( mean < hp->GetXaxis()->GetXmax() && mean > hp->GetXaxis()->GetXmin() ) {
ResiFitData[3] = mean1;
ResiFitData[4] = sig1;
ResiFitData[6] = fun1->GetParError(1);
ResiFitData[7] = fun1->GetParError(2);
}
return 0;
} //end DrawGaus()
/************************************************************
* Draw individual 1D histograms with a single Gaussian fit
* ResiFitData[0] = Number of entries
* ResiFitData[1] = Histogram mean
* ResiFitData[2] = RMS
* ResiFitData[3] = Gasssian mean;
* ResiFitData[4] = Gaussian sigma;
* ResiFitData[5] = Histogram mean error = rms/sqrt(n)
* ResiFitData[6] = Gaussian mean error
* ResiFitData[7] = Gaussian sigma error
************************************************************/
TH1 * DrawT0refit(const char *hname ) {
ResiFitData[0] = 0;
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp = (TH1 *) gDirectory->Get(hname);
if( hp == NULL ) {
printf("DrawT0refit ERROR: No histogram %s\n",hname);
return NULL;
}
DrawT0refit( hp );
return hp;
}
int DrawT0refit( TH1 *hp ) {
// Zero ResiFitData array
for( int i=0; i<12; i++ ) ResiFitData[i] = 0;
// By using TH1 this works for TH1F, TH1D, etc
if( hp == NULL ) {
printf("DrawT0refit ERROR: Null histogram pointer passed\n");
return -1;
}
// Do not plot if no entries or if RMS=0
if( hp->GetEntries() == 0 || hp->GetRMS() == 0 ) {
printf("DrawT0refit WARNING: histogram %s no entries, skipping plot\n",hp->GetName());
return -1;
}
printf("DrawT0refit: Fitting %s\n",hp->GetName());
// Add filename to title of histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
gStyle->SetOptStat("emr");
// gStyle->SetStatX(1.0);
gStyle->SetStatW(0.4);
gStyle->SetStatH(0.35);
TF1 *gaus1=new TF1("gaus1","gaus");
gaus1->SetParNames("Const","Mean","Sigma");
// Set initial guesses of parameters
Int_t i = hp->GetMaximumBin();
Double_t ampl = (hp->GetBinContent(i-1) + hp->GetBinContent(i) + hp->GetBinContent(i+1))/3.;
Double_t mean = hp->GetMean();
Double_t rms = hp->GetRMS();
Double_t peak = hp->GetBinCenter(hp->GetMaximumBin());
// Find narrow peak on a background.
Double_t lo, hi;
lo = peak-6;
hi = peak+6;
gaus1->SetParameters(ampl,peak,rms); //constant,mean,sigma
hp->Fit("gaus1","","",lo,hi);
// Draw fit results on plot
// TPaveText *sigpt = new TPaveText(0.16,0.79,0.45,0.99,"NDC"); //without histo title
// TPaveText *sigpt = new TPaveText(0.16,0.74,0.45,0.94,"NDC"); //with histo title
TPaveText *sigpt = new TPaveText(0.1,0.7,0.4,0.9,"NDC");
sigpt->SetFillColor(0);
sigpt->SetTextAlign(12);
sigpt->SetTextColor(2);
Float_t mean1 = gaus1->GetParameter(1);
Float_t sig1 = TMath::Abs(gaus1->GetParameter(2));
// sigpt->AddText(Form("Peak=%.1lf ns",peak));
sigpt->AddText(Form("#mu=%.1lf ns",mean1));
sigpt->AddText(Form("#sigma=%.1lf ns",sig1));
sigpt->Draw();
// We already know entries>0
ResiFitData[0] = hp->GetEntries();
ResiFitData[1] = mean;
ResiFitData[2] = rms;
// Make sure gaussian mean falls within limits of the histogram range
// i.e. check that fit is reasonable.
// if( mean < hp->GetXaxis()->GetXmax() && mean > hp->GetXaxis()->GetXmin() ) {
ResiFitData[3] = mean1;
ResiFitData[4] = sig1;
// }
// Look for a second peak 25ns below first peak
TF1 *gaus2=new TF1("gaus2","gaus");
gaus2->SetParNames("Const","Mean","Sigma");
ampl /= 2.;
peak = mean1 - 25.;
rms = sig1;
lo = peak-12;
hi = peak+12;
gaus2->SetParameters(ampl,peak,rms); //constant,mean,sigma
gaus2->SetParLimits(1,-100.,peak+12.);
gaus2->SetLineColor(4);
hp->Fit("gaus2","+","",lo,hi);
printf("mean1=%.2f peak=%0.2f limit=%.2f\n",mean1,peak,peak+12.);
printf("LO FIT %.2f %.2f %.2f %.2f %.2f\n",gaus1->GetParameter(0), gaus2->GetParameter(0), gaus2->GetParameter(1), gaus2->GetParameter(2), gaus2->GetParameter(1)-gaus1->GetParameter(1));
TPaveText *sigpt2 = new TPaveText(0.1,0.5,0.4,0.7,"NDC");
sigpt2->SetFillColor(0);
sigpt2->SetTextAlign(12);
sigpt2->SetTextColor(4);
Double_t offset = TMath::Abs(gaus2->GetParameter(1)-gaus1->GetParameter(1));
// if 2nd peak is not significant look for peak above main peak
if( gaus2->GetParameter(0) < 0.05*gaus1->GetParameter(0) || offset < 15. ) {
delete hp->GetListOfFunctions()->FindObject("gaus2");
peak = mean1 + 25.;
lo = peak-6;
hi = peak+6;
gaus2->SetParameters(ampl,peak,rms); //constant,mean,sigma
gaus2->SetParLimits(1,peak-12.,100.);
offset = TMath::Abs(gaus2->GetParameter(1)-gaus1->GetParameter(1));
hp->Fit("gaus2","+","",lo,hi);
printf("HI FIT %.2f %.2f %.2f %.2f\n",gaus1->GetParameter(0), gaus2->GetParameter(0), gaus2->GetParameter(1), gaus2->GetParameter(2));
}
// If 2nd peak is significant write results on plot, if not delete function from histogram.
if( gaus2->GetParameter(0) > 0.05*gaus1->GetParameter(0) && offset > 15. ) {
Float_t mean2 = gaus2->GetParameter(1);
Float_t sig2 = TMath::Abs(gaus2->GetParameter(2));
sigpt2->AddText(Form("#mu_{2}=%.1lf ns",mean2));
sigpt2->AddText(Form("#sigma_{2}=%.1lf ns",sig2));
sigpt2->Draw();
ResiFitData[5] = mean2;
ResiFitData[6] = sig2;
ResiFitData[7] = gaus2->GetParameter(1)-gaus1->GetParameter(1);
} else {
delete hp->GetListOfFunctions()->FindObject("gaus2");
}
makeplot(hp->GetName());
return 0;
} //end DrawT0refit()
/************************************************************
* Draw individual 1D histograms
* Histogram hname is read from the open ROOT file
************************************************************/
void Drawh1( const char *hname, const char *opt, const char *stat) {
// By using TH1 this works for TH1F, TH1D, etc
TH1 *hp = (TH1 *) gDirectory->Get(hname);
if( hp == 0 ) {
printf("Drawh1 ERROR: No histogram %s \n",hname);
return;
}
// Do not plot if no entries or RMS==0 (entries are all underflow/overflow)
if( hp->GetEntries() == 0 ) {
printf("Drawh1 WARNING: histogram %s no entries, skipping plot\n",hname);
return;
}
// Rename histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
gStyle->SetOptStat(stat);
// gStyle->SetStatX(1.0);
// gStyle->SetStatW(0.25);
// gStyle->SetStatY(1.0);
// gStyle->SetStatH(0.2);
// Reset various parameters of the histogram
hp->Draw(opt);
makeplot(hname);
return;
} //end Drawh1
/************************************************************
* Draw individual 2D histograms
************************************************************/
TH2F* Drawh2(const char *hname, const char *chopt, const char *xlab, const char *ylab, const char *chstat ) {
// By using TH2 this works for TH2F, TH2D, etc
TH2F *hp = (TH2F *) gDirectory->Get(hname);
if( hp == 0 ) {
printf("Drawh2 ERROR: No histogram %s\n",hname);
return 0;
}
Drawh2( hp, chopt, xlab, ylab, chstat );
return hp;
}
/************************************************************
* Draw individual 2D histograms
************************************************************/
void Drawh2( TH2F *hp, const char *chopt, const char *xlab, const char *ylab, const char *chstat ) {
// Skip non-existant & empty histograms
if( hp == 0 || hp->GetEntries() == 0. ) return;
// Rename histogram
if( plottitle[0] != '\0' ) {
hp->SetTitle(Form("%s %s",plottitle,hp->GetTitle()));
}
gStyle->SetOptStat(chstat);
// gStyle->SetStatX(1.0);
// gStyle->SetStatW(0.25);
// gStyle->SetStatY(1.0);
// gStyle->SetStatH(0.2);
// Reset various parameters of the histogram
if( xlab[0] != '\0' ) hp->GetXaxis()->SetTitle(xlab);
if( ylab[0] != '\0' ) hp->GetYaxis()->SetTitle(ylab);
hp->Draw(chopt);
makeplot(hp->GetName());
return;
}
// void TwoPlot( TH1 *h[], int inorm, const char *title ) {
// printf("TwoPlot inorm = %i \n",inorm);
// for( int i=0; i<2; i++ ) {
// if( h[i] ) {
// printf("TwoPlot segfault now histo %s\n",h[0]->GetName());
// } else {
// printf("h[%i] is null\n",i);
// }
// }
// gStyle->SetOptStat(0);