-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpLambda_1.cpp
18410 lines (16079 loc) · 744 KB
/
pLambda_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "pLambda_1.h"
#include "FemtoBoyzScripts.h"
#include "OtherTasks.h"
#include "TROOT.h"
#include "TString.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TFile.h"
#include "TLegend.h"
#include "TPaveText.h"
#include "TGraph.h"
#include "TGraphErrors.h"
#include "TF1.h"
#include "TNtuple.h"
#include "TTree.h"
#include "TRandom3.h"
#include "TLatex.h"
#include "TStyle.h"
#include "TSystem.h"
#include "TAttFill.h"
#include "TSpline.h"
#include "TObjString.h"
#include "CATS.h"
#include "CATSconstants.h"
#include "DLM_CkDecomposition.h"
#include "DLM_CkModels.h"
#include "DLM_Ck.h"
#include "CommonAnaFunctions.h"
#include "DLM_Fitters.h"
#include "EnvVars.h"
#include "DLM_Unfold.h"
#include "DLM_HistoAnalysis.h"
#include "DLM_SubPads.h"
#include "DLM_Sort.h"
#include "DLM_Integration.h"
#include "DLM_RootWrapper.h"
#include "DLM_Histo.h"
#include "DLM_DecayMatrix.h"
#include "DLM_Potentials.h"
#include "DLM_Source.h"
#include "DLM_Random.h"
#include "DLM_DrawingTools.h"
#include <unistd.h>
#include <fcntl.h>
#include <cerrno>
#include <iostream>
#include <fstream>
#include "omp.h"
using namespace std;
TH1F* pL_CleverRebin(TH1F* hData_pL, const unsigned& NumMomBins_pL, const double* MomBins_pL){
//the one with var binning
//unsigned NumMomBinsData_pL = NumMomBins_pL+20;
unsigned NumMomBinsData_pL = hData_pL->GetNbinsX();
double* MomBinsData_pL = new double [NumMomBinsData_pL+1];
double StepSize=0;
double StepSize0=0;
for(unsigned uBin=0; uBin<=NumMomBinsData_pL; uBin++){
if(!uBin){StepSize=MomBins_pL[uBin+1]-MomBins_pL[uBin];}
if(uBin<=NumMomBins_pL){
MomBinsData_pL[uBin]=MomBins_pL[uBin];
}
else{
MomBinsData_pL[uBin]=MomBinsData_pL[uBin-1]+StepSize;
}
}
TH1F* hDataClever_pL = new TH1F("hDataClever_pL","hDataClever_pL",NumMomBinsData_pL,MomBinsData_pL);
for(unsigned uBin=1; uBin<=NumMomBinsData_pL; uBin++){
StepSize=hDataClever_pL->GetBinWidth(uBin);
int Which0bin = hData_pL->FindBin(hDataClever_pL->GetBinLowEdge(uBin));
int Initial0bin = Which0bin;
StepSize0=hData_pL->GetBinWidth(Which0bin);
if(fabs(StepSize-StepSize0)<1e-6){
hDataClever_pL->SetBinContent(uBin,hData_pL->GetBinContent(Which0bin));
hDataClever_pL->SetBinError(uBin,hData_pL->GetBinError(Which0bin));
}
else{
while(hData_pL->GetBinCenter(Which0bin)<hDataClever_pL->GetXaxis()->GetBinUpEdge(uBin)){
Which0bin++;
}
double BinError=0;
double BinContent=0;
for(int uFineBin=Initial0bin; uFineBin<Which0bin; uFineBin++){
BinContent+=hData_pL->GetBinContent(uFineBin);
BinError+=hData_pL->GetBinError(uFineBin)*hData_pL->GetBinError(uFineBin);
}
hDataClever_pL->SetBinContent(uBin,BinContent/double(Which0bin-Initial0bin));
hDataClever_pL->SetBinError(uBin,sqrt(BinError)/double(Which0bin-Initial0bin));
}
}
//TFile* fTemp = new TFile(OutputFolder+"fTemp.root","recreate");
//hData_pL->Write();
//hDataClever_pL->Write();
//delete fTemp;
return hDataClever_pL;
}
//a fitter to fit pp and pL using a specific source
//we can fit them together or separately
//For feed-down we will use only pSigma0 and pXi, where the former we model as Oli,
//the latter we model with HALQCD, by fixing the source and radius to a Gauss of size 1.18 (-20% for the systematic variation)
//Fitting mode:
//"Norm": only norm
//"Baseline": baseline but only in the femto region
//"Longbaseline": baseline extending to higher k
//"Longbaseline_prefit": prefit the baseline assuming Cl=1
void Fit_pp_pL(const TString& DataSample, const TString& SourceType, const TString& FittingMode_pp, const TString& FittingMode_pL){
DLM_CommonAnaFunctions AnalysisObject; AnalysisObject.SetCatsFilesFolder("/mnt/Ubuntu_Data/CernBox/Sync/CatsFiles");
const TString OutputFolder = TString::Format("/home/dmihaylov/Dudek_Ubuntu/Work/Kclus/GeneralFemtoStuff/Using_CATS3/Output/pLambda_1/Fit_pp_pL/Test/");
const bool SameSourceSize = false;
const bool SameStability = false;
//the residuals that are not fitted, are assumed to all have a Gaussian source of some size;
double ResidualSourceSize=0;
if(DataSample=="pp13TeV_MB_Run2paper") ResidualSourceSize=1.1;
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19") ResidualSourceSize=1.4;
else if(DataSample=="pp13TeV_HM_March19") ResidualSourceSize=1.4;
else printf("\033[1;31mERROR:\033[0m The data sample '%s' does not exist\n",DataSample.Data());
const unsigned Num_pp_pots = 1;
const unsigned Num_pL_pots = 6;
const unsigned Num_pXim_pots = 2;
const TString pp_Pot[Num_pp_pots] = {"AV18"};
const bool Use_pp_Pot[Num_pp_pots] = {true};
const TString pL_Pot[Num_pL_pots] = {"LO", "LO_Coupled_S", "NLO", "NLO_sp", "NLO_Coupled_S", "Usmani"};
const bool Use_pL_Pot[Num_pL_pots] = {false, false, false, false, false, true};
const TString pXim_Pot[Num_pXim_pots] = {"pXim_HALQCD1","pXim_Lattice"};
const bool Use_pXim_Pot[Num_pXim_pots] = {true, false};
double lambda_pp[4];
AnalysisObject.SetUpLambdaPars_pp(DataSample,0,lambda_pp);
double lambda_pL[5];
AnalysisObject.SetUpLambdaPars_pL(DataSample,0,0,lambda_pL);
double lambda_pXim[5];
AnalysisObject.SetUpLambdaPars_pXim(DataSample,0,0,lambda_pXim);
double* MomBins_pp = NULL;
double* FitRegion_pp = NULL;
unsigned NumMomBins_pp;
AnalysisObject.SetUpBinning_pp(DataSample,NumMomBins_pp,MomBins_pp,FitRegion_pp);
double* MomBins_pL = NULL;
double* FitRegion_pL = NULL;
unsigned NumMomBins_pL;
AnalysisObject.SetUpBinning_pL(DataSample,NumMomBins_pL,MomBins_pL,FitRegion_pL,0,0);
DLM_Ck* Ck_pSigma0 = new DLM_Ck(1,0,NumMomBins_pL,MomBins_pL,Lednicky_gauss_Sigma0);
Ck_pSigma0->SetSourcePar(0,ResidualSourceSize);
TH2F* hResolution_pp = AnalysisObject.GetResolutionMatrix(DataSample,"pp");
TH2F* hResolution_pL = AnalysisObject.GetResolutionMatrix(DataSample,"pLambda");
TH2F* hResidual_pp_pL = AnalysisObject.GetResidualMatrix("pp","pLambda");
TH2F* hResidual_pL_pSigma0 = AnalysisObject.GetResidualMatrix("pLambda","pSigma0");
TH2F* hResidual_pL_pXim = AnalysisObject.GetResidualMatrix("pLambda","pXim");
//GetAliceExpCorrFun(const TString& DataSample,const TString& System,const TString& CutVar,const int& iReb, const bool& AddSyst=false,const int mTbin=-1)
TH1F* hData_pp = AnalysisObject.GetAliceExpCorrFun(DataSample,"pp","_0",0);
//! this has to be changed for finer binning
TH1F* hData_pL = AnalysisObject.GetAliceExpCorrFun(DataSample,"pLambda","_0",2);
//TH1F* hDataClever_pL = pL_CleverRebin(hData_pL,NumMomBins_pL,MomBins_pL);
double lam_pp[4];
double lam_pL[5];
double lam_pXim[5];
AnalysisObject.SetUpLambdaPars_pp(DataSample,0,lam_pp);
AnalysisObject.SetUpLambdaPars_pL(DataSample,0,0,lam_pL);
AnalysisObject.SetUpLambdaPars_pXim(DataSample,0,0,lam_pXim);
TFile* OutputFile = new TFile(OutputFolder+TString::Format("Output_%s_%s_%s_%s.root",DataSample.Data(),SourceType.Data(),
FittingMode_pp.Data(),FittingMode_pL.Data()),"recreate");
hData_pp->Write();
hData_pL->Write();
//hDataClever_pL->Write();
//iterate over all potentials
for(unsigned uPot_pp=0; uPot_pp<Num_pp_pots; uPot_pp++){
if(!Use_pp_Pot[uPot_pp]) continue;
CATS AB_pp;
AB_pp.SetMomBins(NumMomBins_pp,MomBins_pp);
AnalysisObject.SetUpCats_pp(AB_pp,pp_Pot[uPot_pp],SourceType,0,2);
AB_pp.SetNotifications(CATS::nWarning);
AB_pp.KillTheCat();
DLM_Ck* Ck_pp = new DLM_Ck(AB_pp.GetNumSourcePars(),0,AB_pp);
for(unsigned uPot_pL=0; uPot_pL<Num_pL_pots; uPot_pL++){
if(!Use_pL_Pot[uPot_pL]) continue;
CATS AB_pL;
AB_pL.SetMomBins(NumMomBins_pL,MomBins_pL);
AnalysisObject.SetUpCats_pL(AB_pL,pL_Pot[uPot_pL],SourceType,0,3);
AB_pL.SetNotifications(CATS::nWarning);
AB_pL.KillTheCat();
DLM_Ck* Ck_pL = new DLM_Ck(AB_pL.GetNumSourcePars(),0,AB_pL);
for(unsigned uPot_pXim=0; uPot_pXim<Num_pXim_pots; uPot_pXim++){
if(!Use_pXim_Pot[uPot_pXim]) continue;
printf("Current iteration:----------------------\n");
printf(" Data sample: %s\n",DataSample.Data());
printf(" Source: %s\n",SourceType.Data());
printf(" Within this iteration I am at:\n");
printf(" pp: %s\n",pp_Pot[uPot_pp].Data());
printf(" pΛ: %s\n",pL_Pot[uPot_pL].Data());
printf(" pΞ: %s\n",pXim_Pot[uPot_pXim].Data());
CATS AB_pXim;
//same binning as pL, as we only use pXim as feed-down
AB_pXim.SetMomBins(NumMomBins_pL,MomBins_pL);
AnalysisObject.SetUpCats_pXim(AB_pXim,pXim_Pot[uPot_pXim],"Gauss");
AB_pXim.SetAnaSource(0,ResidualSourceSize);
AB_pXim.SetNotifications(CATS::nWarning);
AB_pXim.KillTheCat();
DLM_Ck* Ck_pXim = new DLM_Ck(AB_pXim.GetNumSourcePars(),0,AB_pXim);
Ck_pp->Update();
Ck_pL->Update();
Ck_pSigma0->Update();
Ck_pXim->Update();
DLM_CkDecomposition CkDec_pp("pp",3,*Ck_pp,hResolution_pp);
DLM_CkDecomposition CkDec_pL("pLambda",4,*Ck_pL,hResolution_pL);
DLM_CkDecomposition CkDec_pSigma0("pSigma0",0,*Ck_pSigma0,NULL);
DLM_CkDecomposition CkDec_pXim("pXim",2,*Ck_pXim,NULL);
CkDec_pp.AddContribution(0,lam_pp[1],DLM_CkDecomposition::cFeedDown,&CkDec_pL,hResidual_pp_pL);
CkDec_pp.AddContribution(1,lam_pp[2],DLM_CkDecomposition::cFeedDown);
CkDec_pp.AddContribution(2,lam_pp[3],DLM_CkDecomposition::cFake);
CkDec_pL.AddContribution(0,lam_pL[1],DLM_CkDecomposition::cFeedDown,&CkDec_pSigma0,hResidual_pL_pSigma0);
CkDec_pL.AddContribution(1,lam_pL[2],DLM_CkDecomposition::cFeedDown,&CkDec_pXim,hResidual_pL_pXim);
CkDec_pL.AddContribution(2,lam_pL[3],DLM_CkDecomposition::cFeedDown);
CkDec_pL.AddContribution(3,lam_pL[4],DLM_CkDecomposition::cFake);//0.03
//for Xim we simplify a bit and take ALL feed-down as flat
CkDec_pXim.AddContribution(0,lam_pXim[1]+lam_pXim[2]+lam_pXim[3],DLM_CkDecomposition::cFeedDown);
CkDec_pXim.AddContribution(1,lam_pXim[4],DLM_CkDecomposition::cFake);
DLM_Fitter1* fitter = new DLM_Fitter1(2);
if(FittingMode_pp=="Norm"||FittingMode_pp.Contains("Baseline")){
//printf("FitRegion_pp[0]=%f FitRegion_pp[1]=%f\n",FitRegion_pp[0],FitRegion_pp[1]);
fitter->SetSystem(0,*hData_pp,1,CkDec_pp,
FitRegion_pp[0],FitRegion_pp[1],FitRegion_pp[1],FitRegion_pp[1]);
}
else if(FittingMode_pp.Contains("Longbaseline")){
fitter->SetSystem(0,*hData_pp,1,CkDec_pp,
FitRegion_pp[0],FitRegion_pp[1],FitRegion_pp[2],FitRegion_pp[3]);
}
else{
printf("\033[1;31mERROR:\033[0m Unknown fitting mode '%s'",FittingMode_pp.Data());
}
if(FittingMode_pL=="Norm"||FittingMode_pL.Contains("Baseline")){
fitter->SetSystem(1,*hData_pL,1,CkDec_pL,
FitRegion_pL[0],FitRegion_pL[1],FitRegion_pL[1],FitRegion_pL[1]);
}
else if(FittingMode_pL.Contains("Longbaseline")){
fitter->SetSystem(1,*hData_pL,1,CkDec_pL,
FitRegion_pL[0],FitRegion_pL[1],FitRegion_pL[2],FitRegion_pL[3]);
}
else{
printf("\033[1;31mERROR:\033[0m Unknown fitting mode '%s'",FittingMode_pL.Data());
}
fitter->SetSeparateBL(0,false);
fitter->SetSeparateBL(1,false);
//!p_a
fitter->SetParameter("pp",DLM_Fitter1::p_a,1.0,0.7,1.3);
fitter->SetParameter("pLambda",DLM_Fitter1::p_a,1.0,0.7,1.3);
//!p_b
if(FittingMode_pp.Contains("Baseline")||FittingMode_pp.Contains("Longbaseline"))
fitter->SetParameter("pp",DLM_Fitter1::p_b,0,-2e-3,2e-3);
else
fitter->FixParameter("pp",DLM_Fitter1::p_b,0);
if(FittingMode_pL.Contains("Baseline")||FittingMode_pL.Contains("Longbaseline"))
fitter->SetParameter("pLambda",DLM_Fitter1::p_b,0,-2e-3,2e-3);
else
fitter->FixParameter("pLambda",DLM_Fitter1::p_b,0);
//!p_c
if(FittingMode_pp.Contains("Baseline2")||FittingMode_pp.Contains("Longbaseline2"))
fitter->SetParameter("pp",DLM_Fitter1::p_c,0,-2e-3,2e-3);
else
fitter->FixParameter("pp",DLM_Fitter1::p_c,0);
if(FittingMode_pL.Contains("Baseline2")||FittingMode_pL.Contains("Longbaseline2"))
fitter->SetParameter("pLambda",DLM_Fitter1::p_c,0,-2e-3,2e-3);
else
fitter->FixParameter("pLambda",DLM_Fitter1::p_c,0);
fitter->FixParameter("pp",DLM_Fitter1::p_Cl,-1);
fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,-1);
//!p_sor0
if(SourceType=="Gauss"){
fitter->SetParameter("pp",DLM_Fitter1::p_sor0,1.1,0.6,1.6);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.2,0.8,1.8);
if(SameSourceSize){
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor0,"pp",DLM_Fitter1::p_sor0);
}
//fitter->FixParameter("pp",DLM_Fitter1::p_sor0,1.41);
//fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,1.41);
}
else if(SourceType=="CleverLevy_Nolan"||SourceType=="CleverLevy_Single"||SourceType=="CleverLevy_Diff"){
fitter->SetParameter("pp",DLM_Fitter1::p_sor0,1.0,0.3,1.7);
fitter->SetParameter("pp",DLM_Fitter1::p_sor1,1.6,1.0,2.0);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.0,0.3,1.7);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.4,1.0,2.0);
if(SameSourceSize){
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor0,"pp",DLM_Fitter1::p_sor0);
}
if(SameStability){
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor1,"pp",DLM_Fitter1::p_sor1);
}
}
else if(SourceType=="McLevyNolan_Reso"){
/*
fitter->SetParameter("pp",DLM_Fitter1::p_sor0,0.8,0.2,1.4);
fitter->SetParameter("pp",DLM_Fitter1::p_sor1,1.6,1.0,2.0);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.8,0.2,1.4);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.4,1.0,2.0);
if(SameSourceSize){
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor0,"pp",DLM_Fitter1::p_sor0);
}
if(SameStability){
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor1,"pp",DLM_Fitter1::p_sor1);
}
*/
if(DataSample=="pp13TeV_MB_Run2paper"){
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,0.82);//at mT 1.27
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,1.5);
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.71);//at mT 1.44
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.5);
}
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19"){
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,1.12);//at mT 1.32
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,1.45);
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,1.02);//at mT 1.52
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.45);
}
else if(DataSample=="pp13TeV_HM_March19"){
//fitter->FixParameter("pp",DLM_Fitter1::p_sor0,1.03);//at mT 1.35
//fitter->FixParameter("pp",DLM_Fitter1::p_sor1,1.5);
//fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.92);//at mT 1.55
//fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.5);
fitter->SetParameter("pp",DLM_Fitter1::p_sor0,1.0,0.3,1.7);
fitter->SetParameter("pp",DLM_Fitter1::p_sor1,1.6,1.0,2.0);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.0,0.3,1.7);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.4,1.0,2.0);
}
else printf("WHAT HAPPEND?\n");
}
else if(SourceType=="McGauss_Reso"){
if(DataSample=="pp13TeV_MB_Run2paper"){
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,0.79);//at mT 1.27
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,2.0);
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.71);//at mT 1.44
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19"){
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,1.01);//at mT 1.32
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,2.0);
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.95);//at mT 1.52
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else if(DataSample=="pp13TeV_HM_March19"){
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,0.96);//at mT 1.35
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,2.0);
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.87);//at mT 1.55
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else printf("WHAT HAPPEND?\n");
if(SameSourceSize){
//fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor0,"pp",DLM_Fitter1::p_sor0);
}
}
else{
printf("\033[1;31mERROR:\033[0m '%s' does not exist",SourceType.Data());
}
//fitter->AddSameParameter("pp",DLM_Fitter1::p_sor0,"pLambda",DLM_Fitter1::p_sor0);
//fitter->AddSameParameter("pp",DLM_Fitter1::p_sor1,"pLambda",DLM_Fitter1::p_sor1);
//fitter->AddSameParameter("pp",DLM_Fitter1::p_a,"pLambda",DLM_Fitter1::p_a);
//fitter->AddSameParameter("pp",DLM_Fitter1::p_b,"pLambda",DLM_Fitter1::p_b);
//fitter->AddSameParameter("pp",DLM_Fitter1::p_c,"pLambda",DLM_Fitter1::p_c);
fitter->FixParameter("pp",DLM_Fitter1::p_sor0,1.05);
fitter->FixParameter("pp",DLM_Fitter1::p_sor1,1.6);
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor0,"pp",DLM_Fitter1::p_sor0);
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_sor1,"pp",DLM_Fitter1::p_sor1);
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_a,"pp",DLM_Fitter1::p_a);
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_b,"pp",DLM_Fitter1::p_b);
fitter->AddSameParameter("pLambda",DLM_Fitter1::p_c,"pp",DLM_Fitter1::p_c);
//AB_pp.KillTheCat();
//AB_pL.KillTheCat();
CkDec_pp.Update();
CkDec_pL.Update();
CkDec_pSigma0.Update();
CkDec_pXim.Update();
fitter->GoBabyGo(false);
TGraph FitResult_pp;
FitResult_pp.SetName(TString::Format("pp_%s_%s_%s",pp_Pot[uPot_pp].Data(),pL_Pot[uPot_pL].Data(),pXim_Pot[uPot_pXim].Data()));
fitter->GetFitGraph(0, FitResult_pp);
TGraph FitResult_pL;
FitResult_pL.SetName(TString::Format("pL_%s_%s_%s",pp_Pot[uPot_pp].Data(),pL_Pot[uPot_pL].Data(),pXim_Pot[uPot_pXim].Data()));
fitter->GetFitGraph(1, FitResult_pL);
//TString Description = TString::Format("%s_%s_%s",pp_Pot[uPot_pp].Data(),pL_Pot[uPot_pL].Data(),pXim_Pot[uPot_pXim].Data());
OutputFile->cd();
FitResult_pp.Write();
FitResult_pL.Write();
printf("χ2/ndf = %.2f/%i = %.2f\n",fitter->GetChi2(),fitter->GetNdf(),fitter->GetChi2Ndf());
printf("R(pp) = %.3f +/- %.3f\n",fitter->GetParameter("pp",DLM_Fitter1::p_sor0),fitter->GetParError("pp",DLM_Fitter1::p_sor0));
printf(" R(pΛ)= %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_sor0),fitter->GetParError("pLambda",DLM_Fitter1::p_sor0));
if(SourceType=="CleverLevy_Nolan"||SourceType=="CleverLevy_Single"||SourceType=="CleverLevy_Diff"||
SourceType=="McLevyNolan_Reso"||SourceType=="McGauss_Reso"){
printf("α(pp) = %.3f +/- %.3f\n",fitter->GetParameter("pp",DLM_Fitter1::p_sor1),fitter->GetParError("pp",DLM_Fitter1::p_sor1));
printf(" α(pΛ)= %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_sor1),fitter->GetParError("pLambda",DLM_Fitter1::p_sor1));
}
printf("Info on the baseline:\n");
printf("a(pp) = %.3f +/- %.3f\n",fitter->GetParameter("pp",DLM_Fitter1::p_a),fitter->GetParError("pp",DLM_Fitter1::p_a));
printf(" a(pΛ)= %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_a),fitter->GetParError("pLambda",DLM_Fitter1::p_a));
printf("a(pp) = %.3fe-3 +/- %.3f\n",fitter->GetParameter("pp",DLM_Fitter1::p_b)*1e3,fitter->GetParError("pp",DLM_Fitter1::p_b)*1e3);
printf(" a(pΛ)= %.3fe-3 +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_b)*1e3,fitter->GetParError("pLambda",DLM_Fitter1::p_b)*1e3);
printf("a(pp) = %.3fe-6 +/- %.3f\n",fitter->GetParameter("pp",DLM_Fitter1::p_c)*1e6,fitter->GetParError("pp",DLM_Fitter1::p_c)*1e6);
printf(" a(pΛ)= %.3fe-6 +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_c)*1e6,fitter->GetParError("pLambda",DLM_Fitter1::p_c)*1e6);
//printf("AB_pp.EvalCorrFun(25)=%.4f\n",AB_pp.EvalCorrFun(25));
//printf("AB_pp.EvaluateTheSource(25,2,0)=%.4f\n",AB_pp.EvaluateTheSource(25,2,0));
//printf("pars: %.3f, %.3f\n",AB_pp.AnaSourcePar->GetParameter(0),AB_pp.AnaSourcePar->GetParameter(1));
delete Ck_pXim;
delete fitter;
}
delete Ck_pL;
}
delete Ck_pp;
}
delete Ck_pSigma0;
delete [] MomBins_pp;
delete [] MomBins_pL;
delete [] FitRegion_pp;
delete [] FitRegion_pL;
//delete hDataClever_pL;
delete OutputFile;
}
//For feed-down we will use only pSigma0 and pXi, where the former we model as Oli,
//the latter we model with HALQCD, by fixing the source and radius to a Gauss of size 1.18 (-20% for the systematic variation)
//Fitting mode:
//"Norm": only norm
//"Baseline": baseline but only in the femto region
//"Longbaseline": baseline extending to higher k
//if SourceScale||SourceStability==0 => we take the values we have obtained from the pp fit (hard-coded at the moment)
//SourceScale == -1, fit within 10% of the expected value (based on mT or whatever)
//SourceScale == -11, completely free fit
//pL_Pot: "LO", "LO_Coupled_S", "NLO", "NLO_sp", "NLO_Coupled_S", "Usmani"
//in VARIATIONS:
//[0] = femto range
//[1] = fit range
//[2] = fractions for p
//[3] = fractions for L
//[4] = kc parameter
//[5] = which mT bin
//[6] = in case of Reso source: smearing of the mass of the resonance (on or off)//NOT ACTIVE YET
//[7] = in case of Reso source: smearing of the momentum of the resonance (fraction, from 0 to 1)//NOT ACTIVE YET
void Fit_pL(DLM_CommonAnaFunctions& AnalysisObject, const TString& OutputFolder, const TString& OutputFileName,
const TString& DataSample, const TString& DataVar, const TString& SourceType, const double& SourceScale, const double& SourceStability,
const TString& pL_Pot,const TString& FittingMode_pL, const int* VARIATIONS, const long& UniqueID=-1, const TString ntFileName="", const TString ntName=""){
//printf("VARIATIONS[2]=%i\n",VARIATIONS[2]);
//the residuals that are not fitted, are assumed to all have a Gaussian source of some size;
double ResidualSourceSize=0;
if(DataSample=="pp13TeV_MB_Run2paper") ResidualSourceSize=1.1;
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19") ResidualSourceSize=1.4;
else if(DataSample=="pp13TeV_HM_March19"||DataSample=="pp13TeV_HM_Dec19") ResidualSourceSize=1.4;
else printf("\033[1;31mERROR:\033[0m The data sample '%s' does not exist\n",DataSample.Data());
double* MomBins_pL = NULL;
double* FitRegion_pL = NULL;
unsigned NumMomBins_pL;
AnalysisObject.SetUpBinning_pL(DataSample,NumMomBins_pL,MomBins_pL,FitRegion_pL,VARIATIONS[0],VARIATIONS[1]);
//if(pL_Pot=="LO"||pL_Pot=="NLO"||pL_Pot=="Usmani"){
// FitRegion_pL[1] = 192;
// FitRegion_pL[2] = 312;
// FitRegion_pL[3] = 372;
//}
DLM_Ck* Ck_pSigma0 = new DLM_Ck(1,0,NumMomBins_pL,MomBins_pL,Lednicky_gauss_Sigma0);
Ck_pSigma0->SetSourcePar(0,ResidualSourceSize);
TH2F* hResolution_pL = AnalysisObject.GetResolutionMatrix(DataSample,"pLambda");
TH2F* hResidual_pL_pSigma0 = AnalysisObject.GetResidualMatrix("pLambda","pSigma0");
TH2F* hResidual_pL_pXim = AnalysisObject.GetResidualMatrix("pLambda","pXim");
TH1F* hData_pL = AnalysisObject.GetAliceExpCorrFun(DataSample,"pLambda",DataVar,2,false,VARIATIONS[5]);
double lam_pL[5];
double lam_pXim[5];
AnalysisObject.SetUpLambdaPars_pL(DataSample,VARIATIONS[2],VARIATIONS[3],lam_pL);
AnalysisObject.SetUpLambdaPars_pXim(DataSample,VARIATIONS[2],0,lam_pXim);
TString SourceDescription = SourceType;
if(SourceScale<0) {SourceDescription+="ScaFree";}
else if(SourceScale==0) {SourceDescription+="ScaDefault";}
else {SourceDescription+=TString::Format("Sca%.2f",SourceScale);}
if(SourceStability<0||SourceStability>2) {SourceDescription+="StaFree";}
else if(SourceStability==0) {SourceDescription+="StaDefault";}
else {SourceDescription+=TString::Format("Sta%.2f",SourceStability);}
TString OutFileName = OutputFileName;
if(OutFileName==""){
OutFileName=TString::Format("AUTO%li_%s_%s_%s_%s_%i_%i_%i_%i_%i_mT%i.root",UniqueID,
DataSample.Data(),SourceDescription.Data(),
pL_Pot.Data(),FittingMode_pL.Data(),
VARIATIONS[0],VARIATIONS[1],VARIATIONS[2],VARIATIONS[3],VARIATIONS[4],VARIATIONS[5]);
}
TFile* OutputFile = new TFile(OutputFolder+OutFileName,"recreate");
hData_pL->Write();
CATS AB_pL;
DLM_Ck* Ck_pL;
if(pL_Pot.Contains("Lednicky_")){
Ck_pL = AnalysisObject.SetUpLednicky_pL(NumMomBins_pL,MomBins_pL,pL_Pot);
Ck_pL->SetSourcePar(0,SourceScale);
}
else{
AB_pL.SetMomBins(NumMomBins_pL,MomBins_pL);
AnalysisObject.SetUpCats_pL(AB_pL,pL_Pot,SourceType,0,3);
AB_pL.SetNotifications(CATS::nWarning);
AB_pL.KillTheCat();
Ck_pL = new DLM_Ck(AB_pL.GetNumSourcePars(),0,AB_pL);
Ck_pL->SetSourcePar(0,SourceScale);
if(AB_pL.GetNumSourcePars()>1){
Ck_pL->SetSourcePar(0,SourceStability>=1?SourceStability:1.5);
}
}
CATS AB_pXim;
//same binning as pL, as we only use pXim as feed-down
AB_pXim.SetMomBins(NumMomBins_pL,MomBins_pL);
AnalysisObject.SetUpCats_pXim(AB_pXim,"pXim_HALQCD1","Gauss");
AB_pXim.SetAnaSource(0,ResidualSourceSize);
AB_pXim.SetNotifications(CATS::nWarning);
AB_pXim.KillTheCat();
DLM_Ck* Ck_pXim = new DLM_Ck(AB_pXim.GetNumSourcePars(),0,AB_pXim);
Ck_pL->Update();
Ck_pSigma0->Update();
Ck_pXim->Update();
DLM_CkDecomposition CkDec_pL("pLambda",4,*Ck_pL,hResolution_pL);
DLM_CkDecomposition CkDec_pSigma0("pSigma0",0,*Ck_pSigma0,NULL);
DLM_CkDecomposition CkDec_pXim("pXim",2,*Ck_pXim,NULL);
CkDec_pL.AddContribution(0,lam_pL[1],DLM_CkDecomposition::cFeedDown,&CkDec_pSigma0,hResidual_pL_pSigma0);
CkDec_pL.AddContribution(1,lam_pL[2],DLM_CkDecomposition::cFeedDown,&CkDec_pXim,hResidual_pL_pXim);
CkDec_pL.AddContribution(2,lam_pL[3],DLM_CkDecomposition::cFeedDown);
CkDec_pL.AddContribution(3,lam_pL[4],DLM_CkDecomposition::cFake);//0.03
//for Xim we simplify a bit and take ALL feed-down as flat
CkDec_pXim.AddContribution(0,lam_pXim[1]+lam_pXim[2]+lam_pXim[3],DLM_CkDecomposition::cFeedDown);
CkDec_pXim.AddContribution(1,lam_pXim[4],DLM_CkDecomposition::cFake);
DLM_Fitter1* fitter = new DLM_Fitter1(1);
if(FittingMode_pL.Contains("Norm")||FittingMode_pL.Contains("Baseline")||
(FittingMode_pL.Contains("S2020")&&!FittingMode_pL.Contains("pol3"))){
fitter->SetSystem(0,*hData_pL,1,CkDec_pL,
FitRegion_pL[0],FitRegion_pL[1],FitRegion_pL[1],FitRegion_pL[1]);
}
else if(FittingMode_pL.Contains("Longbaseline")||FittingMode_pL.Contains("Spline")||
FittingMode_pL.Contains("S2020_pol3")){
fitter->SetSystem(0,*hData_pL,1,CkDec_pL,
FitRegion_pL[0],FitRegion_pL[1],FitRegion_pL[2],FitRegion_pL[3]);
}
else{
printf("\033[1;31mERROR:\033[0m Unknown fitting mode '%s'",FittingMode_pL.Data());
}
if(FittingMode_pL.Contains("_prefit")){
fitter->SetSeparateBL(0,true);
fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,-1);
}
else{
fitter->SetSeparateBL(0,false);
//fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,-1);
//fitter->SetParameter("pLambda",DLM_Fitter1::p_Cl,-1,-1,-0.95);
if(pL_Pot.Contains("Lednicky_")){
fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,1);
}
else if(VARIATIONS[4]<0){
fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,-1);
}
else{
//fitter->SetParameter("pLambda",DLM_Fitter1::p_Cl,1,0.9,1.1);
if(VARIATIONS[4]>0&&FittingMode_pL!="Norm") fitter->FixParameter("pLambda",DLM_Fitter1::p_kc,VARIATIONS[4]);
else fitter->SetParameter("pLambda",DLM_Fitter1::p_kc,2000,400,10000);
//fitter->SetParameter("pLambda",DLM_Fitter1::p_kc,2000,400,10000);
}
}
printf("FittingMode_pL=%s\n",FittingMode_pL.Data());
//!p_a
fitter->SetParameter("pLambda",DLM_Fitter1::p_a,1.0,0.7,1.3);
if(FittingMode_pL.Contains("Spline")){
fitter->FixParameter("pLambda",DLM_Fitter1::p_a,1.0);
}
//!p_b
if(FittingMode_pL.Contains("Baseline")||FittingMode_pL.Contains("Longbaseline"))
fitter->SetParameter("pLambda",DLM_Fitter1::p_b,0,-2e-3,2e-3);
else
fitter->FixParameter("pLambda",DLM_Fitter1::p_b,0);
//!p_c
if(FittingMode_pL.Contains("Baseline2")||FittingMode_pL.Contains("Longbaseline2"))
fitter->SetParameter("pLambda",DLM_Fitter1::p_c,0,-2e-4,2e-4);
else
fitter->FixParameter("pLambda",DLM_Fitter1::p_c,0);
if(FittingMode_pL.Contains("Spline")){
int NumKnots=0;
if(FittingMode_pL.Contains("_2")) NumKnots=2;
if(FittingMode_pL.Contains("_3")) NumKnots=3;
if(FittingMode_pL.Contains("_4")) NumKnots=4;
if(FittingMode_pL.Contains("_5")) NumKnots=5;
if(FittingMode_pL.Contains("_6")) NumKnots=6;
if(FittingMode_pL.Contains("_7")) NumKnots=7;
if(FittingMode_pL.Contains("_8")) NumKnots=8;
if(FittingMode_pL.Contains("_9")) NumKnots=9;
if(FittingMode_pL.Contains("_10")) NumKnots=10;
if(FittingMode_pL.Contains("_11")) NumKnots=11;
if(FittingMode_pL.Contains("_Tune1")) NumKnots=5;
fitter->FixParameter("pLambda",DLM_Fitter1::p_spline,NumKnots);
fitter->FixParameter("pLambda",DLM_Fitter1::p_spline+1,0);
fitter->SetParameter("pLambda",DLM_Fitter1::p_spline+2,0);
double* Nodes_x = new double [NumKnots];
Nodes_x[0] = FitRegion_pL[0];
Nodes_x[NumKnots-1] = FitRegion_pL[3];
if(FittingMode_pL.Contains("_Tune1")){
Nodes_x[0] = 0;
Nodes_x[1] = 90;
Nodes_x[2] = 180;
Nodes_x[3] = 360;
Nodes_x[4] = 540;
fitter->FixParameter("pLambda",DLM_Fitter1::p_spline+2,0.00022);
}
else{
double NodeLength = (Nodes_x[NumKnots-1]-Nodes_x[0])/double(NumKnots-1);
//printf("NodeLength=%f\n",NodeLength);
for(int iKnot=1; iKnot<NumKnots-1; iKnot++){
Nodes_x[iKnot] = Nodes_x[iKnot-1]+NodeLength;
//printf("Nodes_x[%i]=%f\n",iKnot,Nodes_x[iKnot]);
}
}
for(int iKnot=0; iKnot<NumKnots; iKnot++){
fitter->FixParameter("pLambda",DLM_Fitter1::p_spline+3+iKnot,Nodes_x[iKnot]);//x
fitter->SetParameter("pLambda",DLM_Fitter1::p_spline+3+NumKnots+iKnot,1,0,5);//y
}
delete [] Nodes_x;
}
//!p_sor0
if(SourceType=="Gauss"){
if(SourceScale==0){fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,1.2);}
else if(SourceScale<0) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.2,0.5,2.0);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
}
else if(SourceType=="CleverLevy_Nolan"||SourceType=="CleverLevy_Single"||SourceType=="CleverLevy_Diff"){
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.0,0.3,1.7);
fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.4,1.0,2.0);
}
else if(SourceType=="McLevyNolan_Reso"){
if(DataSample=="pp13TeV_MB_Run2paper"){
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.71);}//at mT 1.44
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.71,0.71/2.,0.71*2.);}
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.71,0.71/2.,0.71*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
if(SourceStability==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.5);}
else if(SourceStability==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.5,1.5*0.90,1.5*1.10);}
else if(SourceStability==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.5,1.0,2.0);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,SourceStability);}
}
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19"){
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,1.02);}//at mT 1.44
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.02,1.02*0.90,1.02*1.10);}
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,1.02,1.02/2.,1.02*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
if(SourceStability==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.45);}
else if(SourceStability==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.45,1.45*0.90,1.45*1.10);}
else if(SourceStability==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.5,1.0,2.0);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,SourceStability);}
}
else if(DataSample=="pp13TeV_HM_March19"){
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.92);}//at mT 1.55
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.92,0.92*0.90,0.92*1.10);}
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.92,0.92/2.,0.92*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
if(SourceStability==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,1.5);}
else if(SourceStability==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.5,1.5*0.90,1.5*1.10);}
else if(SourceStability==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor1,1.5,1.0,2.0);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,SourceStability);}
}
else printf("WHAT HAPPEND?\n");
}
else if(SourceType=="McGauss_Reso"){
if(DataSample=="pp13TeV_MB_Run2paper"){
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.71);}//at mT 1.44
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.71,0.71*0.90,0.71*1.10);}
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.71,0.71/2.,0.71*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else if(DataSample=="pPb5TeV_Run2paper"||DataSample=="pPb5TeV_CPR_Mar19"){
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.95);}//at mT 1.52
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.95,0.95*0.90,0.95*1.10);}
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.95,0.95/2.,0.95*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else if(DataSample=="pp13TeV_HM_March19"){
//if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.87);}//at mT 1.55
//else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.87,0.87*0.90,0.87*1.10);}
//else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.87,0.87/2.,0.87*2.);}
//else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
//these are the value shown at the PF previews
//if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.918078);}//at mT 1.55
//else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.918078,0.90218,0.933344);}
if(SourceScale==0) {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,0.918);}//at mT 1.55
else if(SourceScale==-1) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.918,0.871,0.965);}//3 sigma
else if(SourceScale==-11) {fitter->SetParameter("pLambda",DLM_Fitter1::p_sor0,0.87,0.87/2.,0.87*2.);}
else {fitter->FixParameter("pLambda",DLM_Fitter1::p_sor0,SourceScale);}
fitter->FixParameter("pLambda",DLM_Fitter1::p_sor1,2.0);
}
else printf("WHAT HAPPEND?\n");
}
else{
printf("\033[1;31mERROR:\033[0m '%s' does not exist",SourceType.Data());
}
if(pL_Pot.Contains("Lednicky_")){
fitter->FixParameter("pLambda",DLM_Fitter1::p_pot0,Ck_pL->GetPotPar(0));
fitter->FixParameter("pLambda",DLM_Fitter1::p_pot1,Ck_pL->GetPotPar(1));
fitter->FixParameter("pLambda",DLM_Fitter1::p_pot2,Ck_pL->GetPotPar(2));
fitter->FixParameter("pLambda",DLM_Fitter1::p_pot3,Ck_pL->GetPotPar(3));
//fitter->SetFullCkForBaseline(0,true);
//fitter->FixParameter("pLambda",DLM_Fitter1::p_Cl,-1);
}
CkDec_pL.Update();
CkDec_pSigma0.Update();
CkDec_pXim.Update();
fitter->GoBabyGo(false);
TGraph FitResult_pL;
FitResult_pL.SetName(TString::Format("FitResult_pL"));
fitter->GetFitGraph(0, FitResult_pL);
//TString Description = TString::Format("%s_%s_%s",pp_Pot[uPot_pp].Data(),pL_Pot[uPot_pL].Data(),pXim_Pot[uPot_pXim].Data());
OutputFile->cd();
FitResult_pL.Write();
TGraph FitBaseline_pL;
FitBaseline_pL.SetName(TString::Format("FitBaseline_pL"));
fitter->GetMultBaselineGraph(0, FitBaseline_pL);
//TString Description = TString::Format("%s_%s_%s",pp_Pot[uPot_pL].Data(),pL_Pot[uPot_pL].Data(),pXim_Pot[uPot_pXim].Data());
OutputFile->cd();
FitBaseline_pL.Write();
fitter->GetUnfoldedCk(0,7,OutputFolder+"Unfold_"+OutFileName);
OutputFile->cd();
double CHI2_312=0;
unsigned NDF_312=0;
double xVal;
double yVal;
unsigned hBin;
for(unsigned uPoint=0; uPoint<FitResult_pL.GetN(); uPoint++){
FitResult_pL.GetPoint(uPoint,xVal,yVal);
if(xVal>312) break;
hBin = hData_pL->FindBin(xVal);
CHI2_312 += pow( (hData_pL->GetBinContent(hBin)-yVal)/(hData_pL->GetBinError(hBin)) ,2.);
NDF_312++;
}
printf("χ2/ndf = %.2f/%i = %.2f\n",fitter->GetChi2(),fitter->GetNdf(),fitter->GetChi2Ndf());
printf("χ2/ndf (312) = %.2f/%i = %.2f\n",CHI2_312,NDF_312,CHI2_312/double(NDF_312));
printf("R(pΛ) = %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_sor0),fitter->GetParError("pLambda",DLM_Fitter1::p_sor0));
if(AB_pL.GetNumSourcePars()>1){
printf("α(pΛ) = %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_sor1),fitter->GetParError("pLambda",DLM_Fitter1::p_sor1));
}
printf("a = %.2e +/- %.2e\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_a),fitter->GetParError("pLambda",DLM_Fitter1::p_a));
printf("b = %.2e +/- %.2e\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_b),fitter->GetParError("pLambda",DLM_Fitter1::p_b));
printf("c = %.2e +/- %.2e\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_c),fitter->GetParError("pLambda",DLM_Fitter1::p_c));
printf("Cl = %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_Cl),fitter->GetParError("pLambda",DLM_Fitter1::p_Cl));
printf("kc = %.3f +/- %.3f\n",fitter->GetParameter("pLambda",DLM_Fitter1::p_kc),fitter->GetParError("pLambda",DLM_Fitter1::p_kc));
printf("mT = %i\n",VARIATIONS[5]);
TGraph gChi2Ndf;
gChi2Ndf.SetName("gChi2Ndf");
gChi2Ndf.Set(1);
gChi2Ndf.SetPoint(0,fitter->GetChi2(),fitter->GetNdf());
gChi2Ndf.SetMarkerStyle(2);
gChi2Ndf.SetMarkerSize(4);
gChi2Ndf.Write();
TF1* fBaseline = new TF1("fBaseline","[0]+[1]*x+[2]*x*x",0,600);
fBaseline->FixParameter(0,fitter->GetParameter("pLambda",DLM_Fitter1::p_a));
fBaseline->FixParameter(1,fitter->GetParameter("pLambda",DLM_Fitter1::p_b));
fBaseline->FixParameter(2,fitter->GetParameter("pLambda",DLM_Fitter1::p_c));
fBaseline->SetLineColor(kCyan+4);
fBaseline->SetLineWidth(3);
fBaseline->SetLineStyle(7);
fBaseline->Write();
TGraphErrors gScaleStability;
gScaleStability.SetName("gScaleStability");
gScaleStability.Set(1);
double SCALE = fitter->GetParameter("pLambda",DLM_Fitter1::p_sor0);
double dSCALE = fitter->GetParError("pLambda",DLM_Fitter1::p_sor0);
double STABILITY = AB_pL.GetNumSourcePars()>1?fitter->GetParameter("pLambda",DLM_Fitter1::p_sor1):2;
double dSTABILITY = AB_pL.GetNumSourcePars()>1?fitter->GetParError("pLambda",DLM_Fitter1::p_sor1):0;
gScaleStability.SetPoint(0,SCALE,STABILITY);
gScaleStability.SetPointError(0,dSCALE,dSTABILITY);
gScaleStability.SetMarkerStyle(20);
gScaleStability.SetMarkerSize(1);
gScaleStability.SetLineWidth(2);
gScaleStability.Write();
//TFile* OutputFileNT = new TFile(OutputFolder+TString::Format("NT_%s_%s_%s_%s_%i_%i_%i_%i_%i.root",
// DataSample.Data(),SourceDescription.Data(),
// pL_Pot.Data(),FittingMode_pL.Data(),
// VARIATIONS[0],VARIATIONS[1],VARIATIONS[2],VARIATIONS[3],VARIATIONS[4]),"recreate");
TFile* NtFile = NULL;
TNtuple* ntResult = NULL;
if(ntFileName!=""&&ntName!=""){
bool FileIsOpen=false;
bool FileDoesNotExist=false;
double WaitedInSec=0;
do{
if(FileIsOpen) {usleep(1000); WaitedInSec+=1e-3;}//sleep for a millisecond
if(WaitedInSec>60){
printf("\033[1;31mERROR: \033[0mCannot access the file %s\n", ntFileName.Data());
printf("\033[1;31m ABORTING THE EXECUTABLE!\033[0m\n");
abort();
}
int fd = open(ntFileName.Data(), O_RDONLY);
if (fd < 0) {
//perror("open");
//file does not exist
FileIsOpen = false;
FileDoesNotExist = true;
}
if (fcntl(fd, F_SETLEASE, F_WRLCK) && EAGAIN == errno) {
FileIsOpen = true;
}
else {
fcntl(fd, F_SETLEASE, F_UNLCK);
FileIsOpen = false;
}
close(fd);
}
while(FileIsOpen);
if(FileDoesNotExist) NtFile = new TFile(ntFileName,"RECREATE");
else NtFile = new TFile(ntFileName,"UPDATE");
ntResult = (TNtuple*)NtFile->Get(ntName);
if(!ntResult){
//printf("\033[1;31mERROR:\033[0m For whatever reason the ");
ntResult = new TNtuple("ntResult", "ntResult",
"IterM:Iter:Config:Data:SourceType:SourceScale:SourceStability:Potential:Baseline:FemRan:FitRan:pFrac:LamFrac:kcVar:mTbin:FemtoMin:FemtoMax:BlMin:BlMax:"
"p_a:e_a:p_b:e_b:p_c:e_c:p_Cl:e_Cl:p_kc:e_kc:p_sor0:e_sor0:p_sor1:e_sor1:chi2:ndf:chi2_312:ndf_312");
}
}
if(NtFile&&ntResult){
Float_t buffer[37];
long Iter = UniqueID/1000;
long Config = UniqueID%1000;
buffer[0] = Iter/long(1000000);
buffer[1] = Iter%long(1000000);
buffer[2] = UniqueID%1000;
TString Temp = DataVar;
Temp.ReplaceAll("_","");
buffer[3] = Temp.Atoi();
if(SourceType=="Gauss") buffer[4] = 0;
if(SourceType=="McGauss_Reso") buffer[4] = 1;
if(SourceType=="McLevyNolan_Reso") buffer[4] = 2;
buffer[5] = SourceScale;
buffer[6] = SourceStability;
if(pL_Pot=="LO") buffer[7] = 0;
if(pL_Pot=="NLO") buffer[7] = 10;
if(pL_Pot=="LO_Coupled_S") buffer[7] = 1;
if(pL_Pot=="NLO_Coupled_S") buffer[7] = 11;
if(pL_Pot=="NLO_sp") buffer[7] = 12;
if(pL_Pot=="Usmani") buffer[7] = 100;
if(pL_Pot=="Lednicky_ND") buffer[7] = 1001;
if(pL_Pot=="Lednicky_NF") buffer[7] = 1002;
if(pL_Pot=="Lednicky_NSC89") buffer[7] = 1003;
if(pL_Pot=="Lednicky_NSC97a") buffer[7] = 1004;
if(pL_Pot=="Lednicky_NSC97b") buffer[7] = 1005;
if(pL_Pot=="Lednicky_NSC97c") buffer[7] = 1006;
if(pL_Pot=="Lednicky_NSC97d") buffer[7] = 1007;
if(pL_Pot=="Lednicky_NSC97e") buffer[7] = 1008;
if(pL_Pot=="Lednicky_NSC97f") buffer[7] = 1009;
if(pL_Pot=="Lednicky_ESC08") buffer[7] = 1010;
if(pL_Pot=="Lednicky_XeftLO") buffer[7] = 1011;
if(pL_Pot=="Lednicky_XeftNLO") buffer[7] = 1012;
if(pL_Pot=="Lednicky_JulichA") buffer[7] = 1013;
if(pL_Pot=="Lednicky_JulichJ04") buffer[7] = 1014;
if(pL_Pot=="Lednicky_JulichJ04c") buffer[7] = 1015;
if(FittingMode_pL=="Norm") buffer[8] = 0;
if(FittingMode_pL=="Baseline") buffer[8] = 1;
if(FittingMode_pL=="Baseline2") buffer[8] = 2;
if(FittingMode_pL=="Longbaseline") buffer[8] = 11;
if(FittingMode_pL=="Longbaseline2") buffer[8] = 12;
if(FittingMode_pL=="Norm_prefit") buffer[8] = 100;
if(FittingMode_pL=="Baseline_prefit") buffer[8] = 101;
if(FittingMode_pL=="Baseline2_prefit") buffer[8] = 102;
if(FittingMode_pL=="Longbaseline_prefit") buffer[8] = 111;
if(FittingMode_pL=="Longbaseline2_prefit") buffer[8] = 112;
if(FittingMode_pL=="Spline3_3") buffer[8] = 403;
if(FittingMode_pL=="Spline3_4") buffer[8] = 404;
if(FittingMode_pL=="Spline3_5") buffer[8] = 405;
if(FittingMode_pL=="Spline3_6") buffer[8] = 406;
if(FittingMode_pL=="Spline3_7") buffer[8] = 407;
if(FittingMode_pL=="Spline3_8") buffer[8] = 408;
if(FittingMode_pL=="Spline3_9") buffer[8] = 409;
if(FittingMode_pL=="Spline3_10") buffer[8] = 410;
if(FittingMode_pL=="Spline3_11") buffer[8] = 411;
if(FittingMode_pL=="Spline3_Tune1") buffer[8] = 451;
buffer[9] = VARIATIONS[0];
buffer[10] = VARIATIONS[1];
buffer[11] = VARIATIONS[2];
buffer[12] = VARIATIONS[3];
buffer[13] = VARIATIONS[4];
buffer[14] = VARIATIONS[5];
buffer[15] = FitRegion_pL[0];
buffer[16] = FitRegion_pL[1];
buffer[17] = FitRegion_pL[2];
buffer[18] = FitRegion_pL[3];
buffer[19] = fitter->GetParameter("pLambda",DLM_Fitter1::p_a);
buffer[20] = fitter->GetParError("pLambda",DLM_Fitter1::p_a);
buffer[21] = fitter->GetParameter("pLambda",DLM_Fitter1::p_b);
buffer[22] = fitter->GetParError("pLambda",DLM_Fitter1::p_b);
buffer[23] = fitter->GetParameter("pLambda",DLM_Fitter1::p_c);
buffer[24] = fitter->GetParError("pLambda",DLM_Fitter1::p_c);
buffer[25] = fitter->GetParameter("pLambda",DLM_Fitter1::p_Cl);
buffer[26] = fitter->GetParError("pLambda",DLM_Fitter1::p_Cl);