-
Notifications
You must be signed in to change notification settings - Fork 2
/
RAINIER.C
2250 lines (2027 loc) · 83.3 KB
/
RAINIER.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************* RAINIER l.kirsch 04/27/2017 start date *****************/
/********************* version 1.2.0: 02/14/2018 add table+usr def models****/
/********************* [email protected] ***************************************/
// ____________________________________________
// |* * * * * * * *|############################|
// | * * * * * * * | |
// |* * * * * * * *|############################|
// | * * * * * * * | |
// |* * * * * * * *|############################|
// | * * * * * * * | |
// |* * * * * * * *|############################|
// |~~~~~~~~~~~~~~~' |
// |############################################|
// | |
// |############################################|
// | |
// |############################################|
// '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
// Randomizer of Assorted Initial Nuclear Intensities and Emissions of Radiation
// Follow readme to run in bash
// A) via run_RAINIER.sh script
// B) direct; but need to copy the settings.h file to the RAINIER directory
// $ root RAINIER.C++
// doubles, ints, and bools marked with prescript "d", "n", and "b" respectively
// arrays marked with prescript "a"
// globals marked with "g_" are accessible after the run, so are the functions
// full lowercase named variables (i.e. no CamelCase) are index variables
// precompiler commands "#" make things run fast when unnecessary items are out
// - better than 40 "if" statements for every call
// - also makes src code clear as to what contributes and what doesn't
// - dormant code is error prone
// the term "spin" usually means "angular momentum" in this code
/////////////////////////////// Program Includes ///////////////////////////////
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <tuple>
#include <numeric>
#include "math.h"
#include "TTimeStamp.h"
using namespace std;
#include "TRandom2.h"
// 2=Tausworthe is faster and smaller than 3=Mersenne Twister (MT19937)
// search and replace "TRandom2" to "TRandom3" to change PRNG
#include "TH1D.h"
#include "TH2D.h"
#include "TH3D.h"
#include "TGraphErrors.h"
#include "TString.h"
#include "TFile.h"
#include "TMath.h"
#include <TROOT.h>
#include "TF1.h"
#include "TF2.h"
#include "TTree.h"
#include <vector>
// determine OS for briccs
#ifdef __linux__
char cbriccs[] = "briccs";
#endif
#ifdef __MACH__
char cbriccs[] = "briccsMac";
#endif
#ifdef _WIN32
char cbriccs[] = "BrIccS.exe"; // haven't done any windows testing yet
#endif
/////////////////////////// Settings & Parameters ///////////////////////////////
#include "settings.h" // all (or most) parameters for the simulations
string g_sRAINIERPath; // Path to RAINIER
///////////////////////// Discrete Input File //////////////////////////////////
double g_adDisEne[g_nDisLvlMax]; // discrete lvl energy
double g_adDisSp [g_nDisLvlMax]; // discrete lvl spin
int g_anDisPar[g_nDisLvlMax]; // discrete lvl parity
double g_adDisT12[g_nDisLvlMax]; // discrete lvl half-life
int g_anDisGam[g_nDisLvlMax]; // number of gammas known
int g_anDisGamToLvl[g_nDisLvlMax][g_nDisLvlGamMax]; // daughter lvls
double g_adDisGamBR [g_nDisLvlMax][g_nDisLvlGamMax]; // daughter branching ratio
double g_adDisGamICC[g_nDisLvlMax][g_nDisLvlGamMax]; // daughter Alpha ICC
// could do these dynamically, but takes time to code
double g_dECrit; // trust lvl scheme up to this E, determined by g_nDisLvlMax
double g_dLvlT12_arb_max = 1e9; // if halflife not know, set to this value
void ReadDisInputFile() {
ifstream lvlFile;
// to to open local file first
#ifdef buse_nondefault_levels_file
TString szFile = slevels_file; // might e.g. add missing half-life
#else
TString szFile = TString(g_sRAINIERPath) + "/levels/z" + TString::Format("%03d",g_nZ) + ".dat";
#endif // buse_nondefault_levels_file
lvlFile.open(szFile.Data());
if (lvlFile.fail()) {cerr << "Level File: " << szFile << " could not be opened" << endl; exit(0);}
cout << "Opened level file at: " << szFile << endl;
string sNucSearchLine;
string sChem;
int nA, nZ, nLvlTot = 0;
bool bFoundNuc = false;
int nTries = 1e6, nTry = 0;
while(!bFoundNuc && nTry < nTries) {
nTry++;
getline(lvlFile, sNucSearchLine); // Header
istringstream issHeader(sNucSearchLine);
issHeader >> sChem >> nA >> nZ >> nLvlTot;
if(nA == g_nAMass && nZ == g_nZ)
{bFoundNuc = true; cout << "Nucleus: " << endl << sNucSearchLine << endl;}
}
if(nLvlTot < 2) { cerr << "err: No levels, check levels file" << endl; cin.get(); }
for(int lvl=0; lvl<g_nDisLvlMax; lvl++) {
string sLvlLine;
getline(lvlFile,sLvlLine);
istringstream issLvl(sLvlLine);
int nLvl, nLvlPar, nLvlGam;
double dLvlEner, dLvlSp, dLvlT12;
issLvl >> nLvl >> dLvlEner >> dLvlSp >> nLvlPar >> dLvlT12 >> nLvlGam;
nLvl--; // to match convention of ground state is lvl 0
if(nLvlPar == -1) nLvlPar = 0; // 1=+, 0=- diff convention dicebox and talys
if(nLvl != lvl || lvl > nLvlTot) cerr << "err: File mismatch at nLvl:" << nLvl << " lvl: " << lvl << endl;
if(int(dLvlT12) == dLvlT12 && dLvlT12<100) {
// sometimes no halflife meas; or a halflive is very(!) long
cerr << "err: For level " << lvl << " Halflives not reported; set to arb value; check levels file" << endl;
if (lvl==0) { nLvlGam = 0; } // unstable gs
else {nLvlGam = dLvlT12;} // nLvlGam read as half-life
dLvlT12 = g_dLvlT12_arb_max;
}
g_adDisEne[lvl] = dLvlEner;
g_adDisSp[lvl] = dLvlSp;
g_anDisPar[lvl] = nLvlPar;
g_anDisGam[lvl] = nLvlGam;
g_adDisT12[lvl] = dLvlT12 * 1e15; // fs
double dTotBR = 0.0;
for(int gam=0; gam<nLvlGam; gam++) {
string sGamLine;
getline(lvlFile,sGamLine);
istringstream issGam(sGamLine);
int nGamToLvl;
double dGamBR, dGamICC, dGamE, dPg;
issGam >> nGamToLvl >> dGamE >> dPg >> dGamBR >> dGamICC;
nGamToLvl--; // to match convention of ground state is lvl 0
dTotBR += dGamBR;
g_anDisGamToLvl[lvl][gam] = nGamToLvl;
g_adDisGamBR [lvl][gam] = dGamBR;
g_adDisGamICC [lvl][gam] = dGamICC;
} // gam
// Renormalize so BR adds to 1.000
for(int gam=0; gam<nLvlGam; gam++) {
g_adDisGamBR[lvl][gam] /= dTotBR;
} // gam
} // lvl
lvlFile.close();
g_dECrit = g_adDisEne[g_nDisLvlMax-1];
#ifdef bForceBinNum
g_dConESpac = (g_dExIMax - g_dECrit) / double(g_nConEBin);
#else
g_nConEBin = int((g_dExIMax - g_dECrit) / g_dConESpac) + 1; // 1 beyond
#endif
} // Read Input
void PrintDisLvl() {
cout << "****** Discrete ******" << endl;
cout << "i \t E \t J \t Pi(1=+) \t T1/2" << endl;
cout << "\t i_final \t Br" << endl;
cout << " ---------------------- " << endl;
for(int lvl=0; lvl<g_nDisLvlMax; lvl++) {
// levels
cout << lvl << ":\t " << g_adDisEne[lvl] << " " << g_adDisSp[lvl]
<< (g_anDisPar[lvl]==1?"+":"-") // careful dicebox flips parity
<< " ";
if(g_adDisT12[lvl] < g_dLvlT12_arb_max) cout << g_adDisT12[lvl] << " fs" << endl;
else cout << "N/A" << endl; // lifetime not measured
// gammas
for(int gam=0; gam<g_anDisGam[lvl]; gam++) {
cout << " " << g_anDisGamToLvl[lvl][gam] << " : "
<< g_adDisGamBR[lvl][gam] << endl;
} // gam
} // lvl
} // Print Discrete
TH3D *g_h3PopDist;
#ifdef bExFullRxn
/////////////////////// TALYS Rxn Population File //////////////////////////////
void ReadPopFile() {
cout << "Reading Population File" << endl;
// copy the "Population of Z= 60 N= 84 (144Nd) before decay" section
// from TALYS File:
// projectile p
// element nd
// mass 144
// energy 10
// outpopulation y
// bins 54
// maxlevelstar 16
double adEx [g_nExPopI];
double adPop[g_nExPopI][g_nSpPopIBin][2];
ifstream filePop;
filePop.open(popFile);
if (filePop.fail()) {cerr << "PopFile could not be opened" << endl; exit(0);}
string sLine;
//ifdef bParPop_Equipar: header " bin Ex Popul. J= 0.0 J= 1.0..."
//else header " bin Ex Popul. J= 0.0- J= 0.0+ ..."
getline(filePop,sLine); //header
getline(filePop,sLine); // header "blank line"
while( getline(filePop, sLine) ) {
istringstream issPop(sLine);
int nBin;
double dPopTot, dEx;
issPop >> nBin >> dEx >> dPopTot;
adEx[nBin] = dEx; // iss cant input directly into array elements
for(int s=0; s<g_nSpPopIBin; s++) {
#ifdef bParPop_Equipar
double dPop;
issPop >> dPop;
// for equal parity: "fake" that all are read as negative parity
adPop[nBin][s][0] = 2*dPop; // this should also fix the talys 2x "bug"
adPop[nBin][s][1] = 0;
#else
for(int par=0; par<2; par++) { // read distribution per parity
double dPop;
issPop >> dPop;
adPop[nBin][s][par] = dPop;
} // read par
#endif //bParPop_Equipar
} // read J
} // read E
// need arrays for TH3D constructor; different from TH2D
// arrays give the lower-edges; therefor the size must be nbin+1
const double abinPar[3]={0,1,2}; // parity bins; positive:1 and negative:0
double abinSpPop[g_nSpPopIBin+1];
for(int binJ=0; binJ<=g_nSpPopIBin; binJ++){
abinSpPop[binJ] = binJ;
}
g_h3PopDist = new TH3D("h3PopDist","h3PopDist",
g_nSpPopIBin, abinSpPop, g_nExPopI-1, adEx, 2, abinPar);
for(int binE=1; binE<g_nExPopI; binE++) {
for(int binJ=1; binJ<=g_nSpPopIBin; binJ++) {
for(int binPar=1; binPar<=2; binPar++) {
g_h3PopDist->SetBinContent(binJ,binE,binPar,adPop[binE-1][binJ-1][binPar-1]);
} // assign par
} // assign J
} // assign E
} // ReadPopFile
#endif // talys input for Oslo Analysis
////////////////////////// Level Density ///////////////////////////////////////
double GetEff(double dEx) {
#ifdef bLD_BSFG
double dEff = dEx - g_dE1;
#endif
#ifdef bLD_CTM
double dEff = dEx - g_dE0;
#endif
#ifdef bLD_UsrDef
double dEff = dEx - g_dE0;
#endif
#ifdef bLD_Table
double dEff = dEx - g_dDelta;
#endif
if(dEff < 0.0) dEff = 0.00000001;
return dEff;
} // GetEff
#ifdef bJCut_UsrDef_Shift
double GetEff_JCut_Usr(double dEx) {
double dEff = dEx - g_dE1Usr;
if(dEff < 0.0) dEff = 0.00000001;
return dEff;
} // GetEff_JCut_Usr
#endif
double GetLDa(double dEx) { // TALYS 1.8 asymptotic dependence
double dEff = GetEff(dEx);
#ifdef bLDaConst
return g_dLDa;
#endif
#ifdef bLDaEx
return g_dLDaAsym * (1 + g_dShellDelW * (1 - exp(-g_dDampGam * dEff)) / dEff);
#endif
#ifdef bLD_Table
return grLDa->Eval(dEx);
#endif
} // GetLDa
double GetSpinCut2(double dEx) {
#ifndef bLD_Table
#ifdef bJCut_UsrDef_Shift
double dEff = GetEff_JCut_Usr(dEx);
#else
double dEff = GetEff(dEx);
#endif
double dLDa = GetLDa(dEx);
#endif
#ifdef bJCut_VonEgidy05 // Von Egidy PRC72,044311(2005)
double dSpinCut2 = 0.0146 * pow(g_nAMass, 5.0/3.0)
* (1 + sqrt(1 + 4 * dLDa * dEff)) / (2 * dLDa);
#endif
#ifdef bJCut_SingPart // Gholami PRC75,044308(2007)
double dSpinCut2 = 0.1461 * sqrt(dLDa * dEff) * pow(g_nAMass, 2.0/3.0);
#endif
#ifdef bJCut_RigidSph // Grimes PRC10(1974) 2373-2386
double dSpinCut2 = 0.0145 * sqrt(dEff / dLDa) * pow(g_nAMass, 5.0/3.0);
#endif
#ifdef bJCut_VonEgidy09 // Von Egidy PRC80,054310(2009)
// empirical fit to other data with only mass table parameters
double dExPd = dEx - 0.5 * g_dDeuPair;
if(dExPd < 0) dExPd = 0.000001;
double dSpinCut2 = 0.391 * pow(g_nAMass, 0.675)
* pow(dExPd,0.312);
#endif
#ifdef bJCut_TALYS // TALYS 1.8 default:
double dSpinCutF2 = 0.01389 * pow(g_nAMass, 5.0/3.0) / g_dLDaAsym
* sqrt(dLDa * dEff);
double dEffSn = GetEff(g_dSn);
double dLDaSn = GetLDa(g_dSn);
double dSpinCutSn2 = 0.01389 * pow(g_nAMass, 5.0/3.0) / g_dLDaAsym
* sqrt(dLDaSn * dEffSn);
double dSpinCutd2 = pow(g_dSpinCutd,2);
double dSpinCut2 = 0.0;
if(dEx <= g_dEd) {
dSpinCut2 = dSpinCutd2;
} else if(dEx < g_dSn) {
dSpinCut2 = dSpinCutd2 + (dEx - g_dEd) / (g_dSn - g_dEd)
* (dSpinCutSn2 - dSpinCutd2);
} else {
dSpinCut2 = dSpinCutF2;
} // dEx condition
#endif
#ifdef bLD_Table
double dJCut = grJCut->Eval(dEx);
double dSpinCut2 = pow(dJCut,2);
#endif
#ifdef bJCut_UsrDef // choose/add what you like, these are some I've found:
// everyone and their mother seems to have a favorite spin cutoff model
//double dSpinCut2 = pow(0.83 * pow(g_nAMass,0.26),2); // TALYS 1.8 global
double dSpinCut2 = pow(0.98 * pow(g_nAMass,0.29),2); // DICEBOX CTM
//double dSpinCut2 = 0.0888*sqrt(dLDa * dEff) * pow(g_nAMass,2/3.0); //DICEBOX
#endif
return dSpinCut2;
}
double GetDensityTot(double dEx) {
#ifdef bLD_CTM // Constant Temperture Function Model
double dEff = GetEff(dEx);
double dEnDen = exp(dEff / g_dTemp) / g_dTemp;
#endif
#ifdef bLD_UsrDef
double dEff = GetEff(dEx);
double dEnDen = exp(dEff / g_dTemp) / g_dTemp;
#endif
#ifdef bLD_BSFG // Back shifted Fermi Gas
double dEff = GetEff(dEx);
double dLDa = GetLDa(dEx);
double dSpinCut2 = GetSpinCut2(dEx);
double dEnDen = 1.0 / (12.0 * sqrt(2) * sqrt(dSpinCut2) * pow(dLDa, 0.25)
* pow(dEff, 5.0 / 4.0) ) * exp(2.0 * sqrt(dLDa * dEff) );
#endif
#ifdef bLD_Table // From external file
double dEnDen = grRho->Eval(dEx);
#endif
return dEnDen;
}
double GetDensity(double dEx, double dSp, int nPar) {
double dEnDen = GetDensityTot(dEx);
double dSpinCut2 = GetSpinCut2(dEx);
double dSpDen = (dSp + 0.5) * exp(-pow(dSp + 0.5, 2) / (2 * dSpinCut2))
/ dSpinCut2;
#ifdef bPar_Equipar
int nParity = nPar; // basically unused in this model
double dParDen = 0.5;
#endif
#ifdef bPar_Edep
// Al-Quraishi PRC67,015803(2003)
double dParDen;
double dExpTerm = 1.0 / (1.0 + exp( g_dParC * (dEx - g_dParD) ) );
if(g_bIsEvenA) {
if(nPar == 1){ // positive parity
dParDen = 0.5 * (1.0 + dExpTerm ); // lot of positive states low E
} else { // negative parity
dParDen = 0.5 * (1.0 - dExpTerm ); // not many negative states low E
} // +/-
} else { // odd A
if(nPar == 0){ // negative parity
dParDen = 0.5 * (1.0 + dExpTerm );
} else { // postive parity
dParDen = 0.5 * (1.0 - dExpTerm );
} // +/-
}
#endif
double dDenEJP = dEnDen * dSpDen * dParDen;
return dDenEJP;
} // plot with: TF2 *fDen2 = new TF2("fDen2","GetDensity(y,x,1)",0,9,0,16); fDen2->Draw("colz")
//////////////////// Build Nucleus /////////////////////////////////////////////
// spins marked with postscript "b" refer to "bin": necessary for half-int spins
// not to be confused with boolean type prescript "b"
// b bin: 0 1 2 3 4 ...
// sp int: 0 1 2 3 4 ...
// half-int: 0.5 1.5 2.5 3.5 4.5 ...
int g_nConLvlTot; // # lvl in constructed scheme. includes multiple in same bin
int g_nConMaxLvlBin; // the largest number of levels in an EJP bin
// * = memory to be dynamically allocated
double *g_adConExCen; // centroid energies of constructed bins
int *g_anConLvl; // number of levels in an EJP bin
int *g_anConCumul; // cumulative levels for random width seeding
int EJP(int ex, int spb, int par) { // index for Energy E, Spin J, Parity P
return ex + spb * g_nConEBin + par * g_nConEBin * g_nConSpbMax;
} // EJP
double GetInBinE(int nReal, int nConEx, int nSpb, int nPar, int nLvlInBin) {
TRandom2 ranInBinE(1 + // have seen issues with 0 seed
nPar +
nConEx * 2 +
nReal * 2 * g_nConEBin +
nSpb * 2 * g_nConEBin * g_nReal +
nLvlInBin * 2 * g_nConEBin * g_nReal * g_nConSpbMax);
double dInBinE = g_adConExCen[nConEx];
dInBinE += (-g_dConESpac / 2.0 + ranInBinE.Uniform(g_dConESpac));
return dInBinE;
} // GetInBinE
const double g_dPi = 3.14159265359;
void BuildConstructed(int nReal) {
// get rid of previous allocations
cout << "Constructing Lvl Scheme" << endl;
delete[] g_adConExCen;
delete[] g_anConLvl;
delete[] g_anConCumul;
g_adConExCen = new double[g_nConEBin]; // center energy of the bin
g_anConLvl = new int [g_nConEBin * g_nConSpbMax * 2];
g_anConCumul = new int [g_nConEBin * g_nConSpbMax * 2];
TRandom2 ranLvlGen(1 + nReal);
g_nConLvlTot = g_nDisLvlMax; // include discrete lvls below
g_nConMaxLvlBin = 0; // max of any bin
#ifdef bPoisson
for(int ex=0; ex<g_nConEBin; ex++) {
g_adConExCen[ex] = g_dECrit + (ex + 0.5) * g_dConESpac;
// bottom of bin ex=0 equals g_dECrit: no gap or overlap with discrete
// constructed in-bin-energies are discretized by gaussian seeds
for(int spb=0; spb<g_nConSpbMax; spb++) {
for(int par=0; par<2; par++) {
double dSp; // integer or half integer determination for density
if(g_bIsEvenA) dSp = spb; else dSp = spb + 0.5;
double dAvgNumLev = g_dConESpac * GetDensity(g_adConExCen[ex],dSp,par);
int nRanNumLvl = ranLvlGen.Poisson(dAvgNumLev); // integer poisson
g_anConLvl[EJP(ex,spb,par)] = nRanNumLvl;
if(nRanNumLvl > g_nConMaxLvlBin) g_nConMaxLvlBin = nRanNumLvl;
g_nConLvlTot += g_anConLvl[EJP(ex,spb,par)];
g_anConCumul[EJP(ex,spb,par)] = g_nConLvlTot;
} // par
} // sp bin
} // ex
#endif
#ifdef bWigner
for(int ex=0; ex<g_nConEBin; ex++) { // assign level energies, same as above
g_adConExCen[ex] = g_dECrit + (ex + 0.5) * g_dConESpac;
} // ex
for(int spb=0; spb<g_nConSpbMax; spb++) {
for(int par=0; par<2; par++) {
double dSp; // integer or half integer, for density
if(g_bIsEvenA) dSp = spb; else dSp = spb + 0.5;
///// initialize E bins to 0 /////
for(int ex=0; ex<g_nConEBin; ex++) {
g_anConLvl[EJP(ex,spb,par)] = 0;
} // ex
///// expected cumulative constructed # of lvls /////
// Each JP has independent average energy bin spacing according to
// the density inverse which is itself a function of energy
double adExpCumulCon[g_nConEBin] = {0.0};
for(int ex=0; ex<g_nConEBin; ex++) {
double dEx = g_adConExCen[ex];
if(ex == 0)
adExpCumulCon[ex] = GetDensity(dEx, dSp, par) * g_dConESpac;
else // ex != 0
adExpCumulCon[ex] = GetDensity(dEx, dSp, par) * g_dConESpac
+ adExpCumulCon[ex-1];
} // ex
///// Level assignment /////
double dWigSampleSum = 2.0 / sqrt(g_dPi)
* sqrt( -log( ranLvlGen.Uniform(1.0) ) );
// expectation value of avg dist between neighboring levels is 1
for(int ex=0; ex<g_nConEBin; ex++) {
while( dWigSampleSum < adExpCumulCon[ex] ) {
dWigSampleSum += 2.0 / sqrt(g_dPi)
* sqrt( -log( ranLvlGen.Uniform(1.0) ) );
g_anConLvl[EJP(ex,spb,par)]++;
} // WigSampleSum < ExpCumulCon
g_nConLvlTot += g_anConLvl[EJP(ex,spb,par)];
g_anConCumul[EJP(ex,spb,par)] = g_nConLvlTot;
} // ex
} // par
} // spb
#endif
} // BuildConstructed
void PrintConLvl() {
int nSpbPrint = 9; // won't algin with double digit spins or bin content > 9
cout << "****** Constructed ******" << endl;
cout << "More levels exist at higher spins" << endl;
cout << "Parity ";
for(int spb=0; spb<=nSpbPrint; spb++) { cout << "-" << " ";} cout << " ";
for(int spb=0; spb<=nSpbPrint; spb++) { cout << "+" << " ";} cout << endl;
cout << "Spin Bin ";
for(int spb=nSpbPrint; spb>=0; spb--) { cout << spb << " ";} cout << " ";
for(int spb=0; spb<=nSpbPrint; spb++) { cout << spb << " ";} cout << endl;
cout << "E(MeV) " << endl;
for(int ex=0; ex<g_nConEBin; ex++) {
cout << fixed << setprecision(3) << g_adConExCen[ex] << " ";
int par = 0;
for(int spb=nSpbPrint; spb>=0; spb--) {
cout << g_anConLvl[EJP(ex,spb,par)] << "|";
} // sp bin
cout << " ";
par = 1;
for(int spb=0; spb<=nSpbPrint; spb++) {
cout << g_anConLvl[EJP(ex,spb,par)] << "|";
} // sp bin
// printing energy of every level in bin would be so many more lines
// but could be done with something like:
// for(int lvl=0; lvl<g_anConLvl[EJP(ex,spb,par)]; lvl++)
// cout << GetInBinE(ex,spb,par,lvl) << endl;
cout << scientific << endl;
} // ex
cout << "Total Number of Levels = " << g_nConLvlTot << endl;
} // PrintConLvl
/////////////////// Transistion Type ///////////////////////////////////////////
int GetTransType(int nSpbI, int nParI, int nSpbF, int nParF) {
// only integer spins
int nTransType = 0;
// 0 No trans; 1 Pure E1; 2 Mixed M1+E2; 3 Pure M1; 4 Pure E2
int ndSpb = TMath::Abs(nSpbF - nSpbI);
int ndPar = TMath::Abs(nParF - nParI);
if(nSpbF < 0 || nSpbF >= g_nConSpbMax) return 0; // not possible
if(nSpbI < 0 ) cerr << "err: Negative input spins" << endl;
// there are faster ways to compute transistion type than what is below,
// but the function is not called that many times
// so its better to be fully explicit for clarity - trust me u dont want gotos
// the only real head-scratchers occur when spin bin 0 is involved
if(g_bIsEvenA) {
if(ndSpb == 0) {
if(nSpbF > 0 && nSpbI > 0) {
if(ndPar == 0) {
nTransType = 2; // M1+E2
} else {
nTransType = 1; // E1
}
} else {
nTransType = 0; // no 0 -> 0 with gammas, ignore E0 Internal Conversion
}
} else if(ndSpb == 1) {
if(nSpbF > 0 && nSpbI > 0) { // triangle check
if(ndPar == 0) {
nTransType = 2; // M1+E2
} else {
nTransType = 1; // E1
}
} else {
if(ndPar == 0) { // 0+ -> 1+ or 0- -> 1- or 1- -> 0- or 1+ -> 0+
nTransType = 3; // M1 Pure
} else { // 0+ -> 1- or 0- -> 1+ or 1+ -> 0- or 1- -> 0+
nTransType = 1; // E1
}
}
} else if(ndSpb == 2) {
if(ndPar == 0) {
nTransType = 4; // E2
} else {
nTransType = 0; // no M2,E3
}
} else { // ndSpb > 2
nTransType = 0; // no Octupole
}
} else { //////////////////// odd A //////////////////////////////////////////
// 0 No trans; 1 Pure E1; 2 Mixed M1+E2; 3 Pure M1; 4 Pure E2
if(ndSpb == 0) {
if(nSpbF > 0 && nSpbI > 0) {
if(ndPar == 0) {
nTransType = 2; // M1+E2
} else {
nTransType = 1; // E1
}
} else {
if(ndPar == 0) {
nTransType = 3; // 1/2+ -> 1/2+ pure M1, no E2 via triangle condition
} else {
nTransType = 1; // 1/2+ -> 1/2- E1
}
}
} else if(ndSpb == 1) {
if(nSpbF > 0 && nSpbI > 0) { // triangle check
if(ndPar == 0) {
nTransType = 2; // M1+E2
} else {
nTransType = 1; // E1
}
} else {
if(ndPar == 0) { // 1/2+ -> 3/2+ can be quadrupole unlike 0+ -> 1-
nTransType = 2; // M1+E2
} else { // 1/2+ -> 3/2- , etc.
nTransType = 1; // E1
}
}
} else if(ndSpb == 2) {
if(ndPar == 0) {
nTransType = 4; // E2
} else {
nTransType = 0; // no M2,E3
}
} else { // ndSpb > 2
nTransType = 0; // no Octupole
}
} // A determination
return nTransType;
} // GetTransType
/////////////////////// Gamma Strength * Eg^(2L+1) /////////////////////////////
// Physical Constants
const double g_d4Pi2 = 39.4784176; // 4*pi^2
const double g_dKX2 = 5.204155555E-08; // mb^-1 MeV^-2; = 1/(5*(pi*hbar*c)^2)
double GetTemp(double dEx) {
double dEff = GetEff(dEx);
double dLDa = GetLDa(dEx);
#ifdef b_GenLor_CT
return g_GenLor_CT;
#endif
return sqrt(dEff / dLDa);
} // GetTemp
double GetStrE1(double dEx, double dEg) {
double dStr = 0.0;
#ifdef bGSF_Table
dStr = grGSF_E1->Eval(dEg);
#else
double dTemp = GetTemp(dEx - dEg);
for(int set=0; set<g_nParE1; set++) { // sum over split dipoles in applicable
double dGam = g_adGamE1[set] * (dEg*dEg + g_d4Pi2 * dTemp*dTemp)
/ (g_adEneE1[set]*g_adEneE1[set]); // energy dependent width
#ifdef bE1_GenLor // Kopecky and Uhl Gen Lorentzian;
#ifdef bE1_EGLO
if(g_nAMass >= 148) { // enhanced Generalized Lorentzian
double deo = 4.5; // reference energy
double dk = 1 + 0.09 * pow(g_nAMass-148,2) * exp(-0.18 * (g_nAMass-148));
double dChi = dk + (1- dk) * (dEg - deo) / (g_adEneE1[0] - deo);
dGam *= dChi;
} // A > 148
#endif
double dTerm1 = dEg * dGam
/ ( pow( (dEg*dEg - g_adEneE1[set]*g_adEneE1[set]),2) + pow(dEg*dGam,2) );
double dTerm2 = 0.7 * g_adGamE1[set] * g_d4Pi2 * dTemp*dTemp
/ pow(g_adEneE1[set],5);
// non zero limit, F=0.7 is the fermi liquid quasiparticle collision fact
double dTerm = dTerm1 + dTerm2;
#endif
#ifdef bE1_KMF // Kadmenskij Markushev Furman
double dTerm = 0.7 * g_adEneE1[set] * dGam
/ pow( dEg*dEg - g_adEneE1[set]*g_adEneE1[set], 2);
#endif
#ifdef bE1_KopChr // Kopecky Chrien
double dTerm = dEg * dGam
/ ( pow( (dEg*dEg - g_adEneE1[set]*g_adEneE1[set]),2) + pow(dEg*dGam,2) );
#endif
#ifdef bE1_StdLor // Standard Lorentzian
double dTerm = dEg * g_adGamE1[set]
/ ( pow(dEg*dEg - g_adEneE1[set]*g_adEneE1[set], 2)
+ pow(dEg*g_adGamE1[set], 2) );
#endif
#ifdef bE1_UsrDef // user defined; includes multiple resonances
// edit as you please
double dTerm = dEg * g_adGamE1[set]
/ ( pow(dEg*dEg - g_adEneE1[set]*g_adEneE1[set], 2)
+ pow(dEg*g_adGamE1[set], 2) );
#endif
dStr += g_dKX1 * g_adSigE1[set] * g_adGamE1[set] * dTerm;
} // E1 parameter set
#endif // bGSF_Table
if(dStr < 0) {cerr << "err: Negative strength" << endl;}
return dStr * pow(dEg,3); // Eg^(2L+1) so this in not formally gamma strength
} // GetStrE1
double GetStrM1(double dEg) {
// Standard Lorentzian
double dStr = 0.0;
#ifdef bGSF_Table
dStr = grGSF_M1->Eval(dEg);
#else
for(int set=0; set<g_nParM1; set++) {
#ifdef bM1_StdLor
dStr += g_dKX1 * g_adSigM1[set] * dEg * g_adGamM1[set]*g_adGamM1[set]
/ ( pow(dEg*dEg - g_adEneM1[set]*g_adEneM1[set], 2)
+ pow(dEg*g_adGamM1[set], 2) );
#endif
#ifdef bM1_UsrDef // user defined; includes multiple resonances
// edit as you please
dStr += g_dKX1 * g_adSigM1[set] * dEg * g_adGamM1[set]*g_adGamM1[set]
/ ( pow(dEg*dEg - g_adEneM1[set]*g_adEneM1[set], 2)
+ pow(dEg*g_adGamM1[set], 2) );
#endif
} // M1 parameter set
#ifdef bM1StrUpbend
double dUpbend = g_dUpbendM1Const * exp(-g_dUpbendM1Exp * dEg);
dStr += dUpbend;
#endif
#ifdef bM1_SingPart
dStr = g_dSpSigM1;
#endif
#endif // bGSF_Table
if(dStr < 0) {cerr << "err: Negative strength" << endl;}
return dStr * pow(dEg,3);
}
double GetStrE2(double dEg) {
#ifdef bE2_StdLor
// Standard Lorentzian
double dStr = g_dKX2 * g_dSigE2 * g_dGamE2*g_dGamE2
/ (dEg * (pow(dEg*dEg - g_dEneE2*g_dEneE2,2) + pow(dEg*g_dGamE2,2)));
// divide by Eg so units work out: TALYS formula units don't work
#endif
#ifdef bE2_UsrDef // user defined
// edit as you please
double dStr = g_dKX2 * g_dSigE2 * g_dGamE2*g_dGamE2
/ (dEg * (pow(dEg*dEg - g_dEneE2*g_dEneE2,2) + pow(dEg*g_dGamE2,2)));
#endif
#ifdef bE2_SingPart
double dStr = g_dSpSigE2;
#endif
#ifdef bGSF_Table
double dStr = grGSF_E2->Eval(dEg);
#endif
if(dStr < 0) {cerr << "err: Negative strength" << endl;}
return dStr * pow(dEg,5);
}
double g_de = 2.7182818284590452353; // Euler's number
double g_dlam = 0.5; // need to convert Gamma dist to Chi2 dist
double GetRanChi2(TRandom2 &ran, double dnu) {
// ROOT doesn't supply Chi-Squared Dist tied to a TRandom
// http://pdg.lbl.gov/2013/reviews/rpp2013-rev-monte-carlo-techniques.pdf
double dAcceptX = -1;
bool bAccept = false;
double dk = dnu / 2.0;
if(dk == 1) { // exponential dist
double du = ran.Uniform();
bAccept = true;
dAcceptX = -log(du);
} else if(dk > 0 && dk < 1) { // pole at 0, could return 0 due to underflow
double dv1 = (g_de + dk) / g_de;
while(!bAccept) {
double du1 = ran.Uniform();
double du2 = ran.Uniform();
double dv2 = dv1 * du1;
if(dv2 <= 1) {
double dx = pow(dv2, 1.0/dk);
if(du2 <= exp(-dx) ) {
bAccept = true;
dAcceptX = dx;
} // else restart with new u1, u2
} else { // dv2 > 1
double dx = -log((dv1 - dv2) / dk);
if(du2 <= pow(dx, dk-1)) {
bAccept = true;
dAcceptX = dx;
} // else restart with new u1, u2
} // v2 condition
} // accept
} else if(dk > 1) { // closed like gaussian
double dc = 3 * dk - 0.75;
while(!bAccept) {
double du1 = ran.Uniform();
double dv1 = du1 * (1 - du1);
double dv2 = (du1 - 0.5) * sqrt(dc / dv1);
double dx = dk + dv2 - 1;
if(dx > 0) {
double du2 = ran.Uniform();
double dv3 = 64 * dv1*dv1*dv1 * du2*du2;
if( (dv3 <= 1 - 2 * dv2*dv2 / dx)
|| (log(dv3) <= 2 * ( (dk -1) * log(dx / (dk - 1)) - dv2) ) ) {
bAccept = true;
dAcceptX = dx;
} // v3 condtion
} // x condtion
} // accept
} else {
cerr << "err: negative chi2 degree freedom" << endl;
} // k conditon
if(dAcceptX < 0) cerr << "err: no ch2 random assigned" << endl;
return dAcceptX / g_dlam;
} // GetRanChi2
double GetStr(double dEx, double dEg, int nTransType, double &dMixDelta2,
TRandom2 &ranStr) {
// returns sum_XL( Str_XL * Eg^(2L+1) )
dMixDelta2 = 0.0;
switch(nTransType) {
case 0: return 0.0; // save some flops for impossible transistions
case 1: { // int nX = 0, nL = 1;
#ifdef bWFD_PTD
double dGaus = ranStr.Gaus();
double dFluct = dGaus * dGaus;
#endif
#ifdef bWFD_nu
double dFluct = GetRanChi2(ranStr, g_dNu) / g_dNu;
#endif
#ifdef bWFD_Off
double dFluct = 1.0;
#endif
return dFluct * GetStrE1(dEx, dEg);
}
case 2: {
// both decay branches fluctuate independently
// int nX = 1, nL = 1;
#ifdef bWFD_PTD
double dGausM1 = ranStr.Gaus();
double dFluctM1 = dGausM1 * dGausM1;
#endif
#ifdef bWFD_nu
double dFluctM1 = GetRanChi2(ranStr, g_dNu) / g_dNu;
#endif
#ifdef bWFD_Off
double dFluctM1 = 1.0;
#endif
double dStrM1 = dFluctM1 * GetStrM1(dEg);
// int nX = 0, nL = 2;
#ifdef bWFD_PTD
double dGausE2 = ranStr.Gaus();
double dFluctE2 = dGausE2 * dGausE2;
#endif
#ifdef bWFD_nu
double dFluctE2 = GetRanChi2(ranStr, g_dNu) / g_dNu;
#endif
#ifdef bWFD_Off
double dFluctE2 = 1.0; // PT fluct off
#endif
double dStrE2 = dFluctE2 * GetStrE2(dEg);
// delta = <I1||E2||I0> / <I1||M1||I0>; I0,1 = init,final w.f.
// = sqrt(GamE2 / GamM1)
// = sqrt(strE2 * Eg^5 / strM1 * Eg^3)
dMixDelta2 = dStrE2 / dStrM1; // fact of Eg in GetStrXL
return dStrM1 + dStrE2;
}
case 3: { // int nX = 1, nL = 1;
#ifdef bWFD_PTD
double dGaus = ranStr.Gaus();
double dFluct = dGaus * dGaus;
#endif
#ifdef bWFD_nu
double dFluct = GetRanChi2(ranStr, g_dNu) / g_dNu;
#endif
#ifdef bWFD_Off
double dFluct = 1.0;
#endif
return dFluct * GetStrM1(dEg);
}
case 4: { // int nX = 0, nL = 2;
#ifdef bWFD_PTD
double dGaus = ranStr.Gaus();
double dFluct = dGaus * dGaus;
#endif
#ifdef bWFD_nu
double dFluct = GetRanChi2(ranStr, g_dNu) / g_dNu;
#endif
#ifdef bWFD_Off
double dFluct = 1.0;
#endif
return dFluct * GetStrE2(dEg);
}
default : cerr << "err: Invaild strength type" << endl; return 0.0;
} // TransType
} // GetStr
////////////////////// Internal Conversion /////////////////////////////////////
#ifdef bUseICC
double GetBrICC(double dEg, int nTransMade=1, double dMixDelta2=0.0) {
int nSuccess = -7;
int nReadLine = 0; // BrIcc output changes based on input
switch(nTransMade) {
case 0: return 0.0; break;
case 1: nSuccess = system(
Form("%s/%s -Z %d -g %f -L E1 -w %s > oAlpha.briccs",
g_sRAINIERPath.c_str(),cbriccs, g_nZ, dEg*1000, g_sBrIccModel) ); nReadLine = 8; break; // MeV
case 2: nSuccess = system(
Form("%s/%s -Z %d -g %f -L M1+E2 -d %f -w %s > oAlpha.briccs",
g_sRAINIERPath.c_str(), cbriccs, g_nZ, dEg*1000, sqrt(dMixDelta2), g_sBrIccModel) );
nReadLine = 11; break;
case 3: nSuccess = system(
Form("%s/%s -Z %d -g %f -L M1 -w %s > oAlpha.briccs",
g_sRAINIERPath.c_str(), cbriccs, g_nZ, dEg*1000, g_sBrIccModel) ); nReadLine = 8; break;
case 4: nSuccess = system(
Form("%s/%s -Z %d -g %f -L E2 -w %s > oAlpha.briccs",
g_sRAINIERPath.c_str(), cbriccs, g_nZ, dEg*1000, g_sBrIccModel) ); nReadLine = 8; break;
default: cerr << "err: impossible transistion" << endl;
} // transistion
if(nSuccess) cerr << "err: BrIcc failure" << endl;
ifstream fileAlpha("oAlpha.briccs");
string sAlphaLine;
for(int line=0; line<nReadLine; line++) { getline(fileAlpha,sAlphaLine); }
getline(fileAlpha,sAlphaLine);
double dAlpha;
istringstream issAlpha(sAlphaLine);
issAlpha >> dAlpha;
return dAlpha;
} // GetBrICC
// unmixed conv coeff from BrICC, hist interpolation faster than graph
TH1D *g_hE1ICC;
TH1D *g_hM1ICC;
TH1D *g_hE2ICC;
// plot after run: g_hE1ICC->Draw()
void InitICC() {
cout << "Initializing internal conversion coefficients: alphas" << endl;
g_hE1ICC = new TH1D("g_hE1ICC","g_hE1ICC", g_nBinICC,g_dICCMin,g_dICCMax);
g_hM1ICC = new TH1D("g_hM1ICC","g_hM1ICC", g_nBinICC,g_dICCMin,g_dICCMax);
g_hE2ICC = new TH1D("g_hE2ICC","g_hE2ICC", g_nBinICC,g_dICCMin,g_dICCMax);
for(int bin=1; bin<=g_nBinICC; bin++) {
double dBinCenter = g_hE1ICC->GetBinCenter(bin);
g_hE1ICC->SetBinContent(bin, GetBrICC(dBinCenter,1,0));
g_hM1ICC->SetBinContent(bin, GetBrICC(dBinCenter,3,0));
g_hE2ICC->SetBinContent(bin, GetBrICC(dBinCenter,4,0));
cout << bin << " / " << g_nBinICC << "\r" << flush;
} // bin
int nSuccess = system("rm oAlpha.briccs");
cout << endl;
} // InitICC