-
Notifications
You must be signed in to change notification settings - Fork 10
/
xsec.cc
3409 lines (2652 loc) · 119 KB
/
xsec.cc
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
/*
* @file xsec.cc
* @author Luca Maccione, Daniele Gaggero
* @email luca.maccione@desy.de
* @email daniele.gaggero@sissa.it
* @brief All the classes related to the cross sections are implemented.
*/
#include "xsec.h"
#include "grid.h"
#include "nucleilist.h"
#include "utilities.h"
#include "kamae.h"
#include "input.h"
#include <algorithm>
#include <fstream>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_vector.h>
using namespace std;
//ofstream outf("spallation_xsec.dat", ios::out);
const double TSpallationNetwork::ethr = 5.e1;
TSpallationNetwork::TSpallationNetwork(TGrid* co, Input* in, vector<TXSecBase*> xsecmodel, vector<int>& nuclei) {
/* the relevant structures of TSpallationNetwork to be filled are
1) for nucleus --> nucleus
-- given that pair<int,int> couple(1000*iz+ia,1000*jz+ja); is the parent-daugther uid pair --
map<pair<int,int>, vector<double> > spall; //the spallation cross section vector for all energies for each pair (primary, secondary)
the spall cross section is obtained, depending on the xsec model (Galprop, Webber, Fluka) via
spall[couple] = xsecmodel[?]->GetXSec(iz,ia,jz,ja) (parent Z,A, daughter Z,A)
or
spall[couple][ip] = xsecmodel[?]->GetXSec(couple, energy[ip])
GetXSec is a method of Galprop, Webber or Fluka classes -- that inherit from XSecBase class
in the xsec class the xsections are stored in the private object map<pair<int,int>, vector<double> > xsec;
2) for nucleus --> antiprotons
3) for nucleus --> leptons
-- pair<int,int> coupleel(1001, -1000); // Electrons from protons
-- pair<int,int> couplepos(1001, 1000); // Positrons from protons
spall_apel[coupleel] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[couplepos] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
-- pair<int,int> coupleelHe(2004, -1000); // Electrons from He
-- pair<int,int> coupleposHe(2004, 1000); // Positrons from He
spall_apel[coupleelHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[coupleposHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
In Galprop and Fluka modes, the vectors are filled in
TSpallationNetwork::InitXSecGalprop(factorelpos);
TSpallationNetwork::InitXSecFluka(factorelpos);
respectively
*/
energy = co->GetEk();
const int dimEn = energy.size();
const double factor = Clight*1.e-27;
// vector<int> nuclei = TNucleiList::GetInstance()->GetList();
//ofstream outf("spallation_xsec.dat", ios::in);
for (int iloop = 0; iloop < nuclei.size()-1; ++iloop) {
// If antiprotons or leptons, do not compute spallation. If protons, do not compute, because their spallation products will be computed elsewhere
if (nuclei[iloop] <= 1001) continue;
int iz = -1000; // parent nucleus charge
int ia = -1000; // parent nucleus mass
Utility::id_nuc(nuclei[iloop], ia, iz);
for (int idaught = iloop+1; idaught < nuclei.size(); ++idaught) {
int jz = -1000; // daughter nucleus charge
int ja = -1000; // daughter nucleus mass
Utility::id_nuc(nuclei[idaught], ja, jz);
// If nucleus is antiproton of leptons skip it. Skip also if mass(daughter) > mass(parent)
if (nuclei[idaught] < 1001 || ia < ja) continue;
pair<int,int> couple(1000*iz+ia,1000*jz+ja);
if (in->spallationxsec == GalpropXSec) spall[couple] = xsecmodel[0]->GetXSec(iz,ia,jz,ja);
else if (in->spallationxsec == Webber03) {
if (!xsecmodel[1]->IsPresent(couple)) spall[couple] = xsecmodel[0]->GetXSec(iz,ia,jz,ja);
vector<double> beta = co->GetBeta();
// TWebber03::GetInstance()->Print(co);
for(unsigned int ip = 0; ip < dimEn; ip++) {
spall[couple].push_back(xsecmodel[1]->GetXSec(couple, energy[ip])*factor*beta[ip]*(1.0*He_abundance*xsecmodel[1]->GetHefactor()));
}
}
else if (in->spallationxsec == Fluka) {
vector<double> beta = co->GetBeta();
if (!xsecmodel[1]->IsPresent(couple))
spall[couple] = xsecmodel[0]->GetXSec(iz,ia,jz,ja); //if the cross section is not present, use Galprop database
else { //do nothing at the moment --> only gaprop files are actually read...
//if the cross section is present, then use Fluka model
/*
for(unsigned int ip = 0; ip < dimEn; ip++) {
spall[couple].push_back(xsecmodel[1]->GetXSec(couple, energy[ip])*factor*beta[ip]*(1.0*He_abundance*xsecmodel[1]->GetHefactor()));
//fills spall[couple] with Fluka cross section.
//Fluka->GetXSec(couple,energy) gives xsec in mbarn/GeV --> conversion to cm^3/s via "factor"
}*/
}
}
else {
cerr << "Wrong SpallationXSec option" << endl;
}
if(!in->SPALL) for(int i=0;i<spall[couple].size();i++) spall[couple][i]=0.; //fk130701 sets Xsecs to Zero i.e. no Spallation // for(unsigned int ip = 0; ip < dimEn; ip++) cout << couple.first << " " << couple.second << " " << spall[couple].back() << endl;
}
}
// outf.close();
//exit(-1);
const double factorprot = factor*co->GetDeltaE();
const double factorelpos = 1.e3*factorprot; // barn/GeV --- *10^3 ---> mbarn/GeV --- *factorprot ---> cm^3/s
double PP_inel = 0.0;
double PA_inel = 0.0;
double aPP_non = 0.0;
double aPA_non = 0.0;
double aPP_ann = 0.0;
double aPA_ann = 0.0;
if (in->spallationxsec != Fluka) {
pair<int,int> coupleprpr(1001,1001); // Secondary protons
spall[coupleprpr] = vector<double>(dimEn, 0);
for(unsigned int ip = 0; ip < dimEn; ++ip) {
xsecmodel[0]->nucleon_cs(2, energy[ip], 1, 2, 4, &PP_inel, &PA_inel, &aPP_non, &aPA_non, &aPP_ann, &aPA_ann); // Galprop CS
spall[coupleprpr][ip] = in->SPALL*factorprot*(PP_inel + He_abundance*PA_inel);
}
}
else { //fluka
pair<int,int> coupleppr(1001, 1001); // Secondary protons, from protons
pair<int,int> couplepHe(2004, 1001); // Secondary protons, from Helium
spall_apel[coupleppr] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[couplepHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
TSpallationNetwork::InitXSecFluka(factorelpos,2); //2-->p
//cout << "Secondary protons ok" << endl;
/*vector<double> beta = co->GetBeta();
for(unsigned int ip2 = 0; ip2 < dimEn; ip2++) {
spall[coupleprpr].push_back(xsecmodel[1]->GetXSec(coupleprpr, energy[ip2])*factor*beta[ip2]*(1.0*He_abundance*xsecmodel[1]->GetHefactor()));
}*/
}
// If antiprotons and/or leptons are wanted in output, add them, and add also secondary protons
if (in->prop_ap || in->prop_lep || in->prop_deuteron) {
if (in->prop_ap) {
if (in->spallationxsec != Fluka) {
pair<int,int> coupletert(-999,-999); // Tertiary antiprotons
spall[coupletert] = vector<double>(dimEn, 0.0);
for(unsigned int ip = 0; ip < dimEn; ++ip) {
xsecmodel[0]->nucleon_cs(2, energy[ip], -1, 2, 4, &PP_inel, &PA_inel, &aPP_non, &aPA_non, &aPP_ann, &aPA_ann);
spall[coupletert][ip] = factorprot*( aPP_non + He_abundance*aPA_non );
// Exploits approximation d\sigma/dEkin \propto 1/Ekin' [Tan & Ng '83]
}
}
else { //fluka
pair<int,int> coupleapap(-999, -999); // Tertiary antiprotons, from sec. antiprotons
spall_apel[coupleapap] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
TSpallationNetwork::InitXSecFluka(factorelpos,3); //3-->tertiary ap
//cout << "Tertiary antiprotons ok" << endl;
}
spall_apel[pair<int,int>(2003,-999)] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
pair<int,int> coupleappr(1001,-999); // Secondary antiprotons, from protons
pair<int,int> coupleapHe(2004,-999); // Secondary antiprotons, from Helium
vector<double> pp = co->GetMomentum();
spall_apel[coupleappr] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[coupleapHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
size_t limit = 100000;
gsl_integration_workspace* w = gsl_integration_workspace_alloc(limit);
if(in->SPALL) //fk 130701
{
if ( in->apy == FlukaAp)
TSpallationNetwork::InitXSecFluka(factorelpos,1); //1-->ap
//cout << "Secondary antiprotons ok" << endl;
for (unsigned int i = 0; i < dimEn; i++) {
if ( in->apy == GalpropFunction ){
for (unsigned int ii=i+1; ii < dimEn; ii++) {
spall_apel[coupleappr][i][ii] = factorelpos*energy[ii]*(xsecmodel[0]->antiproton_cc1(w,limit,in->antiproton_cs, pp[i], pp[ii], 1, 1, 1, 1) * ( (!in->scaling) + (in->scaling)*(0.12 * pow(energy[i], -1.67) + 1.78)) + (!in->scaling)*He_abundance*xsecmodel[0]->antiproton_cc1(w,limit,in->antiproton_cs, pp[i], pp[ii], 1, 1, 2, 4));
spall_apel[coupleapHe][i][ii] = factorelpos*energy[ii]*4.0*(xsecmodel[0]->antiproton_cc1(w,limit,in->antiproton_cs, pp[i], 4.0*pp[ii], 2, 4, 1, 1) * ( (!in->scaling) + (in->scaling)*(0.12 * pow(energy[i], -1.67) + 1.78)) + (!in->scaling)*He_abundance*xsecmodel[0]->antiproton_cc1(w,limit,in->antiproton_cs, pp[i], 4.0*pp[ii], 2, 4, 2, 4));
}
}
else if ( in->apy == QGSJET ){
// === TEST ===
spec_ini();
double x,es,fff;
for ( int i=1;i<=100;i++ ){
x = (double)i/100.-.005;
es = x*100.;
fff=spec_int(100.,es,1,1);
cout<<x<<"\t"<<fff<<endl;
}
exit(3);
// === END TEST ===
}
}
}
gsl_integration_workspace_free(w);
} // ap
if (in->prop_lep) {
pair<int,int> coupleel(1001, -1000); // Electrons from protons
pair<int,int> couplepos(1001, 1000); // Positrons from protons
spall_apel[coupleel] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[couplepos] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
pair<int,int> coupleelHe(2004, -1000); // Electrons from He
pair<int,int> coupleposHe(2004, 1000); // Positrons from He
spall_apel[coupleelHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[coupleposHe] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[pair<int,int>(2003,-1000)] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
spall_apel[pair<int,int>(2003,1000)] = vector< vector<double> >(dimEn, vector<double>(dimEn, 0.0));
// Read in the tabulated database
if(in->SPALL){ //fk 130628
if (in->ly == GalpropTable) TSpallationNetwork::InitXSecGalprop(factorelpos);
else if (in->ly == Pohl) TSpallationNetwork::InitXSecPohl(factorelpos);
else if (in->ly == Kamae) TSpallationNetwork::InitXSecKamae(factorelpos);
else if (in->ly == FlukaLep) {TSpallationNetwork::InitXSecFluka(factorelpos,0); cout << "Sec. leptons ok " << endl; } //0-->lep
}
} // el
if (in->prop_deuteron) {
pair<int,int> coupledeutdeut(-998,-998); // Tertiary antideuterons
pair<int,int> coupledeutapr(-999,-998); // Secondary antideuterons, from antiprotons
pair<int,int> coupledeutpr(1001,-998); // Secondary antideuterons, from protons
pair<int,int> coupledeutHe(2004,-998); // Secondary antideuterons, from Helium
}
} // either
return ;
}
vector<double> TSpallationNetwork::GetXSec(int i,int j) {
pair<int,int> input(i,j);
// return spall[pair<int,int>(i,j)];
map< pair<int,int>, vector<double> >::iterator it = spall.find(input);
if (it != spall.end()) return (*it).second;
else {
//cerr << "No channel in TSpallationNetwork. Parent = " << i << " daughter = " << j << endl;
return vector<double>();
}
}
double TSpallationNetwork::GetXSec(int i, int j, double en) {
if (en > energy.back()) {
//cerr << "Out of range!" << endl;
return 0;
}
int l = 0;
for (l = 0; l < energy.size(); ++l) {
if (en >= energy[l]) break;
}
//return spall[pair<int,int>(i,j)][l];
pair<int,int> input(i,j);
map< pair<int,int>, vector<double> >::iterator it = spall.find(input);
if (it != spall.end()) {
return (*it).second[l];
}
else {
// cerr << "Out of range in TSpallationNetwork" << endl;
return 0;
}
}
double TSpallationNetwork::GetXSec(int i, int j, int k) {
if (k >= energy.size()) {
//cerr << "Out of range!" << endl;
return 0;
}
// return spall[pair<int,int>(i,j)][k];
pair<int,int> input(i,j);
map< pair<int,int>, vector<double> >::iterator it = spall.find(input);
if (it != spall.end()) return (*it).second[k];
else {
//cerr << "Out of range in TSpallationNetwork" << endl;
return 0;
}
}
vector<double> TSpallationNetwork::GetXSecApEl(int i, int j, int k) {
if (k >= energy.size()) {
//cerr << "Out of range!" << endl;
return vector<double>();
}
//return spall_apel[pair<int,int>(i,j)][k];
pair<int,int> input(i,j);
map< pair<int,int>, vector< vector<double> > >::iterator it = spall_apel.find(input);
if (it != spall_apel.end()) return (*it).second[k];
else {
//cerr << "No channel in TSpallationNetwork. Parent = " << i << " daughter = " << j << endl;
return vector<double>();
}
}
//TPP
vector<double> TSpallationNetwork::GetXSecTPP(vector<double> nu_vector) { // nu_vector -> vector of frequencies of ISRF
//double photon_energy = 10.*1.e-9; //GeV
double m_e = 0.511e-3 ; //GeV
double hPlanck = 4.135667e-15;
vector<double> result(energy.size()*energy.size()*nu_vector.size());
for (int k =0; k<energy.size(); ++k) {
for (int inu=0; inu < nu_vector.size(); ++inu) {
for (int l = 0; l < energy.size(); ++l) { // l -> energy index of parent electron
result[(k*nu_vector.size() + inu)*energy.size() + l] = 0.;
}
}
}
for (int k =0; k<energy.size(); ++k) { // k -> energy index of secondary particle
for (int inu=0; inu < nu_vector.size(); ++inu) {
double photon_energy = hPlanck*nu_vector[inu]*1.e-9; //GeV
if (k == 0)
//cout << "***" << endl;
for (int l = 0; l < energy.size(); ++l) { // l -> energy index of parent electron
int index = (k*nu_vector.size() + inu)*energy.size() + l;
double Average_TPP_positron_energy = 0.5 * sqrt(energy[l] / photon_energy ) * m_e;
double s = energy[l] * hPlanck*nu_vector[inu]*1.e-9 / pow(m_e, 2.); //tutto in GeV; s: numero puro
double correction = 0.;
if (s>4.) {
correction = 0.1193662073189215 * exp(-3.839009766244388 - 0.1223186374016053*pow(log(-4. + s), 2) ) * pow((-4. + s),1.8194204144025334);
if (s>79.)
correction = 0.13 * (-8.07407 + 3.11111 * log(0.0153186 * energy[l] * 3.));
}
if (k == 0)
cout << " photon energy [eV] " << photon_energy*1.e9 << " energy of electron [GeV] -> " << energy[l] << " s-> " << s << " correction-> " << correction << endl;
double sigma_tot = 9.46 * 6.65 * 1.e-2 * (1/137.) * correction;// * temp; // c sigma_Thompson alpha_F; units: cm/Myr * cm^2
//double std_dev = 30;//Average_TPP_positron_energy;
double std_dev = sqrt(Average_TPP_positron_energy); // GeV
//double x = energy[l]*photon_energy/(m_e*m_e);
//if (x>4)
result[index] = sigma_tot * energy[l] * exp( - pow(energy[k] - Average_TPP_positron_energy,2.0) / (2.*(pow(std_dev,2.0))) ) / (sqrt(2*3.14) * std_dev);
// cm^3/Myr GeV 1/GeV
}
}
}
return result;
}
//*********************************************************************************************************************************************
void TSpallationNetwork::InitDataTablesGalprop() {
cout << "Please provide Galprop leptonic cross sections: data/Electron_production.dat and data/Positron_production.dat" << endl;
Matrix_El_pp = vector<double>(401*801, 0.0);
Matrix_El_pHe = vector<double>(401*801, 0.0);
Matrix_El_Hep = vector<double>(401*801, 0.0);
Matrix_El_HeHe = vector<double>(401*801, 0.0);
Matrix_Pos_pp = vector<double>(401*801, 0.0);
Matrix_Pos_pHe = vector<double>(401*801, 0.0);
Matrix_Pos_Hep = vector<double>(401*801, 0.0);
Matrix_Pos_HeHe = vector<double>(401*801, 0.0);
ifstream infile(ElTablefile.c_str(), ios::in);
double a,b,c,d;
Nelectrons = 401;
Nprotons = 801;
for (int i = 0; i < 401; i++) {
for (int j = 0; j < 801; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_El_pp[ind] = a;
Matrix_El_pHe[ind] = b;
Matrix_El_Hep[ind] = c;
Matrix_El_HeHe[ind] = d;
}
}
infile.close();
infile.open(PosTablefile.c_str(), ios::in);
for (int i = 0; i < 401; i++) {
for (int j = 0; j < 801; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_Pos_pp[ind] = a;
Matrix_Pos_pHe[ind] = b;
Matrix_Pos_Hep[ind] = c;
Matrix_Pos_HeHe[ind] = d;
}
}
infile.close();
return;
}
//ofstream outf("total_xsec.dat", ios::out);
void TSpallationNetwork::InitXSecKamae(double factorelpos) {
pair<int,int> coupleel(1001, -1000); // Electrons from protons
pair<int,int> couplepos(1001, 1000); // Positrons from protons
pair<int,int> coupleelHe(2004, -1000); // Electrons from He
pair<int,int> coupleposHe(2004, 1000); // Positrons from He
const int dimEn = energy.size();
for (unsigned int j=0; j<dimEn; j++){
double Epr = energy[j];
for (unsigned int i = 0; i < dimEn; i++) {
double Eel = min(1e5,energy[i]);
double cs_pp = KamaeYields::GetSigma(Eel, Epr, ID_ELECTRON);
double cs_pHe = pow(4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_ELECTRON);
double cs_Hep = pow(4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_ELECTRON);
double cs_HeHe = pow(4.0*4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_ELECTRON);
spall_apel[coupleel][i][j] = Epr*(cs_pp + He_abundance*cs_pHe)*factorelpos;
spall_apel[coupleelHe][i][j] = 4.0*Epr*(cs_Hep + He_abundance*cs_HeHe)*factorelpos;
cs_pp = KamaeYields::GetSigma(Eel, Epr, ID_POSITRON);
cs_pHe = pow(4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_POSITRON);
cs_Hep = pow(4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_POSITRON);
cs_HeHe = pow(4.0*4.0,2.0/3.0)*KamaeYields::GetSigma(Eel, Epr, ID_POSITRON);
spall_apel[couplepos][i][j] = Epr*(cs_pp + He_abundance*cs_pHe)*factorelpos; // H
spall_apel[coupleposHe][i][j] = 4.0*Epr*(cs_Hep + He_abundance*cs_HeHe)*factorelpos; // He
}
}
return ;
}
void TSpallationNetwork::InitXSecGalprop(double factorelpos) {
pair<int,int> coupleel(1001, -1000); // Electrons from protons
pair<int,int> couplepos(1001, 1000); // Positrons from protons
pair<int,int> coupleelHe(2004, -1000); // Electrons from He
pair<int,int> coupleposHe(2004, 1000); // Positrons from He
const int dimEn = energy.size();
const int dimlept = 400;
const double DBlog = (log10(1e5)-log10(1e-3))/(double)dimlept;
double Elept[dimlept+1];
for (int i = 0; i <= dimlept; i++) Elept[i] = pow(10, log10(1e-3)+double(i)*DBlog);
const int dimpr = 800;
const double DBprlog = (log10(1e5)-log10(1e-3))/double(dimpr);
double ET[dimpr+1];
for (int j = 0; j <= dimpr; j++) ET[j] = pow(10, log10(1e-3) + double(j)*DBprlog);
TSpallationNetwork::InitDataTablesGalprop();
gsl_interp_accel *acc = gsl_interp_accel_alloc ();
gsl_spline *spline_El_pp = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_pHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_Hep = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pp = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_Hep = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
//gsl_interp_accel *acc = gsl_interp_accel_alloc ();
gsl_spline *spline_El_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
double Vectorlept_El_pp[dimlept+1];
double Vectorlept_El_pHe[dimlept+1];
double Vectorlept_El_Hep[dimlept+1];
double Vectorlept_El_HeHe[dimlept+1];
double Vectorlept_Pos_pp[dimlept+1];
double Vectorlept_Pos_pHe[dimlept+1];
double Vectorlept_Pos_Hep[dimlept+1];
double Vectorlept_Pos_HeHe[dimlept+1];
double Vectorlept_El_pp_up[dimlept+1];
double Vectorlept_El_pHe_up[dimlept+1];
double Vectorlept_El_Hep_up[dimlept+1];
double Vectorlept_El_HeHe_up[dimlept+1];
double Vectorlept_Pos_pp_up[dimlept+1];
double Vectorlept_Pos_pHe_up[dimlept+1];
double Vectorlept_Pos_Hep_up[dimlept+1];
double Vectorlept_Pos_HeHe_up[dimlept+1];
for (unsigned int j=0; j<dimEn; j++){
double Epr = energy[j];
double momentum = sqrt(Epr*Epr + 2.0*mp*Epr);
int j_pr = int(floor(log10(Epr/ET[0])/DBprlog));
if (j_pr > dimpr-1) j_pr = dimpr-1;
double u = (Epr-ET[j_pr])/(ET[j_pr+1]-ET[j_pr]);
for (int i = 0; i <= dimlept; i++) {
int index = index_matrix(i,j_pr);
Vectorlept_El_pp[i] = Matrix_El_pp[index];
Vectorlept_El_pHe[i] = Matrix_El_pHe[index];
Vectorlept_El_Hep[i] = Matrix_El_Hep[index];
Vectorlept_El_HeHe[i] = Matrix_El_HeHe[index];
Vectorlept_Pos_pp[i] = Matrix_Pos_pp[index];
Vectorlept_Pos_pHe[i] = Matrix_Pos_pHe[index];
Vectorlept_Pos_Hep[i] = Matrix_Pos_Hep[index];
Vectorlept_Pos_HeHe[i] = Matrix_Pos_HeHe[index];
//
if (j_pr <= dimpr)
index = index_matrix(i,j_pr+1);
else
index = dimpr;
Vectorlept_El_pp_up[i] = Matrix_El_pp[index];
Vectorlept_El_pHe_up[i] = Matrix_El_pHe[index];
Vectorlept_El_Hep_up[i] = Matrix_El_Hep[index];
Vectorlept_El_HeHe_up[i] = Matrix_El_HeHe[index];
Vectorlept_Pos_pp_up[i] = Matrix_Pos_pp[index];
Vectorlept_Pos_pHe_up[i] = Matrix_Pos_pHe[index];
Vectorlept_Pos_Hep_up[i] = Matrix_Pos_Hep[index];
Vectorlept_Pos_HeHe_up[i] = Matrix_Pos_HeHe[index];
}
gsl_spline_init(spline_El_pp, Elept, Vectorlept_El_pp, dimlept+1);
gsl_spline_init(spline_El_pHe, Elept, Vectorlept_El_pHe, dimlept+1);
gsl_spline_init(spline_El_Hep, Elept, Vectorlept_El_Hep, dimlept+1);
gsl_spline_init(spline_El_HeHe, Elept, Vectorlept_El_HeHe, dimlept+1);
gsl_spline_init(spline_Pos_pp, Elept, Vectorlept_Pos_pp, dimlept+1);
gsl_spline_init(spline_Pos_pHe, Elept, Vectorlept_Pos_pHe, dimlept+1);
gsl_spline_init(spline_Pos_Hep, Elept, Vectorlept_Pos_Hep, dimlept+1);
gsl_spline_init(spline_Pos_HeHe, Elept, Vectorlept_Pos_HeHe, dimlept+1);
//
gsl_spline_init(spline_El_pp_up, Elept, Vectorlept_El_pp_up, dimlept+1);
gsl_spline_init(spline_El_pHe_up, Elept, Vectorlept_El_pHe_up, dimlept+1);
gsl_spline_init(spline_El_Hep_up, Elept, Vectorlept_El_Hep_up, dimlept+1);
gsl_spline_init(spline_El_HeHe_up, Elept, Vectorlept_El_HeHe_up, dimlept+1);
gsl_spline_init(spline_Pos_pp_up, Elept, Vectorlept_Pos_pp_up, dimlept+1);
gsl_spline_init(spline_Pos_pHe_up, Elept, Vectorlept_Pos_pHe_up, dimlept+1);
gsl_spline_init(spline_Pos_Hep_up, Elept, Vectorlept_Pos_Hep_up, dimlept+1);
gsl_spline_init(spline_Pos_HeHe_up, Elept, Vectorlept_Pos_HeHe_up, dimlept+1);
for (unsigned int i = 0; i < dimEn; i++) {
double Eel = min(1e5,energy[i]);
double Eel_tot = energy[i] + MeleGeV;
int i_lept = int(floor(log10(Eel/Elept[0])/DBlog));
if (i_lept > dimlept-1) i_lept = dimlept-1;
//double t = (Eel-Elept[i_lept])/(Elept[i_lept+1]-Elept[i_lept]);
double valuefix = gsl_spline_eval(spline_El_pp, Eel, acc);
double valueup = gsl_spline_eval(spline_El_pp_up, Eel, acc);
double cs_pp = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_El_pHe, Eel, acc);
valueup = gsl_spline_eval(spline_El_pHe_up, Eel, acc);
double cs_pHe = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_El_Hep, Eel, acc);
valueup = gsl_spline_eval(spline_El_Hep_up, Eel, acc);
double cs_Hep = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_El_HeHe, Eel, acc);
valueup = gsl_spline_eval(spline_El_HeHe_up, Eel, acc);
double cs_HeHe = valuefix*(1-u) + valueup*u;
spall_apel[coupleel][i][j] = Epr*(cs_pp + He_abundance*cs_pHe)*factorelpos;
spall_apel[coupleelHe][i][j] = 4.0*Epr*(cs_Hep + He_abundance*cs_HeHe)*factorelpos;
//
valuefix = gsl_spline_eval(spline_Pos_pp, Eel, acc);
valueup = gsl_spline_eval(spline_Pos_pp_up, Eel, acc);
cs_pp = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_Pos_pHe, Eel, acc);
valueup = gsl_spline_eval(spline_Pos_pHe_up, Eel, acc);
cs_pHe = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_Pos_Hep, Eel, acc);
valueup = gsl_spline_eval(spline_Pos_Hep_up, Eel, acc);
cs_Hep = valuefix*(1-u) + valueup*u;
valuefix = gsl_spline_eval(spline_Pos_HeHe, Eel, acc);
valueup = gsl_spline_eval(spline_Pos_HeHe_up, Eel, acc);
cs_HeHe = valuefix*(1-u) + valueup*u;
spall_apel[couplepos][i][j] = Epr*(cs_pp + He_abundance*cs_pHe)*factorelpos; // H
spall_apel[coupleposHe][i][j] = 4.0*Epr*(cs_Hep + He_abundance*cs_HeHe)*factorelpos; // He
}
}
return ;
}
//*********************************************************************************************************************************************
// Fluka model
//*********************************************************************************************************************************************
void TSpallationNetwork::InitDataTablesFluka(int which_particle) {
cout << "Entering in TSpallationNetwork InitDataTablesFluka routine ..." << endl;
cout << "which particle? "<< which_particle << endl;
//reads from the tables
if (which_particle == 0) { //Leptonic tables
cout << "leptonic tables" << endl;
Matrix_El_pp = vector<double>(408*380, 0.0);
Matrix_El_pHe = vector<double>(408*380, 0.0);
Matrix_El_Hep = vector<double>(408*380, 0.0);
Matrix_El_HeHe = vector<double>(408*380, 0.0);
Matrix_Pos_pp = vector<double>(408*380, 0.0);
Matrix_Pos_pHe = vector<double>(408*380, 0.0);
Matrix_Pos_Hep = vector<double>(408*380, 0.0);
Matrix_Pos_HeHe = vector<double>(408*380, 0.0);
ifstream infile(FlukaElTablefile.c_str(), ios::in);
double a,b,c,d;
Nelectrons = 408;
Nprotons = 380;
for (int i = 0; i < Nelectrons; i++) {
for (int j = 0; j < Nprotons; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_El_pp[ind] = a;
Matrix_El_pHe[ind] = b;
Matrix_El_Hep[ind] = c;
Matrix_El_HeHe[ind] = d;
}
}
infile.close();
infile.open(FlukaPosTablefile.c_str(), ios::in);
for (int i = 0; i < Nelectrons; i++) {
for (int j = 0; j < Nprotons; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_Pos_pp[ind] = a;
Matrix_Pos_pHe[ind] = b;
Matrix_Pos_Hep[ind] = c;
Matrix_Pos_HeHe[ind] = d;
}
}
infile.close();
}
if (which_particle == 1) { //sec Antiproton tables
cout << "ap tables " << endl;
Matrix_Ap_pp = vector<double>(408*380, 0.0);
Matrix_Ap_pHe = vector<double>(408*380, 0.0);
Matrix_Ap_Hep = vector<double>(408*380, 0.0);
Matrix_Ap_HeHe = vector<double>(408*380, 0.0);
ifstream infile(FlukaApTablefile.c_str(), ios::in);
double a,b,c,d;
Nap = 408;
Nprotons = 380;
for (int i = 0; i < Nap; i++) {
for (int j = 0; j < Nprotons; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_Ap_pp[ind] = a;
Matrix_Ap_pHe[ind] = b;
Matrix_Ap_Hep[ind] = c;
Matrix_Ap_HeHe[ind] = d;
}
}
infile.close();
}
if (which_particle == 2) { //sec Proton tables
cout << "proton tables " << endl;
Matrix_p_pp = vector<double>(408*380, 0.0);
Matrix_p_pHe = vector<double>(408*380, 0.0);
Matrix_p_Hep = vector<double>(408*380, 0.0);
Matrix_p_HeHe = vector<double>(408*380, 0.0);
ifstream infile(FlukaProtTablefile.c_str(), ios::in);
double a,b,c,d;
Nap = 408;
Nprotons = 380;
for (int i = 0; i < Nap; i++) {
for (int j = 0; j < Nprotons; j++) {
infile >> a >> b >> c >> d;
int ind = index_matrix(i,j);
Matrix_p_pp[ind] = a;
Matrix_p_pHe[ind] = b;
Matrix_p_Hep[ind] = c;
Matrix_p_HeHe[ind] = d;
if (i%100==0 && j%100==0)
cout << i << " <-i,j-> " << j << "; abcd= " << a << " " << b << " " << c << " " << d << endl;
}
}
infile.close();
}
if (which_particle == 2) { //tertiary antiProton tables
cout << "tertiary antiproton tables " << endl;
Matrix_3Ap_app = vector<double>(408*380, 0.0);
Matrix_3Ap_apHe = vector<double>(408*380, 0.0);
ifstream infile(FlukaTertiaryApTablefile.c_str(), ios::in);
double a,b,c,d;
Nap = 408;
Nprotons = 380;
for (int i = 0; i < Nap; i++) {
for (int j = 0; j < Nprotons; j++) {
infile >> a >> b;
int ind = index_matrix(i,j);
Matrix_3Ap_app[ind] = a;
Matrix_3Ap_apHe[ind] = b;
if (i%100==0 && j%100==0)
cout << i << " <-i,j-> " << j << "; abcd= " << a << " " << b << endl;
}
}
infile.close();
}
return;
}
void TSpallationNetwork::InitXSecFluka(double factorelpos, int which_particle) {
//which_particle: 0-->leptons
//1-->sec antiprotons
//2-->sec protons
//3-->tertiary antiprotons
cout << "Entering in TSpallationNetwork InitXSecFluka routine ..." << endl;
pair<int,int> coupleel(1001, -1000); // Electrons from protons
pair<int,int> couplepos(1001, 1000); // Positrons from protons
pair<int,int> coupleelHe(2004, -1000); // Electrons from He
pair<int,int> coupleposHe(2004, 1000); // Positrons from He
pair<int,int> coupleappr(1001,-999); // Secondary antiprotons, from CR protons
pair<int,int> coupleapHe(2004,-999); // Secondary antiprotons, from CR Helium
pair<int,int> coupleppr(1001,1001); // Secondary antiprotons, from CR protons
pair<int,int> couplepHe(2004,1001); // Secondary antiprotons, from CR Helium
pair<int,int> coupleapap(-999,-999); // Tertiary antiprotons
const int dimEn = energy.size();
const int dimlept = 407;
const int dimap = 407;
const int dimp = 407;
const double DBlog = log10(1.05);
double Elept[dimlept+1];
double Eap[dimap+1];
for (int i = 0; i <= dimlept; i++) {
Elept[i] = 0.001*pow(1.05, double(i)+0.5);
Elept[i] = pow(10., log10(1e-3)+double(i)*DBlog+0.5*DBlog);
Eap[i] = Elept[i];
//cout << i << " " << Elept[i] << endl;
}
const int dimpr = 379;
const double DBprlog = log10(1.05);
double ET[dimpr+1];
for (int j = 0; j <= 94; j++) ET[j] = pow(10, log10(1e-3) + double(j)*DBprlog);
for (int j = 0; j <= 284; j++) {
ET[j+95] = 0.1*pow(1.05, double(j));
ET[j+95] = pow(10, log10(1e-1) + double(j)*DBprlog);
}
// for (int j = 0; j <= dimpr; j++) {
// cout << j << " " << ET[j] << endl;
// }
TSpallationNetwork::InitDataTablesFluka(which_particle);
cout << "test" << endl;
gsl_interp_accel *acc = gsl_interp_accel_alloc ();
gsl_spline *spline_El_pp = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_pHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_Hep = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pp = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_Hep = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
//
gsl_spline *spline_Ap_pp = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_pHe = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_Hep = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
//
gsl_spline *spline_p_pp = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_pHe = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_Hep = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_HeHe = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
//
gsl_spline *spline_3Ap_app = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_3Ap_apHe = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
//gsl_interp_accel *acc = gsl_interp_accel_alloc ();
gsl_spline *spline_El_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_El_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
gsl_spline *spline_Pos_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimlept+1);
//
gsl_spline *spline_Ap_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_Ap_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
//
gsl_spline *spline_p_pp_up = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_pHe_up = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_Hep_up = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
gsl_spline *spline_p_HeHe_up = gsl_spline_alloc(gsl_interp_cspline, dimp+1);
//
gsl_spline *spline_3Ap_app_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
gsl_spline *spline_3Ap_apHe_up = gsl_spline_alloc(gsl_interp_cspline, dimap+1);
double Vectorlept_El_pp[dimlept+1];
double Vectorlept_El_pHe[dimlept+1];
double Vectorlept_El_Hep[dimlept+1];
double Vectorlept_El_HeHe[dimlept+1];
double Vectorlept_Pos_pp[dimlept+1];
double Vectorlept_Pos_pHe[dimlept+1];
double Vectorlept_Pos_Hep[dimlept+1];
double Vectorlept_Pos_HeHe[dimlept+1];
//
double Vector_Ap_pp[dimap+1];
double Vector_Ap_pHe[dimap+1];
double Vector_Ap_Hep[dimap+1];
double Vector_Ap_HeHe[dimap+1];
//
double Vector_p_pp[dimp+1];
double Vector_p_pHe[dimp+1];
double Vector_p_Hep[dimp+1];
double Vector_p_HeHe[dimp+1];
//
double Vector_3Ap_app[dimap+1];
double Vector_3Ap_apHe[dimap+1];
//
double Vectorlept_El_pp_up[dimlept+1];
double Vectorlept_El_pHe_up[dimlept+1];
double Vectorlept_El_Hep_up[dimlept+1];
double Vectorlept_El_HeHe_up[dimlept+1];
double Vectorlept_Pos_pp_up[dimlept+1];
double Vectorlept_Pos_pHe_up[dimlept+1];
double Vectorlept_Pos_Hep_up[dimlept+1];
double Vectorlept_Pos_HeHe_up[dimlept+1];
//
double Vector_Ap_pp_up[dimap+1];
double Vector_Ap_pHe_up[dimap+1];
double Vector_Ap_Hep_up[dimap+1];
double Vector_Ap_HeHe_up[dimap+1];
//
double Vector_p_pp_up[dimp+1];
double Vector_p_pHe_up[dimp+1];
double Vector_p_Hep_up[dimp+1];
double Vector_p_HeHe_up[dimp+1];
//
double Vector_3Ap_app_up[dimp+1];
double Vector_3Ap_apHe_up[dimp+1];
if (which_particle == 0) { //leptons
for (unsigned int j=0; j<dimEn; j++){
double Epr = energy[j];
double momentum = sqrt(Epr*Epr + 2.0*mp*Epr);