-
Notifications
You must be signed in to change notification settings - Fork 1
/
CECA_Paper.cpp
10055 lines (8511 loc) · 337 KB
/
CECA_Paper.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 "CECA_Paper.h"
#include "CommonAnaFunctions.h"
#include "EnvVars.h"
#include "DLM_CppTools.h"
#include "DLM_OmpTools.h"
#include "DLM_Random.h"
#include "DLM_RootWrapper.h"
#include "DLM_HistoAnalysis.h"
#include "DLM_Source.h"
#include "DLM_Potentials.h"
#include "DLM_Histo.h"
#include "DLM_MathFunctions.h"
#include "DLM_RootFit.h"
#include "DLM_CkDecomposition.h"
#include "DLM_Ck.h"
#include "CATS.h"
#include "DLM_MultiFit.h"
#include "DLM_SubPads.h"
#include "FemtoBoyzScripts.h"
#include "EosDimiVale.h"
#include <iostream>
#include <unistd.h>
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include "TREPNI.h"
#include "CATS.h"
#include "CATSconstants.h"
#include "CATStools.h"
#include "CECA.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TFile.h"
#include "TF1.h"
#include "TGenPhaseSpace.h"
#include "TRandom3.h"
#include "TGraphErrors.h"
#include "TGraph.h"
#include "TNtuple.h"
#include "TSystem.h"
#include "TROOT.h"
#include "TLegend.h"
#include "TFitResultPtr.h"
#include "TFitResult.h"
#include "TGraphAsymmErrors.h"
#include "TLatex.h"
#include "TStyle.h"
#include "TTreeFormula.h"
#include <boost/algorithm/string.hpp>
#include<fstream>
using namespace std;
char* replaceSubstring(const char* input, const char* target, const char* replacement) {
std::string result(input);
size_t pos = 0;
while ((pos = result.find(target, pos)) != std::string::npos) {
result.replace(pos, strlen(target), replacement);
pos += strlen(replacement);
}
char* output = new char[result.length() + 1];
strcpy(output, result.c_str());
return output;
}
void TestSaveStuctToFile(){
DoubleLevy SourcePars;
SourcePars.alpha1 = 1.5;
SourcePars.sigma1 = 1.4;
SourcePars.alpha2 = 2.0;
SourcePars.sigma2 = 1.3;
SourcePars.wght1 = 0.4;
SourcePars.Print();
printf("Size of a float: %lu\n",sizeof(float));
printf("Size of the stucture: %lu\n",sizeof(DoubleLevy));
TString OutputFileName = TString::Format("%s/CECA_Paper/TestSaveStuctToFile/DoubleLevy.bin",GetFemtoOutputFolder());
ofstream wf(OutputFileName.Data(), ios::out | ios::binary);
if(!wf) {
cout << "Cannot open file!" << endl;
return;
}
else{
cout << "File opened!" << endl;
}
wf.write((char *) &SourcePars, sizeof(DoubleLevy));
wf.close();
if(!wf.good()) {
cout << "Error occurred at writing time!" << endl;
return;
}
else{
cout << "Writing to file done!" << endl;
}
DoubleLevy SourceParsFromFile;
ifstream is;
is.open (OutputFileName.Data(), ios::binary );
is.read ((char*)&SourceParsFromFile,20);
is.close();
SourceParsFromFile.Print();
}
void TestDoubleSourceOperation(){
DoubleLevy SourcePars1;
SourcePars1.alpha1 = 1.5;
SourcePars1.sigma1 = 1.4;
SourcePars1.alpha2 = 2.0;
SourcePars1.sigma2 = 1.3;
SourcePars1.wght1 = 0.4;
DoubleLevy SourcePars2;
SourcePars2.alpha1 = 1.7;
SourcePars2.sigma1 = 1.2;
SourcePars2.alpha2 = 1.8;
SourcePars2.sigma2 = 1.5;
SourcePars2.wght1 = 0.6;
printf("SourcePars1 ----------------------------\n");
SourcePars1.Print();
printf("SourcePars2 ----------------------------\n");
SourcePars2.Print();
DLM_Histo<DoubleLevy> SHst;
SHst.SetUp(1);
SHst.SetUp(0,2,0,2);
SHst.Initialize();
SHst.SetBinContent(unsigned(0),SourcePars1);
SHst.SetBinContent(unsigned(1),SourcePars2);
DoubleLevy s1;
DoubleLevy s2;
DoubleLevy a12;
s1 = SHst.Eval(0.5);
s2 = SHst.Eval(1.5);
a12 = SHst.Eval(1.0);
printf("s1 ----------------------------\n");
s1.Print();
printf("s2 ----------------------------\n");
s2.Print();
printf("a12 ----------------------------\n");
a12.Print();
TString HistoFileName = TString::Format("%s/CECA_Paper/TestSaveStuctToFile/Histo1.dlm.hst",GetFemtoOutputFolder());
SHst.QuickWrite(HistoFileName.Data(),true);
DLM_Histo<DoubleLevy> SHst_FromFile;
SHst_FromFile.QuickLoad(HistoFileName.Data());
DoubleLevy fs1;
DoubleLevy fs2;
DoubleLevy fa12;
fs1 = SHst_FromFile.Eval(0.5);
fs2 = SHst_FromFile.Eval(1.5);
fa12 = SHst_FromFile.Eval(1.0);
printf("fs1 ----------------------------\n");
fs1.Print();
printf("fs2 ----------------------------\n");
fs2.Print();
printf("fa12 ----------------------------\n");
fa12.Print();
}
//test the DLM_Histo and statistics for pp
//fit the distos with Levy
void Test_pp_Statistics_1(){
//12h of running on 6 core old AMD Desktop
TString InputHistoFile = TString::Format("%s/FunWithCeca/Ceca_pp_EffFix/12h/KstarDist_pp_ET1_PR1_DD0.0_EF-1.Ghetto_kstar_rstar_mT",GetFemtoOutputFolder());
DLM_Histo<float> kstar_rstar_mT;
kstar_rstar_mT.QuickLoad(InputHistoFile.Data());
const unsigned NumMomBins = kstar_rstar_mT.GetNbins(0);
const unsigned NumRadBins = kstar_rstar_mT.GetNbins(1);
const unsigned NumMtBins = kstar_rstar_mT.GetNbins(2);
const double MaxKstar = 200;
printf("NumMomBins = %u\n",NumMomBins);
printf("NumRadBins = %u\n",NumRadBins);
printf("NumMtBins = %u\n",NumMtBins);
TH1F*** hMtKstar_Rad = new TH1F** [NumMtBins];
TF1*** fDoubleGauss = new TF1** [NumMtBins];
//TF1*** fStupidGauss = new TF1** [NumMtBins];
for(unsigned uMt=0; uMt<NumMtBins; uMt++){
printf("uMt = %u\n",uMt);
double Mt = kstar_rstar_mT.GetBinCenter(2,uMt);
hMtKstar_Rad[uMt] = new TH1F* [NumMomBins];
fDoubleGauss[uMt] = new TF1* [NumMomBins];
//fStupidGauss[uMt] = new TF1* [NumMomBins];
for(unsigned uMom=0; uMom<NumMomBins; uMom++){
double Momentum = kstar_rstar_mT.GetBinCenter(0,uMom);
if(Momentum>MaxKstar){
hMtKstar_Rad[uMt][uMom] = NULL;
fDoubleGauss[uMt][uMom] = NULL;
//fStupidGauss[uMt][uMom] = NULL;
continue;
}
TString HistoName = TString::Format("hMtKstar_Rad_%.0f_%.0f",Mt,Momentum);
hMtKstar_Rad[uMt][uMom] = new TH1F(HistoName,HistoName,
kstar_rstar_mT.GetNbins(1), kstar_rstar_mT.GetLowEdge(1), kstar_rstar_mT.GetUpEdge(1));
double Rad,upperlimit,lowerlimit;
for(unsigned uRad=0; uRad<NumRadBins; uRad++){
Rad = kstar_rstar_mT.GetBinContent(uMom,uRad,uMt);
hMtKstar_Rad[uMt][uMom]->SetBinContent(uRad+1,Rad);
}
hMtKstar_Rad[uMt][uMom]->Sumw2();
hMtKstar_Rad[uMt][uMom]->Scale(1./hMtKstar_Rad[uMt][uMom]->Integral(), "width");
GetCentralInterval(*hMtKstar_Rad[uMt][uMom], 0.98, lowerlimit, upperlimit, true);
if(lowerlimit>5) lowerlimit = 5;
if(upperlimit>20) upperlimit = 20;
TString FitName = TString::Format("fDoubleGauss_%.0f_%.0f",Mt,Momentum);
fDoubleGauss[uMt][uMom] = new TF1(FitName,NormTripleShiftedGaussTF1,0.,20.,9);
//like chi2, but not normalized to error
double Dist2 = 0;
double NDPts = 0;
double Chi2 = 0;
double NDPts_chi2 = 0;
double Dist_Max = 0;
double Nsig_AtDistMax = 0;
double Rad_AtDistMax = 0;
const double Dist_Limit = 0.015;
const double Nsig_Limit = 3.0;
const unsigned Patience = 32;//increase limit after X fits
const double BadFitWarning = 0.06;
double Dist_CurLim = Dist_Limit;
unsigned StuckCount = 0;
unsigned ResetCount = 0;
TRandom3 rangen(11);
do{
Dist2 = 0;
NDPts = 0;
Chi2 = 0;
NDPts_chi2 = 0;
Dist_Max = 0;
Nsig_AtDistMax = 0;
//NORM
fDoubleGauss[uMt][uMom]->SetParameter(0,rangen.Uniform(0.9,1.0));
fDoubleGauss[uMt][uMom]->SetParLimits(0,0.,1.);
//G1
fDoubleGauss[uMt][uMom]->SetParameter(1,rangen.Uniform(0.2,0.4));//sigma
fDoubleGauss[uMt][uMom]->SetParLimits(1,0.,0.8);
fDoubleGauss[uMt][uMom]->SetParameter(2,rangen.Uniform(0.0,0.5));//shift
fDoubleGauss[uMt][uMom]->SetParLimits(2,0.,2.0);
fDoubleGauss[uMt][uMom]->SetParameter(3,rangen.Uniform(0.2,0.4));//weight
fDoubleGauss[uMt][uMom]->SetParLimits(3,0.,0.95);
if(hMtKstar_Rad[uMt][uMom]->GetEntries()>200 || ResetCount>=1){
//G2
//sigma
fDoubleGauss[uMt][uMom]->SetParameter(4,rangen.Uniform(2.0,4.0));
fDoubleGauss[uMt][uMom]->SetParLimits(4,0,20.);
//shift
fDoubleGauss[uMt][uMom]->SetParameter(5,rangen.Uniform(0,0.5));
fDoubleGauss[uMt][uMom]->SetParLimits(5,0.,10.);
//weight
fDoubleGauss[uMt][uMom]->SetParameter(6,rangen.Uniform(0.4,0.6));
fDoubleGauss[uMt][uMom]->SetParLimits(6,0.,1.0);
}
else{
//G2
//sigma
fDoubleGauss[uMt][uMom]->FixParameter(4,1);
//shift
fDoubleGauss[uMt][uMom]->FixParameter(5,0);
//weight
fDoubleGauss[uMt][uMom]->FixParameter(6,0);
}
//if we have enough data
if(hMtKstar_Rad[uMt][uMom]->GetEntries()>1000 || ResetCount>=2){
//G3
//sigma
fDoubleGauss[uMt][uMom]->SetParameter(7,rangen.Uniform(0.4,0.7));
fDoubleGauss[uMt][uMom]->SetParLimits(7,0,20.);
//shift
fDoubleGauss[uMt][uMom]->SetParameter(8,rangen.Uniform(0,0.5));
fDoubleGauss[uMt][uMom]->SetParLimits(8,0.,10.);
}
else{
//G3
//sigma
fDoubleGauss[uMt][uMom]->FixParameter(7,1);
//shift
fDoubleGauss[uMt][uMom]->FixParameter(8,0);
}
hMtKstar_Rad[uMt][uMom]->Fit(fDoubleGauss[uMt][uMom],"Q, S, N, R, M","",lowerlimit,upperlimit);
//up to 10 fm
const double RadDistMax = 8;
for(unsigned uRad=0; uRad<NumRadBins; uRad++){
double Rad = hMtKstar_Rad[uMt][uMom]->GetBinCenter(uRad+1);
if(Rad>RadDistMax) break;
double dst = hMtKstar_Rad[uMt][uMom]->GetBinContent(uRad+1)-fDoubleGauss[uMt][uMom]->Eval(Rad);
double err;
if(hMtKstar_Rad[uMt][uMom]->GetBinContent(uRad+1)){
err = hMtKstar_Rad[uMt][uMom]->GetBinError(uRad+1);
}
else{
err = fabs(dst)*1000;
}
Dist2 += dst*dst;
NDPts++;
if(hMtKstar_Rad[uMt][uMom]->GetBinError(uRad+1)){
Chi2 += (dst*dst)/(err*err);
NDPts_chi2++;
}
if(Dist_Max<fabs(dst)){
Dist_Max = fabs(dst);
Nsig_AtDistMax = Dist_Max/err;
Rad_AtDistMax = Rad;
}
}
Dist2 /= NDPts;
Chi2 /= NDPts_chi2;
//printf("uMt_%u uMom_%u Dist2=%e (%e); Dist_Max = %f (%.2f)\n",uMt,uMom,Dist2,Chi2,Dist_Max,Nsig_AtDistMax);
//usleep(100e3);
StuckCount++;
if(StuckCount>Patience){
Dist_CurLim += Dist_Limit;
StuckCount = 0;
ResetCount++;
}
}
while(Dist_Max>Dist_CurLim && Nsig_AtDistMax>Nsig_Limit);
if(Dist_Max>BadFitWarning && Nsig_AtDistMax>Nsig_Limit){
printf("WARNING: uMt_%u uMom_%u (r = %.3f)\n",uMt,uMom,Rad_AtDistMax);
}
/*
TString FitName = TString::Format("fStupidGauss_%.0f_%.0f",Mt,Momentum);
fStupidGauss[uMt][uMom] = new TF1(FitName,StupidGaussSumTF1,0.,20.,13);
fStupidGauss[uMt][uMom]->FixParameter(0,4);
for(unsigned uG=0; uG<4; uG++){
fStupidGauss[uMt][uMom]->SetParameter(1+uG*3,0.5);//W
fStupidGauss[uMt][uMom]->SetParLimits(1+uG*3,0.,1.);
fStupidGauss[uMt][uMom]->SetParameter(2+uG*3,1.0*pow(1.+double(uG),1.5));//M
fStupidGauss[uMt][uMom]->SetParLimits(2+uG*3,0.,4.*pow(1.+double(uG),1.5));
fStupidGauss[uMt][uMom]->SetParameter(3+uG*3,1.0*pow(1.+double(uG),1.5));//S
fStupidGauss[uMt][uMom]->SetParLimits(3+uG*3,0.,2.*pow(1.+double(uG),1.5));
//fStupidGauss[uMt][uMom]->FixParameter(1+uG*3,0.5);
//fStupidGauss[uMt][uMom]->FixParameter(2+uG*3,1.0*pow(1.+double(uG),1.5));//M
//fStupidGauss[uMt][uMom]->FixParameter(3+uG*3,1.0*pow(1.+double(uG),1.5));//S
//fStupidGauss[uMt][uMom]->FixParameter(1+uG*3,0.5);
//fStupidGauss[uMt][uMom]->FixParameter(2+uG*3,1);//M
//fStupidGauss[uMt][uMom]->FixParameter(3+uG*3,3);//S
}
*/
}
}
TFile fOutput(TString::Format("%s/CECA_Paper/Test_pp_Statistics_1/HistoAndFits.root",GetFemtoOutputFolder()),"recreate");
for(unsigned uMt=0; uMt<NumMtBins; uMt++){
for(unsigned uMom=0; uMom<NumMomBins; uMom++){
if(hMtKstar_Rad[uMt][uMom]){
hMtKstar_Rad[uMt][uMom]->Write();
delete hMtKstar_Rad[uMt][uMom];
hMtKstar_Rad[uMt][uMom]=NULL;
}
if(fDoubleGauss[uMt][uMom]){
fDoubleGauss[uMt][uMom]->Write();
delete fDoubleGauss[uMt][uMom];
fDoubleGauss[uMt][uMom]=NULL;
}
//if(fStupidGauss[uMt][uMom]){
// fStupidGauss[uMt][uMom]->Write();
// delete fStupidGauss[uMt][uMom];
// fStupidGauss[uMt][uMom]=NULL;
//}
}
if(hMtKstar_Rad[uMt]){delete [] hMtKstar_Rad[uMt]; hMtKstar_Rad[uMt]=NULL;}
if(fDoubleGauss[uMt]){delete [] fDoubleGauss[uMt]; fDoubleGauss[uMt]=NULL;}
//if(fStupidGauss[uMt]){delete [] fStupidGauss[uMt]; fStupidGauss[uMt]=NULL;}
}
delete [] hMtKstar_Rad;
delete [] fDoubleGauss;
//delete [] fStupidGauss;
}
DLM_Histo<float>* GetPtEta(TString FileNameP, TString FileNameAP,
TString HistoNameP, TString HistoNameAP, const double EtaCut){
TH1F* h_pT_p;
TH1F* h_pT_ap;
TH1F* h_pT_all;
TFile file_p(FileNameP,"read");
h_pT_p = (TH1F*)file_p.Get(HistoNameP);
if(!h_pT_p) printf("ISSUE with h_pT_p\n");
gROOT->cd();
h_pT_all = (TH1F*)h_pT_p->Clone("h_pT_all");
TFile file_ap(FileNameAP,"read");
h_pT_ap = (TH1F*)file_ap.Get(HistoNameAP);
if(!h_pT_ap) printf("ISSUE with h_pT_ap\n");
h_pT_all->Add(h_pT_ap);
DLM_Histo<float>* dlm_pT_p = Convert_TH1F_DlmHisto(h_pT_all);
dlm_pT_p->RescaleAxis(0,1000,false);
double* BinRange = NULL;
double axis[2];
DLM_Histo<float>* dlm_pT_eta = new DLM_Histo<float>();
dlm_pT_eta->SetUp(2);
BinRange = dlm_pT_p->GetBinRange(0);
dlm_pT_eta->SetUp(0,dlm_pT_p->GetNbins(),BinRange);
delete [] BinRange;
dlm_pT_eta->SetUp(1,1,-EtaCut,EtaCut);
dlm_pT_eta->Initialize();
for(unsigned uBin=0; uBin<dlm_pT_p->GetNbins(); uBin++){
dlm_pT_eta->SetBinContent(uBin,0,dlm_pT_p->GetBinContent(uBin));
}
file_p.Close();
file_ap.Close();
delete h_pT_all;
return dlm_pT_eta;
}
//for Lambda, more like pT in 0.4 --> inf
DLM_Histo<float>* GetPtEta_13TeV(TString FileNameIn,
TString GraphNameIn, const double pT_min, const double pT_max, const double EtaCut){
TGraphAsymmErrors* gSpectrum;
TFile file_in(FileNameIn,"read");
gSpectrum = (TGraphAsymmErrors*)file_in.Get(GraphNameIn);
if(!gSpectrum) printf("ISSUE with gSpectrum\n");
//gROOT->cd();
double* BinRange = new double[gSpectrum->GetN()+1];
double* BinCenter = new double[gSpectrum->GetN()];
double* BinContent = new double[gSpectrum->GetN()];
//printf("Iter over %u\n",gSpectrum->GetN());
for(unsigned uBin=0; uBin<gSpectrum->GetN(); uBin++){
//printf(" -- %u\n",uBin);
double pT,Yield;
gSpectrum->GetPoint(uBin,pT,Yield);
pT *= 1000;
double pT_low = pT - gSpectrum->GetErrorXlow(uBin)*1000.;
double pT_high = pT + gSpectrum->GetErrorXhigh(uBin)*1000.;
BinCenter[uBin] = 0.5*(pT_high+pT_low);
if(BinCenter[uBin]<pT_min || BinCenter[uBin]>pT_max)
BinContent[uBin] = 0;
else
BinContent[uBin] = Yield;
//if(uBin) BinRange[uBin] = BinRange[uBin-1];
//else BinRange[uBin] = pT_low;
BinRange[uBin] = pT_low;
if(uBin==gSpectrum->GetN()-1){
BinRange[uBin+1] = pT_high;
}
}
//for(unsigned uBin=0; uBin<=gSpectrum->GetN(); uBin++){
//printf(" BinRange[%u] = %.f\n",uBin,BinRange[uBin]);
//}
DLM_Histo<float>* dlm_pT_eta = new DLM_Histo<float>();
dlm_pT_eta->SetUp(2);
dlm_pT_eta->SetUp(0,gSpectrum->GetN(),BinRange);
dlm_pT_eta->SetUp(1,1,-EtaCut,EtaCut);
dlm_pT_eta->Initialize();
for(unsigned uBin=0; uBin<gSpectrum->GetN(); uBin++){
dlm_pT_eta->SetBinContent(uBin,BinContent[uBin]);
}
file_in.Close();
delete [] BinRange;
delete [] BinCenter;
delete [] BinContent;
return dlm_pT_eta;
}
//parameters to control:
//MUST:
// SEED, GLOB_TIMEOUT, multiplicity, target_yield, femto_region,
// d_x, d_y, d_z, h_x, h_y, h_z, h_fct, tau, tau_prp, tau_fct;
// hdr_size, hdr_slope, th_kick, frag_beta, fixed_hdr;
// a flag for the momentum distribution;
// a flag for resonance variations;
// a flag for the type (1 is pp, 2 is pL)
// 24 numbers in total -> input from file
//
// OUTPUT:
// DLM_Histo: Ghetto_kstar_rstar_mT
// A settings file (perhaps not, integrate as input), which will again be a histo (or a custum class?),
// with the values of all parameters above.
// the names of the file should be unique, e.g. SEED id or whatever
//QUESTIONS: do we care about h_xyz differentially
// -> it leads to 1.5% error -> take as systematics :D
// actually, if a take the hz = 2x hT, than we have +4.3% on the radius, but the scaling remains the same
// i.e. we can comment that the choice of hz can simply scale the thing up and down by a small amount
//the names should be given without extension. They should also have the FULL path!!
//the assumed extension is *.txt for the Input and .dlm.hst for the Output
int Ceca_pp_or_pL(const TString FileBase, const TString InputFolder, const TString OutputFolder, const TString LogFolder,
const int ParID, const int JobID, const int NumCPU){
printf("FileBase = %s\n",FileBase.Data());
printf("InputFolder = %s\n",InputFolder.Data());
printf("OutputFolder = %s\n",OutputFolder.Data());
printf("LogFolder = %s\n",LogFolder.Data());
printf("ParID = %i\n",ParID);
printf("JobID = %i\n",JobID);
printf("NumCPU = %i\n",NumCPU);
const double TIMEOUT = 30;
const double EtaCut = 0.8;
const bool PROTON_RESO = true;
const bool EQUALIZE_TAU = true;
int SEED = (ParID+1)*10. + JobID;
TString InputFileName = InputFolder+FileBase+TString::Format(".%i.%i.dlm.job",ParID,JobID);
TString OutputFileNameFull = OutputFolder+FileBase+TString::Format(".%i.%i.full.dlm.hst",ParID,JobID);
TString OutputFileNameCore = OutputFolder+FileBase+TString::Format(".%i.%i.core.dlm.hst",ParID,JobID);
TString OutputFileName_p_dist = OutputFolder+FileBase+TString::Format(".%i.%i.p_dist.dlm.hst",ParID,JobID);
TString OutputFileName_L_dist = OutputFolder+FileBase+TString::Format(".%i.%i.L_dist.dlm.hst",ParID,JobID);
//a binary file that contains information on the statistics we have collected so far
//this program will search for that file, and if it exists it will read it and add the current yield
//to the total yield
TString LogFileName = LogFolder+FileBase+TString::Format(".%i.%i.dlm.log",ParID,JobID);
printf("\n");
printf("InputFileName = %s\n",InputFileName.Data());
printf("OutputFileNameFull = %s\n",OutputFileNameFull.Data());
printf("OutputFileNameCore = %s\n",OutputFileNameCore.Data());
printf("LogFileName = %s\n",LogFileName.Data());
TREPNI Database(0);
Database.SetSeed(11);
std::vector<TreParticle*> ParticleList;
ParticleList.push_back(Database.NewParticle("Proton"));
ParticleList.push_back(Database.NewParticle("ProtonReso"));
ParticleList.push_back(Database.NewParticle("Lambda"));
ParticleList.push_back(Database.NewParticle("LambdaReso"));
ParticleList.push_back(Database.NewParticle("Pion"));
//DLM_Histo<double> SettingsHisto;
//SettingsHisto.QuickLoad(InputFileName.Data());
double GLOB_TIMEOUT = 0;
unsigned multiplicity = 0;
unsigned target_yield = 0;
float femto_region = 100;
float d_x = 0;
float d_y = 0;
float d_z = 0;
float h_x = 0;
float h_y = 0;
float h_z = 0;
float h_fct = 0;
float tau = 0;
float tau_fct = 0;
bool tau_prp = true;
float hdr_size = 0;
float hdr_slope = 0;
float th_kick = 0;
float frag_beta = 0;
float fixed_hdr = 1;
int momdst_flag = 1;
int reso_flag = 1;//default, read out masses etc
//int type_flag = 0;
int wildcard_flag = 0;
TString type = "";
TString AnaVersion = "";
double m_proton_reso;
double frac_proton_reso;
double tau_proton_reso;
double m_lambda_reso;
double frac_lambda_reso;
double tau_lambda_reso;
double del_proton;
double del_proton_reso;
double del_lambda;
double del_lambda_reso;
char* cline = new char [512];
char* cdscr = new char [128];
char* cval = new char [128];
double read_value;
FILE *InFile;
InFile = fopen(InputFileName.Data(), "r");
if(!InFile){
printf("\033[1;31mERROR:\033[0m The file\033[0m %s cannot be opened!\n", InputFileName.Data());
return 0;
}
fseek ( InFile , 0 , SEEK_END );
long EndPos;
EndPos = ftell (InFile);
fseek ( InFile , 0 , SEEK_SET );
long CurPos;
while(!feof(InFile)){
if(!fgets(cline, 511, InFile)){
//printf("\033[1;31mERROR:\033[0m The file\033[0m %s cannot be properly read (%s)!\n", InputFileName.Data(),cline);
}
sscanf(cline, "%s %s",cdscr,cval);
if(strcmp(cdscr,"type")==0){
type = TString(cval);
}
else if(strcmp(cdscr,"AnaVersion")==0){
AnaVersion = TString(cval);
}
else{
read_value = stod(cval);
if(strcmp(cdscr,"GLOB_TIMEOUT")==0) {GLOB_TIMEOUT = read_value;}
else if(strcmp(cdscr,"multiplicity")==0) {multiplicity = unsigned(read_value);}
else if(strcmp(cdscr,"target_yield")==0) {target_yield = unsigned(read_value);}
else if(strcmp(cdscr,"femto_region")==0) {femto_region = read_value;}
else if(strcmp(cdscr,"d_x")==0) {d_x = read_value;}
else if(strcmp(cdscr,"d_y")==0) {d_y = read_value;}
else if(strcmp(cdscr,"d_z")==0) {d_z = read_value;}
else if(strcmp(cdscr,"h_x")==0) {h_x = read_value;}
else if(strcmp(cdscr,"h_y")==0) {h_y = read_value;}
else if(strcmp(cdscr,"h_z")==0) {h_z = read_value;}
else if(strcmp(cdscr,"h_fct")==0) {h_fct = read_value;}
else if(strcmp(cdscr,"tau")==0) {tau = read_value;}
else if(strcmp(cdscr,"tau_fct")==0) {tau_fct = read_value;}
else if(strcmp(cdscr,"tau_prp")==0) {tau_prp = bool(read_value);}
else if(strcmp(cdscr,"hdr_size")==0) {hdr_size = read_value;}
else if(strcmp(cdscr,"hdr_slope")==0) {hdr_slope = read_value;}
else if(strcmp(cdscr,"th_kick")==0) {th_kick = read_value;}
else if(strcmp(cdscr,"frag_beta")==0) {frag_beta = read_value;}
else if(strcmp(cdscr,"fixed_hdr")==0) {fixed_hdr = read_value;}
else if(strcmp(cdscr,"momdst_flag")==0) {momdst_flag = int(read_value);}
else if(strcmp(cdscr,"reso_flag")==0) {reso_flag = int(read_value);}
else if(strcmp(cdscr,"wildcard_flag")==0) {wildcard_flag = int(read_value);}
else if(strcmp(cdscr,"m_proton_reso")==0) {m_proton_reso = read_value;}
else if(strcmp(cdscr,"tau_proton_reso")==0) {tau_proton_reso = read_value;}
else if(strcmp(cdscr,"frac_proton_reso")==0) {frac_proton_reso = read_value;}
else if(strcmp(cdscr,"m_lambda_reso")==0) {m_lambda_reso = read_value;}
else if(strcmp(cdscr,"tau_lambda_reso")==0) {tau_lambda_reso = read_value;}
else if(strcmp(cdscr,"frac_lambda_reso")==0) {frac_lambda_reso = read_value;}
else if(strcmp(cdscr,"del_proton")==0) {del_proton = read_value;}
else if(strcmp(cdscr,"del_proton_reso")==0) {del_proton_reso = read_value;}
else if(strcmp(cdscr,"del_lambda")==0) {del_lambda = read_value;}
else if(strcmp(cdscr,"del_lambda_reso")==0) {del_lambda_reso = read_value;}
}
}
delete [] cval;
delete [] cline;
delete [] cdscr;
printf("AnaVersion = %s\n",AnaVersion.Data());
printf("GLOB_TIMEOUT = %f\n",GLOB_TIMEOUT);
printf("multiplicity = %u\n",multiplicity);
printf("target_yield = %u\n",target_yield);
//printf("current_yield = %u\n",current_yield);
printf("femto_region = %f\n",femto_region);
printf("d_x = %f\n",d_x);
printf("d_y = %f\n",d_y);
printf("d_z = %f\n",d_z);
printf("h_x = %f\n",h_x);
printf("h_y = %f\n",h_y);
printf("h_z = %f\n",h_z);
printf("h_fct = %f\n",h_fct);
printf("tau = %f\n",tau);
printf("tau_fct = %f\n",tau_fct);
printf("tau_prp = %i\n",tau_prp);
printf("hdr_size = %f\n",hdr_size);
printf("hdr_slope = %f\n",hdr_slope);
printf("th_kick = %f\n",th_kick);
printf("frag_beta = %f\n",frag_beta);
printf("fixed_hdr = %f\n",fixed_hdr);
printf("momdst_flag = %i\n",momdst_flag);
printf("reso_flag = %i\n",reso_flag);
printf("wildcard_flag = %i\n",wildcard_flag);
printf("frac_proton_reso = %f\n",frac_proton_reso);
printf("m_proton_reso = %f\n",m_proton_reso);
printf("tau_proton_reso = %f\n",tau_proton_reso);
printf("frac_lambda_reso = %f\n",frac_lambda_reso);
printf("m_lambda_reso = %f\n",m_lambda_reso);
printf("tau_lambda_reso = %f\n",tau_lambda_reso);
printf("del_proton = %f\n",del_proton);
printf("del_proton_reso = %f\n",del_proton_reso);
printf("del_lambda = %f\n",del_lambda);
printf("del_lambda_reso = %f\n",del_lambda_reso);
printf("type = %s\n",type.Data());
//if(current_yield>=target_yield){
// printf("\033[1;31mERROR:\033[0m current_yield>=target_yield, this should NOT happen!\n");
// return 0;
//}
//return;
//here use the flags if needed
//frac_proton_reso = 64.22;
//m_proton_reso = 1362;
//tau_proton_reso = 1.65;
//frac_lambda_reso = 64.38;
//m_lambda_reso = 1463;
//tau_lambda_reso = 4.69;
//basic QA: too lazy to doo it
if(multiplicity<1){
printf("Bad multiplicity!\n");
return 0;
}
if(multiplicity==1){
printf("Potenitally bad multiplicity (1)!\n");
}
if(type!="pp"&&type!="pL"){
printf("WHAT IS THIS: type = %s\n", type.Data());
return 0;
}
DLM_Histo<float>* dlm_pT_eta_p;
DLM_Histo<float>* dlm_pT_eta_L;
//printf("momdst_flag=%u\n",momdst_flag);
//momdst_flag -> 1 from FemtoDream (101 -> save histo)
//momdst_flag -> 2 from FemtoDream (102 -> save histo)
if(momdst_flag%100==1){
dlm_pT_eta_p = GetPtEta(
TString::Format("%s/Jaime/p_pT.root",GetCernBoxDimi()),
TString::Format("%s/Jaime/ap_pT.root",GetCernBoxDimi()),
"pTDist_after", "pTDist_after", EtaCut);
dlm_pT_eta_L = GetPtEta(
TString::Format("%s/Jaime/L_pT.root",GetCernBoxDimi()),
TString::Format("%s/Jaime/aL_pT.root",GetCernBoxDimi()),
"pTDist_after", "pTDist_after", EtaCut);
}
else if(momdst_flag%100==2){
dlm_pT_eta_p = GetPtEta_13TeV(
TString::Format("%s/CatsFiles/Source/CECA/proton_pT/p_dist_13TeV_ClassI.root",GetCernBoxDimi()),
"Graph1D_y1", 500, 4050, EtaCut);
dlm_pT_eta_L = GetPtEta_13TeV(
TString::Format("%s/CatsFiles/Source/CECA/Lambda_pT/L_dist_13TeV_ClassI.root",GetCernBoxDimi()),
"Graph1D_y1", 400, 8000, EtaCut);
}
else{
printf("ERROR momdst_flag\n");
return 0;
}
//printf("inited\n");
if(momdst_flag/100==1){
dlm_pT_eta_p->QuickWrite(OutputFileName_p_dist,true);
dlm_pT_eta_L->QuickWrite(OutputFileName_L_dist,true);
}
for(TreParticle* prt : ParticleList){
if(prt->GetName()=="Proton"){
prt->SetMass(Mass_p);
prt->SetAbundance(100.-frac_proton_reso);
prt->SetRadius(hdr_size);
prt->SetRadiusSlope(hdr_slope);
prt->SetDelayTau(del_proton);
if(dlm_pT_eta_p) prt->SetPtEtaPhi(*dlm_pT_eta_p);
else prt->SetPtPz(0.85*prt->GetMass(),0.85*prt->GetMass());
}
else if(prt->GetName()=="ProtonReso"){
prt->SetMass(m_proton_reso);
prt->SetAbundance(frac_proton_reso);
prt->SetWidth(hbarc/tau_proton_reso);
prt->SetDelayTau(del_proton_reso);
prt->NewDecay();
prt->GetDecay(0)->AddDaughter(*Database.GetParticle("Proton"));
prt->GetDecay(0)->AddDaughter(*Database.GetParticle("Pion"));
prt->GetDecay(0)->SetBranching(100);
if(dlm_pT_eta_p) prt->SetPtEtaPhi(*dlm_pT_eta_p);
else prt->SetPtPz(0.85*prt->GetMass(),0.85*prt->GetMass());
}
else if(prt->GetName()=="Lambda"){
prt->SetMass(Mass_L);
prt->SetAbundance(100.-frac_lambda_reso);
prt->SetRadius(hdr_size);
prt->SetRadiusSlope(hdr_slope);
prt->SetDelayTau(del_lambda);
if(dlm_pT_eta_L) prt->SetPtEtaPhi(*dlm_pT_eta_L);
else prt->SetPtPz(0.85*prt->GetMass(),0.85*prt->GetMass());
}
else if(prt->GetName()=="LambdaReso"){
prt->SetMass(m_lambda_reso);
prt->SetAbundance(frac_lambda_reso);
prt->SetWidth(hbarc/tau_lambda_reso);
prt->SetDelayTau(del_lambda_reso);
prt->NewDecay();
prt->GetDecay(0)->AddDaughter(*Database.GetParticle("Lambda"));
prt->GetDecay(0)->AddDaughter(*Database.GetParticle("Pion"));
prt->GetDecay(0)->SetBranching(100);
if(dlm_pT_eta_L) prt->SetPtEtaPhi(*dlm_pT_eta_L);
else prt->SetPtPz(0.85*prt->GetMass(),0.85*prt->GetMass());
}
else if(prt->GetName()=="Pion"){
prt->SetMass(Mass_pic);
prt->SetAbundance(0);
prt->SetRadius(hdr_size);
prt->SetRadiusSlope(hdr_slope);
}
}//ParticleList
std::vector<std::string> ListOfParticles;
if(type=="pp"){
ListOfParticles.push_back("Proton");
ListOfParticles.push_back("Proton");
}
else if(type=="pL"){
ListOfParticles.push_back("Proton");
ListOfParticles.push_back("Lambda");
}
else{
printf("Issue with the type!\n");
return 0;
}
CECA Ivana(Database,ListOfParticles);
Ivana.SetDisplacementX(d_x);
Ivana.SetDisplacementY(d_y);
Ivana.SetDisplacementZ(d_z);
Ivana.SetHadronizationX(h_x);
Ivana.SetHadronizationY(h_y);
Ivana.SetHadronizationZ(h_z);
Ivana.SetHadrFluctuation(h_fct);
Ivana.SetTau(tau,tau_prp);
Ivana.SetTauFluct(tau_fct);
Ivana.SetThermalKick(th_kick);
Ivana.SetFixedHadr(fixed_hdr);
Ivana.SetFragmentBeta(frag_beta);
Ivana.SetTargetStatistics(target_yield);
Ivana.SetEventMult(multiplicity);
Ivana.SetSourceDim(2);
Ivana.SetDebugMode(false);
Ivana.SetThreadTimeout(TIMEOUT);
Ivana.SetGlobalTimeout(GLOB_TIMEOUT);
Ivana.EqualizeFsiTime(true);
Ivana.SetFemtoRegion(femto_region);
Ivana.GHETTO_EVENT = true;
if(type=="pp"){
if(wildcard_flag==-1){
//Ivana.Ghetto_NumMtBins = 206;
//Ivana.Ghetto_MtBins = new double [Ivana.Ghetto_NumMtBins+1];
//for(unsigned uMt=0; uMt<=156; uMt++){
// Ivana.Ghetto_MtBins[uMt] = 940. + double(uMt)*10;
//}
//for(unsigned uMt=157; uMt<=Ivana.Ghetto_NumMtBins; uMt++){
// Ivana.Ghetto_MtBins[uMt] = 2500. + double(uMt-156)*50;
//}
Ivana.Ghetto_NumMtBins = 360;
Ivana.Ghetto_MtBins = new double [Ivana.Ghetto_NumMtBins+1];
for(unsigned uMt=0; uMt<=360; uMt++){
Ivana.Ghetto_MtBins[uMt] = 940. + double(uMt)*10;
}
Ivana.Ghetto_NumMomBins = 25;
Ivana.Ghetto_MomMin = 0;
Ivana.Ghetto_MomMax = 100;
Ivana.Ghetto_NumRadBins = 192;//twice the bin width compared to default
Ivana.Ghetto_RadMin = 0;
Ivana.Ghetto_RadMax = 48;
}
else{
Ivana.Ghetto_NumMtBins = 10;
Ivana.Ghetto_MtBins = new double [Ivana.Ghetto_NumMtBins+1];
Ivana.Ghetto_MtBins[0] = 930; //avg 983 ( 985)
Ivana.Ghetto_MtBins[1] = 1020;//avg 1054 (1055)
Ivana.Ghetto_MtBins[2] = 1080;//avg 1110 (1110)
Ivana.Ghetto_MtBins[3] = 1140;//avg 1168 (1170)
Ivana.Ghetto_MtBins[4] = 1200;//avg 1228 (1230)
Ivana.Ghetto_MtBins[5] = 1260;//avg 1315 (1315)
Ivana.Ghetto_MtBins[6] = 1380;//avg 1463 (1460)
Ivana.Ghetto_MtBins[7] = 1570;//avg 1681 (1680)
Ivana.Ghetto_MtBins[8] = 1840;//avg 1923 (1920)
Ivana.Ghetto_MtBins[9] = 2030;//avg 2303 (2300)
Ivana.Ghetto_MtBins[10] = 4500;
Ivana.Ghetto_NumMomBins = 150;
Ivana.Ghetto_MomMin = 0;
Ivana.Ghetto_MomMax = 600;
}
}
else if(type=="pL"){
//NOT_DONE_YET
if(wildcard_flag==-1){
Ivana.Ghetto_NumMtBins = 360;
Ivana.Ghetto_MtBins = new double [Ivana.Ghetto_NumMtBins+1];
for(unsigned uMt=0; uMt<=360; uMt++){
Ivana.Ghetto_MtBins[uMt] = 1000. + double(uMt)*10;
}
Ivana.Ghetto_NumMomBins = 25;
Ivana.Ghetto_MomMin = 0;
Ivana.Ghetto_MomMax = 100;
Ivana.Ghetto_NumRadBins = 192;//twice the bin width compared to default
Ivana.Ghetto_RadMin = 0;
Ivana.Ghetto_RadMax = 48;
}
else{
Ivana.Ghetto_NumMtBins = 8;
Ivana.Ghetto_MtBins = new double [Ivana.Ghetto_NumMtBins+1];
Ivana.Ghetto_MtBins[0] = 1000;//avg 1121 (1120)
Ivana.Ghetto_MtBins[1] = 1170;//avg 1210 (1210)
Ivana.Ghetto_MtBins[2] = 1250;//avg 1288 (1290)
Ivana.Ghetto_MtBins[3] = 1330;//avg 1377 (1380)
Ivana.Ghetto_MtBins[4] = 1430;//avg 1536 (1540)
Ivana.Ghetto_MtBins[5] = 1680;//avg 1753 (1750)
Ivana.Ghetto_MtBins[6] = 1840;//avg 1935 (1935)
Ivana.Ghetto_MtBins[7] = 2060;//avg 2334 (2330)
Ivana.Ghetto_MtBins[8] = 4800;
Ivana.Ghetto_NumMomBins = 150;
Ivana.Ghetto_MomMin = 0;
Ivana.Ghetto_MomMax = 600;
}
}
if(NumCPU>1){
Ivana.SetDebugMode(true);
for(unsigned uTh=0; uTh<NumCPU; uTh++){
Ivana.SetSeed(uTh,SEED*(NumCPU)+uTh);
}
}
else{
Ivana.SetDebugMode(false);
Ivana.SetSeed(0,SEED);
}
Ivana.GoBabyGo(NumCPU);
Ivana.Ghetto_kstar_rstar_mT->QuickWrite(OutputFileNameFull,true);
Ivana.Ghetto_kstar_rcore_mT->QuickWrite(OutputFileNameCore,true);