-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTrinityPerformanceCalculations.cpp
More file actions
2244 lines (1783 loc) · 83.7 KB
/
Copy pathTrinityPerformanceCalculations.cpp
File metadata and controls
2244 lines (1783 loc) · 83.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <TF1.h>
#include <TGraph.h>
#include <TGaxis.h>
#include <TTimer.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TMultiGraph.h>
#include <TStyle.h>
#include <TMath.h>
#include <TH1D.h>
#include <TROOT.h>
#include <TApplication.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
Double_t sigma[] = { 660, 920, 1400, 1900, 2500, 3700, 4800, 6200, 8700, 11000, 14000, 19000, 24000, 30000, 39000, 48000, 59000, 75000 }; //pb cc cross section cooper-sarkar 2011
Double_t sigmaNC[] = { 240, 350, 530, 730, 980, 1400, 1900, 2400, 3400, 4400, 5600, 7600, 9600, 12000, 16000, 20000, 24000, 31000 }; //pb
Double_t Esig[] = { 1e6, 2e6, 5e6, 1e7, 2e7, 5e7, 1e8, 2e8, 5e8, 1e9, 2e9, 5e9, 1e10, 2e10, 5e10, 1e11, 2e11, 5e11 }; //GeV
//make plot of length distribution of showers
//make plot of azimuth and elevation distribution as function of distance and wi
//need good estimate of length of shower
//Ghandi 1996
//Double_t sigma[] = { 634, 960, 1412, 1749, 2554, 3630, 4436, 6283, 8700, 10490, 14660, 20100, 23790, 32890, 44270, 53570, 73200, 99270, 117900 }; //pb
//Double_t sigmaNC[] = { 260, 402, 600, 748, 1104, 1581, 1939, 2763, 3837, 4641, 6490, 8931, 10660, 14650, 19950, 23770, 32470, 43770, 51960 }; //pb
//Double_t Esig[] = { 1e6, 2.5e6, 6e6, 1e7, 2.5e7, 6e7, 1e8, 2.5e8, 6e8, 1e9, 2.5e9, 6e9, 1e10, 2.5e10, 6e10, 1e11, 2.5e11, 6e11, 1e12 }; //GeV
int iColors[] = {kBlue-3,kCyan-3,kGreen-3,kYellow-3,kRed-3,kRed+3,kMagenta-3};
int marker[] = { 23, 22, 29, 21, 20, 28, 25};
double markerSize[] = { 0.9, 0.9, 1.2, 0.7, 0.9, 1.3, 0.9};
TF1 *fPE = 0;
Double_t c = 299792; //km/s
Double_t pi = 3.14159265359;
Double_t DecayTime = 0.290e-12; //s
Double_t Mtau = 1.7768; //GeV
Double_t REarth = 6371; //km
//All the coefficients to get the right PE intensity
///////////////////////////////
Int_t iConfig = 2;
double DetectorAltitude[] = { 0, 1, 2, 3};
//obtained from 3e4 GeV gamma rays
double lincorr[] = { 0.0509251, 0.0522854, 0.0595455, 0.0642221};
double scalefirst[] = { 1.00001, 1.03346, 1.53535, 2.36961};
double eleScaling[] = { 0.00163848, 0.00191408, 0.0071185, 0.0513182};
double absorptionlength[] = { 16.7049, 16.6106, 17.9808, 19.0274};
//Parameterization of PE distribution at 50km, 0ele, and 0 Altitude
//par[0]*exp(-xx/par[1])+par[2]*exp(-xx/(par[3]+xx*par[4]))
double parPEF[] = { 0.000332267, 0.580756, 4.25751e-05, 1.9491, 0.0427249};
/*
//obtained from 1e6 GeV gamma rays
double lincorr[] = { 0.0497124, 0.0493805, 0.0552341, 0.0604423};
double scalefirst[] = { 1.00001, 1.02504, 1.42546, 1.73371};
double eleScaling[] = { 0.00143344, 0.00164536, 0.00419904, 0.00479111};
double absorptionlength[] = { 16.7647, 16.8572, 18.3202, 19.4597};
//Parameterization of PE distribution at 50km, 0ele, and 0 Altitude
//par[0]*exp(-xx/par[1])+par[2]*exp(-xx/(par[3]+xx*par[4]))
double parPEF[] = { 0.00038827, 0.555588, 4.66631e-05, 1.90266, 0.0426453};
*/
///////////////////////
Double_t dMinEnu = 8.5;
Double_t dMaxEnu = 9.5;
Double_t dST = 10; //km max height of shower tip above ground;
Double_t yMin = 1;
Double_t yMax = 60;
Double_t yDelta = 1;
Double_t MaxElevation = 10; //elevation angle (determines path through Earth;
Double_t DeltaAngle = 0.1; //steps in azimuth and elevation
Double_t DeltaAngleAz = 0.3; //steps in azimuth
Double_t nuIndex = 2; //power law index of the neutrino spectrum the minus sign is added later
Double_t dMaxCherenkovAzimuthAngle = 40.0; //maximum azimuth angle for cherenkov
Double_t dMaxFluorescenceDistance = 100;
//next three parameters are key to the instrument
//plus the telescop height above ground which can be selected above
Double_t tanFoV = tan(5/180.*pi); //Field of view of telescope above the horizon
Double_t dFoVBelow = 5/180.*pi; //Field of view of telescope below horizon
Double_t dMinLength = 0.3; //mimnimum length a shower has to have in the camera, in degrees. This is a conservative estimate because it assumes that the shower starts at a distance l from the detector, which is not necessarily tru for showers with shallow elevation angles.
Double_t dMinimumNumberPhotoelectrons = 20;
Int_t iMirrorSize = 1;
Double_t dMirrorA[] = {1.0, 5.0, 10.0, 100.0}; //m^2
//Double_t dThreshold[] = {8*3, 19*3, 22*3, 120*3}; //pe //three fold coincidence.
//Double_t dThreshold[] = {10*2, 22*2, 24*2, 155*2}; //pe //two fold coincidence
Double_t dThreshold[] = {10*2, 22*2, 24*2, 155*2}; //pe //two fold coincidence
Bool_t bFluorescence = kFALSE;
Bool_t bCombined = kFALSE;
Bool_t bMonoNu = kFALSE; //simulate monoenergetic neutrinos, only good for acceptance calculation. For all other simulations set it to kFALSE
TGraph *grsCC;
TGraph *grsNC;
TH1D *hTriggeredAzimuthAngles;
string Hold()
{
string input;
//hold the code;
TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
timer.TurnOn();
cout<<"Press Enter to continue:"<<endl;
getline(cin,input);
timer.TurnOff();
return input;
}
Double_t myPEfunction(Double_t *x, Double_t *par)
{
//par[0] Distance to where tau comes out in km
//par[1] Elevation in rad
//azimuth angle is our x
Float_t xx =x[0]; //angle is rad here
//if angle is larger 40 degrees return 0
if(xx>0.69813170)
return 0;
//Calculate azimuth angle in frame of master pe distribution (50km, 0ele,
//0altitude
Double_t dTelAngle = atan(DetectorAltitude[iConfig]*1e-3/par[0]);
Double_t dAngle = sqrt(xx*xx + (par[1]-dTelAngle)*(par[1]-dTelAngle))*57.295780; //in deg
//calculate how many PEs / per m2 per GeV
Double_t f = 0;
if(dAngle<1.3)
f = parPEF[0]*exp(-1.1/parPEF[1])+parPEF[2]*exp(-1.1/(parPEF[3]+1.1*parPEF[4]));
else
f = parPEF[0]*exp(-dAngle/parPEF[1])+parPEF[2]*exp(-dAngle/(parPEF[3]+dAngle*parPEF[4]));
//other parameters to get PE intensity for different distance, azimuth and
//elevation
//scale PE distribution to first PE distribution at 50km distance
f*= scalefirst[iConfig];
//Get elevation dependence
f*= (2-exp(-par[1]/eleScaling[iConfig]));
//Get Distance dependence
f*= exp(-(par[0]-55)/
(absorptionlength[iConfig]+(par[0]-55)*lincorr[iConfig])); //55km is the distance for which the normalized PE distribution is extracted
return f;
}
Double_t DistanceThroughEarth(Double_t y, Double_t elevation, Double_t azimuth)
{
elevation = elevation/180*pi; //elevation angle (determines path through Earth;
azimuth = azimuth/180.*pi; //azimuth angle
Double_t l = y; //Distance from detector to where the tau comes out detector is always at z=0
Double_t v = sqrt((REarth+DetectorAltitude[iConfig])*(REarth+DetectorAltitude[iConfig])-REarth*REarth);
//shortest distance d between tau trajectory and detector
Double_t nproj = y*sqrt( 1 + tan(azimuth)*tan(azimuth) ); //projection of trajectory to x-y plane
Double_t denomsquared= y*tan(azimuth)*y*tan(azimuth) + y*y + nproj*nproj*tan(elevation)*tan(elevation) ;
//normalized trajectory vector of tau
Double_t dNormalize = y/sqrt(denomsquared);
//Double_t dNx = dNormalize * tan(azimuth);
Double_t dNy = -dNormalize;
Double_t dNz = dNormalize * sqrt( 1 + tan(azimuth)*tan(azimuth) ) * tan(elevation);
Double_t p = 2 * ( REarth*dNz - (v-l)*dNy );
Double_t q = (v-l)*(v-l);
if(q-p*p/4>=0) //trajectory does not intersect with Earth
return 0;
Double_t i1 = p/2. - sqrt(p*p/4.-q);
Double_t i2 = p/2. + sqrt(p*p/4.-q);
return fabs(i2-i1);
}
string star ;
double number;
int distanceNumber;
vector<double> enerNu,enerTau,prob,dist,EtauNorm;
unsigned rem = 0 ;
void removeDuplicates()
{
while(rem < enerNu.size()-1){
if(enerNu[rem]==enerNu[rem+1]){
enerNu.erase(enerNu.begin()+rem+1);
removeDuplicates();
}else if(enerNu[rem+1]==enerNu[rem+2]){
rem ++;
removeDuplicates();
}
}
}
void readFromTable(){
ifstream ifs("table_with_e_05_a_1.txt") ;
if(ifs.is_open()){
ifs>>star;
while(ifs.good()){
ifs>>number;
enerNu.push_back( pow(10,number-9.0) );
ifs>>number;
//angle.push_back(number);
dist.push_back(cos((180-number)*pi/180)*2*REarth);
for(int i=0;i<100;i++){
ifs>>number;
enerTau.push_back( pow(10,number-9.0) );
EtauNorm.push_back( pow(10,4+i*0.07) );
ifs>>number;
prob.push_back(number);
}
ifs>>number;
enerTau.push_back( pow(10,number-9.0) );
EtauNorm.push_back( pow(10,4+100*0.07) );
ifs>>star;
}
cout << "size: " << enerNu.size() << endl;
removeDuplicates() ;
}
}
void findAngleNumber(){
for(unsigned i=1;i<enerNu.size();i++){
if(dist[0]==dist[i]){
distanceNumber = i;
break;
}else{
continue ;
}
}
}
double biLinearInterpolation(double a1,double n1,double q11,double a2,double n2,double q22,double x,double y){
double q12 = (q11 + q22)/2 ;
double q21 = q12 ;
double p = (n2-y)/(n2-n1)*( (a2-x)/(a2-a1)*q11 + (x-a1)/(a2-a1)*q21 ) + (y-n1)/(n2-n1)*( (a2-x)/(a2-a1)*q12 + (x-a1)/(a2-a1)*q22 ) ;
return p ;
}
//Find index in lookuptable
int FindLion(double dValue, vector<double> &vData,int iSize)
{
int iWidth = iSize/2;
int index = iWidth;
//cout<<dValue<<": ";
while(iWidth>1 && vData[index]!=dValue && index > 0 && index <iSize)
{
iWidth = iWidth/2+ iWidth%2;
index = vData[index]<dValue ? index + iWidth : index - iWidth;
//cout<<index<<" "<<iWidth<<" "<<vData[index]<<"; ";
}
while((dValue>vData[index] || index<0) && index < iSize)
index++;
index--;
if(dValue==vData[index] || index>=iSize)
index--;
if(index<0)
index=0;
//cout<<index<<endl;
return index;
}
//Calculates the probability of tau emergence using NuTauSim LUT
Double_t PEtauNTauSim(Double_t D,Double_t Etau, Double_t Enu, TH1D *hTau)
{
//Enu = log10(Enu) + 9.0;
//Etau = log10(Etau) + 9.0 ;
//double zenithAngle = 180 - acos(D/2/REarth)/M_PI*180 ;
// if(zenithAngle >= angle[0] && zenithAngle <= angle[angleNumber-1] && Enu>=enerNu[0] && Enu <=enerNu[enerNu.size()-1]){
if(D >= dist[0] && D <= dist[distanceNumber-1] && Enu>=enerNu[0] && Enu <=enerNu[enerNu.size()-1] && Etau>=enerTau[0] && Etau <=enerTau[100]){
int indexEnu = FindLion(Enu,enerNu,enerNu.size());
int indexDistance = FindLion(D,dist,distanceNumber);
int indexEtau = FindLion(Etau,enerTau,100);
int indexProb1 = indexEnu*distanceNumber*100+indexDistance*100+indexEtau;
double p1 = prob[indexProb1] ;
int indexProb2 = (indexEnu+1)*distanceNumber*100 + (indexDistance+1)*100 + indexEtau ;
double p2 = prob[indexProb2] ;
double Prob = biLinearInterpolation(dist[indexDistance],enerNu[indexEnu],p1,dist[indexDistance+1],enerNu[indexEnu+1],p2,D,Enu)/
(EtauNorm[indexEtau+1]-EtauNorm[indexEtau]);
//(pow(10,4+(indexEtau+1)*0.07)-pow(10,4+indexEtau*0.07));
//cout<<Prob<<endl;
return Prob ;
}else{
return 0 ;
}
}
//Probability that Tau with Energy Etau emerges for initial nu energy Enu
//Thickness of matter d
//Does not use energy loss of tau in Earth.
//Assumes the energy of the tau is 0.8*Enu
//Double_t PEtauNoTauEnergyLoss(Double_t D,Double_t Etau, Double_t Enu, TH1D *hTau)
//Double_t PEtauNoTauEnergyLoss(Double_t D,Double_t Etau, Double_t Enu, TH1D *hTau)
Double_t PEtau(Double_t D,Double_t Etau, Double_t Enu, TH1D *hTau)
{
int n = hTau->FindBin(Etau);
if(hTau->GetBinLowEdge(n)>0.8*Enu || hTau->GetBinLowEdge(n+1)<0.8*Enu )
return 0;
Double_t sCC = grsCC->Eval(Enu); //crossection in pB
Double_t sNC = grsNC->Eval(Enu); //crossection in pB
Double_t rho = 2.65; //density in g/cm3
Double_t NA = 6.022142e23;
Double_t dInvConvCC = sCC*rho*NA*1e-31; // 1/km 1e-12*1e-28*1e4*1e5
Double_t db = (sNC+sCC)*rho*NA*1e-31; // 1/km
Double_t da = Mtau/(DecayTime*c*0.8*Enu); //1/km
//cout<<dInvConvCC<<endl;
//cout<<"neutrino interaction: "<<db<<" "<<exp(-1.0*db*D)<<endl;
//cout<<"tau survival: "<<da<<" "<<exp(-1.0*da*D)<<endl;
Double_t Prob = dInvConvCC / (da-db) * ( exp(-1.0*db*D)-exp(-1.0*da*D) );
if(Prob<0)
return 0;
Prob /= (hTau->GetBinLowEdge(n+1)-hTau->GetBinLowEdge(n));
return Prob;
}
//Probability that Tau with Energy Etau emerges for initial nu energy Enu
//Thickness of matter d
//follows description in Dutta 2005 in particular equation 28 with
//parameterization of beta in equation 13 case II
//energies in GeV distances in km at inptut
//Fails <1e8 GeV because energy loss (Beta) becoms <0
Double_t PEtauDutta(Double_t D,Double_t Etau, Double_t Enu,TH1D *hTau)
{
if(Etau>0.8*Enu)
return 0;
Double_t sCC = grsCC->Eval(Enu); //crossection in pB
Double_t sNC = grsNC->Eval(Enu); //crossection in pB
Double_t rho = 2.65; //density in g/cm3
Double_t NA = 6.022142e23;
Double_t dInvConvCC = sCC*rho*NA*1e-31; // 1/km 1e-12*1e-28*1e4*1e5
Double_t dInvConvtotal = (sNC+sCC)*rho*NA*1e-31; // 1/km
Double_t beta = 1.2e-6 + 0.16e-6 * log(Etau/1e10); //cm2/g Equation 13 case II in Dutta
//cout<<"beta "<<beta<<endl;
Double_t prefactor = Mtau/(DecayTime*c*1e5*beta*rho*Etau); //dimensionless
//cout<<"Prefactor: "<<prefactor<<endl;
Double_t xDelta = log(Etau/(0.8*Enu))/(beta*rho)*1e-5+D; //where delta function is non zero; 1e-5 convert from cm to km
if(xDelta<0)
return 0;
//cout<<"beta: "<<beta<<" rho: "<<rho<<" Etau: "<<Etau<<endl;
Double_t Prob = 1.e-5/(beta*rho*Etau); //km/GeV
//cout<<"Prob: "<<Prob<<endl;
Double_t Pnu = dInvConvCC*exp(-xDelta*dInvConvtotal); // 1/km
//cout<<"Pnu: "<<Pnu<<endl;
Prob *= Pnu;
//cout<<"Prob2: "<<Prob<<endl;
if(Prob<0)
return 0;
if(prefactor<0)
return 0;
Double_t Ptau = exp(-prefactor*(1.0-exp(-beta*rho*(D-xDelta)*1e5))); //1e5 to convert from km to cm
//cout<<"Ptau: "<<Ptau<<endl;
//cout<<1.0-exp(-beta*rho*(D-xDelta)*1e5)<<endl;
Prob *= Ptau;
return Prob;
}
Double_t PDecayFluorescence(Double_t Etau, Double_t y, Double_t elevation, Double_t azimuth)
{
//cout<<endl<<"elevation: "<<elevation<<" azimuth: "<<azimuth<<" distance: "<<y<<endl;
elevation = elevation/180*pi; //elevation angle (determines path through Earth;
azimuth = azimuth/180.*pi; //azimuth angle
Double_t l = y; //Distance from detector to where the tau comes out detector is always at z=0
//shortest distance d between tau trajectory and detector
Double_t nproj = y*sqrt( 1 + tan(azimuth)*tan(azimuth) ); //projection of trajectory to x-y plane
Double_t denomsquared= y*tan(azimuth)*y*tan(azimuth) + y*y + nproj*nproj*tan(elevation)*tan(elevation) ;
//normalized trajectory vector of tau
Double_t dNormalize = y/sqrt(denomsquared);
Double_t dNx = dNormalize * tan(azimuth);
Double_t dNy = -dNormalize;
Double_t dNz = dNormalize * sqrt( 1 + tan(azimuth)*tan(azimuth) ) * tan(elevation);
if(azimuth>=pi/2.)
{
dNx*=-1;
dNy*=-1;
}
//cout<<"trajectory vector normalized x: "<<dNx<<" y: "<<dNy<<" z: "<<dNz<<" normalization: "<<dNormalize<<endl;
//crossproduct of trajectory vector and vector of where tau emerges. Gives the
//distance between the to perpendicular to the trajecotory vector
//Double_t dx = y*dNz;
//Double_t dy = 0;
//Double_t dz = y*dNx;
//Double_t d = sqrt(dx*dx+dy*dy+dz*dz); //shortest distance d between tau trajectory and detector
//Double_t dem = sqrt(l*l-d*d);
//maximum length of trajectory above horizon befor track leaves atmosphere (dST above ground)
//calculation is not entirely correct but we do not max out on this distance
//anyway
Double_t v = sqrt((REarth+DetectorAltitude[iConfig])*(REarth+DetectorAltitude[iConfig])-REarth*REarth);
Double_t phi = elevation + asin( REarth/sqrt(REarth*REarth+(l-v)*(l-v)) ); //if azimuth > 90
Double_t alpha = asin( sin(phi) * sqrt(REarth*REarth+(l-v)*(l-v)) / (REarth+dST) );
Double_t gamma = pi - alpha - phi;
Double_t dMaxDist = (REarth+dST) * sin(gamma)/sin(phi);
//trim the path length to be fully inside the atmosphere, should always be the
//case
Double_t dED = 0; //extra distance
Double_t dInFoV=0; //Distance in between lower edge of FoV and line of sight to horizon
//If the camera FoV below the horizon is larger than the maximum angle needed to
//cover all the solid angle below the horizon, set the FoV below the horizon
//to the maximum angle needed.
Double_t dMaxFoVBelow = asin(REarth/(REarth+DetectorAltitude[iConfig]));
if(dFoVBelow>dMaxFoVBelow)
dFoVBelow=dMaxFoVBelow;
//length of the visible trajectory between the plane to horizon and the lower edge of the camera
//FoV below the horizon
dInFoV = l * sin(dFoVBelow) / ( dNy * sin(dFoVBelow) + dNz * cos(dFoVBelow) );
//length of tau trajectory below the horizon and earth surface
Double_t p = 2 * ( REarth*dNz - (v-l)*dNy );
Double_t q = (v-l)*(v-l);
if(q-p*p/4>=0) //trajectory does not intersect with Earth
return 0;
Double_t i1 = p/2. - sqrt(p*p/4.-q);
Double_t i2 = p/2. + sqrt(p*p/4.-q);
if(i1<0 || i2<0)
cout<<"PDecay: i1 or i2 less than 0: "<<i1<<" "<<i2<<endl;
dED= i1<i2 ? i1 : i2;
if( (dInFoV>dED && dInFoV>0 ) || dInFoV<0)
dInFoV=dED;
if(l>v) //if shower emerges beyond horizon
dInFoV = 0;
dMaxDist = dST/sin(elevation) + dInFoV; //takes into account distance visible below plane to horizon
// cout<<"dMaxDist: "<<dMaxDist<<endl;
Double_t dTermInSquareRoot = cos(elevation)*cos(azimuth)*cos(elevation)*cos(azimuth)
+ sin(elevation)*sin(elevation)/tanFoV/tanFoV
- cos(elevation)*cos(elevation);
if(dTermInSquareRoot>0) //if it is negative the shower is contained in the FoV anywhere along the track
{
//maximum trajectory length before the tip of the shower is not contained in the camera anymore
Double_t dMaxDisttoSatisfyFovReq = l / ( cos(elevation)*cos(azimuth) + sqrt( dTermInSquareRoot ));
//if the value is negative, the elevation angle is less than the Max FoV would have to point below the
//horizon
if(dMaxDist>dMaxDisttoSatisfyFovReq+dInFoV && dMaxDisttoSatisfyFovReq>0) //correct max. trajectory length
dMaxDist = dMaxDisttoSatisfyFovReq+dInFoV;
// cout<<" dMaxDisttoSatisfyFovReq: "<<dMaxDisttoSatisfyFovReq<<endl;
}
//length of shower in camera plane
Double_t dShwrLgth = 0.304 * log(Etau*0.5/0.088)/log(2); //0.304km radiation length at see level, 0.088GeV critical energy of electrons in air,only 0.5 of the energy goes into the electromagnetic shower
//cout<<"Etau "<<Etau<<" size of shower in km: "<<dShwrLgth<<endl;
//cout<<" dMaxDist: "<<dMaxDist<<endl;
//ok have taken all requirements into account. Lets see if the trajectory
//length allows for a full shower development. If not we quit.
if(dMaxDist<dShwrLgth)
return 0;
//make sure the shower does not develop past the point where more than 90% of the
//taus have decayed
Double_t DecayLength = Etau * c * DecayTime / Mtau;
Double_t d90PctDecayLength = -log(0.1)*DecayLength;
//cout<<"90% of taus decayed after: "<<d90PctDecayLength<<endl;
if(d90PctDecayLength+dShwrLgth<dMaxDist)
dMaxDist = d90PctDecayLength+dShwrLgth;
//cout<<" dMaxDist: "<<dMaxDist<<endl;
//calculate how far away from the detector the shower can be to be still
//detected
//emitted light intensity
Double_t dLight = 5.95844e3*Etau; //in photons. 5.958 comes from the macro FluorescenceDetectionYield.C and includes PDE of S14520-6050CN, it is the integral from 300 to 430nm
dLight /= 4 * pi; //so we do not have to do it in every loop below
//and absorption 0.9 at 337nm is used in condition below
Double_t dFluorescenceMaximumDistance = 10; //km
while(1)
{
//the 1e-6 is for a 1m^2 mirror
if(dLight*1e-6/dFluorescenceMaximumDistance/dFluorescenceMaximumDistance*exp(dFluorescenceMaximumDistance*log(0.9))>dMinimumNumberPhotoelectrons)
dFluorescenceMaximumDistance++;
else
break;
//cout<<dFluorescenceMaximumDistance<<" "<<dLight*1e-6/dFluorescenceMaximumDistance/dFluorescenceMaximumDistance*exp(dFluorescenceMaximumDistance*log(0.9))<<endl;
}
dFluorescenceMaximumDistance--;
//cout<<"Maximum Distance between Detector and Shower: "<<dFluorescenceMaximumDistance<<endl;
//don't know if this is actually good
//check if we need to increase limit
if(dMaxDist>dFluorescenceMaximumDistance) //too speed up calculations
dMaxDist=dFluorescenceMaximumDistance;
//now lets check if the size of the shower is fullfilling the minimum length
//requirement
//calculating length of shower in the camera assuming the shower happens late
//and develops up to the maximumg possible point along the trajectory
Double_t dLength = 0.0;
Double_t m = dMaxDist;
Double_t B = sqrt( m* dNx * m* dNx + (m*dNy+y) * (m*dNy+y) + m*dNz * m*dNz );
Double_t A = 0.0;
//This is if the shower passed and develops behind
while(dMaxDist>dShwrLgth && (dLength<dMinLength || B>dFluorescenceMaximumDistance ))
{
Double_t n = dMaxDist - dShwrLgth -dInFoV;
m = dMaxDist;
Double_t A = sqrt( n* dNx * n* dNx + (n*dNy+y) * (n*dNy+y) + n*dNz * n*dNz );
B = sqrt( m* dNx * m* dNx + (m*dNy+y) * (m*dNy+y) + m*dNz * m*dNz );
Double_t costheta = n*dNx * m*dNx + (n*dNy+y)*(m*dNy+y) + m*dNz * n*dNz;
costheta = costheta / (A*B);
dLength = acos(costheta)*180/pi;
// cout<<"l"<<l<<"az"<<azimuth*180/pi<<"size of shower in degrees: "<<dLength<<" cos of angle: "<<costheta<<" dMaxDist "<<dMaxDist<<"dShwrLgth "<<dShwrLgth<<" minimum shower length in deg "<<dMinLength<<" Distance of tip of shower to telescope "<<B<<endl;
if((dLength<dMinLength && B>l) || B>dFluorescenceMaximumDistance )
dMaxDist-=1.0;
else
break;
}
dMaxDist+=1.0;
if(dLength<dMinLength || B>dFluorescenceMaximumDistance || A>dFluorescenceMaximumDistance) //shower is not long enough in the camera or either end of the shower does not produce sufficient intensity in the telescope
return 0;
// need to check if the shower is pointing away from the telescope and if we find a distance in which the tau can decay and develop a shower which appears larger. Need to adjust the distance so the image has the minimal required size.
//Ok finally we are there. Lets decay the tau in the remaining distance we
//have
Double_t ProbTauDecay = exp(-(dED-dInFoV)/DecayLength); //Tau has to to survive before it becomes visible to the detector
ProbTauDecay *= 1-exp(-(dMaxDist-dShwrLgth)/DecayLength); // then it has to decay before it is out of the FoV
ProbTauDecay*=0.8;//only 80% of taus make a shower
//if(azimuth*180/pi>90 && azimuth*180/pi<8.1)
//cout<<"Etau: "<<Etau<<" el: "<<elevation*180/pi<<" az: "<<azimuth*180/pi<<" alpha "<<alpha<<" beta "<<180/pi*(pi - asin(sinbeta))<<" Prob: "<<ProbTauDecay<<" l "<<l<<" v "<<v<<" below horizon: "<<dBH<<" MaxDistOfTrack: "<<dMaxDist<<" minimal distance between trajectory and telescope "<<d<<endl;
return ProbTauDecay;
}
Double_t PDecay(Double_t Etau, Double_t y, Double_t elevation, Double_t azimuth)
{
elevation = elevation/180*pi; //elevation angle (determines path through Earth;
azimuth = azimuth/180.*pi; //azimuth angle
Double_t l = y; //Distance between the detector and the point where the tau emerges from the ground. The detector is always at z=0
//Distance between telescope and horizon
Double_t v = sqrt((REarth+DetectorAltitude[iConfig])*(REarth+DetectorAltitude[iConfig])-REarth*REarth);
//Below: the shortest distance d between tau trajectory and detector d
Double_t nproj = y*sqrt( 1 + tan(azimuth)*tan(azimuth) ); //projection of trajectory to x-y plane
Double_t denomsquared= y*tan(azimuth)*y*tan(azimuth) + y*y + nproj*nproj*tan(elevation)*tan(elevation) ;
//normalized trajectory vector of tau
Double_t dNormalize = y/sqrt(denomsquared);
Double_t dNx = dNormalize * tan(azimuth);
Double_t dNy = -dNormalize;
Double_t dNz = dNormalize * sqrt( 1 + tan(azimuth)*tan(azimuth) ) * tan(elevation);
//cout<<"trajectory vector normalized x: "<<dNx<<" y: "<<dNy<<" z: "<<dNz<<" normalization: "<<dNormalize<<endl;
//crossproduct of the trajectory vector with the vector pointing to where the tau emerged from the ground.
//The magnitude of the cross product gives the distance of closest approach of the tau to the detector as it travels along
//its trajectory
Double_t dx = y*dNz;
Double_t dy = 0;
Double_t dz = y*dNx;
Double_t d = sqrt(dx*dx+dy*dy+dz*dz); //shortest distance d between tau trajectory and detector
//add some extra distance if the tau passes plane in between telescope and
//horizon
//using dED term assumes we see shower in camera but lower edge of FoV is aligned with line of sight to the horizon
Double_t dED = 0; //extra distance
Double_t dInFoV=0; //Distance in between lower edge of FoV and line of sight to horizon
//Reset FoV below to maximum possible if it is larger
Double_t dMaxFoVBelow = asin(REarth/(REarth+DetectorAltitude[iConfig]));
if(dFoVBelow>dMaxFoVBelow)
dFoVBelow=dMaxFoVBelow;
//length of trajectory between plane to horizon and lower edge of camera
//FoV
dInFoV = l * sin(dFoVBelow) / ( dNy * sin(dFoVBelow) + dNz * cos(dFoVBelow) );
//length of trajectory between plane to horizon and earth surface
Double_t p = 2 * ( REarth*dNz - (v-l)*dNy );
Double_t q = (v-l)*(v-l);
if(q-p*p/4>=0) //trajectory does not intersect with Earth
return 0;
Double_t i1 = p/2. - sqrt(p*p/4.-q);
Double_t i2 = p/2. + sqrt(p*p/4.-q);
if(i1<0 || i2<0)
cout<<"PDecay: i1 or i2 less than 0: "<<i1<<" "<<i2<<endl;
dED= i1<i2 ? i1 : i2;
if( (dInFoV>dED && dInFoV>0 ) || dInFoV<0)
dInFoV=dED;
if(l>v) //if shower emerges beyond horizon
dInFoV = 0;
//maximum distance from where tau emerges to that plane
//modify this to take into account extra length if shower emerges before the
//horizon
//add extra length if trajectory crosses plane between telescope and horizon
Double_t dem = sqrt(l*l-d*d) + dInFoV;
//fix this to use elevation measured when shower emerges from ground
fPE->FixParameter(1,elevation ); //Shower elevation in rad
//length of shower in camera plane
Double_t dShwrLgth = 0.304 * log(Etau*0.5/0.088)/log(2); //0.304km radiation length at see level, 0.088GeV critical energy of electrons in air,only 0.5 of the energy goes into the electromagnetic shower
//cout<<"Etau "<<Etau<<" size of shower in km: "<<dShwrLgth<<endl;
//cout<<" dMaxDist: "<<dMaxDist<<endl;
//minimal distance from tip of shower to the plane that is normal to trajectory and goes through the origin (where the detector is located), constrained by maximum angle a sufficient Cherenkov light reaches the detector. values below are 90-a and a in the sines. Need to have functions of tau energy and distance for a
//dd is first used as the distance to the start of the shower not hte tip of
//the shower
Double_t dd = dShwrLgth+5; //we need to at least have the shower develop. note we neglect the decay length here, which does not really matter. That is taken care of later.
if(dd>dem)
dd = dShwrLgth;
while(dd<dem)
{
//move along trajectory and find spot where MaxCherenkovAngle condition is
//fullfilled
Double_t dDistanceToWhereTauStarts = sqrt(d*d+dd*dd);
fPE->FixParameter(0,dDistanceToWhereTauStarts); //Distance to where the tau starts shower
//get new azimuth
Double_t g = (dem-dd) * cos(elevation);
Double_t az = 0;
if(g>0 && azimuth>0)
{
Double_t xi = ( l - g * cos(azimuth)) / (g * sin(azimuth));
az = pi*0.5 + azimuth - atan(xi);
if (dem-dd-dInFoV < 0 ) //if we are below the plane
az = azimuth;
}
else
cout<<"in PDecay, azimuth is zero or g is smaller zero"<<endl;
//get PE for new azimuth
//double az = asin(d/dDistanceToWhereTauStarts); //azimuth for that distance
if(fPE->Eval(az)*Etau*0.5<dMinimumNumberPhotoelectrons)
dd++;
else
break;
}
//cout<<"maximum available length for decay and shower to happen (dem:) "<<dem<<" distance between trajectory and telescope d: "<<d<<" dd: "<<dd<<endl;
//tip of the shower has to be inside the atmosphere. Check if that is the case. if not adjust dd
//cout<<"need to takeaway dd so we can see all the Cherenkov light: "<<dd<<endl;
//if dem is less then dd, which means Cherenkov light will not hit the
//telescope. return 0
if(dd>dem) // the shower cannot be seen by the telescope because the cherenkov cone does not illuminate the telescope anywhere along the track
return 0;
//dd below is used as the distence between the plane perp. to the trajectory
//and the tip of the shower so lets subtract the length of the shower and the
//5 km again
if(dd<dShwrLgth+5)
dd -= dShwrLgth;
else
dd -= (dShwrLgth+5);
//maximum length of trajectory above horizon befor track leaves atmosphere (dST above ground)
Double_t phi = elevation + asin( REarth/sqrt(REarth*REarth+(l-v)*(l-v)) );
Double_t alpha = asin( sin(phi) * sqrt(REarth*REarth+(l-v)*(l-v)) / (REarth+dST) );
Double_t gamma = pi - alpha - phi;
Double_t dMaxDist = (REarth+dST) * sin(gamma)/sin(phi);
//trim the path length to be fully inside the atmosphere, should always be the
//case
if(l>v)//if the shower is not seen over the entire track in the atmosphere and l>v. Reset the maximum possible track length to the portion that can be seen
{
dMaxDist = dMaxDist>dem-dd ? dem-dd : dMaxDist;
}
else//do the same if the shower emerges l<v from telescope v is where the tangent touches earth.
{
dMaxDist = dST/sin(elevation) + dInFoV;
dMaxDist = dMaxDist>dem-dd ? dem-dd : dMaxDist;
}
// Double_t delta = acos(-dNy);
// cout<<"Delta: "<<delta*180/pi<<" angle from tip of shower to telescope: "<<asin(y*sin(delta)/sqrt(y*y+dMaxDist*dMaxDist-2*dMaxDist*y*cos(delta)))*180/pi <<" shortest distance so Cherenkov light goes to camera: "<<dd<<endl;
Double_t dTermInSquareRoot = cos(elevation)*cos(azimuth)*cos(elevation)*cos(azimuth)
+ sin(elevation)*sin(elevation)/tanFoV/tanFoV
- cos(elevation)*cos(elevation);
if(dTermInSquareRoot>0) //if it is negative the shower is contained in the FoV anywhere along the track
{
//maximum trajectory length before the tip of the shower is not contained in the camera anymore
Double_t dMaxDisttoSatisfyFovReq = l / ( cos(elevation)*cos(azimuth) + sqrt( dTermInSquareRoot )) + dInFoV;
if(dMaxDist>dMaxDisttoSatisfyFovReq+dInFoV && dMaxDisttoSatisfyFovReq>0) //correct max. trajectory length
dMaxDist = dMaxDisttoSatisfyFovReq+dInFoV;
// cout<<" dMaxDisttoSatisfyFovReq: "<<dMaxDisttoSatisfyFovReq<<endl;
}
//ok have taken all requirements into account. Lets see if the trajectory
//length allows for a full shower development.
//If not we quit.
if(dMaxDist<dShwrLgth)
return 0;
//make sure the shower does not develop past the point where more than 90% of the
//taus have decayed
Double_t DecayLength = Etau * c * DecayTime / Mtau;
Double_t d90PctDecayLength = -log(0.1)*DecayLength;
//cout<<"90% of taus decayed after: "<<d90PctDecayLength<<endl;
if(d90PctDecayLength+dShwrLgth<dMaxDist)
dMaxDist = d90PctDecayLength+dShwrLgth;
//now lets check if the size of the shower is fullfilling the minimum length
//requirement
//calculating length of shower in the camera assuming the shower happens late
//and develops up to the maximumg possible point along the trajectory
//add that distance is within maximum distance like we do for the Fluorescence
//part
Double_t n = dMaxDist - dShwrLgth -dInFoV;
Double_t m = dMaxDist;
Double_t A = sqrt( n* dNx * n* dNx + (n*dNy+y) * (n*dNy+y) + n*dNz * n*dNz );
Double_t B = sqrt( m* dNx * m* dNx + (m*dNy+y) * (m*dNy+y) + m*dNz * m*dNz );
Double_t costheta = n*dNx * m*dNx + (n*dNy+y)*(m*dNy+y) + m*dNz * n*dNz;
costheta = costheta / (A*B);
Double_t dLength = acos(costheta)*180/pi;
//cout<<"size of shower in degrees: "<<dLength<<" cos of angle: "<<costheta<<endl;
if(dLength<dMinLength) //shower image is too short
return 0;
//Ok finally we are there. Lets decay the tau in the remaining distance we
//have
//Probabilty that tau survives if it is not in the field of view
//below works for tau emerging beyond horizon and before horizon
Double_t ProbTauDecay = exp(-(dED-dInFoV)/DecayLength); //Tau has to to survive before it becomes visible to the detector
ProbTauDecay *= 1-exp(-(dMaxDist-dShwrLgth)/DecayLength); // then it has to decay before it is out of the FoV
ProbTauDecay*=0.8;//only 80% of taus make a shower
//if(azimuth*180/pi>90 && azimuth*180/pi<8.1)
//cout<<"Etau: "<<Etau<<" el: "<<elevation*180/pi<<" az: "<<azimuth*180/pi<<" alpha "<<alpha<<" beta "<<180/pi*(pi - asin(sinbeta))<<" Prob: "<<ProbTauDecay<<" l "<<l<<" v "<<v<<" below horizon: "<<dBH<<" MaxDistOfTrack: "<<dMaxDist<<" minimal distance between trajectory and telescope "<<d<<endl;
return ProbTauDecay;
}
void PlotEmergenceProbability()
{
TH1D *hTau = new TH1D("hTauS","",70,4,11);
//hTau->SetMaximum(1);
hTau->GetXaxis()->SetTitle("energy [GeV]");
hTau->GetYaxis()->SetTitle("F_tau/F_nu");
TAxis *axis = hTau->GetXaxis();
int bins = axis->GetNbins();
Axis_t from = axis->GetXmin();
Axis_t to = axis->GetXmax();
Axis_t width = (to - from) / bins;
Axis_t *new_bins = new Axis_t[bins + 1];
for (int i = 0; i <= bins; i++) {
new_bins[i] = TMath::Power(10, from + i * width);
}
axis->Set(bins, new_bins);
TMultiGraph *mg = new TMultiGraph();
TLegend *leg = new TLegend(0.7,0.4,0.89,0.88,"neutrino energy");
double Enulog = 11;
double Enuminlog = 5.9;
double Enusteplog = 0.5;
int s=0;
while(Enulog>Enuminlog)
{
//cout<<Enulog<<endl;
double Enu = pow(10,Enulog);
TGraph *grProb = new TGraph();
grProb->SetMarkerStyle(20+s);
TString title;
title.Form("%0.0e GeV",Enu);
leg->AddEntry(grProb,title.Data(),"p");
mg->Add(grProb,"lp");
s++;
// loop over target thickness
double d = 0; //in 10^dmin km
double dmax = 4;
double dstep = 0.2;
int p=0;
while(d<dmax)
{
double targetthickness = pow(10,d);
double dSumProb = 0;
hTau->Reset();
for(int i=1;i<hTau->GetNbinsX();i++)
{
Double_t Etau = hTau->GetBinCenter(i+1);
if(hTau->GetBinLowEdge(i+2)<=Enu)
{
Double_t P = PEtau(targetthickness,Etau,Enu,hTau);
//cout<<i+1<<" "<<targetthickness<<" . "<<Etau<<" "<<Enu<<" P "<<P<<endl;
P *= (hTau->GetBinLowEdge(i+1)-hTau->GetBinLowEdge(i));
hTau->Fill(Etau,P);
hTau->SetBinError(i,0);
dSumProb+=P;
}
}//got the energy spectrum of the taus for this azimuth and elevation
grProb->SetPoint(p,targetthickness,dSumProb);
p++;
d+=dstep;
}
Enulog-=Enusteplog;
}
TCanvas *cProbOfEmergence = new TCanvas("cProbOfEmergence","Probability of emergence",750,500);
cProbOfEmergence->Draw();
cProbOfEmergence->SetLogx();
cProbOfEmergence->SetLogy();
mg->Draw("a");
mg->GetXaxis()->SetTitle("target thickness [km]");
mg->GetXaxis()->SetTitleSize(0.045);
mg->GetXaxis()->SetTitleOffset(1.1);
mg->GetXaxis()->SetLabelSize(0.045);
mg->GetYaxis()->SetTitle("probability of #tau emergence");
mg->GetYaxis()->SetTitleOffset(1.0);
mg->GetYaxis()->SetTitleSize(0.045);
mg->GetYaxis()->SetLabelSize(0.045);
mg->GetYaxis()->SetRangeUser(1e-6,1);
// mg->GetXaxis()->SetRangeUser(1,5e3);
leg->Draw();
//TF1 *fdeg=new TF1("fdeg","90-180/3.1415*TMath::ASin(0.5*x/6371)",0,1e4);
cout<<mg->GetXaxis()->GetXmin()<<endl;
cout<<180/3.1415*TMath::ASin(0.5*mg->GetXaxis()->GetXmin()/6371)<<" "<<180/3.1415*TMath::ASin(0.5*mg->GetXaxis()->GetXmax()/6371)<<endl;
TF1 *fdeg=new TF1("fdeg","x",180/3.1415*TMath::ASin(0.5*mg->GetXaxis()->GetXmin()/6371),180/3.1415*TMath::ASin(0.5*mg->GetXaxis()->GetXmax()/6371));
fdeg->Eval(0);
TGaxis *degaxis = new TGaxis(mg->GetXaxis()->GetXmin(),1,mg->GetXaxis()->GetXmax(),1,"fdeg",510,"-G");
degaxis->SetTitle("elevation angle [degrees]");
degaxis->SetTitleFont(42);
degaxis->SetLabelFont(42);
degaxis->Draw();
}
void GetTauDistribution(TH1D *hTauSpec, Double_t d, Double_t Enumin = 1e9, Double_t Enumax = 3.16e9)
{
hTauSpec->Reset(); //get the energy spectrum of taus coming out of the Earth, starting with nus in the range expmin expMax
//int nEnuSteps = 20;
//Double_t DeltaEnu = (Enumax - Enumin)/nEnuSteps;
Double_t DeltaEnu = 0.1; //logscale
int nEnuSteps = (0.0001+log10(Enumax) - log10(Enumin))/DeltaEnu; //the 0.0001 is due to small uncertainties making sure we get the right number of steps
Double_t Normalization = (nuIndex-1)/(pow(Enumin,1-nuIndex)-pow(Enumax,1-nuIndex));
vector<double> Enu;
vector<double> EnuWeight;
for(int i=0;i<nEnuSteps;i++)
{
//Enu.push_back(Enumin+i*DeltaEnu+0.5*DeltaEnu);
//NO Enu.push_back(pow(10,(log10(Enumin+i*DeltaEnu)+log10(Enumin+(i+1)*DeltaEnu))*0.5));
Enu.push_back(pow(10,log10(Enumin)+i*DeltaEnu+DeltaEnu*0.5));
//EnuWeight.push_back(pow(Enumin+i*DeltaEnu+0.5*DeltaEnu,-nuIndex)*Normalization*DeltaEnu);
//NO EnuWeight.push_back(pow(Enu[Enu.size()-1],-nuIndex)*Normalization*DeltaEnu);
EnuWeight.push_back(pow(Enu[Enu.size()-1],-nuIndex)*Normalization*
(pow(10,log10(Enumin)+(i+1)*DeltaEnu)-pow(10,log10(Enumin)+i*DeltaEnu)));
}
for(int i=1;i<=hTauSpec->GetNbinsX();i++)
{
Double_t Etau = hTauSpec->GetBinCenter(i);
//loop over all Enu in this energy bin to calculate the sensitivity
if(bMonoNu) //if we want to simulate only monoenergetic neutrinos (only good for acceptance calculations
{
//NO removed because that is transferred into PEtau
//if(Etau<=0.8*Enu) //0.8 because I need to account for part of the energy being transferred to the also produced neutrinos
{
Double_t Enu = pow(10,(log10(Enumin)+log10(Enumax))*0.5);
Double_t P = PEtau(d,Etau,Enu,hTauSpec);
hTauSpec->Fill(Etau,P);
}
}
else
{
//while(Enu<Enumax)//loop over nu energy bin
for(int n = 0; n<nEnuSteps;n++)
{
//NO removed because that is transferred into PEtau
//if(Etau<=0.8*Enu) //0.8 because I need to account for part of the energy being transferred to the also produced neutrinos
{
Double_t P = 0;
//if(Enu==Enumin) //mod
P = PEtau(d,Etau,Enu[n],hTauSpec);
//if(Enu==Enumin) //mod
//cout<<P<<" "<<d<<" "<<Etau<<" "<<Enu[n]<<" "<<EnuWeight[n]<<endl; //mod
//P *= DeltaEnu/(Enumax-Enumin);
P *= EnuWeight[n];
//do not know how the below is calculated
//P *= ( pow(Enu,1-nuIndex) - pow(Enu+DeltaEnu,1-nuIndex) )
// / ( pow(Enumin,1-nuIndex) - pow(Enumax,1-nuIndex) );//multiplying in the with
hTauSpec->SetBinContent(i,hTauSpec->GetBinContent(i)+P);
//hTauSpec->Fill(Etau,P);