-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaiGanio.cpp
More file actions
1634 lines (1339 loc) · 55.5 KB
/
BaiGanio.cpp
File metadata and controls
1634 lines (1339 loc) · 55.5 KB
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 "BaiGanio.h"
#include "TRandom3.h"
#include "TNtuple.h"
#include "TH1F.h"
#include "TF1.h"
#include "TFile.h"
#include "TH2F.h"
#include "TGraphErrors.h"
#include "CATS.h"
#include "CATStools.h"
#include "DLM_Source.h"
#include "DLM_Potentials.h"
#include "EnvVars.h"
#include "CATSconstants.h"
#include "CommonAnaFunctions.h"
#include "TROOT.h"
#include "DLM_Histo.h"
#include <fstream> // at the top of your file
#include <iomanip>
#include "Math/MinimizerOptions.h"
//4D: //f0,d0,kstar,rstar
DLM_Histo<float>* dlm_wf_u_pp_coarse = NULL;
DLM_Histo<float>* dlm_wf_u_pp_fine = NULL;
struct Ganio_pp_pot_pars
{
float V0,mu0,V1,mu1,f0,d0;
int num_entries=0;
//void add_entry();
Ganio_pp_pot_pars(){
Ganio_pp_pot_pars(0);
}
Ganio_pp_pot_pars(double value){
*this = 0;
}
bool operator+=(const Ganio_pp_pot_pars& other){
//double w = double(num_entries)/double(num_entries+other.num_entries);
//V0 = V0*w + other.V0*(1.-w);
//mu0 = mu0*w + other.mu0*(1.-w);
//V1 = V1*w + other.V1*(1.-w);
//mu1 = mu1*w + other.mu1*(1.-w);
//f0 = f0*w + other.f0*(1.-w);
//d0 = d0*w + other.d0*(1.-w);
//num_entries += other.num_entries;
V0 += other.V0;
mu0 += other.mu0;
V1 += other.V1;
mu1 += other.mu1;
f0 += other.f0;
d0 += other.d0;
num_entries += other.num_entries;
return true;
}
bool operator/=(const double& value){
V0 /= value;
mu0 /= value;
V1 /= value;
mu1 /= value;
f0 /= value;
d0 /= value;
num_entries = TMath::Nint(double(num_entries)/value);
return true;
}
bool operator=(const Ganio_pp_pot_pars& other){
V0 = other.V0;
mu0 = other.mu0;
V1 = other.V1;
mu1 = other.mu1;
f0 = other.f0;
d0 = other.d0;
num_entries = other.num_entries;
return true;
}
bool operator=(const double& value){
V0 = value;
mu0 = value;
V1 = value;
mu1 = value;
f0 = value;
d0 = value;
num_entries = 0;
return true;
}
Ganio_pp_pot_pars operator*(const double& value){
Ganio_pp_pot_pars Result;
Result.V0 = V0 * value;
Result.mu0 = mu0 * value;
Result.V1 = V1 * value;
Result.mu1 = mu1 * value;
Result.f0 = f0 * value;
Result.d0 = d0 * value;
Result.num_entries = num_entries;
return Result;
}
void compute_average(){
*this /= num_entries;
}
void print(){
printf("%p: f0=%.3e d0=%.3e V0=%.3e mu0=%.3e V1=%.3e mu2=%.3e ne=%i\n",this,f0,d0,V0,mu0,V1,mu1,num_entries);
}
};
void SetUp_Ganio_pp_pot(const int n_f0, const double min_f0, const double max_f0,
const int n_d0, const double min_d0, const double max_d0,
const int n_kstar, const double min_kstar, const double max_kstar,
const int n_rstar, const double min_rstar, const double max_rstar,
TNtuple& input_ntuple, const int pot_id, DLM_Histo<float>*& dlm_wf_u_pp){
printf("Hello there, lets set things up!\n");
if(dlm_wf_u_pp) delete dlm_wf_u_pp;
dlm_wf_u_pp = new DLM_Histo<float> ();
//f0,d0,kstar,rstar
dlm_wf_u_pp->SetUp(4);
dlm_wf_u_pp->SetUp(0, n_f0, min_f0, max_f0);
dlm_wf_u_pp->SetUp(1, n_d0, min_d0, max_d0);
dlm_wf_u_pp->SetUp(2, n_kstar, min_kstar, max_kstar);
dlm_wf_u_pp->SetUp(3, n_rstar, min_rstar, max_rstar);
dlm_wf_u_pp->Initialize();
//f0,d0
DLM_Histo<Ganio_pp_pot_pars> dlm_par_map;
dlm_par_map.SetUp(2);
dlm_par_map.SetUp(0, n_f0, min_f0, max_f0);
dlm_par_map.SetUp(1, n_d0, min_d0, max_d0);
dlm_par_map.Initialize();
float SEED, POT_ID, RedM, f0, d0, V0, mu0, V1, mu1;
input_ntuple.SetBranchAddress("SEED",&SEED);
input_ntuple.SetBranchAddress("POT_ID",&POT_ID);
input_ntuple.SetBranchAddress("RedM",&RedM);
input_ntuple.SetBranchAddress("f0",&f0);
input_ntuple.SetBranchAddress("d0",&d0);
input_ntuple.SetBranchAddress("V0",&V0);
input_ntuple.SetBranchAddress("mu0",&mu0);
input_ntuple.SetBranchAddress("V1",&V1);
input_ntuple.SetBranchAddress("mu1",&mu1);
gROOT->cd();
TGraphErrors* g_visual_mu0 = new TGraphErrors();
g_visual_mu0->SetName("g_visual_mu0");
//I did a visual cut to get rid of offliers. Simply check if mu < some pol2 function, and hard cut on V
TF1* fLowerLimit_mu0 = new TF1("fLowerLimit_mu0", "[0]+[1]*x+[2]*x*x",-128,0);
TF1* fUpperLimit_mu0 = new TF1("fUpperLimit_mu0", "[0]+[1]*x+[2]*x*x",-128,0);
TF1* fLowerLimit_V0 = new TF1("fLowerLimit_V0", "[0]+[1]*x+[2]*x*x",0,8);
TF1* fUpperLimit_V0 = new TF1("fUpperLimit_V0", "[0]+[1]*x+[2]*x*x",0,8);
TH2F* h_V0_mu0_input = new TH2F("h_V0_mu0_input","h_V0_mu0_input",512,-128,0,512,0,8);
TH2F* h_V0_mu0_selection = new TH2F("h_V0_mu0_selection","h_V0_mu0_selection",512,-128,0,512,0,8);
//cut out regions in the parameter space (inspect visually)
if(pot_id==1){
g_visual_mu0->SetPoint(0, -85, 1.10);
g_visual_mu0->SetPointError(0, 0, 0.1);
g_visual_mu0->SetPoint(1, -60, 1.29);
g_visual_mu0->SetPointError(1, 0, 0.1);
g_visual_mu0->SetPoint(2, -40, 1.57);
g_visual_mu0->SetPointError(2, 0, 0.1);
g_visual_mu0->SetPoint(3, -25, 1.96);
g_visual_mu0->SetPointError(3, 0, 0.1);
g_visual_mu0->SetPoint(4, -17, 2.34);
g_visual_mu0->SetPointError(4, 0, 0.1);
g_visual_mu0->Fit(fLowerLimit_mu0,"S, N, R, M");
fLowerLimit_mu0->SetParameter(0, fLowerLimit_mu0->GetParameter(0)-0.2);
fUpperLimit_mu0->SetParameter(0, fLowerLimit_mu0->GetParameter(0) + 0.2*2);
fUpperLimit_mu0->SetParameter(1, fLowerLimit_mu0->GetParameter(1));
fUpperLimit_mu0->SetParameter(2, fLowerLimit_mu0->GetParameter(2));
//fLowerLimit_mu0->SetParameter(0, 3.025);
//fLowerLimit_mu0->SetParameter(1, 0.05434);
//fLowerLimit_mu0->SetParameter(2, 0.0003432);
fLowerLimit_V0->SetParameter(0, -88);
fLowerLimit_V0->SetParameter(1, 0);
fLowerLimit_V0->SetParameter(2, 0);
//fUpperLimit_mu0->SetParameter(0, 3.325);
//fUpperLimit_mu0->SetParameter(1, 0.05434);
//fUpperLimit_mu0->SetParameter(2, 0.0003432);
fUpperLimit_V0->SetParameter(0, -16);
fUpperLimit_V0->SetParameter(1, 0);
fUpperLimit_V0->SetParameter(2, 0);
}
if(pot_id==11){
g_visual_mu0->SetPoint(0, -39, 1.55);
g_visual_mu0->SetPointError(0, 0, 0.1);
g_visual_mu0->SetPoint(1, -32, 1.7);
g_visual_mu0->SetPointError(1, 0, 0.1);
g_visual_mu0->SetPoint(2, -27, 1.85);
g_visual_mu0->SetPointError(2, 0, 0.1);
g_visual_mu0->SetPoint(3, -20.75, 2.1);
g_visual_mu0->SetPointError(3, 0, 0.1);
g_visual_mu0->SetPoint(4, -15.5, 2.4);
g_visual_mu0->SetPointError(4, 0, 0.1);
g_visual_mu0->SetPoint(5, -10, 2.95);
g_visual_mu0->SetPointError(5, 0, 0.1);
g_visual_mu0->SetPoint(6, -7.5, 3.35);
g_visual_mu0->SetPointError(6, 0, 0.1);
g_visual_mu0->Fit(fLowerLimit_mu0,"S, N, R, M");
fLowerLimit_mu0->SetParameter(0, fLowerLimit_mu0->GetParameter(0)-0.2);
fUpperLimit_mu0->SetParameter(0, fLowerLimit_mu0->GetParameter(0) + 0.2*2);
fUpperLimit_mu0->SetParameter(1, fLowerLimit_mu0->GetParameter(1));
fUpperLimit_mu0->SetParameter(2, fLowerLimit_mu0->GetParameter(2));
//fLowerLimit_mu0->SetParameter(0, 3.025);
//fLowerLimit_mu0->SetParameter(1, 0.05434);
//fLowerLimit_mu0->SetParameter(2, 0.0003432);
fLowerLimit_V0->SetParameter(0, -26);
fLowerLimit_V0->SetParameter(1, 0);
fLowerLimit_V0->SetParameter(2, 0);
//fUpperLimit_mu0->SetParameter(0, 3.325);
//fUpperLimit_mu0->SetParameter(1, 0.05434);
//fUpperLimit_mu0->SetParameter(2, 0.0003432);
fUpperLimit_V0->SetParameter(0, -9);
fUpperLimit_V0->SetParameter(1, 0);
fUpperLimit_V0->SetParameter(2, 0);
}
if(pot_id==201){
printf("pot_id==201 not set up yet !!!!\n");
}
if(pot_id==202){
printf("pot_id==202 not set up yet !!!!\n");
}
if(pot_id==203){
printf("pot_id==203 not set up yet !!!!\n");
}
if(pot_id==204){
printf("pot_id==204 not set up yet !!!!\n");
}
if(pot_id==205){
printf("pot_id==205 not set up yet !!!!\n");
}
for(unsigned uEntry=0; uEntry<input_ntuple.GetEntries(); uEntry++){
if(uEntry%1000000==0) printf("%u of %u M\n", uEntry/1000000, input_ntuple.GetEntries()/1000000);
input_ntuple.GetEntry(uEntry);
if(TMath::Nint(POT_ID)!=pot_id) continue;
if(f0<min_f0 || f0>max_f0) continue;
if(d0<min_d0 || d0>max_d0) continue;
h_V0_mu0_input->Fill(V0,mu0);
if(V0<fLowerLimit_V0->Eval(V0)) continue;
if(V0>fUpperLimit_V0->Eval(V0)) continue;
if(mu0<fLowerLimit_mu0->Eval(V0)) continue;
if(mu0>fUpperLimit_mu0->Eval(V0)) continue;
h_V0_mu0_selection->Fill(V0,mu0);
//превъртяхме потенциала
//if(pot_id==11&&V0<-32) continue;
//THINK HOW TO DO THE APPROXIMATE ESTIMATION OF THE V0/mu0 <-> f0,d0, WE ACTUALLY JUST NEED A SINGLE SOLUTION PER f0/d0 pair
//use dlm_par_map to get some averages
Ganio_pp_pot_pars ParCombo;
ParCombo.V0 = V0;
ParCombo.mu0 = mu0;
ParCombo.V1 = V1;
ParCombo.mu1 = mu1;
ParCombo.f0 = f0;
ParCombo.d0 = d0;
ParCombo.num_entries = 1;
dlm_par_map.AddAt(f0,d0,ParCombo);
}
//printf("WTF %u\n",dlm_par_map.GetNbins());
for(unsigned uBin=0; uBin<dlm_par_map.GetNbins(); uBin++){
//Ganio_pp_pot_pars& element = dlm_par_map.GetBinElement(uBin);
//element.compute_average();
//dlm_par_map.GetBinElement(uBin).print();
dlm_par_map.GetBinElement(uBin).compute_average();
//dlm_par_map.GetBinElement(uBin).print();
unsigned WhichBin[2];
dlm_par_map.GetBinCoordinates(uBin, WhichBin);
//printf(" %f %f\n",dlm_par_map.GetBinLowEdge(0,WhichBin[0]),dlm_par_map.GetBinUpEdge(0,WhichBin[0]));
//printf(" %f %f\n",dlm_par_map.GetBinLowEdge(1,WhichBin[1]),dlm_par_map.GetBinUpEdge(1,WhichBin[1]));
if( dlm_par_map.GetBinLowEdge(0,WhichBin[0])<=17.3 && dlm_par_map.GetBinUpEdge(0,WhichBin[0])>17.3 &&
dlm_par_map.GetBinLowEdge(1,WhichBin[1])<=2.8 && dlm_par_map.GetBinUpEdge(1,WhichBin[1])>2.8){
dlm_par_map.GetBinElement(uBin).print();
//printf(" bc %.3ef %.3ef\n",dlm_par_map.GetBinCenter(0,WhichBin[0]),dlm_par_map.GetBinCenter(1,WhichBin[1]));
//printf("\n");
//usleep(40e3);
}
}
printf("The parameters for pp:\n");
dlm_par_map.Eval2D(17.3,2.8,false).print();
const double kMin = 0;
const double kMax = 60;
const unsigned kSteps = 10;
const double SourceSize = 1.0;
printf("xCheck:\n");
CATS Kitty;
Kitty.SetMomBins(kSteps, kMin, kMax);
CATSparameters sPars(CATSparameters::tSource,1,true);
Kitty.SetAnaSource(GaussSource, sPars);
Kitty.SetAnaSource(0, SourceSize);
Kitty.SetUseAnalyticSource(true);
Kitty.SetMomentumDependentSource(false);
Kitty.SetThetaDependentSource(false);
Kitty.SetNormalizedSource(false);
Kitty.SetAutoNormSource(true);
Kitty.SetRedMass(0.5*Mass_p);
Kitty.SetQ1Q2(0);
Kitty.SetQuantumStatistics(false);
Kitty.SetNumChannels(1);
Kitty.SetSpin(0,0);
Kitty.SetNumPW(0,1);
Kitty.SetChannelWeight(0, 1);
Kitty.SetEpsilonConv(2e-9);
Kitty.SetEpsilonProp(2e-9);
CATS FatCat;
FatCat.SetMomBins(n_kstar, min_kstar, max_kstar);
FatCat.SetAnaSource(GaussSource, sPars);
FatCat.SetAnaSource(0, SourceSize);
FatCat.SetUseAnalyticSource(true);
FatCat.SetMomentumDependentSource(false);
FatCat.SetThetaDependentSource(false);
FatCat.SetNormalizedSource(false);
FatCat.SetAutoNormSource(true);
FatCat.SetRedMass(0.5*Mass_p);
FatCat.SetQ1Q2(1);
FatCat.SetQuantumStatistics(true);
FatCat.SetNumChannels(2);
FatCat.SetSpin(0,0);
FatCat.SetSpin(1,1);
FatCat.SetNumPW(0,1);
FatCat.SetChannelWeight(0, 0.25);
FatCat.SetChannelWeight(1, 0.75);
FatCat.SetNotifications(CATS::nWarning);
FatCat.SetEpsilonConv(2e-9);
FatCat.SetEpsilonProp(2e-9);
//FatCat.SetMaxRad(128);
if(pot_id==11){
double PotPars[2]={dlm_par_map.Eval2D(17.3,2.8,false).V0, dlm_par_map.Eval2D(17.3,2.8,false).mu0};
//PotPars[0] = -14.08;
//PotPars[1] = 2.547;
CATSparameters cPotPars(CATSparameters::tPotential,2,true);
cPotPars.SetParameters(PotPars);
Kitty.SetShortRangePotential(0,0,SquareWell,cPotPars);
FatCat.SetShortRangePotential(0,0,SquareWell,cPotPars);
printf(" sw pot_pars: %.3f %3f\n", Kitty.GetPotPar(0,0,0), Kitty.GetPotPar(0,0,1));
}
else if(pot_id==1){
double PotPars[2]={dlm_par_map.Eval2D(17.3,2.8,false).V0, dlm_par_map.Eval2D(17.3,2.8,false).mu0};
CATSparameters cPotPars(CATSparameters::tPotential,2,true);
cPotPars.SetParameters(PotPars);
Kitty.SetShortRangePotential(0,0,SingleGauss,cPotPars);
FatCat.SetShortRangePotential(0,0,SingleGauss,cPotPars);
printf(" sg pot_pars: %.3f %3f\n", Kitty.GetPotPar(0,0,0), Kitty.GetPotPar(0,0,1));
}
//DG
else if(pot_id>=200 && pot_id<=299){
double PotPars[4]={dlm_par_map.Eval2D(17.3,2.8,false).V0, dlm_par_map.Eval2D(17.3,2.8,false).mu0,
dlm_par_map.Eval2D(17.3,2.8,false).V1, dlm_par_map.Eval2D(17.3,2.8,false).mu1};
CATSparameters cPotPars(CATSparameters::tPotential,4,true);
cPotPars.SetParameters(PotPars);
Kitty.SetShortRangePotential(0,0,DoubleGaussSum,cPotPars);
FatCat.SetShortRangePotential(0,0,DoubleGaussSum,cPotPars);
printf(" dg pot_pars: %.3f %3f\n", Kitty.GetPotPar(0,0,0), Kitty.GetPotPar(0,0,1), Kitty.GetPotPar(0,0,2), Kitty.GetPotPar(0,0,3));
}
printf("we have a cat\n");
Kitty.KillTheCat();
for(unsigned uf0=0; uf0<n_f0; uf0++){
unsigned WhichBin[4];
WhichBin[0] = uf0;
double f0_val = dlm_wf_u_pp->GetBinCenter(0,uf0);
printf("uf0 %u of %u (%.2f)\n",uf0,n_f0,f0_val);
for(unsigned ud0=0; ud0<n_d0; ud0++){
WhichBin[1] = ud0;
double d0_val = dlm_wf_u_pp->GetBinCenter(1,ud0);
//printf(" ud0 %u of %u (%.2f)\n",ud0,n_d0,d0_val);
double PotPars[2]={dlm_par_map.Eval2D(f0_val,d0_val,false).V0, dlm_par_map.Eval2D(f0_val,d0_val,false).mu0};
//printf(" V = %.3f; mu = %.4f\n",PotPars[0],PotPars[1]);
//dlm_par_map.GetBinContent(uf0,ud0).print();
//usleep(100e3);
FatCat.SetShortRangePotential(0,0,0,PotPars[0]);
FatCat.SetShortRangePotential(0,0,1,PotPars[1]);
FatCat.KillTheCat();
//put the vals for the WF
for(unsigned uks=0; uks<n_kstar; uks++){
WhichBin[2] = uks;
for(unsigned urs=0; urs<n_rstar; urs++){
WhichBin[3] = urs;
double rad = dlm_wf_u_pp->GetBinCenter(3, urs);
//4D: //f0,d0,kstar,rstar
//DLM_Histo<float>* dlm_wf_u_pp = NULL;
//dlm_wf_u_pp->SetUp(0, n_f0, min_f0, max_f0);
//dlm_wf_u_pp->SetUp(1, n_d0, min_d0, max_d0);
//dlm_wf_u_pp->SetUp(2, n_kstar, min_kstar, max_kstar);
//dlm_wf_u_pp->SetUp(3, n_rstar, min_rstar, max_rstar);
dlm_wf_u_pp->SetBinContent(WhichBin,FatCat.EvalRadialWaveFunction(uks, 0, 0, rad, false).real()*hbarc);
//printf("%u %u %u %u %f vs %f\n",
// WhichBin[0],WhichBin[1],WhichBin[2],WhichBin[3], FatCat.EvalRadialWaveFunction(uks, 0, 0, rad, false).real(),
// WhichBin[0],WhichBin[1],WhichBin[2],WhichBin[3], FatCat.EvalReferenceRadialWF(uks, 0, rad, false).real());
//usleep(50e3);
}
}
}
}
//dlm_wf_u_pp->SetUp(0, n_f0, min_f0, max_f0);
//dlm_wf_u_pp->SetUp(1, n_d0, min_d0, max_d0);
//dlm_wf_u_pp->SetUp(2, n_kstar, min_kstar, max_kstar);
//dlm_wf_u_pp->SetUp(3, n_rstar, min_rstar, max_rstar);
double ScatLen, EffRan;
TH1F *hFit;
TF1 *fitSP;
GetScattParameters(Kitty, ScatLen, EffRan, hFit, fitSP, 2, false, false, 0);
printf("I got from the cat f0 = %.2f and d0 = %.2f\n", ScatLen, EffRan);
printf("ERE set up (q1q2): %f\n", fitSP->GetParameter(0));
printf("PARS: %f %f\n", Kitty.GetPotPar(0,0,0), Kitty.GetPotPar(0,0,1));
FatCat.SetShortRangePotential(0,0,0,Kitty.GetPotPar(0,0,0));
FatCat.SetShortRangePotential(0,0,1,Kitty.GetPotPar(0,0,1));
FatCat.KillTheCat(CATS::kAllChanged);
DLM_CommonAnaFunctions AnalysisObject;
AnalysisObject.SetCatsFilesFolder(TString::Format("%s/CatsFiles",GetCernBoxDimi()).Data());
CATS Kitty_AV18;
Kitty_AV18.SetMomBins(n_kstar, min_kstar, max_kstar);
Kitty_AV18.SetNotifications(CATS::nWarning);
AnalysisObject.SetUpCats_pp(Kitty_AV18,"AV18_s","Gauss",0,0);//McLevyNolan_Reso
Kitty_AV18.SetAnaSource(0,FatCat.GetAnaSourcePar(0));
Kitty_AV18.KillTheCat();
TFile fOut(TString::Format("%s/BaiGanio/Generate_GaussPotPars_For_Kali/GanioDump.root", GetFemtoOutputFolder()),"recreate");
TGraph gKitty;
gKitty.SetName("gKitty");
TGraph gFatCat;
gFatCat.SetName("gFatCat");
TGraph gAv18;
gAv18.SetName("gAv18");
TGraph gFatCatPS;
gFatCatPS.SetName("gFatCatPS");
TGraph gAv18PS;
gAv18PS.SetName("gAv18PS");
TGraph gFatCatU50;
gFatCatU50.SetName("gFatCatU50");
TGraph gAv18U50;
gAv18U50.SetName("gAv18U50");
TGraphErrors gPotAv18;
gPotAv18.SetName("gPotAv18");
for(double frad=0.05; frad<10; frad+=0.05){
gPotAv18.SetPoint(gPotAv18.GetN(), frad, Kitty_AV18.EvaluateThePotential(0,0,10,frad));
gPotAv18.SetPointError(gPotAv18.GetN()-1, 0.0, 0.1);
}
for(unsigned uKstar=0; uKstar<kSteps; uKstar++){
double kstar, Ck_Kitty;
kstar = Kitty.GetMomentum(uKstar);
Ck_Kitty = Kitty.GetCorrFun(uKstar);
gKitty.SetPoint(uKstar, kstar, Ck_Kitty);
}
for(unsigned uKstar=0; uKstar<n_kstar; uKstar++){
double kstar, Ck_FatCat, Ck_Av18;
kstar = FatCat.GetMomentum(uKstar);
Ck_FatCat = FatCat.GetCorrFun(uKstar);
Ck_Av18 = Kitty_AV18.GetCorrFun(uKstar);
gFatCat.SetPoint(uKstar, kstar, Ck_FatCat);
gAv18.SetPoint(uKstar, kstar, Ck_Av18);
gFatCatPS.SetPoint(uKstar, kstar, FatCat.GetPhaseShift(uKstar,0,0));
gAv18PS.SetPoint(uKstar, kstar, Kitty_AV18.GetPhaseShift(uKstar,0,0));
}
for(double rad=0.025; rad<=8; rad+=0.05){
gFatCatU50.SetPoint(gFatCatU50.GetN(), rad, FatCat.EvalRadialWaveFunction(FatCat.GetMomBin(50), 0, 0, rad, false).real());
gAv18U50.SetPoint(gAv18U50.GetN(), rad, Kitty_AV18.EvalRadialWaveFunction(Kitty_AV18.GetMomBin(50), 0, 0, rad, false).real());
}
gKitty.Write();
gFatCat.Write();
gAv18.Write();
gFatCatPS.Write();
gAv18PS.Write();
gPotAv18.Write();
gFatCatU50.Write();
gAv18U50.Write();
//fitSP->SetParameter(1, 17.3);
//fitSP->SetParameter(2, 2.8);
hFit->Write();
fitSP->Write();
fLowerLimit_mu0->Write();
fUpperLimit_mu0->Write();
fLowerLimit_V0->Write();
fUpperLimit_V0->Write();
h_V0_mu0_input->Write();
h_V0_mu0_selection->Write();
g_visual_mu0->Write();
delete fLowerLimit_mu0;
delete fUpperLimit_mu0;
delete fLowerLimit_V0;
delete fUpperLimit_V0;
delete h_V0_mu0_input;
delete h_V0_mu0_selection;
delete g_visual_mu0;
}
double Ganio_pp_pot(double* pars){
}
//NumEvents in K
void Generate_GaussPotPars_For_Kali(bool ASCII, TString Description, TString PotType, int PotVar, float MinRedM, float MaxRedM, unsigned NumEvents, int SEED){
NumEvents *= 1000;
//const double MinRedM = 450;
//const double MaxRedM = 600;
unsigned* NumBinsPar = new unsigned [4];
float* MinPar = new float [4];
float* MaxPar = new float [4];
bool* LogSampling = new bool [4];
//double MinAmp1;
//double MaxAmp1;
//unsigned NumAmp1;
//double MinAmp2;
//double MaxAmp2;
//unsigned NumAmp2;
//double MinRng1;
//double MaxRng1;
//unsigned NumRng1;
//double MinRng2 = 1.0;
//double MaxRng2 = 2.1;
//unsigned NumRng2;
const double kMin = 0;
const double kMax = 60;
const unsigned kSteps = 6;
//17.3
double f0_goal_min = 17.3*0.7;
double f0_goal_max = 17.3*1.3;
unsigned Num_f0 = 32;
//f0_goal_min = 17.3*0.85;//temp
//f0_goal_max = 17.3*1.15;//temp
//f0_goal_min = 17.0;
//f0_goal_max = 20.0;
//Num_f0 = 8;
//2.8
double d0_goal_min = 2.8*0.7;
double d0_goal_max = 2.8*1.3;
unsigned Num_d0 = 32;//was 16
//d0_goal_min = 2.8*0.85;//temp
//d0_goal_max = 2.8*1.15;//temp
//d0_goal_min = 2.5;
//d0_goal_max = 2.7;
//Num_d0 = 8;
unsigned EachXevent_rnd = 4;
//this turned out VERY tricky, we need fine, really fine binning
if(PotType=="SquareWell"){
Num_f0 = 48;
Num_d0 = 128;
//the values here are too wild, so less random
EachXevent_rnd = 8;
//f0_goal_min = 17.3*0.8;//temp
//f0_goal_max = 17.3*1.4;//temp
}
TRandom3 rangen(SEED);
CATS Kitty;
Kitty.SetMomBins(kSteps, kMin, kMax);
CATSparameters sPars(CATSparameters::tSource,1,true);
Kitty.SetAnaSource(GaussSource, sPars);
Kitty.SetAnaSource(0, 1.0);
Kitty.SetUseAnalyticSource(true);
Kitty.SetMomentumDependentSource(false);
Kitty.SetThetaDependentSource(false);
Kitty.SetNormalizedSource(false);
Kitty.SetAutoNormSource(true);
Kitty.SetRedMass(0.5*Mass_p);
Kitty.SetQ1Q2(0);
Kitty.SetQuantumStatistics(false);
Kitty.SetNumChannels(1);
Kitty.SetSpin(0,0);
Kitty.SetNumPW(0,1);
Kitty.SetChannelWeight(0, 1);
double PotPars[2]={0,1};
CATSparameters cPotPars(CATSparameters::tPotential,4,true);
cPotPars.SetParameters(PotPars);
printf("we have a cat\n");
float potential_id = 0;
unsigned NumPotPars = 0;
double epsc = 1e-8;
double epsp = 1e-8;
if(PotType=="Gauss"){
potential_id = 1;
NumPotPars = 2;
Kitty.SetShortRangePotential(0,0,SingleGauss,cPotPars);
MinPar[0] = -90;
MaxPar[0] = -12;
NumBinsPar[0] = 35;
LogSampling[0] = false;
MinPar[1] = 1.0;
MaxPar[1] = 2.6;
NumBinsPar[1] = 44;
LogSampling[1] = false;
}
else if(PotType=="DoubleGauss"){
//do these variations for the core:
//3000, 0.4
//4500, 0.4
//2250, 0.4
//4500, 0.3
//2250, 0.6
potential_id = 200;
potential_id += PotVar;
NumPotPars = 4;
Kitty.SetShortRangePotential(0,0,DoubleGaussSum,cPotPars);
if(PotVar==1){
MinPar[0] = -420;//480
MaxPar[0] = -30;//160
NumBinsPar[0] = 24*4;
LogSampling[0] = false;
MinPar[1] = 0.8;//0.7
MaxPar[1] = 2.0;//1.4
NumBinsPar[1] = 24*4;
LogSampling[1] = false;
MinPar[2] = 3000;
MaxPar[2] = 3000;
NumBinsPar[2] = 1;
LogSampling[2] = true;
MinPar[3] = 0.4;
MaxPar[3] = 0.4;
NumBinsPar[3] = 1;
LogSampling[3] = false;
}
else if(PotVar==2){
MinPar[0] = -500;//560
MaxPar[0] = -60;//240
NumBinsPar[0] = 24*4;
LogSampling[0] = false;
MinPar[1] = 0.75;//0.6
MaxPar[1] = 1.8;//1.3
NumBinsPar[1] = 24*4;
LogSampling[1] = false;
MinPar[2] = 4500;
MaxPar[2] = 4500;
NumBinsPar[2] = 1;
LogSampling[2] = true;
MinPar[3] = 0.4;
MaxPar[3] = 0.4;
NumBinsPar[3] = 1;
LogSampling[3] = false;
}
else if(PotVar==3){
MinPar[0] = -300;//420
MaxPar[0] = -35;//120
NumBinsPar[0] = 24*4;
LogSampling[0] = false;
MinPar[1] = 0.85;//0.7
MaxPar[1] = 1.95;//1.4
NumBinsPar[1] = 24*4;
LogSampling[1] = false;
MinPar[2] = 2250;
MaxPar[2] = 2250;
NumBinsPar[2] = 1;
LogSampling[2] = true;
MinPar[3] = 0.4;
MaxPar[3] = 0.4;
NumBinsPar[3] = 1;
LogSampling[3] = false;
}
else if(PotVar==4){
MinPar[0] = -260;//480
MaxPar[0] = -25;//160
NumBinsPar[0] = 24*4;
LogSampling[0] = false;
MinPar[1] = 0.8;//0.7
MaxPar[1] = 2.2;//1.4
NumBinsPar[1] = 24*4;
LogSampling[1] = false;
MinPar[2] = 4500;
MaxPar[2] = 4500;
NumBinsPar[2] = 1;
LogSampling[2] = true;
MinPar[3] = 0.3;
MaxPar[3] = 0.3;
NumBinsPar[3] = 1;
LogSampling[3] = false;
}
else if(PotVar==5){
MinPar[0] = -1600;//480
MaxPar[0] = -90;//160
NumBinsPar[0] = 24*4;
LogSampling[0] = false;
MinPar[1] = 0.7;//0.7
MaxPar[1] = 1.6;//1.4
NumBinsPar[1] = 24*4;
LogSampling[1] = false;
MinPar[2] = 2250;
MaxPar[2] = 2250;
NumBinsPar[2] = 1;
LogSampling[2] = true;
MinPar[3] = 0.6;
MaxPar[3] = 0.6;
NumBinsPar[3] = 1;
LogSampling[3] = false;
}
else{
MinPar[0] = -100;
MaxPar[0] = 0;
NumBinsPar[0] = 24;
LogSampling[0] = false;
MinPar[1] = 1.0;
MaxPar[1] = 2.1;
NumBinsPar[1] = 24;
LogSampling[1] = false;
MinPar[2] = 1;
MaxPar[2] = 5000;
NumBinsPar[2] = 24;
LogSampling[2] = true;
MinPar[3] = 0.0;
MaxPar[3] = 1.0;
NumBinsPar[3] = 24;
LogSampling[3] = false;
}
}
else if(PotType=="SquareWell"){
potential_id = 11;
NumPotPars = 2;
Kitty.SetShortRangePotential(0,0,SquareWell,cPotPars);
//MinPar[0] = -150;
MinPar[0] = -40;
MaxPar[0] = -7;
NumBinsPar[0] = 35*4;
LogSampling[0] = false;
//MinPar[1] = 0.4;
MinPar[1] = 1.5;
//MaxPar[1] = 1.6;
MaxPar[1] = 3.5;
NumBinsPar[1] = 44*4;
LogSampling[1] = false;
epsc = 5e-9;
epsp = 1e-9;
}
else if(PotType=="SquareWellWall"){
potential_id = 12;
NumPotPars = 4;
printf("still need to adjust pars!!!\n");
Kitty.SetShortRangePotential(0,0,SquareWell,cPotPars);
//MinAmp1 = -150;
//MaxAmp1 = 0;
//MinRng1 = 0.4;
//MaxRng1 = 1.6;
}
DLM_Histo<bool> dlmTable;
//f0,d0 and the pot pars
dlmTable.SetUp(2+NumPotPars);
dlmTable.SetUp(0,Num_f0, f0_goal_min, f0_goal_max);
dlmTable.SetUp(1,Num_d0, d0_goal_min, d0_goal_max);
for(unsigned uPar=0; uPar<NumPotPars; uPar++){
if(NumBinsPar[uPar]==1){
dlmTable.SetUp(2+uPar,NumBinsPar[uPar],MinPar[uPar]*0.99,MaxPar[uPar]*1.01);
}
else{
dlmTable.SetUp(2+uPar,NumBinsPar[uPar],MinPar[uPar],MaxPar[uPar]);
}
}
dlmTable.Initialize();
dlmTable.SetBinContentAll(false);
//Kitty.KillTheCat();
Kitty.SetNotifications(CATS::nWarning);
// before the loop
std::ofstream* outFile = NULL;
if(ASCII) outFile = new std::ofstream(TString::Format("%s/BaiGanio/Generate_GaussPotPars_For_Kali/output_%s_pv%i_SEED%i.txt",GetFemtoOutputFolder(), PotType.Data(), PotVar, SEED).Data());
//std::ofstream outFile(TString::Format("%s/BaiGanio/Generate_GaussPotPars_For_Kali/output_%s_SEED%i.txt",GetFemtoOutputFolder(), PotType.Data(), SEED).Data());
if(outFile) *outFile << "RED_MASS\tSCAT_LEN\tEFF_RNG\t\tPOT_PAR1\tPOT_PAR2\tPOT_PAR3\tPOT_PAR4\n";
//TFile fTemp(TString::Format("%s/BaiGanio/Generate_GaussPotPars_For_Kali/froot_%s_SEED%i.root",GetFemtoOutputFolder(), PotType.Data(), SEED).Data(), "recreate");
TFile fOutput(TString::Format("%s/BaiGanio/Generate_GaussPotPars_For_Kali/%s_%s_pv%i_SEED%i.root",GetFemtoOutputFolder(), Description.Data(), PotType.Data(), PotVar, SEED).Data(), "recreate");
TNtuple* nt_pp_pars = new TNtuple("nt_pp_pars", "nt_pp_pars","SEED:POT_ID:RedM:f0:d0:V0:mu0:V1:mu1");
Float_t nt_buffer[9];
nt_buffer[0] = SEED;
nt_buffer[1] = potential_id;
double RedM = MinRedM;
//a trick to have the RndPar count from zero, but we can also access the axes of our dlm_histo
double* AxisValues = new double [6];
double* RndPar = &AxisValues[2];
std::vector<unsigned> evaluated_bins;
//printf("go go %u\n", evaluated_bins.size());
unsigned whileEvent = 0;
unsigned TotBinId;
unsigned RndBin;
while(whileEvent<NumEvents){
if(MinRedM!=MaxRedM) RedM = rangen.Uniform(MinRedM, MaxRedM);
if(whileEvent%EachXevent_rnd==0 || evaluated_bins.size()==0){
for(unsigned uPar=0; uPar<NumPotPars; uPar++){
if(MinPar[uPar]==MaxPar[uPar]){
RndPar[uPar] = MinPar[uPar];
}
else if(LogSampling[uPar]){
RndPar[uPar] = rangen.Uniform(log(MinPar[uPar]), log(MaxPar[uPar]));
RndPar[uPar] = exp(RndPar[uPar]);
}
else{
RndPar[uPar] = rangen.Uniform(MinPar[uPar], MaxPar[uPar]);
}
}
}
else{
RndBin = rangen.Integer(evaluated_bins.size());
unsigned* BinIdPerAxis = new unsigned [2+NumPotPars];
dlmTable.GetBinCoordinates(evaluated_bins.at(RndBin), BinIdPerAxis);
//printf("sampling from %u (%u)\n",RndBin,evaluated_bins.at(RndBin));
for(unsigned uPar=0; uPar<NumPotPars; uPar++){
if(MinPar[uPar]==MaxPar[uPar]){
RndPar[uPar] = MinPar[uPar];
}
else{
RndPar[uPar] = rangen.Uniform(dlmTable.GetBinLowEdge(2+uPar, BinIdPerAxis[2+uPar]), dlmTable.GetBinUpEdge(2+uPar, BinIdPerAxis[2+uPar]));
}
//printf(" %u %.3f\n", uPar, RndPar[uPar]);
//usleep(100e3);
}
delete [] BinIdPerAxis;
}
/*
//every second event is random, every second we sample from
//our histogram, as long as there are entries there
if(whileEvent%2==1 && evaluated_bins.size()>0){
RndBin = rangen.Integer(evaluated_bins.size());
unsigned* BinIdPerAxis = new unsigned [2+NumPotPars];
dlmTable.GetBinCoordinates(evaluated_bins.at(RndBin), BinIdPerAxis);
//printf("sampling from %u (%u)\n",RndBin,evaluated_bins.at(RndBin));
for(unsigned uPar=0; uPar<NumPotPars; uPar++){
RndPar[uPar] = rangen.Uniform(dlmTable.GetBinLowEdge(2+uPar, BinIdPerAxis[2+uPar]), dlmTable.GetBinUpEdge(2+uPar, BinIdPerAxis[2+uPar]));
//printf(" %u %.3f\n", uPar, RndPar[uPar]);
//usleep(500e3);
}
delete [] BinIdPerAxis;
}
else{
for(unsigned uPar=0; uPar<NumPotPars; uPar++){
if(LogSampling[uPar]){
RndPar[uPar] = rangen.Uniform(log(MinPar[uPar]), log(MaxPar[uPar]));
RndPar[uPar] = exp(RndPar[uPar]);
}
else{
RndPar[uPar] = rangen.Uniform(MinPar[uPar], MaxPar[uPar]);
}
}
}
*/
/*
if(PotType=="Gauss"){
Amp1 = 0;
Rng1 = 0;
//every second event is random, every second we sample from
//our histogram, as long as there are entries there
if(whileEvent%2==1){
}
if(!Amp1 && !Rng){
Amp1 = rangen.Uniform(MinAmp1, MaxAmp1);
Rng1 = rangen.Uniform(MinRng1, MaxRng1);
}
}