-
Notifications
You must be signed in to change notification settings - Fork 13
/
signal.cc
1721 lines (1160 loc) · 59.5 KB
/
signal.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
#include "signal.hh"
//#include "vector.hh"
#include "TF1.h"
#include "TRandom3.h"
//#include "vector.hh"
#include "Vector.h"
//#include "position.hh"
#include "Position.h"
#include "Settings.h"
#include "Event.h"
#include <fstream>
#include "TCanvas.h"
#include "TGraph.h"
#include "Constants.h"
using std::cout;
const double Signal::N_AIR(1.); // index of refraction of air
const double Signal::NICE(1.79); // index of refraction of ice
const double Signal::CHANGLE_ICE(acos(1/NICE)); // index of refraction of ice
const double Signal::NSALT(2.45); // index of refracton for salt
//const double RHOSALT=2165; // density of salt (kg/m**3)
const double Signal::RHOSALT(2050.); // density of salt (kg/m**3)
const double Signal::RHOICE(917); // density of ice (kg/m**3)
const double Signal::RHOH20(1000); // density of water (kg/m**3)
const double Signal::RHOAIR(1.25); // density of air (kg/m**3)
const double Signal::RM_ICE(10.35); // moliere radius, in g/cm^2
const double Signal::RM_SALT(12.09); // moliere radius, in g/cm^2
const double Signal::KR_SALT(1.33); // constant in jaime's parameterization
const double Signal::KR_ICE(1.42); // constant in jaime's parameterization
//const double Signal::X0SALT=0.1024; // radiation length of salt (meters)
const double Signal::X0SALT(0.1081); // radiation length of salt (meters)
//const double Signal::ECSALT=40.; // critical energy in salt (MeV)
const double Signal::ECSALT(38.5); // critical energy in salt (MeV)
const double Signal::X0ICE(0.403);
// //const double Signal::X0ICE=0.392; // radiation length of ice (meters)
const double Signal::ECICE(63.7); // critical energy in ice (MeV)
// //const double Signal::ECICE=73.0; // critical energy in ice (MeV)
const double Signal::AEX_ICE(1.); //efficiency for producing charge asymmetry relative to ice. 1 by definition
const double Signal::ALPHAICE(1.32); // exponent that goes into cutting off the spectrum at high frequencies
const double Signal::AEX_SALT(0.684); // efficiency for producing charge asymmetry relative to ice
const double Signal::ALPHASALT(1.27); // exponent that goes into cutting off the spectrum at high frequencies
const double Signal::KE_SALT(3.2E-16); // constant in jaime's parameterization, in V/cm/MHz
const double Signal::KL_SALT(21.12); //constant in jaime's parameterization
const double Signal::KDELTA_SALT(14.95); // constant in jaime's parameterization
const double Signal::KE_ICE(4.79E-16); // constant in jaime's parameterization, in V/cm/MHz
const double Signal::KL_ICE(23.80); //constant in jaime's parameterization
const double Signal::KDELTA_ICE(18.33); // constant in jaime's parameterization
const double Signal::KELVINS_ICE(250.+150.); // temperature in Kelvin (ice+system)
const double Signal::KELVINS_SALT(500.); // temperature in salt (350) + receiver temp (150)
const double Signal::BETAICE(2.25); // exponent, in jaime's parameterization
// double Signal::NU0_MODIFIED=0.; // nu_0 modified for a specific medium
// double Signal::NU_R;// parameter for signal parameterization
const double Signal::BETASALT(2.60); // exponent, in jaime's parameterization
const double Signal::VIEWANGLE_CUT(sqrt(5.)); // require viewangle is no more than 5 delta away from the cerenkov angle where
Signal::Signal() : N_DEPTH(1.79) {
Initialize();
}
Signal::Signal(Settings *settings1) : N_DEPTH(1.79) {
Initialize(settings1);
}
Signal::~Signal() {
}
void Signal::InitializeMedium() {
if (MEDIUM==1) {
SetKelvins(KELVINS_SALT);
SetRhoMedium(RHOSALT);
SetNDepth(NSALT);
// changle=changle_salt;
SetNMediumReceiver(NSALT);
SetX0Medium(X0SALT);
SetEcMedium(ECSALT);
SetAexMedium(AEX_SALT);
SetAlphaMedium(ALPHASALT);
SetRmMedium(RM_SALT);
SetKeMedium(KE_SALT); // constant in jaime's parameterization, in V/cm/MHz
SetKlMedium(KL_SALT); //constant in jaime's parameterization
SetKdelta_Medium(KDELTA_SALT); // constant in jaime's parameterization
SetKrMedium(KR_SALT); // constant in jaime's parameterization
SetBetaMedium(BETASALT); // exponent, in jaime's parameterization
} //if (MEDIUM==1)
else if (MEDIUM==0) {
SetKelvins(KELVINS_ICE);
SetNDepth(NICE);
//changle=CHANGLE_ICE;
SetRhoMedium(RHOICE);
SetNMediumReceiver(N_AIR);
SetX0Medium(X0ICE);
SetEcMedium(ECICE);
SetAexMedium(AEX_ICE);
SetAlphaMedium(ALPHAICE);
SetRmMedium(RM_ICE);
SetKeMedium(KE_ICE); // constant in jaime's parameterization, in V/cm/MHz
SetKlMedium(KL_ICE); //constant in jaime's parameterization
SetKdelta_Medium(KDELTA_ICE); // constant in jaime's parameterization
SetKrMedium(KR_ICE); // constant in jaime's parameterization
SetBetaMedium(BETAICE); // exponent, in jaime's parameterization
} //if (MEDIUM==0)
}
void Signal::Initialize() {
ReadCalPulserSpectrum();
logscalefactor_taper=0.;
JAIME_FACTOR=1.0; // factor to multiply Jaime's parameterization for error analysis
x0ice=0.403;
//X0ICE=0.392; // radiation length of ice (meters)
ecice=63.7; // critical energy in ice (MeV)
//const static ECICE=73.0; // critical energy in ice (MeV)
nice=1.79; // index of refraction of ice
nfirn=1.3250; // index of refraction at the very surface - Peter
invnfirn=1/nfirn;
invnice=1/nice;
rhoice=917; // density of ice (kg/m**3)
kelvins_ice=250.+150.; // temperature in Kelvin (ice+system)
changle_ice=acos(1./nice);
aex_ice=1.; //efficiency for producing charge asymmetry relative to ice. 1 by definition
alphaice=1.32; // exponent that goes into cutting off the spectrum at high frequencies
rm_ice=10.35; // moliere radius, in g/cm^2
ke_ice=4.79E-16; // const staticant in jaime's parameterization, in V/cm/MHz
kl_ice=23.80; //const staticant in jaime's parameterization
kdelta_ice=18.33; // const staticant in jaime's parameterization
kr_ice=1.42; // const staticant in jaime's parameterization
betaice=2.25; // exponent, in jaime's parameterization
nu0_modified=0.; // nu_0 modified for a specific medium
freq_reference=1.E6; // reference frequency in MHz
pnu_reference=1.E18; // reference energy in MHz
if (WHICHPARAMETERIZATION==1) {
nu_r=(RHOMEDIUM/1000.)
//NU_R=(RHOMEDIUM/1000.) // density in g/cm^3
/KR_MEDIUM/RM_MEDIUM*
CLIGHT*100./N_DEPTH/sin(acos(1/N_DEPTH));
vmmhz1m_reference=KE_MEDIUM/ECMEDIUM* // KE in V/cm/MHz^2, Ec in MeV
(X0MEDIUM*100.) // radiation length in cm
*freq_reference/1.E6 // frequency in MHz
*sqrt(N_DEPTH*N_DEPTH-1)/N_DEPTH // sin(theta_c)
*pnu_reference/1.E6 // energy in MeV
*1./sin(changle);
//cout << "multiplying by 1/changle which is " << 1./sin(changle) << "\n";
// vmmhz1m*=1./(1.+pow(freq/NU_R,ALPHAMEDIUM));
vmmhz1m_reference*=1./(1.+pow(freq_reference/nu_r,ALPHAMEDIUM));
}
else {
//cout<<"whichparameterization : "<<WHICHPARAMETERIZATION<<"\n";
}
}
void Signal::Initialize(Settings *settings1) {
ReadCalPulserSpectrum();
std::string arbitraryWaveform = "arbitrary_waveform.txt"; //Testing out IDL pulser - JCF 4/9/2023
ReadArbitraryWaveform(arbitraryWaveform);
// std::string pulserWaveform = "IDL1_waveform.txt";
std::string pulserWaveform = "IDL1_waveformNoiseless.txt";
ReadPulserWaveform(pulserWaveform);
// Added function to read in voltage versus time of IDL2 pulser data provided by Alisa. Need ot expand this to be dynamic to other voltage sources in the future.
std::string inputVoltage = "IDL2_InputVoltageVersusTime.txt";
ReadInputVoltage(inputVoltage);
SetParameterization(settings1->WHICHPARAMETERIZATION);
logscalefactor_taper=0.;
JAIME_FACTOR=1.0; // factor to multiply Jaime's parameterization for error analysis
x0ice=0.403;
//X0ICE=0.392; // radiation length of ice (meters)
ecice=63.7; // critical energy in ice (MeV)
//const static ECICE=73.0; // critical energy in ice (MeV)
nice=1.79; // index of refraction of ice
nfirn=1.3250; // index of refraction at the very surface - Peter
invnfirn=1/nfirn;
invnice=1/nice;
rhoice=917; // density of ice (kg/m**3)
kelvins_ice=250.+150.; // temperature in Kelvin (ice+system)
changle_ice=acos(1./nice);
aex_ice=1.; //efficiency for producing charge asymmetry relative to ice. 1 by definition
alphaice=1.32; // exponent that goes into cutting off the spectrum at high frequencies
rm_ice=10.35; // moliere radius, in g/cm^2
ke_ice=4.79E-16; // const staticant in jaime's parameterization, in V/cm/MHz
kl_ice=23.80; //const staticant in jaime's parameterization
kdelta_ice=18.33; // const staticant in jaime's parameterization
kr_ice=1.42; // const staticant in jaime's parameterization
betaice=2.25; // exponent, in jaime's parameterization
nu0_modified=0.; // nu_0 modified for a specific medium
freq_reference=1.E6; // reference frequency in MHz
pnu_reference=1.E18; // reference energy in MHz
SetLPM(settings1->LPM); // set LPM effect on/off value
if (WHICHPARAMETERIZATION==1) {
nu_r=(RHOMEDIUM/1000.)
//NU_R=(RHOMEDIUM/1000.) // density in g/cm^3
/KR_MEDIUM/RM_MEDIUM*
CLIGHT*100./N_DEPTH/sin(acos(1/N_DEPTH));
vmmhz1m_reference=KE_MEDIUM/ECMEDIUM* // KE in V/cm/MHz^2, Ec in MeV
(X0MEDIUM*100.) // radiation length in cm
*freq_reference/1.E6 // frequency in MHz
*sqrt(N_DEPTH*N_DEPTH-1)/N_DEPTH // sin(theta_c)
*pnu_reference/1.E6 // energy in MeV
*1./sin(changle);
//cout << "multiplying by 1/changle which is " << 1./sin(changle) << "\n";
// vmmhz1m*=1./(1.+pow(freq/NU_R,ALPHAMEDIUM));
vmmhz1m_reference*=1./(1.+pow(freq_reference/nu_r,ALPHAMEDIUM));
}
else {
//cout<<"whichparameterization : "<<WHICHPARAMETERIZATION<<"\n";
}
if (settings1->SIMULATION_MODE==1){
Build_Param_RE_Tterm_tables();
}
}
void Signal::ReadCalPulserSpectrum(){
int frequency;
double vmmhz1m_temp;
int count = 0;
ifstream infile("calpulser_spectrum.txt");
if (infile){
while (1) {
infile >> frequency >> vmmhz1m_temp;
if (!infile.good()) break;
CalpulserVmMHz1m[count] = vmmhz1m_temp;
count++;
}
} else {
//std::cerr << "No calpulser spectrum file!" << std::endl;
}
}
void Signal::ReadArbitraryWaveform(string target){
double e_field;
double time_tmp;
ifstream infile(target.c_str());
if (infile){
while (1){
infile >> time_tmp >> e_field;
if (!infile.good()) break;
// cout << time_tmp << " : " << e_field <<endl;
ArbitraryWaveform_T.push_back(time_tmp);
ArbitraryWaveform_V.push_back(e_field);
}
} else {
std::cerr << "No arbitrary waveform file!" << std::endl;
}
}
void Signal::ReadPulserWaveform(string target){
double e_field;
double time_tmp;
ifstream infile(target.c_str());
if (infile){
while (1){
infile >> time_tmp >> e_field;
if (!infile.good()) break;
PulserWaveform_T.push_back(time_tmp);
PulserWaveform_V.push_back(e_field);
}
} else {
std::cerr << "No pulser waveform file!" << std::endl;
}
}
//Adding function to read input voltage at transmitting antenna - JCF 1/10/2024
void Signal::ReadInputVoltage(string target){
double voltage_tmp;
double time_tmp;
ifstream infile(target.c_str());
if (infile){
while (1){
infile >> time_tmp >> voltage_tmp;
if (!infile.good()) break;
InputVoltage_T.push_back(time_tmp);
InputVoltage_V.push_back(voltage_tmp);
}
} else {
std::cerr << "No pulser waveform file!" << std::endl;
}
}
void Signal::GetVmMHz(double vmmhz_max,double vmmhz1m_max,double pnu,double *freq,double notch_min,double notch_max,double *vmmhz,int nfreq) {
// parametrization from Jaime Alvarez Munhiz
// here using astro-ph/0003315
for (int i=0;i<nfreq;i++) {
vmmhz[i]=vmmhz_max
//*1./FREQ_LOW*freq[i];
*GetVmMHz1m(pnu,freq[i])/vmmhz1m_max;
//if (WHICHPARAMETERIZATION==0)
//vmmhz[i]*=(1./(1.+pow(freq[i]/NU0_MODIFIED,ALPHAMEDIUM)));
//if (WHICHPARAMETERIZATION==1)
//vmmhz[i]*=1./(1.+pow(freq[i]/NU_R,ALPHAMEDIUM));
if (notch_min!=0 && notch_max!=0 && freq[i]>notch_min && freq[i]<notch_max)
vmmhz[i]=0.;
} //for
// double sum[5]={0.};
// if (WHICHPATH==4) {
// for (int j=0;j<5;j++) {
// for (int i=0;i<NFREQ;i++) {
// if (bwslice_min[j]<=freq[i] && bwslice_max[j]>freq[i]) {
// sum[j]+=GetVmMHz1m(pnu,freq[i],x0ice,ecice,N_DEPTH,AEXMEDIUM,WHICHPARAMETERIZATION)*(freq[i+1]-freq[i])/1.E6;
// }
// }
// cout << "j, sum is " << j << " " << sum[j] << "\n";
// }
// }
} //GetVmMHz
double Signal::GetELPM() {
// LPM
// elpm =7.7 TeV/cm * rho * X0 in PDG, but our x0 is in meters
// so use elpm = 7.7TeV/cm*X0
// X0 is radiation lengths in cm
//double elpm=7.7E12*(X0ICE*100.);
double elpm=2.E15*(X0MEDIUM/x0ice); // this is what Jaime uses. see caption under figure 4 of 0003315.
return elpm;
} //GetELPM
int Signal::GetLPM() {
return LPM;
} //GetLPM
void Signal::GetSpread(double pnu,
double emfrac,
double hadfrac,
double freq,
// double n_depth,
//double X0DEPTH,
double& deltheta_em_max,
double& deltheta_had_max) {
// cout << KR_MEDIUM << " " << RM_MEDIUM << " " << KL_MEDIUM << " " << KE_MEDIUM << " " << ECMEDIUM << " " << X0MEDIUM << " " << ALPHAMEDIUM << " " << AEXMEDIUM << " " << KDELTA_MEDIUM << " " << BETAMEDIUM << " " << KELVINS << " " << JAIME_FACTOR << "\n";
//cout << RHOSALT << " " << RHOICE << " " << RM_ICE << " " << RM_SALT << " " << KR_SALT << " " << KR_ICE << " " << X0SALT << " " << ECSALT << " " << X0ICE << " " << ECICE << " " << AEX_ICE << "\n";
// cout << ALPHAICE << " " << AEX_SALT << " " << ALPHASALT << " " << KE_SALT << " " << KL_SALT << " " << KDELTA_SALT << " " << KE_ICE << " " << KL_ICE << " " << KDELTA_ICE << " " << KELVINS_SALT << " " << BETAICE << " " << BETASALT << "\n";
// scale by how far off Cherenkov angle this viewing antenna is
// c.f. A-MZ astro-ph/9706064 and astro-ph/0003315
// and for non-LPM (non-EM) showers from
// Phys.Lett.B434,396 (1998) (astro-ph/9806098)
// The lengths are different hence the angular thickness of
// the shower is different. Get the angular thickness for
// both the EM and hadroic parts.
// cout << KR_MEDIUM << " " << RM_MEDIUM << " " << KL_MEDIUM << " " << KE_MEDIUM << " " << ECMEDIUM << " " << X0MEDIUM << " " << ALPHAMEDIUM << " " << AEXMEDIUM << " " << KDELTA_MEDIUM << " " << BETAMEDIUM << " " << KELVINS << " " << JAIME_FACTOR << "\n";
// cout << RHOSALT << " " << RHOICE << " " << RM_ICE << " " << RM_SALT << " " << KR_SALT << " " << KR_ICE << " " << X0SALT << " " << ECSALT << " " << X0ICE << " " << ECICE << " " << AEX_ICE << "\n";
// cout << ALPHAICE << " " << AEX_SALT << " " << ALPHASALT << " " << KE_SALT << " " << KL_SALT << " " << KDELTA_SALT << " " << KE_ICE << " " << KL_ICE << " " << KDELTA_ICE << " " << KELVINS_SALT << " " << BETAICE << " " << BETASALT << "\n";
//--------------------------------------------------
// double elpm=GetLPM();
//--------------------------------------------------
double elpm=GetELPM();
//cout << "elpm is " << elpm << "\n";
// cout << "elpm is " << elpm << "\n";
freq=freq/1.E6; // frequency in MHz
double showerlength=3.1; //shower length in meters-gets a modification
//for em showers due to lpm effect.
// this shower length is chosen somewhat arbitrarily, but is
// approximately the length of a shower in ice.
// Then, the coefficient out front of the equations for
// deltheta_em_max and deltheta_had_max are set so that
// for ice, we get the equations in astro-ph/9706064
// with the coefficient in front being 2.7 degrees.
// I wanted to make the dependence on the shower length
// and index of refraction explicit, so I pulled those variables
// out of the equations for deltheta_em_max and deltheta_had_max.
double em_eshower; // em shower energy
double had_eshower; // had shower energy
double nu0; // reference frequency
em_eshower=emfrac*pnu; // first, consider the electromagnetic shower.
had_eshower=hadfrac*pnu; // just the energy of the hadronic component of the shower
// lengthen the shower to account for the lpm effect.
// from astro-ph/9706064
if (em_eshower<1.E15 || !LPM)
showerlength/=pow((em_eshower/1.e15),-0.03);
else
showerlength/=pow(elpm/(0.14*(em_eshower)+elpm),0.3);
// cout << "showerlength is " << showerlength << "\n";
if (WHICHPARAMETERIZATION==0) {
nu0=500.E6/1.E6*x0ice/X0MEDIUM; // for rego (astro-ph/9706064)
// decoherence frequency scales with radiation length
// when X0MEDIUM=X0ICE, nu0=500 MHz as in astro-ph/9706064
// these equations are in astro-ph/9706064, but we have pulled
// out the dependence on index of refraction and shower length.
// note that 12.32/sqrt(pow(n_depth,2)-1)*RADDEG/showerlength=2.7 degrees.
// remember that Jaime has a factor of ln2 in the exponential here which we'll have to correct for further down
deltheta_em_max=12.32/sqrt(pow(N_DEPTH,2)-1)*(nu0/freq)*RADDEG/showerlength;
//cout<<"1) daltheta_em_max : "<<deltheta_em_max<<endl;
if (hadfrac>0.00001) { // if there is a hadronic component
// these equations are in astro-ph/9806098, but we have pulled
// out the dependence on index of refraction and shower length.
// remember that in this paper he includes a factor of ln2 in
// the exponential, which we account for further down
double epsilon=log10(had_eshower/1.E12);
if (had_eshower>=1E12 && had_eshower<100.E12)
deltheta_had_max=1.473/sqrt(pow(N_DEPTH,2)-1)*nu0/freq*RADDEG*(2.07-0.33*epsilon+(7.5e-2)*epsilon*epsilon);
else if (had_eshower<100.E15)
deltheta_had_max=1.473/sqrt(pow(N_DEPTH,2)-1)*nu0/freq*RADDEG*(1.744-(1.21e-2)*epsilon);
else if (had_eshower<10.E18)
deltheta_had_max=1.473/sqrt(pow(N_DEPTH,2)-1)*nu0/freq*RADDEG*(4.23-0.785*epsilon+(5.5e-2)*epsilon*epsilon);
else {
// beyond param, just use value at 10 EeV since slow variation
// and parameterization might diverge
// so scale from 10 EeV at 7.5% per decade (30/4=7.5)
//deltheta_had_max=1.473/sqrt(pow(N_DEPTH,2)-1)*nu0/freq*RADDEG*(4.23-0.785*7.+5.5e-2*49.); // the last part in parenthesis if the previous equation evaluated at epsilon=7.
//deltheta_had_max=deltheta_had_max*(1.+(epsilon-7.)*0.075);
// It doesn't increase deltheta_had_max by 7.5% per decade anymore. Now it decreases the energy factor by 0.07 per decade.
deltheta_had_max=1.473/sqrt(pow(N_DEPTH,2)-1)*nu0/freq*RADDEG*(4.23-0.785*7.+5.5e-2*49. - (epsilon-7.)*0.07);
} //else : beyond paramatrization
deltheta_had_max/=sqrt(log(2.)); // in astro-ph/9706064, Jaime uses exp(-0.5* (theta-theta_c)^2/delta_had^2)
// we adjust the delta's so that we can use the same form for both parameterizations: exp(-(theta-theta_c)^2/delta^2)
}
else
deltheta_had_max=1.E-10;
deltheta_em_max/=sqrt(log(2.)); // in astro-ph/9706064, Jaime uses exp(-0.5 (theta-theta_c)^2/delta_had^2)
//cout<<"2) daltheta_em_max : "<<deltheta_em_max<<endl;
}
else if (WHICHPARAMETERIZATION==1) {
// cout << "I'm here inside GetSpread.\n";
// we use the old parameterization for em showers
nu0=500.E6/1.E6; // for rego (astro-ph/9706064)
deltheta_em_max=12.32/sqrt(nice*nice-1)*(nu0/freq)*RADDEG/showerlength;
// and then scale it according to astro-ph/0512337
// Eq. 9
deltheta_em_max*=RHOMEDIUM/rhoice
/KDELTA_MEDIUM*kdelta_ice
/X0MEDIUM*x0ice
/sqrt(N_DEPTH*N_DEPTH-1)*sqrt(nice*nice-1);
if (hadfrac>0.00001) { // if there is a hadronic component
// for had showers, just use the one from astro-ph/0512337
// Eq. 9
// straight away
deltheta_had_max=CLIGHT*100.// speed of light in cm/s
/(freq*1.E6)
*1/KDELTA_MEDIUM
/(X0MEDIUM*100.) // radiation length in cm
/sqrt(N_DEPTH*N_DEPTH-1.);
} //if (hadronic component)
else
deltheta_had_max=1.E-10;
} // if more recent parameterization
} //GetSpread
double Signal::GetVmMHz1m(double pnu,double freq) { // constructor
if (WHICHPARAMETERIZATION==0) {
// parametrization from Jaime Alvarez Munhiz
// here using astro-ph/0003315
double nu0=1150.E6/1.E6;
//NU0_MODIFIED=nu0
double nu0_modified=nu0
*(x0ice/ecice)/(X0MEDIUM/ECMEDIUM)
*(1/sqrt(N_DEPTH*N_DEPTH-1.))/(1/sqrt(nice*nice-1.));
freq=freq/1.E6; // frequency in MHz
double factor=
//1/sin(changle) // should be cerenkov angle for ice
1/sqrt(1-1/(nice*nice)) // sin(changle) for ice
*1/nu0 //
*X0MEDIUM/x0ice // track length *** use dE/dX rho instead
*ecice/ECMEDIUM
*AEXMEDIUM/aex_ice; // to account for critical energy
// to account for cerenkov threshold // maybe should be "a" instead
vmmhz1m_max=factor*(2.53E-7)*(pnu/1.E12)*freq
// *(1./(1.+pow(freq/NU0_MODIFIED,ALPHAMEDIUM)))
*(1./(1.+pow(freq/nu0_modified,1.44)));
}
else if (WHICHPARAMETERIZATION==1) {
vmmhz1m_max=vmmhz1m_reference
*freq/freq_reference
*pnu/pnu_reference
*1./(1.+pow(freq/nu_r,ALPHAMEDIUM))
*(1.+pow(freq_reference/nu_r,ALPHAMEDIUM));
}
vmmhz1m_max=vmmhz1m_max/2.; // This factor of 2 is to account for the 2 in the definition of the fourier transform in Equation 8 of the Halzen, Stanev and Zas paper. The same factor of 2 seems to have propagated through subsequent Jaime papers.
vmmhz1m_max=vmmhz1m_max*sqrt(2.); // This is to account for the fact that the E fields quoted in the theory papers are double-sided in frequency (they extend from -F to F) whereas we are using it as a single-sided E-field (only from 0 to F).
// cout << "jaime_factor is " << JAIME_FACTOR << "\n";
return vmmhz1m_max*JAIME_FACTOR;
// vmmhz1m=vmmhz1m/sqrt(1.E6/(BW/(double)NFREQ)); //THIS IS NEEDED TO CONSERVE ENERGY FOR DIFFERENT BIN WIDTHS.
// // this is the old version
// double factor=
// X0MEDIUM/X0ICE // track length
// *(1-1/(N_DEPTH*N_DEPTH))/(1-1/(NICE*NICE)) // cerenkov index of refraction factor
// *N_DEPTH/NICE // to account for cerenkov threshold
// *ECICE/ECMEDIUM; // to account for critical energy
// double vmmhz1m=factor*(2.53E-7)*(pnu/1.E12)*(freq/nu0)*(1./(1.+pow(freq/nu0_modified,1.44)))*JAIME_FACTOR;
} //Signal constructor
double Signal::GetVmMHz1mCalPulser(int bin) { // constructor
vmmhz1m_max = CalpulserVmMHz1m[bin];
// std::cout << bin << " : " << vmmhz1m_max << std::endl;
// vmmhz1m_max=vmmhz1m_max/2.; // This factor of 2 is to account for the 2 in the definition of the fourier transform in Equation 8 of the Halzen, Stanev and Zas paper. The same factor of 2 seems to have propagated through subsequent Jaime papers.
// vmmhz1m_max=vmmhz1m_max*sqrt(2.); // This is to account for the fact that the E fields quoted in the theory papers are double-sided in frequency (they extend from -F to F) whereas we are using it as a single-sided E-field (only from 0 to F).
// cout << "jaime_factor is " << JAIME_FACTOR << "\n";
// return vmmhz1m_max*JAIME_FACTOR;
return vmmhz1m_max;
// vmmhz1m=vmmhz1m/sqrt(1.E6/(BW/(double)NFREQ)); //THIS IS NEEDED TO CONSERVE ENERGY FOR DIFFERENT BIN WIDTHS.
// // this is the old version
// double factor=
// X0MEDIUM/X0ICE // track length
// *(1-1/(N_DEPTH*N_DEPTH))/(1-1/(NICE*NICE)) // cerenkov index of refraction factor
// *N_DEPTH/NICE // to account for cerenkov threshold
// *ECICE/ECMEDIUM; // to account for critical energy
// double vmmhz1m=factor*(2.53E-7)*(pnu/1.E12)*(freq/nu0)*(1./(1.+pow(freq/nu0_modified,1.44)))*JAIME_FACTOR;
} //Signal constructor
void Signal::SetParameterization(int whichparameterization) {
WHICHPARAMETERIZATION=whichparameterization;
}
void Signal::TaperVmMHz(double viewangle,
double deltheta_em,
double deltheta_had,
double emfrac,
double hadfrac,
double& vmmhz1m,
double& vmmhz1m_em_obs) {
//--EM
bool calpulser = false;
double vmmhz1m_em=0; // V/m/MHz at 1m due to EM component of shower
double vmmhz1m_had=0; // V/m/MHz at 1m due to HAD component of shower
// this is the number that get exponentiated
// double rtemp=0.5*(viewangle-changle)*(viewangle-changle)/(deltheta_em*deltheta_em);
double rtemp=(viewangle-changle)*(viewangle-changle)/(deltheta_em*deltheta_em);
//cout << "dangle, deltheta_em is " << viewangle-changle << " " << deltheta_em << "\n";
//cout << "rtemp (em) is " << rtemp << "\n";
// the power goes like exp(-(theta_v-theta_c)^2/Delta^2)
// so the e-field is the same with a 1/2 in the exponential
if (emfrac>pow(10.,-10.)) { // if there is an em component
if (calpulser == false){
if (rtemp<=20) { // if the viewing angle is less than 20 sigma away from the cerankov angle
// this is the effect of the em width on the signal
vmmhz1m_em=vmmhz1m*exp(-rtemp);
}
else // if it's more than 20 sigma just set it to zero
{vmmhz1m_em=0.;}
} else {
vmmhz1m_em = vmmhz1m;
}
} else // if the em component is essentially zero than set this to zero
vmmhz1m_em=0;
//--HAD
// this is the quantity that gets exponentiated
rtemp=(viewangle-changle)*(viewangle-changle)/(deltheta_had*deltheta_had);
//cout << "rtemp (had) is " << rtemp << "\n";
if (hadfrac!=0) { // if there is a hadronic fraction
if (calpulser == false){
if (rtemp<20) { // if we are less than 20 sigma from cerenkov angle
vmmhz1m_had=vmmhz1m*exp(-rtemp); // this is the effect of the hadronic width of the signal
}
else // if we're more than 20 sigma from cerenkov angle
vmmhz1m_had=0.; // just set it to zero
} else {
vmmhz1m_had = vmmhz1m;
}
}
else
vmmhz1m_had=0.;
logscalefactor_taper=log10((emfrac*vmmhz1m_em+hadfrac*vmmhz1m_had)/vmmhz1m);
//cout << "emfrac, vmmhz1m_em, hadfrac, vmmhz1m_had are " << emfrac << " " << vmmhz1m_em << " " << hadfrac << " " << vmmhz1m_had << "\n";
vmmhz1m=sin(viewangle)*(emfrac*vmmhz1m_em+hadfrac*vmmhz1m_had);
if (vmmhz1m==0)
vmmhz1m_em_obs=0.;
else
vmmhz1m_em_obs=sin(viewangle)*emfrac*vmmhz1m_em/vmmhz1m;
} //TaperVmMHz
// for t-domain signal generation,
// first we need to generate shower profile
//
void Signal::GetShowerProfile(double E_shower, // energy of shower
int shower_mode, // 0 : EM shower, 1 : HAD shower
double shower_step_m, // shower step in meters
int param_model, // 0 : Jaime's fit, 1 : Carl's fit
//int q_excess_model, // 0 : const 25% (only option now)
std::vector <double> &depth, // shower depth array, output
std::vector <double> &Q_shower, // shower charge excess profile, output
double &LQ // integrated Q_shower
) {
// reset all output vectors
depth.clear();
Q_shower.clear();
// fit parameters
double params[5];
double X_0_const = 36.08;
double X_max;
double X_max_m;
// if we use our fit parameters
if ( param_model == 1 ) {
// EM shower case
if ( shower_mode == 0 ) {
params[0] = 0.168971; // S_0
params[1] = 37.5961; // X_0
params[2] = 59.9807; // lambda
params[3] = 0.158426; // E_c
//params[4] = pow(10, E_shower - 9. ); // shower energy E_0 in GeV
params[4] = E_shower/1.e9; // shower energy E_0 in GeV
X_max = params[1]*log(params[4]/params[3]); // in g/cm2
X_max_m = X_max/0.917/100.; // in m
}
// Hadronic shower case
else if ( shower_mode == 1 ) {
params[0] = 0.1261; // S_0
params[1] = 39.62; // X_0
params[2] = 73.98; // lambda
params[3] = 0.1691; // E_c
//params[4] = pow(10, E_shower - 9. ); // shower energy E_0 in GeV
params[4] = E_shower/1.e9; // shower energy E_0 in GeV
X_max = params[1]*log(params[4]/params[3]);
X_max_m = X_max/0.917/100.; // in m
}
}
// if we use Jaime's fit parameters
else if ( param_model == 0 ) {
// EM shower case
if ( shower_mode == 0 ) {
params[0] = 0.073; // E_c
//params[1] = pow(10, E_shower - 9. ); // shower energy E_0 in GeV
params[1] = E_shower/1.e9; // shower energy E_0 in GeV
X_max = X_0_const*log(params[1]/params[0]); // not correct but just a approx.
X_max_m = X_max/0.917/100.; // in m
}
// Hadronic shower case
else if ( shower_mode == 1 ) {
params[0] = 0.11842; // S_0
params[1] = 39.562; // X_0
params[2] = 113.03; // lambda
params[3] = 0.17006; // E_c
//params[4] = pow(10, E_shower - 9. ); // shower energy E_0 in GeV
params[4] = E_shower/1.e9; // shower energy E_0 in GeV
X_max = params[1]*log(params[4]/params[3]);
X_max_m = X_max/0.917/100.; // in m
}
}
int downflag = 0; // after X_max
double currentN = 0;
int steps = 0;
int steps_limit = 100000;
double shower_step_gcm2 = shower_step_m * 1.e2 * 0.917; // g/cm2
double shower_step_gcm2_X0factor = shower_step_gcm2 / X_0_const; // in unit of radiation length
//double gcm2_tmp = 0.;
double gcm2_tmp = shower_step_gcm2_X0factor; // don't start with zero
LQ = 0.;
while (downflag==0 || currentN>100) {
//gcm2.push_back( gcm2_tmp * X_0_const ); // gcm2 is in unit of g/cm2
if ( param_model == 0 && shower_mode == 0 ) {
currentN = Greisen(gcm2_tmp, params); // input value gcm2_tmp is in unit of radiation length
}
else {
currentN = GaisserHillas(gcm2_tmp, params);
}
//if (currentN < 1) currentN = 0;
if (currentN < 4) currentN = 0; // 4 total = 1 excess
// currently just apply 25% const factor for charge excess
Q_shower.push_back( currentN * 0.25 );
LQ += currentN * 0.25;
depth.push_back( gcm2_tmp*X_0_const/0.917/100. ); // 0.917 for ice density, 100 for cm to m
if (downflag==0 && depth[steps] > X_max_m ) downflag = 1; // now we are going down in shower profile
if (steps > steps_limit) break; // if steps go too long, come out from while loop
gcm2_tmp += shower_step_gcm2_X0factor;
steps++;
}
//cout<<"E_shower : "<<E_shower<<" steps : "<<steps<<endl;
}// GetShowerProfile
double Signal::GaisserHillas(double x_in, double *par) {
double X_max = par[1]*log(par[4]/par[3]);
double S_0 = par[0];
double X_0 = par[1];
double lambda = par[2];
double E_c = par[3];
double E_0 = par[4];
const double X_0_const = 36.08; // factor to change input x_in (unit of raidation) to g/cm2 unit
double value = S_0*E_0/E_c * (X_max-lambda)/X_max * exp(X_max/lambda-1) * pow(x_in * X_0_const / (X_max - lambda), X_max/lambda) * exp( -1 * x_in * X_0_const / lambda);
return value;
}
double Signal::Greisen(double x_in, double *par) {
double E_c = par[0];
double E_0 = par[1];
// fit parameter is in unit of radiation length
double value = 0.31/sqrt( log(E_0/E_c) )*exp( x_in-1.5*x_in*log( (3.*x_in)/(x_in+2.*log(E_0/E_c)) ) );
return value;
}
void Signal::get_Param_RA(int em_or_had, double (&the_params)[8]){
/*
Depending on if em_or_had = 0 or 1 (0 = EM, 1 = HAD)
Assing the parameters
*/
if(em_or_had==0){
the_params[0] = 0.057;
the_params[1] = 2.87;
the_params[2] = -3.;
the_params[3] = -0.03;
the_params[4] = -3.05;
the_params[5] = -3.5;
}
else if(em_or_had==1){
the_params[0] = 0.043;
the_params[1] = 2.92;
the_params[2] = -3.21;
the_params[3] = -0.065;
the_params[4] = -3.00;
the_params[5] = -2.65;
}
}
double Signal::evaluate_param_re_table(double time, std::vector<double> &table){
double ans = 0;
if( time > tables_t_min && time < tables_t_max){
int low_bin = (time - tables_t_min)*tables_inv_dt; // low bin
int hi_bin = low_bin+1; // hi bin
double frac = (time - (low_bin*tables_dt + tables_t_min))*tables_inv_dt; // which bin is it closer to
ans = table[low_bin]*(frac) + table[hi_bin]*(1.-frac); // evaluate
}
return ans;
}
std::vector<double> Signal::pick_table(int em_or_had){
if(em_or_had==0){
return tterm_table_em;
}
else{
return tterm_table_had;
}
}
void Signal::Build_Param_RE_Tterm_tables(){
cout<<"Building the Param RE Tterm tables..."<<endl;
tables_dt = 0.0001;
tables_inv_dt = 1./tables_dt;
tables_max_t = 75.;
tables_t_min = (-tables_max_t) + tables_dt/2.; // start it 1/2 sample "in" so that it "hops" time = 0
tables_t_max = (tables_max_t) - tables_dt/2.;
int table_num_bins = int((tables_max_t/tables_dt)*2);
double param_RA_em[8];
double param_RA_had[8];
get_Param_RA(0, param_RA_em);
get_Param_RA(1, param_RA_had);
for(int i=0; i<table_num_bins; i++){
double time = (i*tables_dt) + tables_t_min;
tterm_table_em.push_back(Param_RE_Tterm(time, param_RA_em));
tterm_table_had.push_back(Param_RE_Tterm(time, param_RA_had));
}
cout<<"Finished building the Param RE Tterm tables."<<endl;
}
// depending on the shower_mode, make Vm array for em shower/had shower or both
void Signal::GetVm_FarField_Tarray( Event *event, Settings *settings1, double viewangle, double atten_factor, int outbin, double *Tarray, double *Earray, int &skip_bins ) {
double sin_view = sin(viewangle);
double cos_view = cos(viewangle);
double sin_changle = sin(changle_ice);
double offcone_factor = 1.-nice*cos_view;
//double c_ns = 2.998e-1; // speed of light in m/ns
double c_ns = CLIGHT *1.e-9; // speed of light in m/ns
double Const;
double Integrate = 0.;
double V_s;
//double param_RA[6];
double param_RA[8];