-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinaliseSystematicErrorsConvCalo_PbPb.C
1135 lines (1029 loc) · 60.1 KB
/
FinaliseSystematicErrorsConvCalo_PbPb.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <Riostream.h>
#include <fstream>
#include "TMath.h"
#include <stdlib.h>
#include <fstream>
#include <math.h>
#include <TROOT.h>
#include <TApplication.h>
#include <TPaveLabel.h>
#include <TSystem.h>
#include <TFrame.h>
#include <TStyle.h>
#include <TString.h>
#include "TGaxis.h"
#include "TFile.h"
#include "TH1F.h"
#include "TH1D.h"
#include "TH2F.h"
#include "TF1.h"
#include "TVirtualFitter.h"
#include "TObject.h"
#include "TCanvas.h"
#include "TMultiGraph.h"
#include "TLegend.h"
#include "TDatabasePDG.h"
#include "TMinuit.h"
#include "TBenchmark.h"
#include "TRandom.h"
#include "TLatex.h"
#include "TASImage.h"
#include "TPostScript.h"
#include "TGraphErrors.h"
#include "TArrow.h"
#include "TGraphAsymmErrors.h"
#include "TGaxis.h"
#include "TMarker.h"
#include "CommonHeaders/PlottingGammaConversionHistos.h"
#include "CommonHeaders/PlottingGammaConversionAdditional.h"
#include "CommonHeaders/FittingGammaConversion.h"
#include "CommonHeaders/ConversionFunctionsBasicsAndLabeling.h"
#include "CommonHeaders/ConversionFunctions.h"
void FinaliseSystematicErrorsConvCalo_PbPb( TString nameDataFileErrors = "",
TString energy = "",
TString meson = "",
Int_t numberOfPtBins = 1,
Int_t numberCutStudies = 1,
Float_t startPtSys = 0,
TString additionalName = "pp",
TString additionalNameOutput = "",
TString suffix = "eps",
Int_t mode = 2,
Bool_t useMBSyst = kFALSE
){
// ***************************************************************************************************
// ****************************** General style settings *********************************************
// ***************************************************************************************************
StyleSettingsThesis();
SetPlotStyle();
// ***************************************************************************************************
// ****************************** Create output directory ********************************************
// ***************************************************************************************************
TString additionalName2 = additionalName;
if(additionalName.Contains("ZNA") || additionalName.Contains("CL1")) additionalName2.Replace(3,1,"_");
cout << additionalName2.Data() << endl;
gSystem->Exec("mkdir -p SystematicErrorsCalculatedConvCalo");
gSystem->Exec(Form("mkdir -p SystematicErrorsCalculatedConvCalo/%s",additionalName2.Data()));
gSystem->Exec(Form("mkdir -p SystematicErrorsCalculatedConvCalo/%s/full",additionalName2.Data()));
// ***************************************************************************************************
// ***************************** labeling and color settings *****************************************
// ***************************************************************************************************
TString date = ReturnDateString();
TString dateForOutput = ReturnDateStringForOutput();
TString collisionSystem = ReturnFullCollisionsSystem(energy);
TString detectionSystem = ReturnTextReconstructionProcess(mode);
TString energyForOutput = energy;
energyForOutput.ReplaceAll(".","_");
TString recoMethod = "";
if(mode == 2) recoMethod = "PCMEMC";
if(mode == 3) recoMethod = "PCMPHOS";
// ***************************************************************************************************
// ******************************* general variable definition **************************************
// ***************************************************************************************************
const Int_t nPtBins = numberOfPtBins;
const Int_t nCuts = numberCutStudies;
Double_t* ptBins = NULL;
Double_t* ptBinsErr = NULL;
TString nameCutVariation[19];
TString nameCutVariationSC[19];
TString nameCutVariationSCCurrent[19] = {"YieldExtraction", "dEdxE", "dEdxPi", "TPCCluster", "SinglePt",
"Chi2", "Qt", "Alpha", "ConvPhi", "ClusterMinEnergy",
"ClusterNCells", "ClusterNonLinearity", "ClusterTrackMatchingCalo", "ClusterM02", "CellTiming",
"ClusterMaterialTRD", "Trigger", "Efficiency", "YieldExtractionPi0"};
if(mode == 3) nameCutVariationSCCurrent[12] = "ClusterTrackMatching";
// 0 - "YieldExtraction",
// 1 - "dEdxE",
// 2 - "dEdxPi",
// 3 - "TPCCluster",
// 4 - "SinglePt",
// 5 - "Chi2",
// 6 - "Qt",
// 7 - "Alpha",
// 8 - "ConvPhi",
// 9 - "ClusterMinEnergy",
// 10 - "ClusterNCells",
// 11 - "ClusterNonLinearity",
// 12 - "ClusterTrackMatching",
// 13 - "ClusterM02",
// 14 - "CellTiming",
// 15 - "ClusterMaterialTRD",
// 16 - "Trigger",
// 17 - "Efficiency",
// 18 - "YieldExtractionPi0"
Color_t color[20];
Style_t markerStyle[20];
for (Int_t k = 0; k < 19; k++){
color[k] = GetColorSystematics( nameCutVariationSCCurrent[k], 2);
markerStyle[k] = GetMarkerStyleSystematics( nameCutVariationSCCurrent[k], 2);
}
for (Int_t i = 0; i < numberCutStudies; i++){
nameCutVariation[i] = GetSystematicsName(nameCutVariationSCCurrent[i]);
nameCutVariationSC[i] = nameCutVariationSCCurrent[i];
}
if (meson.CompareTo("EtaToPi0") == 0){
nameCutVariation[0] = "yield extraction #eta";
}
// ***************************************************************************************************
// ******************************** Booleans for smoothing *******************************************
// ***************************************************************************************************
Bool_t bsmooth[19] = { 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0 };
// minimum bias trigger PCM-EMC
Bool_t bsmoothMBPi0[19] = { 0, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
Bool_t bsmoothMBEta[19] = { 0, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
Bool_t bsmoothMBEtaToPi0[19] = { 0, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
// minimum bias trigger PCM-PHOS
Bool_t bsmoothMBPi0PCMPHOS[19] = { 0, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
// = { 0, 0, 0, 0, 0,
// 0, 0, 0, 1, 0,
// 0, 0, 0, 0, 1,
// 1, 1, 1, 0 };
Bool_t bsmoothMBEtaPCMPHOS[19] = { 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
Bool_t bsmoothMBEtaToPi0PCMPHOS[19]= { 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0 };
for (Int_t i = 0; i < numberCutStudies; i++){
if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("Pi0")==0 && mode == 2){
bsmooth[i] = bsmoothMBPi0[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("Pi0")==0 && mode == 3){
bsmooth[i] = bsmoothMBPi0PCMPHOS[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("Eta")==0 && mode == 2){
bsmooth[i] = bsmoothMBEta[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("Eta")==0 && mode == 3){
bsmooth[i] = bsmoothMBEtaPCMPHOS[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("EtaToPi0")==0 && mode == 2){
bsmooth[i] = bsmoothMBEtaToPi0[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("EtaToPi0")==0 && mode == 3){
bsmooth[i] = bsmoothMBEtaToPi0PCMPHOS[i];
}
}
// ***************************************************************************************************
// ****************************** Initialize error vectors & graphs **********************************
// ***************************************************************************************************
Double_t* errorsNeg [nCuts];
Double_t errorsNegCorr [nCuts][nPtBins];
Double_t errorsNegSummed [nPtBins];
Double_t errorsNegCorrSummed [nPtBins];
Double_t errorsNegCorrMatSummed [nPtBins];
Double_t* errorsNegErr [nCuts];
Double_t errorsNegErrCorr [nCuts][nPtBins];
Double_t errorsNegErrSummed [nPtBins];
Double_t errorsNegErrCorrSummed [nPtBins];
Double_t* errorsPos [nCuts];
Double_t errorsPosCorr [nCuts][nPtBins];
Double_t errorsPosSummed [nPtBins];
Double_t errorsPosCorrSummed [nPtBins];
Double_t errorsPosCorrMatSummed [nPtBins];
Double_t* errorsPosErr [nCuts];
Double_t errorsPosErrSummed [nPtBins];
Double_t errorsPosErrCorr [nCuts][nPtBins];
Double_t errorsPosErrCorrSummed [nPtBins];
Double_t errorsMean [nCuts][nPtBins];
Double_t errorsMeanCorr [nCuts][nPtBins];
Double_t errorsMeanSummed [nPtBins];
Double_t errorsMeanCorrSummed [nPtBins];
Double_t errorsMeanCorrMatSummed [nPtBins];
Double_t errorsMeanErr [nCuts][nPtBins];
Double_t errorsMeanErrCorr [nCuts][nPtBins];
Double_t errorsMeanErrSummed [nPtBins];
Double_t errorsMeanErrCorrSummed [nPtBins];
Double_t errorsMeanErrCorrMatSummed [nPtBins];
TGraphErrors* negativeErrors [nCuts];
TGraphErrors* positiveErrors [nCuts];
TGraphErrors* negativeErrorsCorr [nCuts];
TGraphErrors* positiveErrorsCorr [nCuts];
TGraphErrors* meanErrors [nCuts];
TGraphErrors* meanErrorsCorr [nCuts];
TGraphErrors* negativeErrorsSummed;
TGraphErrors* positiveErrorsSummed;
TGraphErrors* negativeErrorsCorrSummed;
TGraphErrors* positiveErrorsCorrSummed;
TGraphErrors* meanErrorsSummed;
TGraphErrors* meanErrorsCorrSummed;
TGraphErrors* meanErrorsCorrSummedIncMat;
for (Int_t l = 0; l < nPtBins; l++){
errorsPosSummed[l] = 0.;
errorsNegSummed[l] = 0.;
errorsMeanSummed[l] = 0.;
errorsPosCorrSummed[l] = 0.;
errorsNegCorrSummed[l] = 0.;
errorsMeanCorrSummed[l] = 0.;
}
// ***************************************************************************************************
// ****************************** Read & process data from file **************************************
// ***************************************************************************************************
TFile* fileErrorInput= new TFile(nameDataFileErrors.Data());
for (Int_t i = 0; i < nCuts; i++){
// read data
TGraphAsymmErrors* graphPosErrors;
TGraphAsymmErrors* graphNegErrors;
// YieldExtraction - 0, CellTiming - 14, Trigger - 16, Efficiency - 17
// if ( i == 0 || i == 8 || i == 14 || i == 15 || i == 16 || i == 17 || (i!=18 && useMBSyst)){
if ( i != 18 ){
TString nameGraphPos = "";
TString nameGraphNeg = "";
if ( meson.CompareTo("EtaToPi0") != 0 ){
nameGraphPos = Form("%s_SystErrorRelPos_YieldExtraction_%s",meson.Data(),additionalName.Data() );
nameGraphNeg = Form("%s_SystErrorRelNeg_YieldExtraction_%s",meson.Data(),additionalName.Data() );
} else {
nameGraphPos = Form("Eta_SystErrorRelPos_YieldExtraction_%s",additionalName.Data() );
nameGraphNeg = Form("Eta_SystErrorRelNeg_YieldExtraction_%s",additionalName.Data() );
}
cout << "Cutstudies " << i<< "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
} else if ( i == 18 ){ // special treatment for eta to pi0 ratio
TString nameGraphPos = Form("Pi0EtaBinning_SystErrorRelPos_YieldExtraction_%s",additionalName.Data() );
TString nameGraphNeg = Form("Pi0EtaBinning_SystErrorRelNeg_YieldExtraction_%s",additionalName.Data() );
cout << "Cutstudies " << i<< "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
} else { // read graphs from input file
TString nameGraphPos = Form("%s_SystErrorRelPos_%s%s",meson.Data(),nameCutVariationSC[i].Data(),additionalName.Data() );
TString nameGraphNeg = Form("%s_SystErrorRelNeg_%s%s",meson.Data(),nameCutVariationSC[i].Data(),additionalName.Data() );
cout << "Cutstudies " << i<< "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
}
// take out offsets
while (graphPosErrors->GetX()[0] < startPtSys){
graphPosErrors->RemovePoint(0);
graphNegErrors->RemovePoint(0);
}
// Filling arrays
if (i == 0) {
ptBins = graphNegErrors->GetX();
ptBinsErr = graphNegErrors->GetEXhigh();
}
errorsNeg[i] = graphNegErrors->GetY();
errorsNegErr[i] = graphNegErrors->GetEYhigh();
errorsPos[i] = graphPosErrors->GetY();
errorsPosErr[i] = graphPosErrors->GetEYhigh();
cout << nameCutVariationSC[i].Data() << endl;
// Averaging of upper and lower errors
CalculateMeanSysErr(errorsMean[i], errorsMeanErr[i], errorsPos[i], errorsNeg[i], nPtBins);
// Automatic smoothing of 0 bins according to adjoining bins
CorrectSystematicErrorsWithMean(errorsPos[i],errorsPosErr[i], errorsPosCorr[i], errorsPosErrCorr[i], nPtBins);
CorrectSystematicErrorsWithMean(errorsNeg[i],errorsNegErr[i], errorsNegCorr[i], errorsNegErrCorr[i], nPtBins);
CorrectSystematicErrorsWithMean(errorsMean[i], errorsMeanErr[i], errorsMeanCorr[i], errorsMeanErrCorr[i], nPtBins);
// Routing for manual smoothing of systematic errors
// ATTTENTION! you have to do this manually for each data set/trigger never trust the values mentioned here
if (bsmooth[i]){
// manual smoothing for Yield extraction errors - variation 0
if (nameCutVariationSC[i].CompareTo("YieldExtraction") == 0){
if ( meson.CompareTo("Pi0") == 0 ){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 0;
if (mode == 2 || mode == 3){
if (ptBins[k] < 1.2) continue;
error = 1.1 + 0.05*ptBins[k] + 0.02*ptBins[k]*ptBins[k];
} else{
error = 3.909 - 7.138e-01*ptBins[k] + 1.075e-01*ptBins[k]*ptBins[k];
}
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
} else {
if (mode == 2 || mode == 3){
for (Int_t k = 0; k < nPtBins; k++){
if (ptBins[k] < 2.2) continue;
Double_t error = 4.0+0.025*ptBins[k]*ptBins[k];
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
}
}
if (nameCutVariationSC[i].CompareTo("YieldExtractionPi0") == 0){
if (mode == 2 || mode == 3){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 1.0 + 0.06*ptBins[k] + 0.02*ptBins[k]*ptBins[k];
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
}
// manual smoothing for dEdx electron line errors - variation 1
if (nameCutVariationSC[i].CompareTo("dEdxE")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 3.95761 + -1.07724*ptBins[k] + 8.87406e-02*ptBins[k]*ptBins[k];
if(mode == 3) error = 1.03607;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for dEdx pion line errors - variation 2
if (nameCutVariationSC[i].CompareTo("dEdxPi")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 8.51266e-01 + -1.70473e-01*ptBins[k] + 4.64281e-02*ptBins[k]*ptBins[k];
if(mode == 3) error = 1.36726;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for TPC cluster related errors - variation 3
if (nameCutVariationSC[i].CompareTo("TPCCluster")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 7.58013e-01;
if(mode == 3) error = 7.36994e-02;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for single track momentum errors - variation 4
if (nameCutVariationSC[i].CompareTo("SinglePt")==0){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 9.80233e-01;
if(mode == 3) error = 5.13426e-01;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for chi2/psi pair photon errors - variation 5
if (nameCutVariationSC[i].CompareTo("Chi2")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 8.56494 + -2.42977*ptBins[k] + 2.27482e-01*ptBins[k]*ptBins[k];
if(ptBins[k]>4) error = 8.56494 + -2.42977*4 + 2.27482e-01*4*4;
if(mode == 3) error = 1.54987;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for Qt/alpha photon errors - variation 6
if (nameCutVariationSC[i].CompareTo("Qt")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 1.72241;
if(mode == 3) error = 9.11066e-01;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for alpha meson errors - variation 7
if (nameCutVariationSC[i].CompareTo("Alpha")==0 ){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 5.61092e-01;
if(mode == 3) error = 1.52109;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for conversion acceptance cuts - variation 8
if (nameCutVariationSC[i].CompareTo("ConvPhi")==0 ){
if ( meson.CompareTo("Pi0") == 0){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 0.;
if (mode == 2 || mode == 3){
if (additionalNameOutput.CompareTo("")==0 ){
error = 0.12+0.004*ptBins[k]*ptBins[k]; // parametrisation 2.76TeV
// error = 0.5; // parametrisation 2.76TeV
}
}
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
} else {
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 0.;
if (mode == 2 || mode == 3){
if (additionalNameOutput.CompareTo("")==0 ){
error = 200*pow(0.07,ptBins[k])+1.0+0.01*ptBins[k]*ptBins[k]; // parametrisation
}
}
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
}
// manual smoothing for minimum cluster energy errors - variation 9
if (nameCutVariationSC[i].CompareTo("ClusterMinEnergy")==0 ){
Double_t error = 0;
for (Int_t k = 0;k < nPtBins;k++){
error = 3.5/2.;
if (meson.Contains("Eta")) error *= 1.2 ;
if (mode == 3){
error = 6.05134 + -1.83321*ptBins[k] + 1.21437e-01*ptBins[k]*ptBins[k];
if ( ptBins[k] > 4. ) error = 6.05134 + -1.83321*4 + 1.21437e-01*4*4;
}
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for minimum number of cells in cluster errors - variation 10
if (nameCutVariationSC[i].CompareTo("ClusterNCells")==0 ){
cout << "Cluster NCells smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 1.5/2.;
if (meson.CompareTo("EtaToPi0") == 0 )
error = 0.5;
if (mode == 3) error = 2.0;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for energy calibration errors - variation 11
if (nameCutVariationSC[i].CompareTo("ClusterNonLinearity")==0 ){ //&& meson.Contains("Pi0")
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 4.97046;
if(meson.Contains("Eta")) error *= 1.2;
if (mode == 3) error = 3.03672;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for cluster V0 matching errors - variation 12
if (nameCutVariationSC[i].CompareTo("ClusterTrackMatchingCalo")==0 || nameCutVariationSC[i].CompareTo("ClusterTrackMatching")==0){
Double_t error = 0.;
for (Int_t k = 0; k < nPtBins; k++){
error = 1.52944 + -4.22995e-01*ptBins[k] + 6.41679e-02*ptBins[k]*ptBins[k];
if(meson.Contains("Eta")) error *= 1.2;
if (mode == 3) error = 3.04651;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = 0.01*error;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = 0.01*error;
}
}
// manual smoothing for cluster shape errors - variation 13
if (nameCutVariationSC[i].CompareTo("ClusterM02")==0 ){ //&& meson.Contains("Pi0")
cout << "Cluster M02 smoothing" << endl;
Double_t error = 0;
for (Int_t k = 0;k < nPtBins;k++){
error = (2.4+(0.01)*ptBins[k]*ptBins[k]);
if(additionalName.CompareTo("0-10%") == 0 || additionalName.CompareTo("0-5%") == 0 || additionalName.CompareTo("5-10%") == 0) error *= 1.4;
if(additionalName.CompareTo("10-30%") == 0 || additionalName.CompareTo("10-20%") == 0 || additionalName.CompareTo("20-30%") == 0 ) error *= 1.0;
if(additionalName.CompareTo("30-50%") == 0 || additionalName.CompareTo("30-40%") == 0 || additionalName.CompareTo("40-50%") == 0) error *= 0.8;
if(additionalName.CompareTo("50-90%") == 0 || additionalName.CompareTo("50-60%") == 0 || additionalName.CompareTo("60-70%") == 0 ||
additionalName.CompareTo("70-80%") == 0 || additionalName.CompareTo("80-90%") == 0 ) error *= 0.6;
if(meson.Contains("Eta")) error *= 1.2;
if (mode == 3){
// error = 1.06259e+01+-1.82800*ptBins[k]+0.1*ptBins[k]*ptBins[k];
// if( ptBins[k] > 9. ) error = 1.06259e+01+-1.82800*9.+0.1*9.*9.;
error = 4.57112 + -1.32271*ptBins[k] + 9.35700e-02*ptBins[k]*ptBins[k];
if ( ptBins[k] > 4. ) error = 4.57112 + -1.32271*4 + 9.35700e-02*4*4;
}
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for opening angle errors -
if (nameCutVariationSC[i].CompareTo("OpeningAngle")==0 ){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 0;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for cell timing of EMC - variation 14
if (nameCutVariationSC[i].CompareTo("CellTiming")==0 ){
Double_t error = 0.95;
for (Int_t k = 0;k < nPtBins;k++){
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for Material infront of EMC - variation 15
if (nameCutVariationSC[i].CompareTo("ClusterMaterialTRD")==0 ){
Double_t error = 2.8; //(2% for TRD mat, 2% for TOF mat added in quadrature)
if (mode == 3)
error = 2.5;
if (meson.CompareTo("EtaToPi0") == 0)
error = 0;// cancels fully for eta/pi0
for (Int_t k = 0;k < nPtBins;k++){
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for Trigger normalization uncertainties - variation 16
if (nameCutVariationSC[i].CompareTo("Trigger") == 0){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 0.;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for Efficiency uncertainties - variation 17
if (nameCutVariationSC[i].CompareTo("Efficiency") == 0){
for (Int_t k = 0; k < nPtBins; k++){
Double_t error = 3.0;
Double_t errorPi0 = 4.;
Double_t errorEta = 6.;
if (meson.CompareTo("EtaToPi0")==0){
error = TMath::Sqrt(2*2+5*5);
} else if (meson.CompareTo("Pi0")==0) {
error = errorPi0;
} else {
error = errorEta;
}
if(additionalName.CompareTo("0-5%") == 0 || additionalName.CompareTo("5-10%") == 0 ||
additionalName.CompareTo("0-10%") == 0 || additionalName.CompareTo("10-20%") == 0 ||
additionalName.CompareTo("20-30%") == 0 || additionalName.CompareTo("10-30%") == 0 ) error *= 1.4;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
} else {
for (Int_t k = 0; k < nPtBins; k++){
errorsMeanErr[i][k] = 0.03;
errorsMeanErrCorr[i][k] = 0.03;
}
}
// Quadratic sum of errors except material error infront of EMCal & inner material
if (!(nameCutVariationSC[i].CompareTo("ClusterMaterialTRD")==0)){
cout << "errors added quadratically" << endl;
for (Int_t l = 0; l < nPtBins; l++){
errorsPosSummed[l] = errorsPosSummed[l]+pow(errorsPos[i][l],2);
errorsNegSummed[l] = errorsNegSummed[l]+ pow(errorsNeg[i][l],2);
errorsMeanSummed[l] = errorsMeanSummed[l]+ pow(errorsMean[i][l],2);
errorsPosCorrSummed[l] = errorsPosCorrSummed[l]+pow(errorsPosCorr[i][l],2);
errorsNegCorrSummed[l] = errorsNegCorrSummed[l] +pow(errorsNegCorr[i][l],2);
errorsMeanCorrSummed[l] = errorsMeanCorrSummed[l]+ pow(errorsMeanCorr[i][l],2);
}
}
// fill error graphs for plotting
negativeErrors[i] = new TGraphErrors(nPtBins,ptBins ,errorsNeg[i] ,ptBinsErr ,errorsNegErr[i] );
meanErrors[i] = new TGraphErrors(nPtBins,ptBins ,errorsMean[i] ,ptBinsErr ,errorsMeanErr[i] );
positiveErrors[i] = new TGraphErrors(nPtBins,ptBins ,errorsPos[i] ,ptBinsErr ,errorsPosErr[i] );
negativeErrorsCorr[i] = new TGraphErrors(nPtBins,ptBins ,errorsNegCorr[i] ,ptBinsErr ,errorsNegErrCorr[i] );
meanErrorsCorr[i] = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorr[i] ,ptBinsErr ,errorsMeanErrCorr[i] );
positiveErrorsCorr[i] = new TGraphErrors(nPtBins,ptBins ,errorsPosCorr[i] ,ptBinsErr ,errorsPosErrCorr[i] );
}
// Error for inner material budget
Double_t errorMaterial = 4.50;
if (meson.CompareTo("EtaToPi0") == 0)
errorMaterial = 0.;
Int_t nMaterialError = -1;
for (Int_t j = 0; j < nCuts; j++){
if (nameCutVariationSC[j].CompareTo("ClusterMaterialTRD")==0)
nMaterialError = j;
}
if ( nMaterialError == -1) {
cout << "ERROR: couldn't find material error related to TRD, aborting" << endl;
return;
}
// Calculate sqrt of summed errors for final errors, add material budget errors
for (Int_t l = 0; l < nPtBins; l++){
errorsPosSummed[l] = pow(errorsPosSummed[l],0.5);
errorsMeanSummed[l] = pow(errorsMeanSummed[l],0.5);
errorsPosErrSummed[l] = errorsPosSummed[l]*0.001;
errorsMeanErrSummed[l] = errorsMeanSummed[l]*0.001;
errorsNegSummed[l] = -pow(errorsNegSummed[l],0.5);
errorsNegErrSummed[l] = errorsNegSummed[l]*0.001;
// add PCM & EMCal material errors
errorsPosCorrMatSummed[l] = pow(errorsPosCorrSummed[l]+ pow(errorMaterial ,2.) + pow(errorsPosCorr[nMaterialError][l],2) ,0.5);
errorsMeanCorrMatSummed[l] = pow(errorsMeanCorrSummed[l]+ pow(errorMaterial ,2.)+ pow(errorsMeanCorr[nMaterialError][l],2),0.5);
errorsNegCorrMatSummed[l] = -pow(errorsNegCorrSummed[l]+ pow(errorMaterial ,2.)+ pow(errorsNegCorr[nMaterialError][l],2),0.5);
errorsPosCorrSummed[l] = pow(errorsPosCorrSummed[l],0.5);
errorsMeanCorrSummed[l] = pow(errorsMeanCorrSummed[l],0.5);
errorsPosErrCorrSummed[l] = errorsPosCorrSummed[l]*0.001;
errorsMeanErrCorrSummed[l] = errorsMeanCorrSummed[l]*0.001;
errorsMeanErrCorrMatSummed[l] = errorsMeanCorrMatSummed[l]*0.001;
errorsNegCorrSummed[l] = -pow(errorsNegCorrSummed[l],0.5);
errorsNegErrCorrSummed[l] = errorsNegCorrSummed[l]*0.001;
}
// Create material graph
Double_t ptBinsMaterial [nPtBins];
Double_t errorsMat [nPtBins];
for (Int_t l = 0; l < nPtBins; l++){
errorsMat[l] = errorMaterial;
ptBinsMaterial[l] = ptBins[l]+0.05;
}
TGraphErrors* graphMaterialError = new TGraphErrors(nPtBins,ptBinsMaterial ,errorsMat ,ptBinsErr ,errorsMeanErrSummed );
// Create all other summed graphs
cout << __LINE__ << endl;
negativeErrorsSummed = new TGraphErrors(nPtBins,ptBins ,errorsNegSummed ,ptBinsErr ,errorsNegErrSummed );
negativeErrorsCorrSummed = new TGraphErrors(nPtBins,ptBins ,errorsNegCorrSummed ,ptBinsErr ,errorsNegErrCorrSummed );
positiveErrorsSummed = new TGraphErrors(nPtBins,ptBins ,errorsPosSummed ,ptBinsErr ,errorsPosErrSummed );
positiveErrorsCorrSummed = new TGraphErrors(nPtBins,ptBins ,errorsPosCorrSummed ,ptBinsErr ,errorsPosErrCorrSummed );
meanErrorsSummed = new TGraphErrors(nPtBins,ptBins ,errorsMeanSummed ,ptBinsErr ,errorsMeanErrSummed );
meanErrorsCorrSummed = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrSummed ,ptBinsErr ,errorsMeanErrCorrSummed );
meanErrorsCorrSummedIncMat = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrMatSummed ,ptBinsErr ,errorsMeanErrCorrMatSummed );
cout << __LINE__ << endl;
// Give legend position for plotting
Double_t minXLegend = 0.12;
Double_t maxYLegend = 0.95;
if (meson.CompareTo("Eta") == 0){
minXLegend = 0.23;
} else if (meson.CompareTo("EtaToPi0") == 0){
minXLegend = 0.18;
}
Double_t widthLegend = 0.25;
if (numberCutStudies> 9)
widthLegend = 0.5;
Double_t heightLegend = 1.02 * 0.035 * (numberCutStudies+1);
if (numberCutStudies> 9)
heightLegend = 1.02 * 0.035 * (numberCutStudies/2+1);
// ***************************************************************************************************
// ****************************** Plot all mean erros separately *************************************
// ***************************************************************************************************
TCanvas* canvasSysErrMean = new TCanvas("canvasSysErrMean","",200,10,1350,900);// gives the page size
DrawGammaCanvasSettings( canvasSysErrMean, 0.08, 0.01, 0.015, 0.09);
// create dummy histo
TH2D *histo2DSysErrMean ;
if ( meson.CompareTo("Pi0") == 0 ){
histo2DSysErrMean = new TH2D("histo2DSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,0.,30.);
} else {
histo2DSysErrMean = new TH2D("histo2DSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,0.,35.);
}
SetStyleHistoTH2ForGraphs( histo2DSysErrMean, "#it{p}_{T} (GeV/#it{c})", "mean systematic Err %", 0.03, 0.04, 0.03, 0.04,
1,0.9, 510, 510);
histo2DSysErrMean->Draw();
// create legend
TLegend* legendMean = GetAndSetLegend2(minXLegend,maxYLegend-heightLegend,minXLegend+widthLegend,maxYLegend, 30);
if (numberCutStudies> 9) legendMean->SetNColumns(2);
for(Int_t i = 0; i< numberCutStudies ; i++){
// ClusterMaterialTRD - 15, Trigger - 16
if ( meson.CompareTo("EtaToPi0") == 0 && (i == 15 || i == 16 || i == 14) ){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
// Trigger - 16
if ((additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") == 0 ) && i == 16){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
// Alpha - 7
if (!(additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") == 0 ) ) {
if ( i == 7 ){
cout << "not drawing: "<< nameCutVariation[i].Data() << endl;
continue;
}
}
DrawGammaSetMarkerTGraphErr(meanErrors[i], markerStyle[i], 1.,color[i],color[i]);
meanErrors[i]->Draw("pE0,csame");
legendMean->AddEntry(meanErrors[i],nameCutVariation[i].Data(),"p");
}
// PCM material error
if ( meson.CompareTo("EtaToPi0") != 0 ){
DrawGammaSetMarkerTGraphErr(graphMaterialError, 24, 1.,color[10],color[10]);
graphMaterialError->Draw("pX0,csame");
legendMean->AddEntry(graphMaterialError,"Inner Material","p");
}
legendMean->Draw();
// plot labeling
TLatex *labelMeson = NULL;
if (meson.CompareTo("EtaToPi0") == 0){
labelMeson= new TLatex(0.96,0.89,Form("#eta/#pi^{0} %s", detectionSystem.Data()));
} else if (meson.CompareTo("Pi0") == 0){
labelMeson= new TLatex(0.96,0.89,Form("#pi^{0} %s", detectionSystem.Data()));
} else {
labelMeson= new TLatex(0.96,0.89,Form("#eta %s", detectionSystem.Data()));
}
SetStyleTLatex( labelMeson, 0.038,4,1, 42, kTRUE, 31);
labelMeson->Draw();
TLatex *labelCentrality = new TLatex(0.96,0.93,Form("%s %s",additionalName.Data(),collisionSystem.Data() ));
SetStyleTLatex( labelCentrality, 0.038,4,1, 42, kTRUE, 31);
labelCentrality->Draw();
TLatex *labelTrig = NULL;
labelTrig= new TLatex(0.96,0.84,Form(""));
SetStyleTLatex( labelTrig, 0.038,4,1, 42, kTRUE, 31);
labelTrig->Draw();
canvasSysErrMean->Update();
canvasSysErrMean->SaveAs(Form("SystematicErrorsCalculatedConvCalo/%s/SysMean_%s_%s%s_%s.%s",additionalName2.Data(),meson.Data(), energyForOutput.Data(),additionalNameOutput.Data(),dateForOutput.Data(),suffix.Data()));
delete canvasSysErrMean;
// ***************************************************************************************************
// ********************* Plot all mean erros separately after smoothing ******************************
// ***************************************************************************************************
TCanvas* canvasNewSysErrMean = new TCanvas("canvasNewSysErrMean","",200,10,1350,900);// gives the page size
DrawGammaCanvasSettings( canvasNewSysErrMean, 0.08, 0.01, 0.015, 0.09);
// create dummy histo
TH2D *histo2DNewSysErrMean ;
if ( meson.CompareTo("Pi0") == 0 ){
histo2DNewSysErrMean = new TH2D("histo2DNewSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,-0.5,40.);
} else {
histo2DNewSysErrMean = new TH2D("histo2DNewSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,-0.5,70.);
}
SetStyleHistoTH2ForGraphs( histo2DNewSysErrMean, "#it{p}_{T} (GeV/#it{c})", "mean smoothed systematic Err %", 0.03, 0.04, 0.03, 0.04,
1,0.9, 510, 510);
histo2DNewSysErrMean->Draw();
// create legend
TLegend* legendMeanNew = GetAndSetLegend2(minXLegend,maxYLegend-heightLegend,minXLegend+widthLegend,maxYLegend, 30);
legendMeanNew->SetMargin(0.1);
if (numberCutStudies> 9) legendMeanNew->SetNColumns(2);
for(Int_t i = 0; i< numberCutStudies ; i++){
cout << i << "\t"<< additionalNameOutput.Data() << endl;
// Trigger - 16
if ((additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") ==0 ) && i == 16){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
// Alpha - 7
if (!(additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") == 0) ) {
if ( i == 7 ){
cout << "not drawing: "<< nameCutVariation[i].Data() << endl;
continue;
}
}
// ClusterMaterialTRD - 15, Trigger - 16
if ( meson.CompareTo("EtaToPi0") == 0 && (i == 15 || i == 16 || i == 14) ){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[i], markerStyle[i], 1.,color[i],color[i]);
meanErrorsCorr[i]->Draw("pX0,csame");
legendMeanNew->AddEntry(meanErrorsCorr[i],nameCutVariation[i].Data(),"p");
}
meanErrorsCorr[8]->Draw("pX0,csame");
// PCM material
if ( meson.CompareTo("EtaToPi0") != 0 ){
DrawGammaSetMarkerTGraphErr(graphMaterialError, GetMarkerStyleSystematics( "InnerMaterial", 2), 1.,GetColorSystematics( "InnerMaterial", 2),GetColorSystematics( "InnerMaterial", 2));
graphMaterialError->Draw("pX0,csame");
legendMeanNew->AddEntry(graphMaterialError,"Inner Material","p");
}
DrawGammaSetMarkerTGraphErr(meanErrorsCorrSummedIncMat, 20, 1.,kBlack,kBlack);
meanErrorsCorrSummedIncMat->Draw("p,csame");
legendMeanNew->AddEntry(meanErrorsCorrSummedIncMat,"quad. sum.","p");
legendMeanNew->Draw();
// labeling
labelMeson->Draw();
labelCentrality->Draw();
labelTrig->Draw();
meanErrorsCorr[0]->Draw("pX0,csame");
canvasNewSysErrMean->Update();
canvasNewSysErrMean->SaveAs(Form("SystematicErrorsCalculatedConvCalo/%s/SysMeanNewWithMean_%s_%s%s_%s.%s",additionalName2.Data(),meson.Data(), energyForOutput.Data(),additionalNameOutput.Data(),dateForOutput.Data(),suffix.Data()));
// ***************************************************************************************************
// ********************* Plot unsmoothed errors with fits ********************************************
// ***************************************************************************************************
for (Int_t cut =0 ; cut < numberCutStudies; cut++ ){
canvasNewSysErrMean->cd();
histo2DNewSysErrMean->Draw();
if (bsmooth[cut]) continue;
cout <<endl << endl<< "variation: " << cut << " \t"<< nameCutVariation[cut].Data() << endl;
Double_t minPt = startPtSys;
// if (additionalNameOutput.CompareTo("EMC1")==0) minPt = 2.6;
Double_t maxPt = ptBins[nPtBins-2]+1;
// if (cut == 13) maxPt = 6;
// if (cut == 12 || cut == 5) maxPt = 8;
// if (cut == 6) maxPt = 8;
TF1* pol0 = new TF1("pol0","[0]",minPt,maxPt); //
TF1* pol1 = new TF1("pol1","[0]+[1]*x",minPt,maxPt); //
TF1* pol2 = new TF1("pol2","[0]+[1]*x+[2]*x*x",minPt,maxPt); //
TF1* pol4 = new TF1("pol4","[0]+[1]*x+[2]*x*x+[3]*x*x*x*x",minPt,maxPt); //
pol4->SetParLimits(3,0,10);
if (cut == 13) pol2->SetParLimits(2,0,0.1);
meanErrorsCorr[cut]->Fit(pol4,"NRMEX0+","",minPt,maxPt);
meanErrorsCorr[cut]->Fit(pol2,"NRMEX0+","",minPt,maxPt);
meanErrorsCorr[cut]->Fit(pol1,"NRMEX0+","",minPt,maxPt);
meanErrorsCorr[cut]->Fit(pol0,"NRMEX0+","",minPt,maxPt);
pol4->SetLineColor(kRed+2);
pol2->SetLineColor(kBlue+2);
pol1->SetLineColor(kCyan+2);
pol0->SetLineColor(kBlack);
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[cut], 20+cut, 1.,color[cut],color[cut]);
meanErrorsCorr[cut]->Draw("p,csame");
pol4->Draw("same");
pol2->Draw("same");
pol1->Draw("same");
pol0->Draw("same");
canvasNewSysErrMean->SaveAs(Form("SystematicErrorsCalculatedConvCalo/%s/SysMeanNewWithMeanSingle_%s_%s%s_%s_Variation%d_%s.%s",additionalName2.Data(),meson.Data(), energyForOutput.Data(),additionalNameOutput.Data(),dateForOutput.Data(),cut,nameCutVariationSCCurrent[cut].Data(),suffix.Data()));
}
// ***************************************************************************************************
// ********************* Create output files with errors *********************************************
// ***************************************************************************************************
const char *SysErrDatnameMean = Form("SystematicErrorsCalculatedConvCalo/%s/SystematicErrorAveraged%s_%s_%s%s_%s.dat",additionalName2.Data(),recoMethod.Data(),meson.Data(),energyForOutput.Data(),additionalNameOutput.Data(),dateForOutput.Data());
fstream SysErrDatAver;
cout << SysErrDatnameMean << endl;
SysErrDatAver.open(SysErrDatnameMean, ios::out);
for (Int_t l=0; l< nPtBins; l++){
SysErrDatAver << ptBins[l] << "\t" << "-"<< errorsMeanCorrMatSummed[l] << "\t" <<errorsMeanCorrMatSummed[l] << "\t" << "-"<< errorsMeanCorrSummed[l] << "\t" <<errorsMeanCorrSummed[l] << endl;
}
SysErrDatAver.close();
const char *SysErrDatnameMeanSingleErr = Form("SystematicErrorsCalculatedConvCalo/%s/full/SystematicErrorAveragedSingle%s_%s_%s%s_%s.dat",additionalName2.Data(),recoMethod.Data(),meson.Data(),energyForOutput.Data(),additionalNameOutput.Data(),dateForOutput.Data());
fstream SysErrDatAverSingle;
cout << SysErrDatnameMeanSingleErr << endl;
SysErrDatAverSingle.open(SysErrDatnameMeanSingleErr, ios::out);
SysErrDatAverSingle << "Pt bin\t" ;
for (Int_t i= 0; i< numberCutStudies; i++){
SysErrDatAverSingle << nameCutVariationSC[i] << "\t";
}
SysErrDatAverSingle << "InnerMaterial" << endl;
for (Int_t l=0;l< nPtBins;l++){
SysErrDatAverSingle << ptBins[l] << "\t";
for (Int_t i= 0; i< numberCutStudies; i++){
SysErrDatAverSingle << errorsMeanCorr[i][l] << "\t";
}
SysErrDatAverSingle << errorsMat[l] << "\t" << errorsMeanCorrMatSummed[l] << endl;
}
SysErrDatAverSingle.close();
// ***************************************************************************************************
// ********************* Group errors according to topic *********************************************
// ***************************************************************************************************
Double_t errorsMeanCorrPID[nPtBins];
Double_t errorsMeanCorrSignalExtraction[nPtBins];
Double_t errorsMeanCorrTrackReco[nPtBins];
Double_t errorsMeanCorrPhotonReco[nPtBins];
Double_t errorsMeanCorrClusterDescription[nPtBins];
for (Int_t l=0; l< nPtBins; l++){
// "YieldExtraction"-0,"dEdxE"-1,"dEdxPi"-2, "TPCCluster"-3, "SinglePt"-4, "Chi2"-5, "Qt"-6, "Alpha"-7, "ConvPhi"-8, "ClusterMinEnergy"-9, "ClusterNCells"-10,
// "NonLinearity"-11, "ClusterTrackMatching" -12, "ClusterM02" -13, "CellTiming" -14,"ClusterMaterialTRD" -15
// grouping:
// Signal extraction: Yield extraction 0, Alpha 7
if (numberCutStudies>8){
errorsMeanCorrSignalExtraction[l] = TMath::Sqrt(errorsMeanCorr[0][l]*errorsMeanCorr[0][l]+errorsMeanCorr[7][l]*errorsMeanCorr[7][l]);
} else {
errorsMeanCorrSignalExtraction[l] = TMath::Sqrt(errorsMeanCorr[0][l]*errorsMeanCorr[0][l]);
}
if (meson.CompareTo("EtaToPi0") == 0){
errorsMeanCorrSignalExtraction[l] = TMath::Sqrt(errorsMeanCorr[0][l]*errorsMeanCorr[0][l]+errorsMeanCorr[7][l]*errorsMeanCorr[7][l]+errorsMeanCorr[18][l]*errorsMeanCorr[18][l]);
}
// PID: dEdxE 1, dEdxPi 2
errorsMeanCorrPID[l] =TMath::Sqrt(errorsMeanCorr[1][l]*errorsMeanCorr[1][l]+ errorsMeanCorr[2][l]*errorsMeanCorr[2][l]);
// photon reco: Chi2 5, Qt 6
errorsMeanCorrPhotonReco[l] =TMath::Sqrt( errorsMeanCorr[5][l]* errorsMeanCorr[5][l]+errorsMeanCorr[6][l]*errorsMeanCorr[6][l]);
// track reconstruction: TPCCluster 3, Single pt 4, ConvPhi 8
errorsMeanCorrTrackReco[l] = TMath::Sqrt(errorsMeanCorr[3][l]*errorsMeanCorr[3][l]+errorsMeanCorr[4][l]*errorsMeanCorr[4][l]+errorsMeanCorr[8][l]*errorsMeanCorr[8][l]);
// cluster description in MC: ClusterMinEnergy 9, ClusterNCells 10, ClusterM02 13
errorsMeanCorrClusterDescription[l] = TMath::Sqrt(errorsMeanCorr[9][l]*errorsMeanCorr[9][l]+errorsMeanCorr[10][l]*errorsMeanCorr[10][l]+errorsMeanCorr[13][l]*errorsMeanCorr[13][l]);
}
TGraphErrors* meanErrorsPID = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrPID ,ptBinsErr ,errorsMeanErrCorrSummed );
TGraphErrors* meanErrorsPhotonReco = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrPhotonReco ,ptBinsErr ,errorsMeanErrCorrSummed );
TGraphErrors* meanErrorsSignalExtraction = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrSignalExtraction ,ptBinsErr ,errorsMeanErrCorrSummed );