-
Notifications
You must be signed in to change notification settings - Fork 21
/
HFPtSpectrumRaa.C
1450 lines (1332 loc) · 63.8 KB
/
HFPtSpectrumRaa.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
#if !defined(__CINT__) || defined(__MAKECINT__)
#include "TFile.h"
#include "TSystem.h"
#include "TH1.h"
#include "TH1D.h"
#include "TH2.h"
#include "TH2D.h"
#include "TH3.h"
#include "TH3D.h"
#include "TNtuple.h"
#include "TGraphAsymmErrors.h"
#include "TMath.h"
#include "TCanvas.h"
#include "TLegend.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TLine.h"
#include "TLatex.h"
#include "AliHFSystErr.h"
#include <Riostream.h>
#endif
/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
//
// Macro to compute the Raa, taking as inputs the output of the corrected yields
// and the pp reference
//
// R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
//
//
// Parameters:
// 1. ppfile = reference pp in the same pt binning
// 2. ABfile = corrected AB yields
// 3. outfile = output file name
// 4. decay = decay as in HFSystErr class
// 5. sigmaABCINT1B = cross section for normalization (**USE THE SAME AS ON 2.**)
// 6. fdMethod = feed-down subtraction method (kNb, kfc)
// 7. cc = centrality class
// 8. Energy = colliding energy (k276,k55)
// 9. MinHypo = minimum energy loss hypothesis (Default 1./3.)
// 10. MaxHypo = maximum energy loss hypothesis (Default 3.0)
// 11. MaxRb = maximum Raa(b) hypothesis (Default 6.0, won't do anything)
// 12. RbHypo : flag to decide whether the Eloss hypothesis is Rb or Rb/Rc
// 13. CentralHypo = central energy loss hypothesis, DEFAULT TO 1.0
// 14. isRaavsEP = flag to compute the Raa IN/OUT of plane, divides the reference by 2.0
// 15. ScaledAndExtrapRef: flag to tag scaled+reference pp-scaled-data
//
// Complains to : Zaida Conesa del Valle
//
///////////////////////////////////////////////////////////////////////////////
enum centrality{ kpp, k07half, kpPb0100, k010, k1020, k020, k1030, k2040, k2030, k3040, k4050, k3050, k5060, k4060, k6080, k4080, k5080, k80100,kpPb010, kpPb020, kpPb1020, kpPb2040, kpPb4060, kpPb60100 };
enum centestimator{ kV0M, kV0A, kZNA, kCL1 };
enum energy{ k276, k5dot023, k55 };
enum datayear{k2010, k2011, k2012, k2013, k2015, k2016, k2017, k2018};
enum BFDSubtrMethod { kfc, kNb };
enum RaavsEP {kPhiIntegrated, kInPlane, kOutOfPlane};
enum rapidity{ kdefault, k08to04, k07to04, k04to01, k01to01, k01to04, k04to07, k04to08, k01to05 };
enum particularity{ kTopological, kLowPt, kPP7TeVPass4, kBDT };
Bool_t printout = false;
Double_t ptprintout = 1.5;
Double_t NormPPUnc = 0.035;
Double_t NormABUnc = 0.037;
Bool_t elossFDQuadSum = true;
//____________________________________________________________
Bool_t PbPbDataSyst(AliHFSystErr *syst, Double_t pt, Int_t cc, Double_t &dataSystUp, Double_t &dataSystDown);
//____________________________________________________________
Double_t ExtractFDSyst(Double_t total, Double_t fd) {
// total^2 = data^2 + fd^2
Double_t data2 = total*total - fd*fd ;
return TMath::Sqrt( data2 );
}
//____________________________________________________________
Int_t FindGraphBin(TGraphAsymmErrors *gr, Double_t pt)
{
Int_t istart =0;
Int_t npoints = gr->GetN();
for(Int_t i=0; i<=npoints; i++){
Double_t x=0.,y=0.;
gr->GetPoint(i,x,y);
if ( TMath::Abs ( x - pt ) < 0.4 ) {
istart = i;
break;
}
}
return istart;
}
//
//
// R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
//
//
//____________________________________________________________
void HFPtSpectrumRaa(const char *ppfile="ppreference/Ds_ppreference_pp5TeV_noyshift_pt_1_2_3_4_5_6_8_12_16_24_FONLLextrap_pt_24_36_50_ML.root",
const char *ABfile="$HOME/cernbox/ALICE_WORK/AnalysisPbPb2018/DmesonCutSelection/outputs/crosssec/HFPtSpectrum.root",
const char *outfile="$HOME/cernbox/ALICE_WORK/AnalysisPbPb2018/DmesonCutSelection/outputs/raa/HFPtSpectrumRaa.root",
Int_t decay=4,
Double_t sigmaABCINT1B=1.0,
Int_t fdMethod = kNb,
Int_t cc=k010,
Int_t year=k2018,
Int_t Energy=k5dot023,
Double_t MinHypo=1./3.,
Double_t MaxHypo=3.0,
Double_t MaxRb=6.0,
Bool_t isRbHypo=false,
Double_t CentralHypo = 1.0,
Bool_t fChangeCentralHypo = false, // true for non-strange D mesons
Int_t ccestimator = kV0M,
Bool_t isUseTaaForRaa=true,
const char *shadRbcFile="",
Int_t nSigmaShad=3.0,
Int_t isRaavsEP=kPhiIntegrated,
Bool_t isScaledAndExtrapRef=kTRUE,
Int_t rapiditySlice=kdefault,
Int_t analysisSpeciality=kTopological)
{
gROOT->Macro("$ALICE_PHYSICS/PWGHF/vertexingHF/macros/LoadLibraries.C");
//
// Defining the TAB values for the given centrality class
//
Double_t Tab = 1., TabSyst = 0., A=208, B=208;
// the isotope of Pb that is accelerated in LHC is 208Pb
if ( Energy!=k276 && Energy!=k5dot023) {
printf("\n The Tab values for this cms energy have not yet been implemented, please do it ! \n");
return;
}
if ( cc == kpp ){
Tab = 1.;
}
// all values from A. Toia's https://alice-notes.web.cern.ch/system/files/notes/public/711/2019-04-02-ALICE_public_note.pdf
// PbPb at 2.76 TeV
if( (ccestimator == kV0M) && (Energy==k276) ) {
if ( cc == k07half ) {
Tab = 24.81; TabSyst = 0.8037; // value from A. Toia's twiki: https://twiki.cern.ch/twiki/bin/viewauth/ALICE/CentStudies (not present in latest AN)
} else if ( cc == k010 ) {
Tab = 23.37; TabSyst = 0.2;
} else if ( cc == k1020 ) {
Tab = 14.53; TabSyst = 0.2;
} else if ( cc == k020 ) {
Tab = 18.95; TabSyst = 0.19;
} else if ( cc == k1030 ) {
Tab = 11.4; TabSyst = 0.36; // value from A. Toia's twiki: https://twiki.cern.ch/twiki/bin/viewauth/ALICE/CentStudies (not present in latest AN)
} else if ( cc == k2040 ) {
Tab = 7.109; TabSyst = 0.15;
} else if ( cc == k2030 ) {
Tab = 8.96; TabSyst = 0.17;
} else if ( cc == k3040 ) {
Tab = 5.259; TabSyst = 0.14;
} else if ( cc == k4050 ) {
Tab = 2.857; TabSyst = 0.084;
} else if ( cc == k3050 ) {
Tab = 4.058; TabSyst = 0.11;
} else if ( cc == k4060 ) {
Tab = 2.143; TabSyst= 0.07;
} else if ( cc == k4080 ) {
Tab = 1.20451; TabSyst = 0.071843; // value from A. Toia's twiki: https://twiki.cern.ch/twiki/bin/viewauth/ALICE/CentStudies (not present in latest AN)
} else if ( cc == k5060 ) {
Tab = 1.427; TabSyst = 0.058;
} else if ( cc == k6080 ) {
Tab = 0.4505; TabSyst = 0.026;
} else if ( cc == k5080 ) {
Tab = 0.719; TabSyst = 0.054; // value from A. Toia's twiki: https://twiki.cern.ch/twiki/bin/viewauth/ALICE/CentStudies (not present in latest AN)
} else if ( cc == k80100 ){
Tab = 0.05959; TabSyst = 0.0028;
}
}
// PbPb at 5.02 TeV
if( (ccestimator == kV0M) && (Energy==k5dot023) ) {
if ( cc == k010 ) {
Tab = 23.26; TabSyst = 0.168;
} else if ( cc == k3050 ) {
Tab = 3.917; TabSyst = 0.0645;
} else if ( cc == k6080 ) {
Tab = 0.4188; TabSyst = 0.0106;
}
}
// pPb at 5.02 TeV
if( cc == kpPb0100 ){
Tab = 0.09923; TabSyst = 0.0017;
A=208; B=1.;
}
else if( ccestimator == kV0A ){
if ( cc == kpPb020 ) {
Tab = 0.181; TabSyst = 0.00898;
} else if ( cc == kpPb2040 ) {
Tab = 0.1345; TabSyst = 0.00624;
} else if ( cc == kpPb4060 ) {
Tab = 0.09496; TabSyst = 0.00357;
} else if ( cc == kpPb60100 ) {
Tab = 0.04334; TabSyst = 0.00138;
}
}
else if( ccestimator == kZNA ){ // values from the "hybrid method"
if ( cc == kpPb010 ) {
Tab = 0.172; TabSyst = 0.012;
} else if ( cc == kpPb1020 ) {
Tab = 0.158; TabSyst = 0.006;
} else if ( cc == kpPb2040 ) {
Tab = 0.137; TabSyst = 0.003;
} else if ( cc == kpPb4060 ) {
Tab = 0.102; TabSyst = 0.005;
} else if ( cc == kpPb60100 ) {
Tab = 0.0459; TabSyst = 0.0024;
}
}
else if( ccestimator == kCL1 ){
if ( cc == kpPb020 ) {
Tab = 0.1901; TabSyst = 0.00913;
} else if ( cc == kpPb2040 ) {
Tab = 0.1377; TabSyst = 0.00599;
} else if ( cc == kpPb4060 ) {
Tab = 0.0928; TabSyst = 0.0037;
} else if ( cc == kpPb60100 ) {
Tab = 0.03881; TabSyst = 0.00181;
}
}
//
// Reading the pp file
//
if(gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",ppfile)) !=0){
printf("File %s with pp reference does not exist -> exiting\n",ppfile);
return;
}
TFile * ppf = new TFile(ppfile,"read");
TH1D * hSigmaPP;
TGraphAsymmErrors * gSigmaPPSyst;
TGraphAsymmErrors * gSigmaPPSystData = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystData");
TGraphAsymmErrors * gSigmaPPSystTheory = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystExtrap");
TGraphAsymmErrors * gSigmaPPSystFeedDown = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystFeedDown");
TH1I * hCombinedReferenceFlag=0x0;
TGraphAsymmErrors * gReferenceFdSyst=0x0;
if(isScaledAndExtrapRef){
hCombinedReferenceFlag = (TH1I*)ppf->Get("hCombinedReferenceFlag");
hSigmaPP = (TH1D*)ppf->Get("hReference");
gSigmaPPSyst = (TGraphAsymmErrors*)ppf->Get("gReferenceSyst");
gReferenceFdSyst = (TGraphAsymmErrors*)ppf->Get("gReferenceFdSyst");
} else {
hSigmaPP = (TH1D*)ppf->Get("fhScaledData");
gSigmaPPSyst = (TGraphAsymmErrors*)ppf->Get("gScaledData");
}
Double_t scalePPRefToMatchRapidityBin = 1.0;
// Call the systematics uncertainty class for a given decay
AliHFSystErr *systematicsPP = 0x0;
if(ppf->Get("AliHFSystErr")){
systematicsPP = (AliHFSystErr*)ppf->Get("AliHFSystErr");
printf(" --> AliHFSystErr object for pp reference read from file. Object title = %s\n",systematicsPP->GetTitle());
}else{
systematicsPP = new AliHFSystErr();
if(analysisSpeciality==kLowPt){
systematicsPP->SetIsLowPtAnalysis(true);
}
if(analysisSpeciality==kPP7TeVPass4){
systematicsPP->SetIsPass4Analysis(true);
}
systematicsPP->Init(decay);
printf(" --> AliHFSystErr object for pp reference created based on macro arguments. Object title = %s\n",systematicsPP->GetTitle());
}
//
// Reading the AB collisions file
//
if(gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",ABfile)) !=0){
printf("File %s with A-A (p-A) results does not exist -> exiting\n",ABfile);
return;
}
TFile * ABf = new TFile(ABfile,"read");
TH1D *hSigmaAB = (TH1D*)ABf->Get("histoSigmaCorr");
// TH2D *hSigmaABRcb = (TH2D*)ABf->Get("histoSigmaCorrRcb");
// TGraphAsymmErrors * gSigmaABSyst = (TGraphAsymmErrors*)ABf->Get("gSigmaCorr");
TGraphAsymmErrors * gSigmaABSystFeedDown = (TGraphAsymmErrors*)ABf->Get("gSigmaCorrConservative");
TNtuple * nSigmaAB = (TNtuple*)ABf->Get("fnSigma");
//
TH1D *hMassAB = (TH1D*)ABf->Get("hRECpt");
TH1D *hDirectEffptAB = (TH1D*)ABf->Get("hDirectEffpt");
TH1D *histofcAB = (TH1D*)ABf->Get("histofc");
//
TH1D* fhStatUncEffcSigmaAB = (TH1D*)ABf->Get("fhStatUncEffcSigma");
TH1D* fhStatUncEffbSigmaAB = (TH1D*)ABf->Get("fhStatUncEffbSigma");
TH1D* fhStatUncEffcFDAB = (TH1D*)ABf->Get("fhStatUncEffcFD");
TH1D* fhStatUncEffbFDAB = (TH1D*)ABf->Get("fhStatUncEffbFD");
//
TH1D* fhStatUncEffcSigmaAB_Raa = (TH1D*)fhStatUncEffcSigmaAB->Clone("fhStatUncEffcSigmaAB_Raa");
TH1D* fhStatUncEffbSigmaAB_Raa = (TH1D*)fhStatUncEffbSigmaAB->Clone("fhStatUncEffbSigmaAB_Raa");
TH1D* fhStatUncEffcFDAB_Raa = (TH1D*)fhStatUncEffcFDAB->Clone("fhStatUncEffcFDAB_Raa");
TH1D* fhStatUncEffbFDAB_Raa = (TH1D*)fhStatUncEffbFDAB->Clone("fhStatUncEffbFDAB_Raa");
fhStatUncEffcSigmaAB_Raa->Reset();
fhStatUncEffbSigmaAB_Raa->Reset();
fhStatUncEffcFDAB_Raa->Reset();
fhStatUncEffbFDAB_Raa->Reset();
fhStatUncEffcSigmaAB_Raa->SetName("fhStatUncEffcSigmaAB_Raa");
fhStatUncEffbSigmaAB_Raa->SetName("fhStatUncEffbSigmaAB_Raa");
fhStatUncEffcFDAB_Raa->SetName("fhStatUncEffcFDAB_Raa");
fhStatUncEffbFDAB_Raa->SetName("fhStatUncEffvFDAB_Raa");
//
// Call the systematics uncertainty class for a given decay
AliHFSystErr *systematicsAB = 0x0;
if(ABf->Get("AliHFSystErr")){
systematicsAB=(AliHFSystErr*)ABf->Get("AliHFSystErr");
printf(" --> AliHFSystErr object for A-A read from HFPtSpectrum file. Object title = %s\n",systematicsAB->GetTitle());
}else{
systematicsAB = new AliHFSystErr();
systematicsAB->SetCollisionType(1);
if(year==k2010) systematicsAB->SetRunNumber(10);
else if(year==k2011) systematicsAB->SetRunNumber(11);
else if(year==k2012) systematicsAB->SetRunNumber(12);
else if(year==k2013) systematicsAB->SetRunNumber(13);
else if(year==k2015) systematicsAB->SetRunNumber(15);
else if(year==k2016) systematicsAB->SetRunNumber(16);
else if(year==k2017) systematicsAB->SetRunNumber(17);
else if(year==k2018) systematicsAB->SetRunNumber(18);
if(Energy==k276){
if ( cc == k07half ) systematicsAB->SetCentrality("07half");
else if ( cc == k010 ) systematicsAB->SetCentrality("010");
else if ( cc == k1020 ) systematicsAB->SetCentrality("1020");
else if ( cc == k020 ) systematicsAB->SetCentrality("020");
else if ( cc == k2040 || cc == k2030 || cc == k3040 ) {
systematicsAB->SetCentrality("2040");
systematicsAB->SetIsPbPb2010EnergyScan(true);
}
else if ( cc == k4060 || cc == k4050 || cc == k5060 ) systematicsAB->SetCentrality("4060");
else if ( cc == k6080 || cc == k5080 ) systematicsAB->SetCentrality("6080");
else if ( cc == k4080 ) systematicsAB->SetCentrality("4080");
else if ( cc == k3050 ) {
if (isRaavsEP == kPhiIntegrated) systematicsAB->SetCentrality("4080");
else if (isRaavsEP == kInPlane) systematicsAB->SetCentrality("3050InPlane");
else if (isRaavsEP == kOutOfPlane) systematicsAB->SetCentrality("3050OutOfPlane");
}
} else if (Energy==k5dot023){
if ( cc == k010 ){
systematicsAB->SetCentrality("010");
} else if ( cc == k1030 ) {
systematicsAB->SetCentrality("3050"); //no systematics available for 10--30
} else if ( cc == k3050 ) {
systematicsAB->SetCentrality("3050");
} else if ( cc == k6080 ) {
systematicsAB->SetCentrality("6080");
}
}
//
else if ( cc == kpPb0100 || cc == kpPb010 || cc == kpPb020 || cc == kpPb1020 || cc == kpPb2040 || cc == kpPb4060 || cc == kpPb60100 ) {
systematicsAB->SetCollisionType(2);
// Rapidity slices
if(rapiditySlice!=kdefault){
systematicsAB->SetIspPb2011RapidityScan(true);
TString rapidity="";
switch(rapiditySlice) {
case k08to04: rapidity="0804"; scalePPRefToMatchRapidityBin=(0.093+0.280)/1.0; break;
case k07to04: rapidity="0804"; scalePPRefToMatchRapidityBin=0.280/1.0; break;
case k04to01: rapidity="0401"; scalePPRefToMatchRapidityBin=0.284/1.0; break;
case k01to01: rapidity="0101"; scalePPRefToMatchRapidityBin=0.191/1.0; break;
case k01to04: rapidity="0104"; scalePPRefToMatchRapidityBin=0.288/1.0; break;
case k04to07: rapidity="0408"; scalePPRefToMatchRapidityBin=0.288/1.0; break;
case k04to08: rapidity="0408"; scalePPRefToMatchRapidityBin=(0.288+0.096)/1.0; break;
case k01to05: rapidity="0401"; scalePPRefToMatchRapidityBin=0.4; break;
}
systematicsAB->SetRapidity(rapidity);
}
// Centrality slices
if(ccestimator==kV0A) {
if(cc == kpPb020) systematicsAB->SetCentrality("020V0A");
else if(cc == kpPb2040) systematicsAB->SetCentrality("2040V0A");
else if(cc == kpPb4060) systematicsAB->SetCentrality("4060V0A");
else if(cc == kpPb60100) systematicsAB->SetCentrality("60100V0A");
} else if (ccestimator==kZNA) {
if(cc == kpPb010) systematicsAB->SetCentrality("010ZNA");
else if(cc == kpPb020) systematicsAB->SetCentrality("020ZNA");
else if(cc == kpPb1020) systematicsAB->SetCentrality("1020ZNA");
else if(cc == kpPb2040) systematicsAB->SetCentrality("2040ZNA");
else if(cc == kpPb4060) systematicsAB->SetCentrality("4060ZNA");
else if(cc == kpPb60100) systematicsAB->SetCentrality("60100ZNA");
} else if (ccestimator==kCL1) {
if(cc == kpPb020) systematicsAB->SetCentrality("020CL1");
else if(cc == kpPb2040) systematicsAB->SetCentrality("2040CL1");
else if(cc == kpPb4060) systematicsAB->SetCentrality("4060CL1");
else if(cc == kpPb60100) systematicsAB->SetCentrality("60100CL1");
}else {
if(!(cc == kpPb0100)) {
std::cout <<" Error on the pPb options"<<std::endl;
return;
}
}
}
else {
std::cout << " Systematics not yet implemented " << std::endl;
return;
}
if(analysisSpeciality==kLowPt){
systematicsAB->SetIsLowPtAnalysis(true);
}
else if(analysisSpeciality==kBDT){
systematicsAB->SetIsBDTAnalysis(true);
}
//
systematicsAB->Init(decay);
printf(" --> AliHFSystErr object for A-A created based on macro arguments. Object title = %s\n",systematicsAB->GetTitle());
}
//
Int_t entries = nSigmaAB->GetEntries();
Float_t pt=0., signal=0., Rb=0., Rcb=0., fcAB=0., yieldAB=0., sigmaAB=0., statUncSigmaAB=0., sigmaABMin=0.,sigmaABMax=0.;
nSigmaAB->SetBranchAddress("pt",&pt);
nSigmaAB->SetBranchAddress("Signal",&signal);
if (fdMethod==kNb) nSigmaAB->SetBranchAddress("Rb",&Rb);
else if (fdMethod==kfc) nSigmaAB->SetBranchAddress("Rcb",&Rcb);
nSigmaAB->SetBranchAddress("fc",&fcAB);
nSigmaAB->SetBranchAddress("Yield",&yieldAB);
nSigmaAB->SetBranchAddress("Sigma",&sigmaAB);
nSigmaAB->SetBranchAddress("SigmaStatUnc",&statUncSigmaAB);
nSigmaAB->SetBranchAddress("SigmaMax",&sigmaABMax);
nSigmaAB->SetBranchAddress("SigmaMin",&sigmaABMin);
// define the binning
Int_t nbins = hSigmaAB->GetNbinsX();
Double_t binwidth = hSigmaAB->GetBinWidth(1);
Double_t *limits = new Double_t[nbins+1];
Double_t *binwidths = new Double_t[nbins];
Double_t xlow=0.;
for (Int_t i=1; i<=nbins; i++) {
binwidth = hSigmaAB->GetBinWidth(i);
xlow = hSigmaAB->GetBinLowEdge(i);
limits[i-1] = xlow;
binwidths[i-1] = binwidth;
}
limits[nbins] = xlow + binwidth;
//
// Read the shadowing file if given as input
//
Double_t centralRbcShad[nbins+1], minRbcShad[nbins+1], maxRbcShad[nbins+1];
for(Int_t i=0; i<=nbins; i++) { centralRbcShad[i]=1.0; minRbcShad[i]=6.0; maxRbcShad[i]=0.0; }
Bool_t isShadHypothesis = false;
if( strcmp(shadRbcFile,"")!=0 ) {
isShadHypothesis = true;
std::cout<<std::endl<<">> Beware, using the shadowing prediction file with an "<<nSigmaShad<<"*sigma <<"<<std::endl<<std::endl;
TFile *fshad = new TFile(shadRbcFile,"read");
if(!fshad){ std::cout <<" >> Shadowing file not properly opened!!!"<<std::endl<<std::endl; return;}
// TH1D *hRbcShadCentral = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_central");
// TH1D *hRbcShadMin = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_upper");
// TH1D *hRbcShadMax = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_lower");
TH1D *hRbcShadCentral = (TH1D*)fshad->Get("hDfromBoverDfromc_L0");
TH1D *hRbcShadMin = (TH1D*)fshad->Get("hDfromBoverDfromc_L0");
TH1D *hRbcShadMax = (TH1D*)fshad->Get("hDfromBoverDfromc_L1");
if(!hRbcShadCentral || !hRbcShadMin || !hRbcShadMax) {
std::cout<< std::endl <<">> Shadowing input histograms are not ok !! "<<std::endl<<std::endl;
return;
}
// nSigmaShad
// nSigmaShad
for(Int_t i=1; i<=nbins; i++) {
Double_t xpt = hSigmaAB->GetBinCenter(i);
if(xpt>24) xpt = 20;
centralRbcShad[i] = hRbcShadCentral->GetBinContent( hRbcShadCentral->FindBin(xpt) );
Double_t minValue0 = hRbcShadMin->GetBinContent( hRbcShadMin->FindBin(xpt) );
Double_t maxValue0 = hRbcShadMax->GetBinContent( hRbcShadMax->FindBin(xpt) );
Double_t arrayEl[3] = {minValue0,maxValue0, centralRbcShad[i]};
Double_t minValue = TMath::MinElement(3,arrayEl);
Double_t maxValue = TMath::MaxElement(3,arrayEl);
std::cout<<">> Shadowing pt="<<xpt<<" central="<<centralRbcShad[i]<<" min="<<minValue<<" max="<<maxValue<<std::endl;
if(minValue>centralRbcShad[i]){ minValue = centralRbcShad[i]; }
if(maxValue<centralRbcShad[i]){ maxValue = centralRbcShad[i]; }
minRbcShad[i] = centralRbcShad[i] - nSigmaShad*(centralRbcShad[i] - minValue);
maxRbcShad[i] = centralRbcShad[i] + nSigmaShad*(maxValue - centralRbcShad[i]);
std::cout<<">> Shadowing hypothesis pt="<<xpt<<" central="<<centralRbcShad[i]<<" min="<<minRbcShad[i]<<" max="<<maxRbcShad[i]<<std::endl;
}
}
//
// define the bins correspondence bw histos/files/graphs
//
//
TH2D * hRABvsRcb = new TH2D("hRABvsRcb"," R_{AB}(c) vs Rcb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(c) ; Rcb Eloss hypothesis ",nbins,limits,800,0.,4.);
TH2D * hRABvsRb = new TH2D("hRABvsRb"," R_{AB}(c) vs Rb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(c) ; Rb Eloss hypothesis ",nbins,limits,800,0.,4.);
// TH2D * hRABBeautyvsRCharm = new TH2D("hRABBeautyvsRCharm"," R_{AB}(c) vs Rb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(b) ; R_{AB}(c) ",nbins,limits,800,0.,4.);
Int_t nbinsHypo=800;//200;
Double_t *limitsHypo = new Double_t[nbinsHypo+1];
for(Int_t i=1; i<=nbinsHypo+1; i++) limitsHypo[i-1]= i*4./800.;
TH3D * hRABCharmVsRBeautyVsPt = new TH3D("hRABCharmVsRBeautyVsPt"," R_{AB}(c) vs Rb vs p_{T} Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(b) ; R_{AB}(c) ",nbins,limits,nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
TH2D *hRCharmVsRBeauty[nbins+1];
for(Int_t i=0; i<=nbins; i++) hRCharmVsRBeauty[i] = new TH2D(Form("hRCharmVsRBeauty_%i",i),Form("RAB(c) vs RAB(b) for pt bin %i ; R_{AB}(b) ; R_{AB}(c)",i),nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
TH2D *hRCharmVsElossHypo[nbins+1];
for(Int_t i=0; i<=nbins; i++) hRCharmVsElossHypo[i] = new TH2D(Form("hRCharmVsElossHypo_%i",i),Form("RAB(c) vs ElossHypo for pt bin %i ; Eloss Hypothesis (c/b) ; R_{AB}(c)",i),nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
//
TH1D *hRABEloss00= new TH1D("hRABEloss00","hRABEloss00",nbins,limits);
TH1D *hRABEloss05= new TH1D("hRABEloss05","hRABEloss05",nbins,limits);
TH1D *hRABEloss10= new TH1D("hRABEloss10","hRABEloss10",nbins,limits);
TH1D *hRABEloss15= new TH1D("hRABEloss15","hRABEloss15",nbins,limits);
TH1D *hRABEloss20= new TH1D("hRABEloss20","hRABEloss20",nbins,limits);
//
TH2D * hRABvsRbFDlow = new TH2D("hRABvsRbFDlow"," R_{AB}(c) vs Rb Eloss hypothesis (FD low); p_{T} [GeV/c] ; Rb Eloss hypothesis ; R_{AB}(c) ",nbins,limits,800,0.,4.);
TH2D * hRABvsRbFDhigh = new TH2D("hRABvsRbFDhigh"," R_{AB}(c) vs Rb Eloss hypothesis (FD high); p_{T} [GeV/c] ; Rb Eloss hypothesis ; R_{AB}(c) ",nbins,limits,800,0.,4.);
//
TH1D * hRABvsRbFDhigh_proj = new TH1D("hRABvsRbFDhigh_proj","hRABvsRbFDhigh_proj",nbins,limits);
TH1D * hRABvsRbFDlow_proj = new TH1D("hRABvsRbFDlow_proj","hRABvsRbFDlow_proj",nbins,limits);
//
TNtuple *ntupleRAB=0x0 ;
if (fdMethod==kNb) {
ntupleRAB = new TNtuple("ntupleRAB","ntupleRAB (Nb)","pt:TAB:sigmaPP:sigmaAB:invyieldAB:invyieldABFDHigh:invyieldABFDLow:RABCharm:RABCharmFDHigh:RABCharmFDLow:RABBeauty:fc",100000);
} else if (fdMethod==kfc) {
ntupleRAB = new TNtuple("ntupleRAB","ntupleRAB (fc)","pt:TAB:sigmaPP:sigmaAB:invyieldAB:invyieldABFDHigh:invyieldABFDLow:Rcb:RABCharm:RABCharmFDHigh:RABCharmFDLow:RABBeauty:RABBeautyFDHigh:RABBeautyFDLow:fc",100000);
}
if(!ntupleRAB) printf("ERROR: Wrong method option");
TH1D * hYieldABvsPt = new TH1D("hYieldABvsPt"," Yield_{AB}(c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; Yield_{charm} ",nbins,limits);
TH1D * hRABvsPt = new TH1D("hRABvsPt"," R_{AB}(c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; R_{charm} ",nbins,limits);
TH1D * hRABvsPt_DataSystematics = new TH1D("hRABvsPt_DataSystematics"," Systematics of R_{AB} (c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; R_{charm} ",nbins,limits);
TGraphAsymmErrors *gRAB_ElossHypothesis = new TGraphAsymmErrors(nbins+1);
gRAB_ElossHypothesis->SetNameTitle("gRAB_ElossHypothesis","RAB Eloss systematics");
TGraphAsymmErrors *gRAB_FeedDownSystematics = new TGraphAsymmErrors(nbins+1);
gRAB_FeedDownSystematics->SetNameTitle("gRAB_FeedDownSystematics","RAB Feed-Down systematics");
TGraphAsymmErrors *gRAB_fcFeedDownOnly = new TGraphAsymmErrors(nbins+1);
gRAB_fcFeedDownOnly->SetNameTitle("gRAB_fcFeedDownOnly","RAB fc Feed-Down Only");
TGraphAsymmErrors *gRAB_FeedDownSystematicsElossHypothesis = new TGraphAsymmErrors(nbins+1);
gRAB_FeedDownSystematicsElossHypothesis->SetNameTitle("gRAB_FeedDownSystematicsElossHypothesis","RAB Feed-Down systematics considering Eloss hypothesis");
TGraphAsymmErrors *gRAB_DataSystematics = new TGraphAsymmErrors(nbins+1);
gRAB_DataSystematics->SetNameTitle("gRAB_DataSystematics","RAB Measurement (no FD, no Eloss) systematics");
TGraphAsymmErrors *gRAB_DataSystematicsPP = new TGraphAsymmErrors(nbins+1);
gRAB_DataSystematicsPP->SetNameTitle("gRAB_DataSystematicsPP","RAB Measurement PP meas. systematics (data+scaling)");
TGraphAsymmErrors *gRAB_DataSystematicsAB = new TGraphAsymmErrors(nbins+1);
gRAB_DataSystematicsAB->SetNameTitle("gRAB_DataSystematicsAB","RAB Measurement AB (no FD, no Eloss, no PP data) systematics");
TGraphAsymmErrors *gRAB_GlobalSystematics = new TGraphAsymmErrors(nbins+1);
gRAB_GlobalSystematics->SetNameTitle("gRAB_GlobalSystematics","RAB Measurement global (data, FD, Eloss) systematics");
Double_t ElossMax[nbins+1], ElossMin[nbins+1];
for(Int_t i=0; i<=nbins; i++) { ElossMax[i]=0.; ElossMin[i]=6.; }
Double_t fcElossMax[nbins+1], fcElossMin[nbins+1];
for(Int_t i=0; i<=nbins; i++) { fcElossMax[i]=0.; fcElossMin[i]=6.; }
Double_t FDElossMax[nbins+1], FDElossMin[nbins+1];
for(Int_t i=0; i<=nbins; i++) { FDElossMax[i]=0.; FDElossMin[i]=6.; }
TGraphAsymmErrors *gRAB_Norm = new TGraphAsymmErrors(1);
gRAB_Norm->SetNameTitle("gRAB_Norm","RAB Normalization systematics (pp norm + Tab)");
Double_t normUnc = TMath::Sqrt ( NormPPUnc*NormPPUnc + (TabSyst/Tab)*(TabSyst/Tab) );
if(!isUseTaaForRaa) normUnc = TMath::Sqrt ( NormPPUnc*NormPPUnc + NormABUnc*NormABUnc );
gRAB_Norm->SetPoint(1,0.5,1.);
gRAB_Norm->SetPointError(1,0.25,0.25,normUnc,normUnc);
//
// R_AB = ( dN/dpt )_AB / <Ncoll_AB> * ( dN/dpt )_pp ; <Ncoll> = <Tab> * sigma_NN^inel
// R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
//
Int_t istartPPfd=0, istartPPsyst=0, istartABfd=0, istartPPextr=0;
Double_t yPPh=0., yPPl=0., yABh=0., yABl=0.;
Double_t RaaCharm =0., RaaBeauty=0.;
Double_t RaaCharmFDhigh = 0., RaaCharmFDlow = 0.;
Double_t RaaBeautyFDhigh = 0., RaaBeautyFDlow = 0.;
Double_t systUp=0., systLow=0., systPPUp=0., systPPLow=0., systABUp=0., systABLow=0.;
//
//
// Search the central value of the energy loss hypothesis Rb = Rc (bin)
//
Double_t ElossCentral[nbins+1];
for(Int_t i=0; i<=nbins; i++) { ElossCentral[i]=0.; }
//
Double_t stdCentralHypo = CentralHypo; //central hypothesis passed to the macro
Double_t stdMinHypo = MinHypo; //minimum hypothesis passed to the macro
Double_t stdMaxHypo = MaxHypo; //maximum hypothesis passed to the macro
for(Int_t ientry=0; ientry<=entries; ientry++){
CentralHypo = stdCentralHypo;
nSigmaAB->GetEntry(ientry);
// std::cout << " pt="<< pt<<" sigma-AB="<<sigmaAB<<std::endl;
if ( !(sigmaAB>0.) ) continue;
//if(decay==2 && pt<2.) continue;
// Compute RAB and the statistical uncertainty
Int_t hppbin = hSigmaPP->FindBin( pt );
Int_t hABbin = hSigmaAB->FindBin( pt );
Double_t sigmapp = hSigmaPP->GetBinContent( hppbin );
sigmapp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
// std::cout << " pt="<< pt<<", sigma-pp="<< sigmapp<<std::endl;
if (isRaavsEP>0.) sigmapp = 0.5*sigmapp;
if ( !(sigmapp>0.) ) continue;
RaaCharm = ( sigmaAB / sigmaABCINT1B ) / ((Tab*1e3) * sigmapp *1e-12 ) ;
if(!isUseTaaForRaa) {
RaaCharm = ( sigmaAB ) / ( (A*B) * sigmapp ) ;
}
if (fdMethod==kNb) {
RaaBeauty = Rb ;
}
else if (fdMethod==kfc) {
RaaBeauty = ( RaaCharm / Rcb ) ;
}
Double_t ElossHypo = 0.;
if (fdMethod==kfc) { ElossHypo = 1. / Rcb; }
else { ElossHypo = 1. / (RaaCharm / RaaBeauty) ; }
if(isRbHypo) ElossHypo = RaaBeauty;
//change central hypothesis
if(fChangeCentralHypo && pt<3 && (decay==1 || decay==2 || decay==3)){
CentralHypo = 1.5;
printf("********* changed central hypothesis for pt<3 (%f): %f \n",pt,CentralHypo);
}
if(fChangeCentralHypo && pt>=24 && (decay==1 || decay==2 || decay==3)){
CentralHypo = 1.5;
printf("********* changed central hypothesis for pt>=24 (%f): %f \n",pt,CentralHypo);
}
// If using shadowing hypothesis, change the central hypothesis too
if(isShadHypothesis) CentralHypo = centralRbcShad[hABbin];
// std::cout <<" pt "<< pt << " Raa charm " << RaaCharm << " Raa beauty " << RaaBeauty << " eloss hypo "<< ElossHypo<<std::endl;
//
// Find the bin for the central Eloss hypo
//
if( TMath::Abs( ElossHypo - CentralHypo ) < 0.075 ){
Double_t DeltaIni = TMath::Abs( ElossCentral[ hABbin ] - CentralHypo );
Double_t DeltaV = TMath::Abs( ElossHypo - CentralHypo );
// std::cout << " pt " << pt << " ECentral " << ElossCentral[ hABbin ] << " Ehypo "<< ElossHypo ;
if ( DeltaV < DeltaIni ) ElossCentral[ hABbin ] = ElossHypo;
// std::cout << " final ECentral " << ElossCentral[ hABbin ] << std::endl;
}
}
//
// Calculation of the Raa and its uncertainties
//
for(Int_t ientry=0; ientry<entries; ientry++){
MinHypo = stdMinHypo;
MaxHypo = stdMaxHypo;
nSigmaAB->GetEntry(ientry);
if ( !(sigmaAB>0.) ) continue;
// if ( pt<2 || pt>16) continue;
// Compute RAB and the statistical uncertainty
Int_t hppbin = hSigmaPP->FindBin( pt );
Double_t sigmapp = hSigmaPP->GetBinContent( hppbin );
if (isRaavsEP>0.) sigmapp = 0.5*sigmapp;
sigmapp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
if ( !(sigmapp>0.) ) continue;
RaaCharm = ( sigmaAB / sigmaABCINT1B ) / ((Tab*1e3) * sigmapp *1e-12 );
if(!isUseTaaForRaa) {
RaaCharm = ( sigmaAB ) / ( (A*B) * sigmapp ) ;
}
// Flag to know if it is an scaled or extrapolated point of the pp reference
Bool_t isExtrapolatedBin = kFALSE;
if(isScaledAndExtrapRef && hCombinedReferenceFlag) isExtrapolatedBin = hCombinedReferenceFlag->GetBinContent( hppbin );
istartPPsyst = -1;
istartPPsyst = FindGraphBin(gSigmaPPSyst,pt);
//
// FONLL Feed-Down systematics
//
istartPPfd = -1;
if(!isExtrapolatedBin) istartPPfd = FindGraphBin(gSigmaPPSystFeedDown,pt);
istartABfd = -1;
istartABfd = FindGraphBin(gSigmaABSystFeedDown,pt);
// std::cout << " Starting bin for pp is "<< istartPPfd <<", for AA is "<<istartABfd << std::endl;
if(isExtrapolatedBin){
if(gReferenceFdSyst){
Int_t ibinfd = FindGraphBin(gReferenceFdSyst,pt);
yPPh = gReferenceFdSyst->GetErrorYhigh(ibinfd);
yPPl = gReferenceFdSyst->GetErrorYlow(ibinfd);
}
} else {
yPPh = gSigmaPPSystFeedDown->GetErrorYhigh(istartPPfd);
yPPl = gSigmaPPSystFeedDown->GetErrorYlow(istartPPfd);
}
if (isRaavsEP>0.) {
yPPh = yPPh*0.5;
yPPl = yPPl*0.5;
}
yPPh *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
yPPl *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
yABh = gSigmaABSystFeedDown->GetErrorYhigh(istartABfd);
yABl = gSigmaABSystFeedDown->GetErrorYlow(istartABfd);
RaaCharmFDhigh = ( sigmaABMax / sigmaABCINT1B ) / ((Tab*1e3) * (sigmapp+yPPh) *1e-12 ) ;
RaaCharmFDlow = ( sigmaABMin / sigmaABCINT1B ) / ((Tab*1e3) * (sigmapp-yPPl) *1e-12 ) ;
if(printout && TMath::Abs(ptprintout-pt)<0.1 ) std::cout << std::endl<<" pt "<< pt << " Raa " << RaaCharm <<" high "<< RaaCharmFDhigh << " low "<< RaaCharmFDlow<<std::endl;
if(!isUseTaaForRaa) {
RaaCharmFDhigh = ( sigmaABMax ) / ( (A*B)* (sigmapp+yPPh) ) ;
RaaCharmFDlow = ( sigmaABMin ) / ( (A*B)* (sigmapp-yPPl) ) ;
}
if (fdMethod==kNb) {
RaaBeauty = Rb ;
RaaBeautyFDlow = Rb ;
RaaBeautyFDhigh = Rb ;
ntupleRAB->Fill( pt, Tab*1e3, sigmapp*1e-12, sigmaAB*1e-12, sigmaAB/sigmaABCINT1B,
sigmaABMax / sigmaABCINT1B, sigmaABMin / sigmaABCINT1B,
RaaCharm, RaaCharmFDhigh, RaaCharmFDlow, RaaBeauty, fcAB );
}
else if (fdMethod==kfc) {
RaaBeauty = ( RaaCharm / Rcb ) ;
RaaBeautyFDlow = ( RaaCharmFDlow / Rcb ) ;
RaaBeautyFDhigh = ( RaaCharmFDhigh / Rcb ) ;
hRABvsRcb->Fill( pt, RaaCharm, RaaBeauty );
ntupleRAB->Fill( pt, Tab*1e3, sigmapp*1e-12, sigmaAB*1e-12, sigmaAB/sigmaABCINT1B,
sigmaABMax / sigmaABCINT1B, sigmaABMin / sigmaABCINT1B,
Rcb, RaaCharm, RaaCharmFDhigh, RaaCharmFDlow, RaaBeauty, RaaBeautyFDhigh, RaaBeautyFDlow, fcAB );
}
hRABvsRb->Fill( pt, RaaCharm, RaaBeauty );
hRABvsRbFDlow->Fill( pt, RaaCharmFDlow, RaaBeautyFDlow );
hRABvsRbFDhigh->Fill( pt, RaaCharmFDhigh, RaaBeautyFDhigh );
if(printout && TMath::Abs(ptprintout-pt)<0.1) std::cout << " pt "<< pt << " Rb " << RaaBeauty <<" high "<< RaaBeautyFDhigh << " low "<< RaaBeautyFDlow <<std::endl;
hRABCharmVsRBeautyVsPt->Fill( pt, RaaBeauty, RaaCharm );
Int_t ptbin = hRABvsPt->FindBin( pt );
hRCharmVsRBeauty[ptbin]->Fill( RaaBeauty, RaaCharm );
hRCharmVsRBeauty[ptbin]->Fill( RaaBeautyFDlow, RaaCharmFDlow );
hRCharmVsRBeauty[ptbin]->Fill( RaaBeautyFDhigh, RaaCharmFDhigh );
if (fdMethod==kfc) {
if( TMath::Abs(Rcb-0.015)<0.009 ) hRABEloss00->Fill(pt,RaaCharm);
if( TMath::Abs(Rcb-0.5)<0.009 ) hRABEloss05->Fill(pt,RaaCharm);
if( TMath::Abs(Rcb-1.0)<0.009 ) {
hRABEloss10->Fill(pt,RaaCharm);
hRABvsRbFDhigh_proj->Fill(pt,RaaCharmFDhigh);
hRABvsRbFDlow_proj->Fill(pt,RaaCharmFDlow);
}
if( TMath::Abs(Rcb-1.5)<0.009 ) hRABEloss15->Fill(pt,RaaCharm);
if( TMath::Abs(Rcb-2.0)<0.009 ) hRABEloss20->Fill(pt,RaaCharm);
}
else if (fdMethod==kNb) {
if( TMath::Abs(RaaBeauty-0.015)<0.009 ) hRABEloss00->Fill(pt,RaaCharm);
if( TMath::Abs(RaaBeauty-0.5)<0.009 ) hRABEloss05->Fill(pt,RaaCharm);
if( TMath::Abs(RaaBeauty-1.0)<0.009 ) {
hRABEloss10->Fill(pt,RaaCharm);
hRABvsRbFDhigh_proj->Fill(pt,RaaCharmFDhigh);
hRABvsRbFDlow_proj->Fill(pt,RaaCharmFDlow);
}
if( TMath::Abs(RaaBeauty-1.5)<0.009 ) hRABEloss15->Fill(pt,RaaCharm);
if( TMath::Abs(RaaBeauty-2.0)<0.009 ) hRABEloss20->Fill(pt,RaaCharm);
}
Int_t hABbin = hMassAB->FindBin( pt );
if(isShadHypothesis) CentralHypo = centralRbcShad[hABbin];
if(printout && TMath::Abs(ptprintout-pt)<0.1)
if ( fdMethod==kNb && TMath::Abs(Rb -CentralHypo)< 0.05) {
std::cout << " pt "<< pt <<", at bin "<<hABbin<<std::endl;
std::cout<<" entries "<<entries<<", i="<<ientry<<", pt="<<pt<<", Rb="<<Rb<<", Tab="<<Tab<<", sigmaAB="<<sigmaAB<<", sigmapp="<<sigmapp<<", Raacharm="<<RaaCharm<<", RaaBeauty="<<RaaBeauty<<std::endl;
std::cout << " AB basis: mass "<< hMassAB->GetBinContent(hABbin)<<", eff "<< hDirectEffptAB->GetBinContent(hABbin)<<std::endl;
std::cout<<" FD low, err low AB "<< (sigmaAB-sigmaABMin)<<" err low PP "<< yPPl<<" Raacharm="<<RaaCharmFDlow<<", RaaBeauty="<<RaaBeautyFDlow<<std::endl;
std::cout<<" FD high, err high AB "<< (sigmaABMax-sigmaAB)<<" err high PP "<< yPPh<<" Raacharm="<<RaaCharmFDhigh<<", RaaBeauty="<<RaaBeautyFDhigh<<std::endl;
}
if(printout && TMath::Abs(ptprintout-pt)<0.1)
if ( fdMethod==kfc) if(TMath::Abs(Rcb -CentralHypo)< 0.05 ){
std::cout << " pt "<< pt <<", at bin "<<hABbin<<std::endl;
std::cout<<" entries "<<entries<<", i="<<ientry<<", pt="<<pt<<", Rcb="<<Rcb<<", Tab="<<Tab<<", sigmaAB="<<sigmaAB<<", sigmapp="<<sigmapp<<", Raacharm="<<RaaCharm<<", RaaBeauty="<<RaaBeauty<<std::endl;
std::cout << " AB basis: mass "<< hMassAB->GetBinContent(hABbin)<<", eff "<< hDirectEffptAB->GetBinContent(hABbin)<<", fc "<<histofcAB->GetBinContent(hABbin)<< std::endl;
std::cout<<" FD low, err low AB "<< (sigmaAB-sigmaABMin)<<" err low PP "<< yPPl<<" Raacharm="<<RaaCharmFDlow<<", RaaBeauty="<<RaaBeautyFDlow<<std::endl;
std::cout<<" FD high, err high AB "<< (sigmaABMax-sigmaAB)<<" err high PP "<< yPPh<<" Raacharm="<<RaaCharmFDhigh<<", RaaBeauty="<<RaaBeautyFDhigh<<std::endl;
}
//
// Fill in the global properties ?
//
Double_t ElossHypo = 0.;
if (fdMethod==kfc) { ElossHypo = 1./ Rcb; }
else { ElossHypo = 1. / (RaaCharm / RaaBeauty); }
if(isRbHypo) ElossHypo = RaaBeauty;
hRCharmVsElossHypo[ptbin]->Fill( ElossHypo, RaaCharm );
// If using shadowing hypothesis, change the limit hypothesis too
if(isShadHypothesis) {
MinHypo = minRbcShad[ hABbin ];
MaxHypo = maxRbcShad[ hABbin ];
}
if(fChangeCentralHypo && pt<3 && (decay==1 || decay==2 || decay==3)){
MinHypo = 1.0;
MaxHypo = 2.0;
printf("********* changed min and max hypothesis for pt<3 (%f): %f, minHypo=%f, maxHypo=%f \n",pt,CentralHypo,MinHypo,MaxHypo);
}
if(fChangeCentralHypo && pt>=24 && (decay==1 || decay==2 || decay==3)){
MinHypo = 1.0;
MaxHypo = 2.0;
printf("********* changed min and max hypothesis for pt>=24 (%f): %f, minHypo=%f, maxHypo=%f \n",pt,CentralHypo,MinHypo,MaxHypo);
}
// std::cout <<" pt "<< pt << " Raa charm " << RaaCharm << " Raa beauty " << RaaBeauty << " eloss hypo "<< ElossHypo
if(ientry==0) std::cout<<" pt"<< pt<< " ElossCentral "<< ElossCentral[hABbin] << " min-hypo "<<MinHypo << " max-hypo "<<MaxHypo<<std::endl;
//
// Fill in histos charm (null Eloss hypothesis)
//
Double_t minFdSyst = 0., maxFdSyst = 0.;
if ( ElossHypo == ElossCentral[ hABbin ] ) {
//
// Data stat uncertainty
//
Double_t sigmappStat = hSigmaPP->GetBinError( hppbin );
if (isRaavsEP>0.) sigmappStat = sigmappStat*0.5;
sigmappStat *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
Int_t hRABbin = hRABvsPt->FindBin( pt );
Double_t stat = RaaCharm * TMath::Sqrt( (statUncSigmaAB/sigmaAB)*(statUncSigmaAB/sigmaAB) +
(sigmappStat/sigmapp)*(sigmappStat/sigmapp) ) ;
if ( RaaCharm==0 ) stat =0.;
if ( RaaCharm>0 ) {
hRABvsPt->SetBinContent( hRABbin, RaaCharm );
hRABvsPt->SetBinError( hRABbin, stat );
hYieldABvsPt->SetBinContent( hRABbin, sigmaAB/sigmaABCINT1B );
hYieldABvsPt->SetBinError( hRABbin, statUncSigmaAB/sigmaABCINT1B );
std::cout << "pt="<< pt<< " Raa " << RaaCharm << " stat unc. "<< stat <<
" sigma-pp "<< sigmapp <<" sigma-AB "<< sigmaAB<<std::endl;
if(printout && TMath::Abs(ptprintout-pt)<0.1) {
std::cout << " Raa " << RaaCharm << " stat unc. "<< stat << " is "<< stat/RaaCharm * 100. <<
"%, stat-pp "<< sigmappStat/sigmapp*100. <<"% stat-AB "<< statUncSigmaAB/sigmaAB*100.<<"%"<<std::endl;
}
Double_t errstatEff = fhStatUncEffcSigmaAB->GetBinError( hRABbin );
fhStatUncEffcSigmaAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
errstatEff = fhStatUncEffbSigmaAB->GetBinError( hRABbin );
fhStatUncEffbSigmaAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
errstatEff = fhStatUncEffcFDAB->GetBinError( hRABbin );
fhStatUncEffcFDAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
errstatEff = fhStatUncEffbFDAB->GetBinError( hRABbin );
fhStatUncEffbFDAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
}
//
//
// Data systematics (sigma syst-but FD + extrap) syst
//
//
// Data syst: a) Syst in p-p
//
Double_t ptwidth = hSigmaAB->GetBinWidth(hABbin) / 2. ;
istartPPextr = -1;
if(!isExtrapolatedBin) istartPPextr = FindGraphBin(gSigmaPPSystTheory,pt);
Double_t dataPPUp=0., dataPPLow=0.;
if(isExtrapolatedBin) {
dataPPUp = gSigmaPPSyst->GetErrorYhigh(istartPPsyst);
dataPPLow = gSigmaPPSyst->GetErrorYlow(istartPPsyst);
systPPUp = dataPPUp;
systPPLow = dataPPLow;
} else {
dataPPUp = ExtractFDSyst( gSigmaPPSystData->GetErrorYhigh(istartPPextr), gSigmaPPSystFeedDown->GetErrorYhigh(istartPPfd) );
dataPPLow = ExtractFDSyst( gSigmaPPSystData->GetErrorYlow(istartPPextr), gSigmaPPSystFeedDown->GetErrorYlow(istartPPfd) );
systPPUp = TMath::Sqrt( dataPPUp*dataPPUp + gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr) );
systPPLow = TMath::Sqrt( dataPPLow*dataPPLow + gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*gSigmaPPSystTheory->GetErrorYlow(istartPPextr) );
}
if (isRaavsEP>0.) {
dataPPUp = dataPPUp*0.5;
dataPPLow = dataPPLow*0.5;
if(isExtrapolatedBin) {
systPPUp = dataPPUp;
systPPLow = dataPPLow;
} else {
systPPUp = TMath::Sqrt( dataPPUp*dataPPUp + 0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr) );
systPPLow = TMath::Sqrt( dataPPLow*dataPPLow + 0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr) );
}
}
systPPUp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
systPPLow *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
if(printout && TMath::Abs(ptprintout-pt)<0.1) {
std::cout << " pt : "<< pt<<" Syst-pp-data "<< dataPPUp/sigmapp << "%, ";
if(!isExtrapolatedBin){
if (isRaavsEP>0.) std::cout <<" extr unc + "<< 0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)/sigmapp <<" - "<< 0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr)/sigmapp <<" %";
else std::cout <<" extr unc + "<< (gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*scalePPRefToMatchRapidityBin)/sigmapp <<" - "<< (gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*scalePPRefToMatchRapidityBin)/sigmapp <<" %";
}
std::cout << std::endl;
}
//
// Data syst: b) Syst in PbPb
//
Double_t dataSystUp=0., dataSystDown=0.;
Bool_t PbPbDataSystOk = PbPbDataSyst(systematicsAB,pt,cc,dataSystUp,dataSystDown);
if (!PbPbDataSystOk) { std::cout <<" There is some issue with the PbPb data systematics, please check and rerun"<<std::endl; return; }
systABUp = sigmaAB * TMath::Sqrt( dataSystUp*dataSystUp +
(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin))*(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin)) );
systABLow = sigmaAB * TMath::Sqrt( dataSystDown*dataSystDown +
(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin))*(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin)) );
//
// Data syst : c) combine pp & PbPb
//
systLow = sigmapp>0. ?
RaaCharm * TMath::Sqrt( (systABLow/sigmaAB)*(systABLow/sigmaAB) + (systPPUp/sigmapp)*(systPPUp/sigmapp) )
: 0.;
systUp = sigmapp>0. ?
RaaCharm * TMath::Sqrt( (systABUp/sigmaAB)*(systABUp/sigmaAB) + (systPPLow/sigmapp)*(systPPLow/sigmapp) )
: 0.;
if ( RaaCharm==0 ) { systPPUp =0.; systPPLow =0.; }
// if(printout)
std::cout << " Syst-pp-up "<< systPPUp/sigmapp <<"%, syst-pp-low "<< systPPLow/sigmapp <<"%, syst-AB-up "<<systABUp/sigmaAB<<"%, syst-AB-low "<<systABLow/sigmaAB<<"%, tot-syst-up "<<systUp/RaaCharm<<"%, tot-syst-low "<<systLow/RaaCharm<<"%"<<std::endl;
if ( RaaCharm>0 ) {
hRABvsPt_DataSystematics->SetBinContent( hRABbin, RaaCharm );
hRABvsPt_DataSystematics->SetBinError( hRABbin, systUp );
gRAB_DataSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_DataSystematics->SetPointError( hABbin, ptwidth, ptwidth, systLow, systUp );
gRAB_DataSystematics->SetPointEXlow(hABbin, 0.4); gRAB_DataSystematics->SetPointEXhigh(hABbin,0.4);
gRAB_DataSystematicsPP->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_DataSystematicsPP->SetPointError( hABbin, ptwidth, ptwidth, RaaCharm *(systPPUp/sigmapp), RaaCharm *systPPLow/sigmapp );
gRAB_DataSystematicsAB->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_DataSystematicsAB->SetPointError( hABbin, ptwidth, ptwidth, RaaCharm *systABLow/sigmaAB, RaaCharm *systABUp/sigmaAB );
}
//
// Feed-down Systematics
//
Double_t FDL=0., FDH=0.;
if ( RaaCharmFDhigh > RaaCharmFDlow ){
FDH = RaaCharmFDhigh; FDL = RaaCharmFDlow;
} else {
FDL = RaaCharmFDhigh; FDH = RaaCharmFDlow;
}
if(printout && TMath::Abs(ptprintout-pt)<0.1) std::cout<<" Raa "<<RaaCharm<<", Raa-fd-low "<<RaaCharmFDlow <<", Raa-fd-high "<<RaaCharmFDhigh <<std::endl;
maxFdSyst = TMath::Abs(FDH - RaaCharm);
minFdSyst = TMath::Abs(RaaCharm - FDL);
if ( RaaCharm>0 ) {
gRAB_FeedDownSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_FeedDownSystematics->SetPointError( hABbin, 0.3, 0.3, minFdSyst, maxFdSyst ); // i, x, y
gRAB_fcFeedDownOnly->SetPoint( hABbin, pt,fcAB );
gRAB_fcFeedDownOnly->SetPointError(hABbin, 0.3, 0.3, fcAB-(sigmaABMin/sigmaAB*fcAB), (sigmaABMax/sigmaAB*fcAB)-fcAB );
}
// if(printout) {
std::cout<<" FD syst +"<< maxFdSyst/RaaCharm <<" - "<<minFdSyst/RaaCharm<<std::endl;
std::cout<<" fc = "<<fcAB<<", ("<< sigmaABMax/sigmaAB * fcAB <<","<< sigmaABMin/sigmaAB * fcAB <<")"<<std::endl;
// }
//
// Filling part of the Eloss scenarii information
//
if(RaaCharm>0 ) {
gRAB_ElossHypothesis->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_ElossHypothesis->SetPointEXlow( hABbin, ptwidth);
gRAB_ElossHypothesis->SetPointEXhigh( hABbin, ptwidth);
gRAB_FeedDownSystematicsElossHypothesis->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_FeedDownSystematicsElossHypothesis->SetPointEXlow( hABbin, ptwidth);
gRAB_FeedDownSystematicsElossHypothesis->SetPointEXhigh( hABbin, ptwidth);
gRAB_GlobalSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
gRAB_GlobalSystematics->SetPointEXlow(hABbin,0.4); gRAB_GlobalSystematics->SetPointEXhigh(hABbin,0.4);
}
}
//
// Filling Eloss scenarii information
//
// trick in case not fine enough Rb hypothesis to cope with the min/max range
// if( RaaCharm>0 && ( (ElossHypo >= MinHypo && ElossHypo <=MaxHypo) || ElossHypo == ElossCentral[ hABbin ] ) && RaaBeauty<=MaxRb ) {
// by default better not use it, to monitor when this happens (could affect results)
if( RaaCharm>0 && ElossHypo >= MinHypo && ElossHypo <=MaxHypo && RaaBeauty<=MaxRb ) {
Double_t Ehigh = ElossMax[ hABbin ] ;
Double_t Elow = ElossMin[ hABbin ] ;
if ( RaaCharm > Ehigh ) ElossMax[ hABbin ] = RaaCharm ;
if ( RaaCharm < Elow ) ElossMin[ hABbin ] = RaaCharm ;
if(printout && TMath::Abs(ptprintout-pt)<0.1) {
std::cout<<" Hypothesis " << ElossHypo << " sigma-AB "<< sigmaAB <<", Raa "<< RaaCharm <<", Raa Eloss max "<< ElossMax[hABbin] <<" Raa Eloss min "<< ElossMin[hABbin] << " Rb="<< RaaBeauty <<std::endl;
std::cout<<" Rb="<< RaaBeauty <<" max "<< RaaBeautyFDhigh <<" min "<< RaaBeautyFDlow <<std::endl;
}
Double_t fcEhigh = fcElossMax[ hABbin ] ;
Double_t fcElow = fcElossMin[ hABbin ] ;
if ( fcAB > fcEhigh ) fcElossMax[ hABbin ] = fcAB ;
if ( fcAB < fcElow ) fcElossMin[ hABbin ] = fcAB ;
Double_t FDEhigh = FDElossMax[ hABbin ];
Double_t FDEmin = FDElossMin[ hABbin ];
Double_t RFDhigh = RaaCharmFDhigh>RaaCharmFDlow ? RaaCharmFDhigh : RaaCharmFDlow;
Double_t RFDlow = RaaCharmFDlow<RaaCharmFDhigh ? RaaCharmFDlow : RaaCharmFDhigh;
if ( RFDhigh > FDEhigh ) FDElossMax[ hABbin ] = RFDhigh ;
if ( RFDlow < FDEmin ) FDElossMin[ hABbin ] = RFDlow ;
if(printout && TMath::Abs(ptprintout-pt)<0.1)
std::cout<<" Hypothesis " << ElossHypo << " sigma-AB "<< sigmaAB <<", Raa FD-max Eloss max "<< FDElossMax[hABbin] <<" Raa FD-min Eloss min "<< FDElossMin[hABbin] <<std::endl;
}