-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinaliseSystematicErrorsCalo_pPbV2.C
867 lines (770 loc) · 46.6 KB
/
FinaliseSystematicErrorsCalo_pPbV2.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
#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 FinaliseSystematicErrorsCalo_pPbV2( const char* 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 = 4,
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 SystematicErrorsCalculatedCalo");
gSystem->Exec(Form("mkdir -p SystematicErrorsCalculatedCalo/%s",additionalName2.Data()));
// ***************************************************************************************************
// ***************************** labeling and color settings *****************************************
// ***************************************************************************************************
TString date = ReturnDateString();
TString dateForOutput = ReturnDateStringForOutput();
TString collisionSystem = ReturnFullCollisionsSystem(energy);
TString detectionSystem = ReturnTextReconstructionProcess(4);
TString energyForOutput = energy;
energyForOutput.ReplaceAll(".","_");
// ***************************************************************************************************
// ******************************* general variable definition **************************************
// ***************************************************************************************************
Int_t numberOfEntriesPos = 0;
Int_t numberOfEntriesNeg = 0;
const Int_t nPtBins = numberOfPtBins;
const Int_t nCuts = numberCutStudies;
Double_t* ptBins = NULL;
Double_t* ptBinsErr = NULL;
TString nameCutVariation[12];
TString nameCutVariationSC[12];
Color_t color[20];
Style_t markerStyle[20];
TString nameCutVariationSCCurrent[12] = { "YieldExtraction", "OpeningAngle", "ClusterMinEnergy", "ClusterNCells", "ClusterNonLinearity",
"ClusterTrackMatchingCalo", "ClusterM02","ClusterMaterialTRD", "Rapidity", "ClusterEnergyScale",
"Efficiency", "YieldExtractionPi0"};
for (Int_t k = 0; k < 12; k++){
color[k] = GetColorSystematics( nameCutVariationSCCurrent[k], 4);
markerStyle[k] = GetMarkerStyleSystematics( nameCutVariationSCCurrent[k], 4);
}
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[12] = { 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0 };
Bool_t bsmoothMBPi0[12] = { 0, 0, 0, 1, 1,
0, 0, 1, 0, 1,
1, 1 };
Bool_t bsmoothMBEta[12] = { 0, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1 };
Bool_t bsmoothMBEtaToPi0[12] = { 0, 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){
bsmooth[i] = bsmoothMBPi0[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("Eta")==0){
bsmooth[i] = bsmoothMBEta[i];
} else if (additionalNameOutput.CompareTo("") == 0 && meson.CompareTo("EtaToPi0")==0){
bsmooth[i] = bsmoothMBEtaToPi0[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);
for (Int_t i = 0;i < nCuts;i++){
// read data
TGraphAsymmErrors* graphPosErrors;
TGraphAsymmErrors* graphNegErrors;
if (i == 0 || i == 3 || i == 4 || i == 9 || i==10 || (i!=11 && useMBSyst)){// || i == 8 || i == 9 || i == 10special treatment for Yield extraction error and calculated erros
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 == 11) { // 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());
}
cout << " graphPosErrors " << graphPosErrors << endl;
cout << " graphNegErrors " << graphNegErrors << endl;
// 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){
cout << "Yield extraction smoothing" << endl;
if (meson.CompareTo("Eta") == 0 || (meson.CompareTo("EtaToPi0") == 0 && i == 0) ){
for (Int_t k = 0;k < nPtBins;k++){
Double_t error;
if(ptBins[k]<4.5 && errorsMean[i][k] > 12.5){
error = 12.5;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
}
}
// manual smoothing for Yield extraction errors - variation 1
if (nameCutVariationSC[i].CompareTo("OpeningAngle") == 0){
cout << "Opening Angle smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error;
if(ptBins[k]<4){
error = 0.45;
}else{
error = 0.753156-0.237041*ptBins[k]+0.0327857*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 minimum cluster energy errors - variation 2
if (nameCutVariationSC[i].CompareTo("ClusterMinEnergy")==0 ){
cout << "Cluster minimum energy smoothing" << endl;
Double_t error = 0.5;
if (meson.CompareTo("Eta") == 0 ) error = error*3.;
if (meson.CompareTo("EtaToPi0") == 0 ) error = 2.;
for (Int_t k = 0;k < nPtBins;k++){
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 3
if (nameCutVariationSC[i].CompareTo("ClusterNCells")==0 ){
cout << "Cluster NCells smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 1.5;
if (meson.CompareTo("EtaToPi0") == 0 ) error = TMath::Sqrt(2.)*1.5;
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 4
if (nameCutVariationSC[i].CompareTo("ClusterNonLinearity")==0 ){//&& meson.Contains("Pi0")
cout << "Cluster non linearity smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 0.0104652+0.086*ptBins[k]+0.0032*ptBins[k]*ptBins[k];
if (meson.CompareTo("Eta") == 0 )
error = 2.5+0.086*ptBins[k]+0.01*ptBins[k]*ptBins[k];
if (meson.CompareTo("EtaToPi0") == 0 )
error = 2.5+0.086*ptBins[k]+0.01*ptBins[k]*ptBins[k];
error = TMath::Sqrt(error*error+0.95*0.95);//adding 0.95% error for timing cut
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for cluster matching errors - variation 5
if (nameCutVariationSC[i].CompareTo("ClusterTrackMatchingCalo")==0 ){
cout << "Cluster track matching smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 2.5+(+0.09)*ptBins[k];
if (meson.CompareTo("Eta") == 0)
error = error*1.5;
if( meson.CompareTo("EtaToPi0") == 0 )
error = error*1.5;
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 6
if (nameCutVariationSC[i].CompareTo("ClusterM02")==0 ){//&& meson.Contains("Pi0")
cout << "Cluster M02 smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 0.8+0.0191655*ptBins[k]+0.01*ptBins[k]*ptBins[k];
if( meson.CompareTo("EtaToPi0") == 0 )
error = TMath::Sqrt(2.)*error;
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 7
if (nameCutVariationSC[i].CompareTo("ClusterMaterialTRD")==0 ){
cout << "Material smoothing" << endl;
Double_t error = 4.24; //(3% for TRD mat, 3% for TOF mat added in quadrature)
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 energy scale errors (derived from mass difference MC & Data) - variation 8
if (nameCutVariationSC[i].CompareTo("ClusterEnergyScale")==0 ){//&& meson.Contains("Pi0")
cout << "Cluster non linearity smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 0.2*7.2;
if (meson.CompareTo("Eta") == 0)
error = 2* error;
if (meson.CompareTo("EtaToPi0") == 0)
error = 2* error;
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 9
if (nameCutVariationSC[i].CompareTo("Trigger") == 0){
cout << "Trigger smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 0.;
if (additionalNameOutput.CompareTo("")==0 )
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 10
if (nameCutVariationSC[i].CompareTo("Efficiency") == 0){
cout << "Efficiency smoothing" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 2.0;
if (meson.CompareTo("Eta") == 0) error = 4.0;
if (meson.CompareTo("EtaToPi0")== 0) error = TMath::Sqrt(2*2+4*4);
if(!additionalName.CompareTo("0-100%")==0) error += 2;
errorsMean[i][k] = error;
errorsMeanErr[i][k] = error*0.01;
errorsMeanCorr[i][k] = error;
errorsMeanErrCorr[i][k] = error*0.01;
}
}
// manual smoothing for Rapidity
if (nameCutVariationSC[i].CompareTo("Rapidity")==0 ){
cout << "Rapidity" << endl;
for (Int_t k = 0;k < nPtBins;k++){
Double_t error = 0.75;
if (meson.CompareTo("Eta") == 0 || meson.CompareTo("EtaToPi0") == 0)
error *= 2;
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
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] );
}
for (Int_t i = 0;i < nCuts;i++){
for (Int_t k = 0;k < nPtBins;k++){
cout << "nCuts " << i << " ptbin " << ptBins[k] << " error " << errorsMean[i][k] << endl;
}
}
// Error for inner material budget
Double_t errorMaterial = 0;
// 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 EMCal material errors
errorsPosCorrMatSummed[l] = pow(errorsPosCorrSummed[l]+ pow(errorMaterial ,2.),0.5);
errorsMeanCorrMatSummed[l] = pow(errorsMeanCorrSummed[l]+ pow(errorMaterial ,2.),0.5);
cout << " quad sum " << errorsMeanCorrMatSummed[l] << endl;
errorsNegCorrMatSummed[l] = -pow(errorsNegCorrSummed[l]+ pow(errorMaterial ,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 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;
}
Double_t widthLegend = 0.25;
if (numberCutStudies> 7)
widthLegend = 0.5;
Double_t heightLegend = 1.15 * 0.035 * (numberCutStudies+3);
if (numberCutStudies> 7)
heightLegend = 1.15 * 0.035 * (numberCutStudies/2+2);
// ***************************************************************************************************
// ****************************** 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.,20.);
} else {
histo2DSysErrMean = new TH2D("histo2DSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,0.,30.);
}
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> 7) legendMean->SetNColumns(2);
for(Int_t i = 0;i< numberCutStudies ;i++){
if ((additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") ==0 ) && i == 12){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
// if ( meson.CompareTo("Eta") == 0 && i == 1){
// cout << "not drawing: " << nameCutVariation[i].Data() << endl;
// continue;
// }
if ( meson.CompareTo("EtaToPi0") == 0 && 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");
cout << markerStyle[i] << "\t" << color[i] << endl;
}
legendMean->Draw();
// plot labeling
TLatex *labelMeson = NULL;
if (meson.CompareTo("EtaToPi0") == 0){
labelMeson= new TLatex(0.94,0.89,Form("#eta/#pi^{0} %s",detectionSystem.Data()));
} else if (meson.Contains("Pi0")){
labelMeson= new TLatex(0.94,0.89,Form("#pi^{0} %s",detectionSystem.Data()));
} else {
labelMeson= new TLatex(0.94,0.89,Form("#eta %s",detectionSystem.Data()));
}
SetStyleTLatex( labelMeson, 0.038, 4, 1, 42, kTRUE, 31);
labelMeson->Draw();
TLatex *labelCentrality = new TLatex(0.94,0.93,Form("%s %s",additionalName.Data(),collisionSystem.Data() ));
SetStyleTLatex( labelCentrality, 0.038, 4, 1, 42, kTRUE, 31);
labelCentrality->Draw();
TLatex *labelTrig = NULL;
if (additionalNameOutput.CompareTo("")==0){
labelTrig= new TLatex(0.94,0.84,Form("MB LHC13bc"));
}
SetStyleTLatex( labelTrig, 0.038, 4, 1, 42, kTRUE, 31);
labelTrig->Draw();
canvasSysErrMean->Update();
canvasSysErrMean->SaveAs(Form("SystematicErrorsCalculatedCalo/%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,24.5);
} else {
histo2DNewSysErrMean = new TH2D("histo2DNewSysErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,-0.5,34.5);
}
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> 7) legendMeanNew->SetNColumns(2);
for(Int_t i = 0;i< numberCutStudies ;i++){
cout << i << "\t"<< additionalNameOutput.Data() << endl;
if ((additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") ==0 ) && i == 12){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
}
/* if ( meson.CompareTo("Eta") == 0 && i == 1){
cout << "not drawing: " << nameCutVariation[i].Data() << endl;
continue;
} */
if ( meson.CompareTo("EtaToPi0") == 0 && i == 7){
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");
}
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();
canvasNewSysErrMean->Update();
canvasNewSysErrMean->SaveAs(Form("SystematicErrorsCalculatedCalo/%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();
histo2DNewSysErrMean->GetYaxis()->SetRangeUser(0,15.);
if (bsmooth[cut]) continue;
cout <<endl << endl<< "variation: " << cut << " \t"<< nameCutVariation[cut].Data() << endl;
Double_t minPt = 0.6;
Double_t maxPt = ptBins[nPtBins-2]+3;
if (meson.CompareTo("Eta") == 0) minPt = 2.6;
if (meson.CompareTo("Eta") == 0) maxPt = ptBins[nPtBins-2]+4;
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);
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");
TLegend* leg = new TLegend(0.6,0.6,0.8,0.9);
leg->AddEntry("pol0","pol0","l");
leg->AddEntry("pol1","pol1","l");
leg->AddEntry("pol2","pol2","l");
leg->AddEntry("pol4","pol4","l");
leg->Draw();
TLatex *varationLabel= new TLatex(0.40,0.8,Form("%s",nameCutVariationSCCurrent[cut].Data()));
SetStyleTLatex( varationLabel, 0.038, 4, 1, 42, kTRUE, 31);
varationLabel->Draw();
canvasNewSysErrMean->SaveAs(Form("SystematicErrorsCalculatedCalo/%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()));
histo2DNewSysErrMean->GetYaxis()->UnZoom();
}
// ***************************************************************************************************
// ********************* Create output files with errors *********************************************
// ***************************************************************************************************
const char *SysErrDatnameMean = Form("SystematicErrorsCalculatedCalo/%s/SystematicErrorAveragedEMCEMC_%s_%s%s_%s.dat",additionalName2.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("SystematicErrorsCalculatedCalo/%s/SystematicErrorAveragedSingleEMCEMC_%s_%s%s_%s.dat",additionalName2.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 << 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 << "\t" << errorsMeanCorrMatSummed[l] << endl;
}
SysErrDatAverSingle.close();
// ***************************************************************************************************
// ********************* Group errors according to topic *********************************************
// ***************************************************************************************************
Double_t errorsMeanCorrSignalExtraction[nPtBins];
Double_t errorsMeanCorrClusterEnergy[nPtBins];
Double_t errorsMeanCorrClusterDescription[nPtBins];
for (Int_t l=0;l< nPtBins;l++){
// "YieldExtraction"-0,"OpeningAngle"-1, "ClusterMinEnergy"-2, "ClusterNCells"-3, "NonLinearity"-4, "ClusterTrackMatchingCalo" -5, "ClusterM02" -6, "ClusterMaterialTRD" -7, "ClusterEnergyScale" -8
// grouping:
// Signal extraction: Yield extraction 0, Open-Angle 1
errorsMeanCorrSignalExtraction[l] = TMath::Sqrt(errorsMeanCorr[0][l]*errorsMeanCorr[0][l]+errorsMeanCorr[1][l]*errorsMeanCorr[1][l]);
// Signal extraction: NonLinearity 5 , Energy Scale 8
//errorsMeanCorrClusterEnergy[l] = TMath::Sqrt(errorsMeanCorr[4][l]*errorsMeanCorr[4][l]+errorsMeanCorr[8][l]*errorsMeanCorr[8][l]);
errorsMeanCorrClusterEnergy[l] = TMath::Sqrt(errorsMeanCorr[4][l]*errorsMeanCorr[4][l]);//+errorsMeanCorr[8][l]*errorsMeanCorr[8][l]);
// cluster description in MC: ClusterMinEnergy 2, ClusterNCells 3, ClusterM02 6
errorsMeanCorrClusterDescription[l] = TMath::Sqrt(errorsMeanCorr[2][l]*errorsMeanCorr[2][l]+errorsMeanCorr[3][l]*errorsMeanCorr[3][l]+errorsMeanCorr[6][l]*errorsMeanCorr[6][l]);
}
TGraphErrors* meanErrorsSignalExtraction = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrSignalExtraction ,ptBinsErr ,errorsMeanErrCorrSummed );
TGraphErrors* meanErrorsClusterDescrip = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrClusterDescription ,ptBinsErr ,errorsMeanErrCorrSummed );
TGraphErrors* meanErrorsClusterEnergy = new TGraphErrors(nPtBins,ptBins ,errorsMeanCorrClusterEnergy ,ptBinsErr ,errorsMeanErrCorrSummed );
// ***************************************************************************************************
// ********************* Plot grouped errors for better understanding ********************************
// ***************************************************************************************************
Double_t minXLegend2 = 0.13;
Double_t maxYLegend2 = 0.95;
if (meson.CompareTo("Eta") == 0){
minXLegend2 = 0.20;
}
Double_t widthLegend2 = 0.52;
Double_t heightLegend2 = 0.15;
TCanvas* canvasSummedErrMean = new TCanvas("canvasSummedErrMean","",200,10,1350,900);// gives the page size
DrawGammaCanvasSettings( canvasSummedErrMean, 0.08, 0.01, 0.015, 0.09);
// create dummy histo
TH2D *histo2DSummedErrMean ;
if (meson.Contains("Pi0") ){
histo2DSummedErrMean = new TH2D("histo2DSummedErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,-0.5,30.);
} else {
histo2DSummedErrMean = new TH2D("histo2DSummedErrMean", "", 20,0.,ptBins[nPtBins-1]+ptBinsErr[nPtBins-1],1000.,-0.5,30.);
}
SetStyleHistoTH2ForGraphs( histo2DSummedErrMean, "#it{p}_{T} (GeV/#it{c})", "mean smoothed systematic Err %", 0.03, 0.04, 0.03, 0.04,
1,0.9, 510, 510);
histo2DSummedErrMean->Draw();
// create legend
TLegend* legendSummedMeanNew = GetAndSetLegend2(minXLegend2,maxYLegend2-heightLegend2,minXLegend2+widthLegend2,maxYLegend2, 30);
legendSummedMeanNew->SetNColumns(2);
legendSummedMeanNew->SetMargin(0.1);
// 0 "YieldExtraction"
// 1 "OpeningAngle"
// 2 "ClusterMinEnergy"
// 3 "ClusterNCells"
// 4 "ClusterNonLinearity"
// 5 "ClusterTrackMatchingCalo"
// 6 "ClusterM02"
// 7 "ClusterMaterialTRD"
// 8 "Rapidity"
// 9 "ClusterEnergyScale"
// 10 "Efficiency"
// 11 "YieldExtractionPi0"
// Signal extraction error
DrawGammaSetMarkerTGraphErr(meanErrorsSignalExtraction, 20, 1.,color[0],color[0]);
meanErrorsSignalExtraction->Draw("pX0,csame");
// Cluster description in MC
DrawGammaSetMarkerTGraphErr(meanErrorsClusterDescrip, 22, 1.,color[1],color[1]);
// Track matching to EMCAL
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[5], 25, 1.,color[5],color[5]);
// Material infront of EMCAL
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[7], 21, 1.,color[7],color[7]);
// Cluster energy description
DrawGammaSetMarkerTGraphErr(meanErrorsClusterEnergy, 20, 1.,color[4],color[4]);
meanErrorsClusterEnergy->Draw("pX0,csame");
meanErrorsCorr[7]->Draw("pX0,csame");
meanErrorsCorr[5]->Draw("pX0,csame");
meanErrorsClusterDescrip->Draw("pX0,csame");
if (numberCutStudies>10){
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[10], 23, 1.,color[8],color[8]);
meanErrorsCorr[10]->Draw("pX0,csame");
}
if (numberCutStudies>9 && !(additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") ==0 )){
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[9], 25, 1.,color[6],color[6]);
meanErrorsCorr[9]->Draw("pX0,csame");
}
legendSummedMeanNew->AddEntry(meanErrorsSignalExtraction,"Signal Extraction","p");
legendSummedMeanNew->AddEntry(meanErrorsClusterDescrip,"Cluster Description","p");
legendSummedMeanNew->AddEntry(meanErrorsClusterEnergy,"Cluster Energy Description","p");
legendSummedMeanNew->AddEntry(meanErrorsCorr[5],"track match. to cluster","p");
legendSummedMeanNew->AddEntry(meanErrorsCorr[7],"Mat. infront of EMCal","p");
if (numberCutStudies>10) legendSummedMeanNew->AddEntry(meanErrorsCorr[10],"Efficiency","p");
if (numberCutStudies>9 && !(additionalNameOutput.CompareTo("") == 0 || additionalNameOutput.CompareTo("INT7") ==0 ))
legendSummedMeanNew->AddEntry(meanErrorsCorr[9],"Trigger normalization","p");
DrawGammaSetMarkerTGraphErr(meanErrorsCorrSummedIncMat, 20, 1.,kBlack,kBlack);
meanErrorsCorrSummedIncMat->Draw("p,csame");
legendSummedMeanNew->AddEntry(meanErrorsCorrSummedIncMat,"quad. sum.","p");
legendSummedMeanNew->Draw();
labelMeson->Draw();
labelCentrality->Draw();
labelTrig->Draw();
canvasSummedErrMean->Update();
canvasSummedErrMean->SaveAs(Form("SystematicErrorsCalculatedCalo/%s/SysErrorSummedVisu_%s_%s%s_%s.%s",additionalName2.Data(),meson.Data(), energyForOutput.Data(), additionalNameOutput.Data(), dateForOutput.Data(), suffix.Data()));
delete canvasSummedErrMean;
// const char *SysErrDatnameMeanPaper = Form("SystematicErrorsCalculatedConvCalo/SystematicErrorAveragedPaper_%s_%s%s_%s.dat", meson.Data(), energyForOutput.Data(), additionalNameOutput.Data(), dateForOutput.Data());
// fstream SysErrDatAverPaper;
// cout << SysErrDatnameMeanPaper << endl;
// SysErrDatAverPaper.open(SysErrDatnameMeanPaper, ios::out);
// SysErrDatAverPaper << "#it{p}_{T}" << "\t Material \t Yield Extraction \t PID \t photon reco \t track recon \t summed" << endl;
// for (Int_t l=0;l< nPtBins;l++){
// SysErrDatAverPaper << ptBins[l] <<"\t" << errorMaterial*2 << "\t" << errorsMeanCorrSignalExtraction[l] << "\t" << errorsMeanCorrPID[l]<< "\t" << errorsMeanCorrPhotonReco[l]<< "\t" <<errorsMeanCorrTrackReco[l] <<"\t" << errorsMeanCorrMatSummed[l]<< endl;
// }
//
// SysErrDatAverPaper.close();
}