-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinaliseSystematicErrorsConvCalo_Gammas_pp.C
1184 lines (1080 loc) · 63.2 KB
/
FinaliseSystematicErrorsConvCalo_Gammas_pp.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
// ------------------------------------------------
// This code finalizes the systematic errors for --
// the direct photon analysis. Gamma spectrum as --
// well as double ratio systematics are produced --
// ------------------------------------------------
// Code is maintained by: --
// - Friederike Bock --
// for the Photon Conversion Group --
// ------------------------------------------------
#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"
//*************************************************************************************************************
//*********** Main function to calculate gamma errors for conversion measurements in pp collisions ************
//*************************************************************************************************************
void FinaliseSystematicErrorsConvCalo_Gammas_pp ( TString nameDataFileErrors = "",
TString energy = "",
TString spectrumName = "",
Int_t numberCutStudies = 1,
Double_t minPt = 0,
Double_t maxPt = 10,
TString suffix = "pdf",
Int_t mode = 0
){
//**************************************************************
// Set plotting style and labels
StyleSettingsThesis();
SetPlotStyle();
Double_t textSizeSpectra = 0.04;
TString date = ReturnDateString();
TString collisionSystem = ReturnFullCollisionsSystem(energy);
TString detectionProcess = ReturnFullTextReconstructionProcess(0);
TString detectionProcessPi0 = ReturnTextReconstructionProcess(41);
TString dateForOutput = ReturnDateStringForOutput();
TString energyForOutput = ReturnCollisionEnergyOutputString(energy);
TLatex *labelGamma = new TLatex(0.95,0.88,detectionProcess);
SetStyleTLatex( labelGamma, 0.038,4);
labelGamma->SetTextAlign(31);
TLatex *labelPi0 = new TLatex(0.95,0.84,detectionProcessPi0);
SetStyleTLatex( labelPi0, 0.038,4);
labelPi0->SetTextAlign(31);
Double_t posYLabel = 0.84;
if(!spectrumName.CompareTo("IncRatio") || !spectrumName.CompareTo("DoubleRatio"))
posYLabel = posYLabel-0.04;
TLatex *labelEnergy = new TLatex(0.95,0.92,collisionSystem);
SetStyleTLatex( labelEnergy, 0.038,4);
labelEnergy->SetTextAlign(31);
TLatex *labelSpectrum = 0x0;
if(!spectrumName.CompareTo("IncRatio"))
labelSpectrum = new TLatex(0.95,posYLabel,"#gamma_{inc}/#pi^{0}");
if(!spectrumName.CompareTo("DoubleRatio"))
labelSpectrum = new TLatex(0.95,posYLabel,"R_{#gamma}");
if(!spectrumName.CompareTo("Gamma"))
labelSpectrum = new TLatex(0.95,posYLabel,"#gamma_{inc}");
SetStyleTLatex( labelSpectrum, 0.038,4);
labelSpectrum->SetTextAlign(31);
//**************************************************************
// setup to read different error sources from root file
Int_t numberOfEntriesPos = 0;
Int_t numberOfEntriesNeg = 0;
// read root file with different cutvariations
TFile* fileErrorInput = new TFile(nameDataFileErrors.Data());
const Int_t nPtBins = 60;
Int_t nPtBinsActive = 60;
const Int_t nCuts = numberCutStudies;
Int_t nCutsActive = nCuts;
Double_t* ptBins = 0;
Double_t* ptBinsErr = 0;
Double_t yRangesSysPlotting[2] = {-0.5,24.9};
if (energy.CompareTo("pPb_5.023TeV") == 0 ){
if (spectrumName.Contains("Gamma"))
yRangesSysPlotting[1] = 15.5;
else if (spectrumName.Contains("IncRatio"))
yRangesSysPlotting[1] = 20.5;
else
yRangesSysPlotting[1] = 20.5;
}
// Set names of cut variations for file input
TString nameCutVariationSC[24] = { "dEdxE", "dEdxPi","TPCCluster", "SinglePt", "Chi2",
"Qt" , "CosPoint", "ToCloseV0s", "ConvPhi", "ClusterNonLinearity",
"ClusterM02", "ClusterMinEnergy", "ClusterTrackMatching", "ClusterTiming", "ClusterNCells",
"ClusterMaterialTRD", "OOBPileupGamma", "SPD", "BG","Alpha" ,
"Cocktail", "Material", "IntRange", "Efficiency"
};
// Set colors and markers
Color_t color[24];
Color_t markerStyle[24];
// Set names of cut variations for legends
TString nameCutVariation[24];
for (Int_t k =0; k<nCuts; k++ ){
cout << "variation: " << nameCutVariationSC[k].Data() << endl;
color[k] = GetColorSystematics( nameCutVariationSC[k] );
markerStyle[k] = GetMarkerStyleSystematics( nameCutVariationSC[k] );
nameCutVariation[k] = GetSystematicsName(nameCutVariationSC[k]);
cout << "name for writing: " << nameCutVariation[k].Data() << "\t"<< color[k] << "\t" << markerStyle[k] << endl;
}
// Create output folder
gSystem->Exec("mkdir -p GammaSystematicErrorsCalculated");
// ***************************************************************************************************
// ******************************** Booleans for enabling systematic errors **************************
// ***************************************************************************************************
Bool_t benable[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 };
Bool_t benableIncGamma2760GeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
0, 1, 0, 0 };
Bool_t benableIncRatio2760GeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
0, 0, 1, 1 };
Bool_t benableDR2760GeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
1, 0, 1, 1 };
Bool_t benableIncGamma8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
1, 1, 0, 1 };
Bool_t benableIncRatio8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1, 0, 1, 1 };
Bool_t benableDR8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1, 0, 1, 1 };
// ***************************************************************************************************
// ******************************** Booleans for smoothing *******************************************
// ***************************************************************************************************
Bool_t bsmooth[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 };
Bool_t bsmoothIncGamma2760GeV[24] = { 1, 1, 0, 0, 1, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
0, 1, 0, 1 };
Bool_t bsmoothIncRatio2760GeV[24] = { 1, 1, 0, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
0, 0, 0, 1 };
Bool_t bsmoothDR2760GeV[24] = { 1, 1, 0, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
0, 0, 0, 1 };
Bool_t bsmoothIncGamma8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
0, 1, 0, 1 };
Bool_t bsmoothIncRatio8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
0, 0, 1, 1 };
Bool_t bsmoothDR8TeV[24] = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1, 0, 1, 1 };
for (Int_t i = 0; i < numberCutStudies; i++){
if (energy.CompareTo("2.76TeV") == 0){
if(!spectrumName.CompareTo("IncRatio")){
bsmooth[i] = bsmoothIncRatio2760GeV[i];
benable[i] = benableIncRatio2760GeV[i];
} else if(!spectrumName.CompareTo("DoubleRatio")){
bsmooth[i] = bsmoothDR2760GeV[i];
benable[i] = benableDR2760GeV[i];
} else if(!spectrumName.CompareTo("Gamma")){
bsmooth[i] = bsmoothIncGamma2760GeV[i];
benable[i] = benableIncGamma2760GeV[i];
}
} else if (energy.CompareTo("8TeV") == 0){
if(!spectrumName.CompareTo("IncRatio")){
bsmooth[i] = bsmoothIncRatio8TeV[i];
benable[i] = benableIncRatio8TeV[i];
} else if(!spectrumName.CompareTo("DoubleRatio")){
bsmooth[i] = bsmoothDR8TeV[i];
benable[i] = benableDR8TeV[i];
} else if(!spectrumName.CompareTo("Gamma")){
bsmooth[i] = bsmoothIncGamma8TeV[i];
benable[i] = benableIncGamma8TeV[i];
}
}
if (!benable[i]) nCutsActive--;
}
// ***************************************************************************************************
// ****************************** 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* negativeErrorsSummed;
TGraphErrors* positiveErrors[nCuts];
TGraphErrors* positiveErrorsSummed;
TGraphErrors* negativeErrorsCorr[nCuts];
TGraphErrors* negativeErrorsCorrSummed;
TGraphErrors* positiveErrorsCorr[nCuts];
TGraphErrors* positiveErrorsCorrSummed;
TGraphErrors* meanErrors[nCuts];
TGraphErrors* meanErrorsSummed;
TGraphErrors* meanErrorsCorr[nCuts];
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.;
}
for (Int_t i = 0; i < nCuts; i++){
if (!benable[i]) {
cout << "*****************************************************************" << endl;
cout << "skipping: " << nameCutVariationSC[i].Data() << endl;
cout << "*****************************************************************" << endl;
for (Int_t l = 0; l < nPtBins; l++){
errorsMean[i][l] = 0;
errorsMeanErr[i][l] = 0.0;
errorsMeanCorr[i][l] = 0;
errorsMeanErrCorr[i][l] = 0.0;
}
continue;
}
TGraphAsymmErrors* graphPosErrors = NULL;
TGraphAsymmErrors* graphNegErrors = NULL;
// Set currently undetermined uncertainties
if ( nameCutVariationSC[i].CompareTo("SPD")==0 || nameCutVariationSC[i].CompareTo("Material")==0 || nameCutVariationSC[i].CompareTo("Efficiency")==0){
TString nameGraphPos;
TString nameGraphNeg;
nameGraphPos = Form("%s_SystErrorRelPos_%s_pp",spectrumName.Data(),nameCutVariationSC[0].Data());
nameGraphNeg = Form("%s_SystErrorRelNeg_%s_pp",spectrumName.Data(),nameCutVariationSC[0].Data());
cout << "Cutstudies " << i << "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< "\t fixing" << endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
} else if ( nameCutVariationSC[i].CompareTo("OOBPileupGamma")==0 ){
TString nameGraphPos = Form("Gamma_SystErrorRelPos_%s_pp",nameCutVariationSC[i].Data());
TString nameGraphNeg = Form("Gamma_SystErrorRelNeg_%s_pp",nameCutVariationSC[i].Data());
cout << "Cutstudies " << i << "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
} else {
// Load input graphs from systematics file
TString nameGraphPos = Form("%s_SystErrorRelPos_%s_pp",spectrumName.Data(),nameCutVariationSC[i].Data());
TString nameGraphNeg = Form("%s_SystErrorRelNeg_%s_pp",spectrumName.Data(),nameCutVariationSC[i].Data());
cout << "Cutstudies " << i<< "\t" <<nameGraphPos.Data() << "\t" << nameGraphNeg.Data()<< endl;
graphPosErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphPos.Data());
graphNegErrors = (TGraphAsymmErrors*)fileErrorInput->Get(nameGraphNeg.Data());
}
// Remove first points depending on chosen offset
while (graphPosErrors->GetX()[0] < minPt ){
graphPosErrors->RemovePoint(0);
graphNegErrors->RemovePoint(0);
}
while (graphPosErrors->GetX()[graphPosErrors->GetN()-1] > maxPt){
graphPosErrors->RemovePoint(graphPosErrors->GetN()-1);
graphNegErrors->RemovePoint(graphNegErrors->GetN()-1);
}
if (i == 0) {
nPtBinsActive = graphNegErrors->GetN();
ptBins = graphNegErrors->GetX();
ptBinsErr = graphNegErrors->GetEXhigh();
}
errorsNeg[i] = graphNegErrors->GetY();
errorsNegErr[i] = graphNegErrors->GetEYhigh();
errorsPos[i] = graphPosErrors->GetY();
errorsPosErr[i] = graphPosErrors->GetEYhigh();
// Calculate systematic error from input spectrum
cout << nameCutVariationSC[i].Data() << endl;
CalculateMeanSysErr( errorsMean[i], errorsMeanErr[i], errorsPos[i], errorsNeg[i], nPtBinsActive);
CorrectSystematicErrorsWithMean(errorsPos[i], errorsPosErr[i], errorsPosCorr[i], errorsPosErrCorr[i], nPtBinsActive);
CorrectSystematicErrorsWithMean(errorsNeg[i], errorsNegErr[i], errorsNegCorr[i], errorsNegErrCorr[i], nPtBinsActive);
CorrectSystematicErrorsWithMean(errorsMean[i], errorsMeanErr[i], errorsMeanCorr[i], errorsMeanErrCorr[i], nPtBinsActive);
// ***************************************************************************************************
// ************************ Adjust errors if requested to fixed values *******************************
// ***************************************************************************************************
if (bsmooth[i]){
cout << "smoothing on" << endl;
Double_t errorFixed = -1;
Bool_t adjustPtDependent = kFALSE;
// fix dEdx e error #0
if (!nameCutVariationSC[i].CompareTo("dEdxE")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if (spectrumName.Contains("Ratio")){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k]>1.5){
errorFixed = 0.2+pow(ptBins[k],1.9)*0.04;
}
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.1;
}
} else {
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k]>2.0)
errorFixed = 0.05+pow(ptBins[k],1.8)*0.04;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.05;
}
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// fix dEdxPi sys #1
if (!nameCutVariationSC[i].CompareTo("dEdxPi")){
if (spectrumName.Contains("Ratio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.15+pow(ptBins[k],2.6)*0.02+0.01*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
if(ptBins[k]>=1.8) errorFixed = 0.8;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
} else {
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.6){
errorFixed = 0.3+pow(ptBins[k],2.2)*0.012+0.001*ptBins[k];
}
}else if(!energy.CompareTo("8TeV")){
if(ptBins[k]>=1.8) errorFixed = 0.6;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
}
// fix Single pt sys #3
if (!nameCutVariationSC[i].CompareTo("TPCCluster")){
if (spectrumName.Contains("Ratio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.05+pow(ptBins[k],1.5)*0.02+0.1*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.05;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
} else {
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.05;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.05;
}
}
}
// fix Single pt sys #2
if (!nameCutVariationSC[i].CompareTo("SinglePt")){
if (spectrumName.Contains("Ratio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.2)
errorFixed = 1.3;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.2;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
} else {
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.15;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.1;
}
}
}
// fix Chi2/psi pair uncertainties #4
if (!nameCutVariationSC[i].CompareTo("Chi2")){
if (spectrumName.Contains("Ratio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.2)
errorFixed = 0.5+pow(ptBins[k],2.1)*0.012+0.02*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.8;
if(ptBins[k]>4.) errorFixed += 0.1*(ptBins[k]-4.);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
} else {
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.2+pow(ptBins[k],1.8)*0.07+0.03*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 1.2;
if(ptBins[k]>4.) errorFixed += 0.05*(ptBins[k]-4.);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
}
// fix Qt sys #5
if (!nameCutVariationSC[i].CompareTo("Qt")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if (spectrumName.Contains("Ratio")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.25+pow(ptBins[k],1.5)*0.08+0.02*ptBins[k]*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.1;
if(ptBins[k]>3.) errorFixed += 0.01*(ptBins[k]-3.)*(ptBins[k]-3.) + 0.02*(ptBins[k]-3.);
}
} else {
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.15+pow(ptBins[k],2.3)*0.02+0.04*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.1;
if(ptBins[k]>3.) errorFixed += 0.02*(ptBins[k]-3.)*(ptBins[k]-3.) + 0.04*(ptBins[k]-3.);
}
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// 6 "CosPoint"
// 7 "ToCloseV0s"
// fix ConvPhi pileup sys #8
if (!nameCutVariationSC[i].CompareTo("ConvPhi")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.8;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.5;
}
}
// 9 "ClusterNonLinearity"
if (!nameCutVariationSC[i].CompareTo("ClusterNonLinearity")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBins; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 2.+(0.01)*ptBins[k]+(0.01)*ptBins[k]*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 1.8+25./pow(10,ptBins[k]);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// 10 "ClusterM02"
if (!nameCutVariationSC[i].CompareTo("ClusterM02")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBins; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 1.8+(0.01)*ptBins[k]+(0.07)*ptBins[k]*ptBins[k];
}else if(!energy.CompareTo("8TeV")){
errorFixed = 2.0;
if(ptBins[k]>3.) errorFixed += (0.1)*(ptBins[k]-3.);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// 11 "ClusterMinEnergy"
if (!nameCutVariationSC[i].CompareTo("ClusterMinEnergy")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBins; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 1.4;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.75+20/pow(10,ptBins[k]);;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// 12 "ClusterTrackMatching"
if (!nameCutVariationSC[i].CompareTo("ClusterTrackMatching")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBins; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.4)
errorFixed = 1.2+(0.014)*ptBins[k]+(0.09)*ptBins[k]*ptBins[k]; // parametrisation
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.2;
if(ptBins[k]>=4) errorFixed += 2E-3*(ptBins[k]-4)*(ptBins[k]-4)+0.25*(ptBins[k]-4);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// fix ClusterTiming pileup sys #13
if (!nameCutVariationSC[i].CompareTo("ClusterTiming")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.6;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.7;
}
}
// 14 "ClusterNCells"
if (!nameCutVariationSC[i].CompareTo("ClusterNCells")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.5;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.5;
}
}
// fix ClusterMaterialTRD sys #15
if (!nameCutVariationSC[i].CompareTo("ClusterMaterialTRD")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 2.1;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 2.1;
}
}
// fix out-of-bunch gamma sys #16
if (!nameCutVariationSC[i].CompareTo("OOBPileupGamma")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.5)
errorFixed = 0.9;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 2.25;
if(ptBins[k] < 3.) errorFixed += pow(ptBins[k]-3,2)*0.25;
if(ptBins[k] > 3.) errorFixed += 0.1*(ptBins[k]-3.);
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// fix SPD pileup sys #17
if (!nameCutVariationSC[i].CompareTo("SPD")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.25;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.1;
}
}
// fix BG sys #18
if (!nameCutVariationSC[i].CompareTo("BG")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.3+pow(ptBins[k],2)*0.0035;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// fix alpha uncertainties #19
if (!nameCutVariationSC[i].CompareTo("Alpha")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 0.25;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 0.5;
}
}
// fix "Cocktail" #20
if (!nameCutVariationSC[i].CompareTo("Cocktail")){
if (!spectrumName.CompareTo("DoubleRatio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("8TeV")){
if(ptBins[k]<=3.) errorFixed = 1. ;
else errorFixed = -1;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
}
// fix Material sys #21
if (!nameCutVariationSC[i].CompareTo("Material")){
if (!spectrumName.Contains("Ratio")){
errorFixed = 4.5;
} else {
errorFixed = 0.;
}
}
// fix IntRange sys #22
if (!nameCutVariationSC[i].CompareTo("IntRange")){
if (spectrumName.Contains("Ratio")){
adjustPtDependent = kTRUE;
for (Int_t k = 0; k < nPtBinsActive; k++){
if(!energy.CompareTo("2.76TeV")){
if (ptBins[k] > 1.6)
errorFixed = 1.6+pow(ptBins[k],2)*0.018;
}else if(!energy.CompareTo("8TeV")){
errorFixed = 1.75;
if(ptBins[k]>=2.) errorFixed += 0.15*(ptBins[k]-2) ;
if(ptBins[k]==0.9) errorFixed = 3.;
else if(ptBins[k]==1.1) errorFixed = 2.;
}
if (errorFixed != -1){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
}
// fix Efficiency uncertainties #23
if (!nameCutVariationSC[i].CompareTo("Efficiency")){
if(!energy.CompareTo("2.76TeV")){
errorFixed = 2.0;
}else if(!energy.CompareTo("8TeV")){
if(spectrumName.Contains("Ratio")){
errorFixed = TMath::Sqrt(2.0*2.0 + 0.5*0.5); // pi0_eff - gamma_eff
}else{
errorFixed = TMath::Sqrt(0.5*0.5); // gamma_eff
}
}
}
// put fixed values for pt independent errors, which were adjusted
if (!adjustPtDependent && errorFixed != -1){
for (Int_t k = 0; k < nPtBinsActive; k++){
errorsMean[i][k] = errorFixed;
errorsMeanErr[i][k] = errorFixed*0.01;
errorsMeanCorr[i][k] = errorFixed;
errorsMeanErrCorr[i][k] = errorFixed*0.01;
}
}
}
// Add systematic error contribution from current cutvariation to total summed error
for (Int_t l = 0; l < nPtBinsActive; 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);
}
negativeErrors[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsNeg[i] ,ptBinsErr ,errorsNegErr[i] );
meanErrors[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsMean[i] ,ptBinsErr ,errorsMeanErr[i] );
positiveErrors[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsPos[i] ,ptBinsErr ,errorsPosErr[i] );
negativeErrorsCorr[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsNegCorr[i] ,ptBinsErr ,errorsNegErrCorr[i] );
meanErrorsCorr[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsMeanCorr[i] ,ptBinsErr ,errorsMeanErrCorr[i] );
positiveErrorsCorr[i] = new TGraphErrors(nPtBinsActive,ptBins ,errorsPosCorr[i] ,ptBinsErr ,errorsPosErrCorr[i] );
}
for (Int_t l = 0; l < nPtBinsActive; 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;
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;
errorsNegCorrSummed[l] = -pow(errorsNegCorrSummed[l],0.5);
errorsNegErrCorrSummed[l] = errorsNegCorrSummed[l]*0.001;
}
negativeErrorsSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsNegSummed ,ptBinsErr ,errorsNegErrSummed );
negativeErrorsCorrSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsNegCorrSummed ,ptBinsErr ,errorsNegErrCorrSummed );
positiveErrorsSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsPosSummed ,ptBinsErr ,errorsPosErrSummed );
positiveErrorsCorrSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsPosCorrSummed ,ptBinsErr ,errorsPosErrCorrSummed );
meanErrorsSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsMeanSummed ,ptBinsErr ,errorsMeanErrSummed );
meanErrorsCorrSummed = new TGraphErrors(nPtBinsActive,ptBins ,errorsMeanCorrSummed ,ptBinsErr ,errorsMeanErrCorrSummed );
//++++++++++++++++++++++++++++++ PLOTTING OF SYSMEAN +++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TCanvas* canvasNewSysErrMean = new TCanvas("canvasNewSysErrMean", "", 200, 10, 1200, 1100); // gives the page size
DrawGammaCanvasSettings( canvasNewSysErrMean, 0.075, 0.01, 0.015, 0.095);
canvasNewSysErrMean->SetLogx(1);
Double_t minXLegend = 0.11;
Double_t maxYLegend = 0.95;
Double_t widthLegend = 0.23;
Double_t heightLegend = 1.12* 0.035*0.85 * (nCutsActive+1);
Int_t nColumnsLegend = 1;
if ( nCutsActive+1 > 7){
widthLegend = 0.5;
heightLegend = 1.05* 0.035*0.85 * (nCutsActive/1.5+1);
nColumnsLegend = 2;
}
Double_t textSizeLabelsPixelmean = 55;
Double_t textSizeLabelsRelmean = 55./1200;
TH2F * histo2DNewSysErrMean;
histo2DNewSysErrMean = new TH2F("histo2DNewSysErrMean", "histo2DNewSysErrMean",1000, ptBins[0]-(ptBins[1]-ptBins[0])/2-0.07,1.2*(ptBins[nPtBinsActive-1]+ptBinsErr[nPtBinsActive-1]), 1000.,
yRangesSysPlotting[0], yRangesSysPlotting[1]);
SetStyleHistoTH2ForGraphs( histo2DNewSysErrMean, "#it{p}_{T} (GeV/#it{c})", "mean smoothed systematic Err %",
0.85*textSizeLabelsRelmean, textSizeLabelsRelmean, 0.85*textSizeLabelsRelmean, textSizeLabelsRelmean, 0.9, 0.75);//(#times #epsilon_{pur})
histo2DNewSysErrMean->GetYaxis()->SetLabelOffset(0.001);
//histo2DNewSysErrMean->GetXaxis()->SetLabelOffset(-0.01);
histo2DNewSysErrMean->GetXaxis()->SetMoreLogLabels(kTRUE);
histo2DNewSysErrMean->GetXaxis()->SetNoExponent();
histo2DNewSysErrMean->DrawCopy();
// create legend
TLegend* legendMeanNew = GetAndSetLegend2(minXLegend, maxYLegend-heightLegend, minXLegend+widthLegend, maxYLegend, 40*0.85, nColumnsLegend, "", 43, 0.1);
for(Int_t i = 0;i< nCuts ;i++){
if (benable[i]){
DrawGammaSetMarkerTGraphErr(meanErrorsCorr[i], markerStyle[i], 1.,color[i],color[i]);
meanErrorsCorr[i]->Draw("pX0,csame");
legendMeanNew->AddEntry(meanErrorsCorr[i],nameCutVariation[i].Data(),"p");
}
}
DrawGammaSetMarkerTGraphErr(meanErrorsCorrSummed, 20, 1.,kBlack,kBlack);
meanErrorsCorrSummed->Draw("p,csame");
legendMeanNew->AddEntry(meanErrorsCorrSummed,"qd. sum","p");
legendMeanNew->Draw();
// labeling
labelGamma->Draw();
if (spectrumName.Contains("Ratio")) labelPi0->Draw();
labelEnergy->Draw();
labelSpectrum->Draw();
canvasNewSysErrMean->Update();
canvasNewSysErrMean->SaveAs(Form("GammaSystematicErrorsCalculated/SysMeanNewWithMeanPCMEMC_%s_%s_%s.%s",spectrumName.Data(), energyForOutput.Data(), dateForOutput.Data(),suffix.Data()));
//+++++++++++++++++++++++++ SAVING SYSTEMATICS TO DAT FILE +++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const char *SysErrDatname = Form("GammaSystematicErrorsCalculated/SystematicErrorPCMEMC_%s_%s_%s.dat",spectrumName.Data(), energyForOutput.Data(), dateForOutput.Data());
fstream SysErrDat;
cout << SysErrDatname << endl;
SysErrDat.open(SysErrDatname, ios::out);
for (Int_t l=0; l< nPtBinsActive; l++){
SysErrDat << ptBins[l] << "\t" <<errorsNegCorrSummed[l] << "\t" <<errorsPosCorrSummed[l] << "\t" <<errorsNegCorrSummed[l] << "\t" <<errorsPosCorrSummed[l] << endl;
}
SysErrDat.close();
//+++++++++++++++++++++++++ SAVING AVERAGE SYSTEMATICS TO DAT ++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const char *SysErrDatnameMean = Form("GammaSystematicErrorsCalculated/SystematicErrorAveragedPCMEMC_%s_%s_%s.dat", spectrumName.Data(), energyForOutput.Data(), dateForOutput.Data());
fstream SysErrDatAver;
cout << SysErrDatnameMean << endl;
SysErrDatAver.open(SysErrDatnameMean, ios::out);
for (Int_t l=0; l< nPtBinsActive; l++){
SysErrDatAver << ptBins[l] << "\t" << "-"<< errorsMeanCorrSummed[l] << "\t" <<errorsMeanCorrSummed[l] << "\t" << "-"<< errorsMeanCorrSummed[l] << "\t" <<errorsMeanCorrSummed[l] << endl;
}
SysErrDatAver.close();
//+++++++++++++++++++++++++ SAVING DETAILED SYSTEMATICS ++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const char *SysErrDatnameMeanSingleErr = Form("GammaSystematicErrorsCalculated/SystematicErrorAveragedSinglePCMEMC_%s_%s_%s.dat", spectrumName.Data(),energyForOutput.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++){
if (benable[i]) SysErrDatAverSingle << nameCutVariationSC[i] << "\t";
}
SysErrDatAverSingle << endl;
for (Int_t l=0;l< nPtBinsActive;l++){
SysErrDatAverSingle << ptBins[l] << "\t";
for (Int_t i= 0; i< numberCutStudies; i++){
if (benable[i]) SysErrDatAverSingle << errorsMeanCorr[i][l] << "\t";
}
SysErrDatAverSingle << errorsMeanCorrSummed[l] << endl;
}
SysErrDatAverSingle.close();
Double_t errorsMeanCorrPID[nPtBinsActive];
Double_t errorsMeanCorrSignalExtraction[nPtBinsActive];
Double_t errorsMeanCorrPileup[nPtBinsActive];
Double_t errorsMeanCorrTrackReco[nPtBinsActive];
Double_t errorsMeanCorrPhotonReco[nPtBinsActive];
Double_t errorsMeanCorrClusterProp[nPtBinsActive];
for (Int_t l=0; l< nPtBinsActive; l++){
// 0 "dEdxE"
// 1 "dEdxPi"
// 2 "TPCCluster"
// 3 "SinglePt"
// 4 "Chi2"
// 5 "Qt"
// 6 "CosPoint"
// 7 "ToCloseV0s"
// 8 "ConvPhi"
// 9 "ClusterNonLinearity"
// 10 "ClusterM02"
// 11 "ClusterMinEnergy"
// 12 "ClusterTrackMatching"
// 13 "ClusterTiming"
// 14 "ClusterNCells"
// 15 "ClusterMaterialTRD"
// 16 "OOBPileupGamma"
// 17 "SPD"
// 18 "BG"
// 19 "Alpha"
// 20 "Cocktail"
// 21 "Material"
// 22 "IntRange"
// 23 "Efficiency"
// Signal extraction: Pi0Yield extraction, Alpha ,BG
errorsMeanCorrSignalExtraction[l] = TMath::Sqrt(pow(errorsMeanCorr[19][l],2)+ // Alpha
pow(errorsMeanCorr[18][l],2)+ // BG
pow(errorsMeanCorr[22][l],2)); // Pi0 Yield Extraction
// Pileup: SPD, Out-of-bunch
errorsMeanCorrPileup[l] = TMath::Sqrt(pow(errorsMeanCorr[16][l],2)+ // OOBPileupGamma
pow(errorsMeanCorr[17][l],2)); // SPD
// PID: dEdxE, dEdxPi
errorsMeanCorrPID[l] = TMath::Sqrt(pow(errorsMeanCorr[0][l],2)+ // dEdxE
pow(errorsMeanCorr[1][l],2)); // dEdxPi
// photon reco: Chi2+PsiPair, Qt, CosPoint, MinR
errorsMeanCorrPhotonReco[l] = TMath::Sqrt(pow(errorsMeanCorr[4][l],2)+ // Chi2 PsiPair
pow(errorsMeanCorr[5][l],2)+ // Qt
pow(errorsMeanCorr[7][l],2)+ // DoubleCount
pow(errorsMeanCorr[8][l],2)+ // ConvPhi
pow(errorsMeanCorr[6][l],2)); // CosPoint
// track reconstruction: TPCCluster, Single pT, Eta
errorsMeanCorrTrackReco[l] = TMath::Sqrt(pow(errorsMeanCorr[2][l],2)+ // TPCCluster
pow(errorsMeanCorr[3][l],2)); // Single pT
errorsMeanCorrClusterProp[l] = TMath::Sqrt(pow(errorsMeanCorr[11][l],2)+ // ClusterMinEnergy