7 #include "earthmodel.hh" 14 #include "ChanTrigger.h" 39 #include "EnvironmentVariable.h" 41 #ifdef ANITA_UTIL_EXISTS 43 #include "AnitaEventCalibrator.h" 44 #include "AnitaGeomTool.h" 45 #include "AnitaConventions.h" 48 #include "icemc_random.h" 50 const std::string ICEMC_DATA_DIR=ICEMC_SRC_DIR+
"/data/";
63 arrival_times[0][irx]=arrival_times[1][irx]=0.;
68 Tools::Zero(VNOISE_ANITALITE,16);
69 INCLINE_TOPTHREE = 10.;
71 SIGMA_THETA=0.5*RADDEG;
112 Tools::Zero(bwslice_thresholds,5);
113 for (
int i=0;i<5;i++) {
114 bwslice_allowed[i]=1;
116 bwslice_required[0]=0;
117 bwslice_required[1]=0;
118 bwslice_required[2]=0;
119 bwslice_required[3]=0;
120 bwslice_required[4]=1;
127 bwslice_center[0]=265.e6;
128 bwslice_center[1]=435.e6;
129 bwslice_center[2]=650.e6;
130 bwslice_center[3]=980.e6;
131 bwslice_center[4]=682.5E6;
133 bwslice_width[0]=130.e6;
134 bwslice_width[1]=160.e6;
135 bwslice_width[2]=250.e6;
136 bwslice_width[3]=370.e6;
137 bwslice_width[4]=965.E6;
141 for (
int i=0;i<4;i++) {
142 bwslice_min[i]=bwslice_center[i]-bwslice_width[i]/2.;
143 bwslice_max[i]=bwslice_center[i]+bwslice_width[i]/2.;
146 for (
int i = 0; i < 5; i++)
149 imaxbin[i] = NFOUR/2;
152 bwslice_min[4]= bwslice_center[0]-bwslice_width[0]/2.;
153 bwslice_max[4]=bwslice_center[3]+bwslice_width[3]/2.;
159 const char* outputdir;
160 outputdir =
"outputs";
163 if (stat(outputdir, &sb) == 0 && S_ISDIR(sb.st_mode))
169 mkdir(outputdir,S_IRWXU);
176 coherent_datafile->cd();
178 coherent_waveform_sum_tree->Write();
179 coherent_datafile->Write();
181 coherent_waveform_sum_tree->Delete();
182 coherent_datafile->Close();
183 coherent_datafile->Delete();
189 int Anita::Match(
int ilayer,
int ifold,
int rx_minarrivaltime) {
191 if (ilayer==GetLayer(rx_minarrivaltime) && ifold==GetIfold(rx_minarrivaltime))
200 for (
int i=0;i<ilayer;i++) {
218 return GetRx(ilayer,ifold);
225 if (settings1->WHICH==2 || settings1->WHICH==6) {
226 for (
int il=0;il<NLAYERS_MAX;il++) {
227 bwslice_vnoise[il][0]=5.5125E-6;
228 bwslice_vnoise[il][1]=6.1157E-6;
229 bwslice_vnoise[il][2]=7.64446E-6;
230 bwslice_vnoise[il][3]=9.29989E-6;
231 bwslice_vnoise[il][4]=0.;
232 for (
int i=0;i<4;i++) {
233 bwslice_vnoise[il][4]+=bwslice_vnoise[il][i]*bwslice_vnoise[il][i];
235 bwslice_vnoise[il][4]=sqrt(bwslice_vnoise[il][4]);
239 for (
int il=0;il<NLAYERS_MAX;il++) {
240 for (
int ibw=0;ibw<5;ibw++) {
241 bwslice_vnoise[il][ibw]=
ChanTrigger::GetNoise(settings1,bn1->altitude_bn,antarctica->SurfaceAboveGeoid(bn1->
phi_bn,bn1->theta_bn),THETA_ZENITH[il],bwslice_max[ibw]-bwslice_min[ibw],0.);
254 count_getnoisewaveforms=0;
255 rms_lab[0]=rms_lab[1]=0.;
256 rms_rfcm[0]=rms_rfcm[1]=0.;
263 TIMESTEP=(1./2.6)*1.E-9;
267 if (settings1->WHICH==10) ntuffs=7;
269 for (
int i=0;i<HALFNFOUR;i++) fTimes[i] = i * TIMESTEP * 1.0E9;
271 for (
int i=0;i<NFREQ;i++) {
272 freq[i]=FREQ_LOW+(FREQ_HIGH-FREQ_LOW)*(
double)i/(double)NFREQ;
274 avgfreq_rfcm_lab[i]=0.;
277 initializeFixedPowerThresholds(foutput);
280 if (settings1->WHICH==10){
282 powerthreshold[4] = -3.1;
285 if (settings1->TRIGGERSCHEME==5)
290 minsignalstrength=0.1;
295 INTEGRATIONTIME=3.5E-9;
302 TRIG_TIMESTEP=3.75E-9;
305 MIN_PHI_HYPOTHESIS=-22.5;
306 MAX_PHI_HYPOTHESIS=22.5;
307 MIN_THETA_HYPOTHESIS=-50.;
308 MAX_THETA_HYPOTHESIS=20.;
312 double freqstep=1./(double)(NFOUR/2)/TIMESTEP;
315 for (
int i=0;i<HALFNFOUR;i++) {
316 freq_forfft[2*i]=(double)i*freqstep;
317 freq_forfft[2*i+1]=(double)i*freqstep;
319 if (i<HALFNFOUR/2) freq_forplotting[i]=freq_forfft[2*i];
324 readVariableThresholds(settings1);
335 getLabAttn(NPOINTS_LAB,freqlab,labattn);
338 getDiodeDataAndAttenuation(settings1, outputdir);
340 if (settings1->PULSER==1) {
345 reference_angle[0]=0.;
346 reference_angle[1]=5.;
347 reference_angle[2]=10.;
348 reference_angle[3]=20.;
349 reference_angle[4]=30.;
350 reference_angle[5]=45.;
351 reference_angle[6]=90.;
354 THERMALNOISE_FACTOR=settings1->THERMALNOISE_FACTOR;
355 for (
int j=0;j<settings1->NLAYERS;j++) {
358 VNOISE[j]=1.52889E-5;
359 VNOISE[j]*=THERMALNOISE_FACTOR;
362 #ifdef ANITA_UTIL_EXISTS 363 if (settings1->NOISEFROMFLIGHTDIGITIZER || settings1->NOISEFROMFLIGHTTRIGGER){
364 readNoiseFromFlight(settings1);
366 if (settings1->APPLYIMPULSERESPONSEDIGITIZER){
367 readImpulseResponseDigitizer(settings1);
368 if(settings1->TUFFSTATUS>0){
369 readTuffResponseDigitizer(settings1);
370 readTuffResponseTrigger(settings1);
373 if (settings1->APPLYIMPULSERESPONSETRIGGER){
374 readImpulseResponseTrigger(settings1);
379 if (settings1->WHICH==10){
381 double denom, trig, dig;
385 RayleighFits[0][3] = (TGraph*)RayleighFits[0][2]->Clone();
386 RayleighFits[1][4] = (TGraph*)RayleighFits[1][3]->Clone();
388 RayleighFits[1][27] = (TGraph*)RayleighFits[1][26]->Clone();
389 RayleighFits[1][46] = (TGraph*)RayleighFits[1][47]->Clone();
390 RayleighFits[0][27] = (TGraph*)RayleighFits[0][26]->Clone();
391 RayleighFits[0][28] = (TGraph*)RayleighFits[0][29]->Clone();
392 RayleighFits[0][32] = (TGraph*)RayleighFits[0][33]->Clone();
394 RayleighFits[1][9] = (TGraph*)RayleighFits[1][5]->Clone();
395 RayleighFits[1][42] = (TGraph*)RayleighFits[1][6]->Clone();
397 for (
int ifreq=0; ifreq<numFreqs; ifreq++){
398 fSignalChainResponseA3DigitizerFreqDomain[0][0][3][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[0][0][2][ifreq];
399 fSignalChainResponseA3DigitizerFreqDomain[1][0][4][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[1][0][3][ifreq];
401 fSignalChainResponseA3DigitizerFreqDomain[1][1][11][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[1][1][10][ifreq];
402 fSignalChainResponseA3DigitizerFreqDomain[1][2][14][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[1][2][15][ifreq];
403 fSignalChainResponseA3DigitizerFreqDomain[0][1][11][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[0][1][10][ifreq];
404 fSignalChainResponseA3DigitizerFreqDomain[0][1][12][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[0][1][13][ifreq];
405 fSignalChainResponseA3DigitizerFreqDomain[0][2][0][ifreq] =fSignalChainResponseA3DigitizerFreqDomain[0][2][1][ifreq];
407 fSignalChainResponseA3DigitizerFreqDomain[1][0][9][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[1][0][5][ifreq];
408 fSignalChainResponseA3DigitizerFreqDomain[1][2][10][ifreq]=fSignalChainResponseA3DigitizerFreqDomain[1][0][6][ifreq];
414 calculateImpulseResponsesRatios(settings1);
417 if (settings1->TRIGGEREFFSCAN){
418 readTriggerEfficiencyScanPulser(settings1);
426 setDiodeRMS(settings1, outputdir);
431 string stemp=string(outputdir.Data())+
"/signals.root";
432 fsignals=
new TFile(stemp.c_str(),
"RECREATE");
433 tsignals=
new TTree(
"tsignals",
"tsignals");
435 stemp=string(outputdir.Data())+
"/data.root";
436 fdata=
new TFile(stemp.c_str(),
"RECREATE");
437 tdata=
new TTree(
"tdata",
"tdata");
440 tsignals->Branch(
"signal_vpol_inanita",&signal_vpol_inanita,
"signal_vpol_inanita[5][512]/D");
441 tsignals->Branch(
"timedomainnoise_rfcm_banding",&timedomainnoise_rfcm_banding,
"timedomainnoise_rfcm_banding[2][5][512]/D");
442 tsignals->Branch(
"total_vpol_inanita",&total_vpol_inanita,
"total_vpol_inanita[5][512]/D");
443 tsignals->Branch(
"total_diodeinput_1_inanita",&total_diodeinput_1_inanita,
"total_diodeinput_1_inanita[5][512]/D");
444 tsignals->Branch(
"total_diodeinput_2_inanita",&total_diodeinput_2_inanita,
"total_diodeinput_2_inanita[5][512]/D");
445 tsignals->Branch(
"timedomain_output_corrected_forplotting",&timedomain_output_corrected_forplotting,
"timedomain_output_1_corrected_forplotting[2][6][512]/D");
446 tsignals->Branch(
"timedomain_output_inanita",&timedomain_output_inanita,
"timedomain_output_inanita[2][5][512]/D");
449 tsignals->Branch(
"peak_rx_rfcm_lab",&peak_rx_rfcm_lab,
"peak_rx_rfcm_lab[2]/D");
450 tsignals->Branch(
"inu",&inu,
"inu/I");
451 tsignals->Branch(
"dangle",&dangle_inanita,
"dangle/D");
452 tsignals->Branch(
"emfrac",&emfrac_inanita,
"emfrac/D");
453 tsignals->Branch(
"hadfrac",&hadfrac_inanita,
"hadfrac/D");
454 tsignals->Branch(
"ston",&ston,
"ston[5]/D");
456 tsignals->Branch(
"peak", &peak_v_banding_rfcm,
"peak_v_banding_rfcm[2][5]/D" );
457 tsignals->Branch(
"peak_rx", &peak_rx_signalonly,
"peak_rx[2]/D" );
458 tsignals->Branch(
"peak_rx_rfcm", &peak_rx_rfcm,
"peak_rx_rfcm[2]/D" );
459 tsignals->Branch(
"peak_rx_rfcm_signalonly", &peak_rx_rfcm_signalonly,
"peak_rx_rfcm_signalonly[2]/D" );
460 tsignals->Branch(
"peak_rx_rfcm_lab", &peak_rx_rfcm_lab,
"peak_rx_rfcm_lab[2]/D" );
461 tsignals->Branch(
"bwslice_vrms",&bwslice_vrms,
"bwslice_vrms[5]/D");
462 tsignals->Branch(
"iminbin",&iminbin,
"iminbin[5]/I");
463 tsignals->Branch(
"imaxbin",&imaxbin,
"imaxbin[5]/I");
464 tsignals->Branch(
"maxbin_fortotal",&maxbin_fortotal,
"maxbin_fortotal[5]/I");
465 tsignals->Branch(
"channels_passing",&channels_passing,
"channels_passing[2][5]/I");
466 tsignals->Branch(
"bwslice_rmsdiode",&bwslice_rmsdiode,
"bwslice_rmsdiode[2][5]/D");
467 tsignals->Branch(
"l1_passing",&l1_passing,
"l1_passing/I");
468 tsignals->Branch(
"integral_vmmhz",&integral_vmmhz_foranita,
"integral_vmmhz/D");
471 tsignals->Branch(
"flag_e_inanita",&flag_e_inanita,
"flag_e_inanita[5][512]/I");
472 tsignals->Branch(
"flag_h_inanita",&flag_h_inanita,
"flag_h_inanita[5][512]/I");
475 tdata=
new TTree(
"tdata",
"tdata");
476 tdata->Branch(
"total_diodeinput_1_allantennas",&total_diodeinput_1_allantennas,
"total_diodeinput_1_allantennas[48][512]/D");
477 tdata->Branch(
"total_diodeinput_2_allantennas",&total_diodeinput_2_allantennas,
"total_diodeinput_2_allantennas[48][512]/D");
478 tdata->Branch(
"timedomain_output_allantennas",&timedomain_output_allantennas,
"timedomain_output_allantennas[2][48][512]/D");
479 tdata->Branch(
"arrival_times",&arrival_times,
"arrival_times[2][48]/D");
480 tdata->Branch(
"inu",&inu,
"inu/I");
481 tdata->Branch(
"powerthreshold",&powerthreshold,
"powerthreshold[5]/D");
482 tdata->Branch(
"bwslice_rmsdiode",&bwslice_rmsdiode,
"bwslice_rmsdiode[2][5]/D");
486 tdata->Branch(
"arrayofhits_inanita",&arrayofhits_inanita,
"arrayofhits_inanita[3][16][2][512]/I");
488 tdata->Branch(
"l1trig_anita3and4_inanita",&l1trig_anita3and4_inanita,
"l1trig_anita3and4_inanita[2][16][512]/I");
490 tdata->Branch(
"l1trig_anita4lr_inanita",&l1trig_anita4lr_inanita,
"l1trig_anita4lr_inanita[3][16][512]/I");
493 tdata->Branch(
"l2trig_anita4lr_inanita",&l2trig_anita4lr_inanita,
"l2trig_anita4lr_inanita[16][3][512]/I");
495 tdata->Branch(
"l3type0trig_anita4lr_inanita",&l3type0trig_anita4lr_inanita,
"l3type0trig_anita4lr_inanita[16][512]/I");
496 tdata->Branch(
"l3trig_anita4lr_inanita",&l3trig_anita4lr_inanita,
"l3trig_anita4lr_inanita[16][512]/I");
500 tdata->Branch(
"passglobtrig",&passglobtrig,
"passglobtrig[2]/I");
503 tgaryanderic=
new TTree(
"tgaryanderic",
"tgaryanderic");
504 tgaryanderic->Branch(
"arrayofhits",&arrayofhits_forgaryanderic,
"arrayofhits_forgaryanderic[3][16][2][512]/I");
505 tgaryanderic->Branch(
"l1trig",&l1trig_anita4lr_forgaryanderic,
"l1trig_anita4lr_forgaryanderic[3][16][512]/I");
507 tgaryanderic->Branch(
"l2trig",&l2trig_anita4lr_forgaryanderic,
"l2trig_anita4lr_forgaryanderic[16][512]/I");
508 tgaryanderic->Branch(
"l3type0trig",&l3type0trig_anita4lr_forgaryanderic,
"l3type0trig_anita4lr_forgaryanderic[16][512]/I");
509 tgaryanderic->Branch(
"l3type1trig",&l3type1trig_anita4lr_forgaryanderic,
"l3type1trig_anita4lr_forgaryanderic[16][512]/I");
510 tgaryanderic->Branch(
"passglobtrig",&passglobtrig,
"passglobtrig[2]/I");
511 tgaryanderic->Branch(
"weight",&weight_inanita,
"weight_inanita/D");
512 tgaryanderic->Branch(
"time",&time_trig,
"time_trig[512]/D");
515 tglob=
new TTree(
"tglob",
"tglob");
516 tglob->Branch(
"inu",&inu,
"inu/I");
517 tglob->Branch(
"passglobtrig",&passglobtrig,
"passglobtrig[2]/I");
518 tglob->Branch(
"l1_passing_allantennas",&l1_passing_allantennas,
"l1_passing_allantennas[48]/I");
523 coherent_datafile =
new TFile(Form(
"%s/coherent_sum_data_file.root", outputdir.Data()),
"RECREATE");
524 coherent_waveform_sum_tree =
new TTree(
"coherent_waveform_sum_tree",
"Coherent Waveform Sum");
525 coherent_waveform_sum_tree->Branch(
"event_number", &cwst_event_number);
526 coherent_waveform_sum_tree->Branch(
"center_phi_sector", &cwst_center_phi_sector);
527 coherent_waveform_sum_tree->Branch(
"rms_noise", &cwst_rms_noise);
528 coherent_waveform_sum_tree->Branch(
"actual_rms", &cwst_actual_rms);
529 coherent_waveform_sum_tree->Branch(
"threshold", &cwst_threshold);
530 coherent_waveform_sum_tree->Branch(
"window_start", &cwst_window_start);
531 coherent_waveform_sum_tree->Branch(
"window_end", &cwst_window_end);
533 coherent_waveform_sum_tree->Branch(
"deg_theta", &cwst_deg_theta);
534 coherent_waveform_sum_tree->Branch(
"deg_phi", &cwst_deg_phi);
536 coherent_waveform_sum_tree->Branch(
"actual_deg_theta", &cwst_actual_deg_theta);
537 coherent_waveform_sum_tree->Branch(
"actual_deg_phi", &cwst_actual_deg_phi);
539 coherent_waveform_sum_tree->Branch(
"timesteps", cwst_timesteps);
541 for (
unsigned i = 0; i < 48; ++i) {
542 cwst_RXs[i].waveform =
new vector <double>(HALFNFOUR, 0.);
543 cwst_RXs[i].digitized =
new vector <double>(HALFNFOUR, 0.);
544 coherent_waveform_sum_tree->Branch(Form(
"rx%u", i), &(cwst_RXs[i]));
547 for (
unsigned int i = 0; i < 9; i++) {
548 cwst_aligned_wfms[i].digitized =
new vector <double>(HALFNFOUR, 0.);
549 coherent_waveform_sum_tree->Branch(Form(
"aligned_wfms%u", i), &(cwst_aligned_wfms[i]));
561 coherent_waveform_sum_tree->Branch(
"summed_wfm", &cwst_summed_wfm);
562 coherent_waveform_sum_tree->Branch(
"power_of_summed_wfm", &cwst_power_of_summed_wfm);
563 coherent_waveform_sum_tree->Branch(
"power", &cwst_power);
569 void Anita::initializeFixedPowerThresholds(ofstream &foutput){
577 powerthreshold[0]=-1.87;
578 powerthreshold[1]=-2.53;
579 powerthreshold[2]=-2.15;
580 powerthreshold[3]=-1.;
581 powerthreshold[4]=-4.41;
585 powerthreshold_nadir[0]=-6.7;
586 powerthreshold_nadir[1]=-6.5;
587 powerthreshold_nadir[2]=-5.1;
588 powerthreshold_nadir[3]=-1.;
589 powerthreshold_nadir[4]=-6.7;
592 foutput <<
"Thresholds are (in p/<p>): " <<
593 powerthreshold[0] <<
" (L)\t" <<
594 powerthreshold[1] <<
" (M)\t" <<
595 powerthreshold[2] <<
" (H)\t" <<
596 powerthreshold[4] <<
" (F)\n";
598 else if (BANDING==0 || BANDING==1) {
600 powerthreshold[0]=-3.27;
601 powerthreshold[1]=-3.24;
602 powerthreshold[2]=-2.48;
603 powerthreshold[3]=-2.56;
604 powerthreshold[4]=-3.;
606 foutput <<
"Thresholds are (in p/<p>): " <<
607 powerthreshold[0] <<
" (L)\t" <<
608 powerthreshold[1] <<
" (M1)\t" <<
609 powerthreshold[2] <<
" (M2)\t" <<
610 powerthreshold[3] <<
" (H)\t" <<
611 powerthreshold[4] <<
" \n";
613 }
else if (BANDING==4 || BANDING==5){
614 powerthreshold[0]=-1;
615 powerthreshold[1]=-1;
616 powerthreshold[2]=-1;
617 powerthreshold[3]=-1;
618 powerthreshold[4]=-5.40247;
621 foutput <<
"Thresholds are (in p/<p>): " <<
622 powerthreshold[0] <<
" (L)\t" <<
623 powerthreshold[1] <<
" (M1)\t" <<
624 powerthreshold[2] <<
" (M2)\t" <<
625 powerthreshold[3] <<
" (H)\t" <<
626 powerthreshold[4] <<
" \n";
631 void Anita::readVariableThresholds(
Settings *settings1){
633 if (settings1->WHICH==8) {
634 fturf=
new TFile((ICEMC_DATA_DIR+
"/turfrate_icemc.root").c_str());
635 turfratechain=(TTree*)fturf->Get(
"turfrate_icemc");
636 turfratechain->SetMakeClass(1);
637 turfratechain->SetBranchAddress(
"phiTrigMask",&phiTrigMask);
638 turfratechain->SetBranchAddress(
"realTime",&realTime_turfrate);
639 turfratechain->BuildIndex(
"realTime");
640 turfratechain->GetEvent(0);
641 realTime_tr_min=realTime_turfrate;
642 turfratechain->GetEvent(turfratechain->GetEntries()-1);
643 realTime_tr_max=realTime_turfrate;
646 }
else if (settings1->WHICH==9 || settings1->WHICH==10){
650 if (settings1->WHICH==9){
651 turfFile+=ICEMC_DATA_DIR+
"/SampleTurf_icemc_anita3.root";
652 surfFile+=ICEMC_DATA_DIR+
"/SampleSurf_icemc_anita3.root";
654 turfFile+=ICEMC_DATA_DIR+
"/SampleTurf_run42to367_anita4.root";
655 surfFile+=ICEMC_DATA_DIR+
"/SampleSurf_run42to367_anita4.root";
659 fturf=
new TFile(turfFile.c_str());
660 turfratechain=(TTree*)fturf->Get(
"turfrate_icemc");
661 turfratechain->SetMakeClass(1);
662 turfratechain->SetBranchAddress(
"phiTrigMask",&phiTrigMask);
663 turfratechain->SetBranchAddress(
"phiTrigMaskH",&phiTrigMaskH);
664 turfratechain->SetBranchAddress(
"l1TrigMask",&l1TrigMask);
665 turfratechain->SetBranchAddress(
"l1TrigMaskH",&l1TrigMaskH);
667 turfratechain->SetBranchAddress(
"deadTime",&deadTime);
668 turfratechain->SetBranchAddress(
"realTime",&realTime_turfrate);
669 turfratechain->BuildIndex(
"realTime");
670 turfratechain->GetEvent(0);
671 realTime_tr_min=realTime_turfrate;
672 turfratechain->GetEvent(turfratechain->GetEntries()-1);
673 realTime_tr_max=realTime_turfrate;
676 fsurf=
new TFile(surfFile.c_str());
677 surfchain=(TTree*)fsurf->Get(
"surf_icemc");
678 surfchain->SetMakeClass(1);
679 surfchain->SetBranchAddress(
"thresholds", &thresholds );
680 surfchain->SetBranchAddress(
"scalers", &scalers );
681 surfchain->SetBranchAddress(
"fakeThreshold", &fakeThresholds );
682 surfchain->SetBranchAddress(
"fakeThreshold2", &fakeThresholds2 );
683 surfchain->SetBranchAddress(
"fakeScaler", &fakeScalers );
684 surfchain->SetBranchAddress(
"realTime", &realTime_surf );
685 surfchain->BuildIndex(
"realTime");
686 surfchain->GetEvent(0);
687 realTime_surf_min=realTime_surf;
688 surfchain->GetEvent(surfchain->GetEntries()-1);
689 realTime_surf_max=realTime_surf;
694 void Anita::readAmplification(){
699 TFile *f2=
new TFile((ICEMC_DATA_DIR+
"/gains.root").c_str());
700 TTree *tgain=(TTree*)f2->Get(
"tree1");
702 float freq_ampl_eachantenna[NPOINTS_AMPL];
703 float ampl_eachantenna[NPOINTS_AMPL];
704 float noisetemp_eachantenna[NPOINTS_AMPL];
706 tgain->SetBranchAddress(
"freq",freq_ampl_eachantenna);
707 tgain->SetBranchAddress(
"ampl",ampl_eachantenna);
708 tgain->SetBranchAddress(
"noisetemp",noisetemp_eachantenna);
710 for (
int iant=0;iant<48;iant++) {
711 tgain->GetEvent(iant);
712 for (
int j=0;j<NPOINTS_AMPL;j++) {
714 freq_ampl[iant][j]=(double)freq_ampl_eachantenna[j];
716 ampl[iant][j]=(double)ampl_eachantenna[j];
719 ampl_notdb[iant][j]=pow(10.,ampl[iant][j]/10.);
721 noisetemp[iant][j]=(double)noisetemp_eachantenna[j];
730 void Anita::getDiodeDataAndAttenuation(
Settings *settings1, TString outputdir){
735 sdiode=ICEMC_DATA_DIR+
"/diode_anita1.root";
737 sdiode=ICEMC_DATA_DIR+
"/diode_nobanding.root";
739 sdiode=ICEMC_DATA_DIR+
"/diode_anita2.root";
740 else if (BANDING==4 || BANDING==5)
741 sdiode=ICEMC_DATA_DIR+
"/diode_anita3.root";
743 fnoise=
new TFile(sdiode.c_str());
744 tdiode=(TTree*)fnoise->Get(
"diodeoutputtree");
750 sbands=ICEMC_DATA_DIR+
"/bands_anita1.root";
752 sbands=ICEMC_DATA_DIR+
"/bands_nobanding.root";
754 sbands=ICEMC_DATA_DIR+
"/bands_anita2.root";
755 else if (BANDING==4 || BANDING==5)
756 sbands=ICEMC_DATA_DIR+
"/bands_anita2.root";
758 TFile *fbands=
new TFile(sbands.c_str());
759 TTree *tbands=(TTree*)fbands->Get(
"bandstree");
762 for (
int i=0;i<HALFNFOUR;i++) {
763 time[i]=(double)i*TIMESTEP;
764 time_long[i]=time[i];
766 time_centered[i]=time[i]-(double)HALFNFOUR/2*TIMESTEP;
768 for (
int i=HALFNFOUR;i<NFOUR;i++) {
769 time_long[i]=(double)i*TIMESTEP;
776 int m=(int)(maxt_diode/TIMESTEP);
777 for (
int j=0;j<5;j++) {
778 for (
int i=0;i<m;i++) {
779 fdiode_real[j][i]=diode_real[j][i];
781 for (
int i=m;i<NFOUR;i++) {
782 fdiode_real[j][i]=0.;
785 Tools::realft(fdiode_real[j],1,NFOUR);
790 TCanvas *cdiode=
new TCanvas(
"cdiode",
"cdiode",880,800);
792 TGraph *gdiode=
new TGraph(NFOUR/2,time,diode_real[4]);
795 gdiode=
new TGraph(NFOUR/2,freq_forfft,fdiode_real[4]);
799 stemp=string(outputdir.Data())+
"/diode.eps";
800 cdiode->Print((TString)stemp);
802 tdiode->SetBranchAddress(
"avgfreqdomain_lab",&(avgfreqdomain_lab[0]));
803 tdiode->SetBranchAddress(
"freqdomain_amp_icemc",&(freqdomain_rfcm[0]));
804 tdiode->SetBranchAddress(
"freqdomain_rfcm_banding",&(freqdomain_rfcm_banding[0][0]));
808 tbands->SetBranchAddress(
"freq_bands",freq_bands);
809 tbands->SetBranchAddress(
"bandsattn",bandsattn);
811 tbands->SetBranchAddress(
"correl_banding",&(correl_banding[0][0]));
812 tbands->SetBranchAddress(
"correl_lab",&(correl_lab[0]));
820 for (
int j=0;j<5;j++) {
822 for (
int i=0;i<NPOINTS_BANDS;i++) {
825 if (bandsattn[j][i]>1.)
834 TGraph *gbandsattn[5];
836 TH2F *hbandsattn=
new TH2F(
"hbandsattn",
"hbandsattn",100,0.,2.E9,100,0.,1.);
837 TH2F *hcorr=
new TH2F(
"hcorr",
"hcorr",100,0.,2.E9,100,0.,2.);
838 for (
int i=0;i<5;i++) {
839 gbandsattn[i]=
new TGraph(NPOINTS_BANDS,freq_bands[i],bandsattn[i]);
840 gbandsattn[i]->SetLineColor(2+i);
841 gcorr[i]=
new TGraph(NPOINTS_BANDS,freq_bands[i],correl_banding[i]);
842 gcorr[i]->SetLineColor(2+i);
844 TCanvas *cbands=
new TCanvas(
"cbands",
"cbands",880,800);
848 for (
int i=0;i<5;i++) {
849 gbandsattn[i]->Draw(
"l");
853 for (
int i=0;i<5;i++) {
856 stemp=string(outputdir.Data())+
"/bands.eps";
857 cbands->Print((TString)stemp);
878 void Anita::setDiodeRMS(
Settings *settings1, TString outputdir){
880 double mindiodeconvl[5];
881 double onediodeconvl[5];
883 double power_noise_eachband[5][NFOUR];
884 double timedomain_output[5][NFOUR];
888 for (
int i=0;i<5;i++) {
889 bwslice_enoise[i]=0.;
890 bwslice_rmsdiode[0][i]=bwslice_rmsdiode[1][i]=0.;
895 nnoiseevents=tdiode->GetEntries();
903 for (
int j=0;j<3;j++) {
905 sprintf(histname,
"hnoise_%d",j);
907 hnoise[j]=
new TH1F(histname,histname,nhnoisebins,-40.,20.);
909 hnoise[j]=
new TH1F(histname,histname,nhnoisebins,-80.,40.);
912 sprintf(histname,
"hnoise_3");
913 hnoise[3]=
new TH1F(histname,histname,nhnoisebins,-60.0,40.0);
914 sprintf(histname,
"hnoise_4");
915 hnoise[4]=
new TH1F(histname,histname,nhnoisebins,-60.0,40.0);
918 sprintf(histname,
"hnoise_3");
919 hnoise[3]=
new TH1F(histname,histname,nhnoisebins,-120.0,80.0);
920 sprintf(histname,
"hnoise_4");
921 hnoise[4]=
new TH1F(histname,histname,nhnoisebins,-120.0,80.0);
928 cout <<
"after getting event, freqdomain_rfcm_banding is " << freqdomain_rfcm_banding[0][NFOUR/8-1] <<
"\n";
957 for (
int j=0;j<5;j++) {
959 for (
int k=0;k<NFOUR/4;k++) {
961 if (bwslice_min[j]>freq_forplotting[k] || bwslice_max[j]<freq_forplotting[k]) {
962 freqdomain_rfcm_banding[j][k]=0.;
971 for (
int j=0;j<5;j++) {
972 for (
int k=0;k<NFOUR/4;k++) {
973 power+=freqdomain_rfcm_banding[j][k]/((double)NFOUR/4);
978 int ngeneratedevents=1000;
979 int passes[5]={0,0,0,0,0};
980 double averageoutput[5]={0.,0.,0.,0.,0.};
982 if (!settings1->NOISEFROMFLIGHTTRIGGER){
983 for (
int i=0;i<ngeneratedevents;i++) {
984 cout << double(i)/double(ngeneratedevents) << endl;
988 for (
int j=0;j<5;j++) {
998 myconvlv(timedomainnoise_rfcm_banding[0][j],NFOUR,fdiode_real[j],mindiodeconvl[j],onediodeconvl[j],power_noise_eachband[j],timedomain_output[j]);
1000 hnoise[j]->Fill(onediodeconvl[j]*1.E15);
1002 bwslice_enoise[j]+=onediodeconvl[j];
1005 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1006 bwslice_meandiode[j]+=timedomain_output[j][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1007 bwslice_vrms[j]+=timedomainnoise_rfcm_banding[0][j][m]*timedomainnoise_rfcm_banding[0][j][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1008 averageoutput[j]+=timedomain_output[j][m]*timedomain_output[j][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1026 for (
int j=0;j<5;j++) {
1028 bwslice_vrms[j]=sqrt(bwslice_vrms[j]);
1032 for (
int j=0;j<5;j++) {
1033 bwslice_enoise[j]=hnoise[j]->GetMean()/1.E15;
1035 bwslice_fwhmnoise[j]=Tools::GetFWHM(hnoise[j]);
1040 for (
int i=0;i<ngeneratedevents;i++) {
1041 GetNoiseWaveforms();
1042 for (
int j=0;j<5;j++) {
1044 myconvlv(timedomainnoise_rfcm_banding[0][j],NFOUR,fdiode_real[j],mindiodeconvl[j],onediodeconvl[j],power_noise_eachband[j],timedomain_output[j]);
1046 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1047 bwslice_rmsdiode[0][j]+=(timedomain_output[j][m]-bwslice_meandiode[j])*(timedomain_output[j][m]-bwslice_meandiode[j])/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1053 for (
int j=0;j<5;j++) {
1054 bwslice_rmsdiode[0][j]=bwslice_rmsdiode[1][j]=sqrt(bwslice_rmsdiode[0][j]);
1055 cout <<
"mean, rms are " << bwslice_meandiode[j] <<
" " << bwslice_rmsdiode[0][j] <<
"\n";
1058 double thresh_begin=-1.;
1059 double thresh_end=-11.;
1060 double thresh_step=1.;
1062 double rate[5][100];
1063 for (
double testthresh=thresh_begin;testthresh>=thresh_end;testthresh-=thresh_step) {
1064 for (
int j=0;j<5;j++) {
1067 for (
int i=0;i<ngeneratedevents;i++) {
1069 GetNoiseWaveforms();
1070 for (
int j=0;j<5;j++) {
1072 myconvlv(timedomainnoise_rfcm_banding[0][j],NFOUR,fdiode_real[j],mindiodeconvl[j],onediodeconvl[j],power_noise_eachband[j],timedomain_output[j]);
1074 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1076 if (timedomain_output[j][m+1]<bwslice_rmsdiode[0][j]*testthresh) {
1078 m+=(int)(DEADTIME/TIMESTEP);
1085 for (
int j=0;j<5;j++) {
1086 int ibin=(int)fabs((testthresh-thresh_begin)/thresh_step);
1088 rate[j][ibin]=passes[j]/((double)ngeneratedevents*((
double)NFOUR/2*(TIMESTEP)-maxt_diode));
1089 if (rate[j][ibin]!=0)
1090 rate[j][ibin]=log10(rate[j][ibin]);
1097 #ifdef ANITA_UTIL_EXISTS 1098 double quickNoise[HALFNFOUR];
1100 memset(bwslice_diodemean_fullband_allchan, 0,
sizeof(bwslice_diodemean_fullband_allchan) );
1101 memset(bwslice_dioderms_fullband_allchan, 0,
sizeof(bwslice_dioderms_fullband_allchan) );
1103 static double tempdiodeoutput[1000][NFOUR];
1105 if (settings1->WHICH==9) {
1106 for (
int ipol=0; ipol<2; ipol++){
1107 for (
int iant=0; iant<48; iant++){
1109 std::cout <<
"Using noise from flight to get rms of channel " << (ipol == 0 ? iant : 48+iant) + 1 <<
" of 96\r" << std::flush;
1110 if((ipol == 0 ? iant : 48+iant) + 1 == 96){std::cout << std::endl;}
1112 for (
int ituff=0; ituff<ntuffs; ituff++){
1113 memset(tempdiodeoutput, 0,
sizeof(tempdiodeoutput) );
1115 for (
int i=0;i<ngeneratedevents;i++) {
1117 getQuickTrigNoiseFromFlight(settings1, quickNoise, ipol, iant, ituff);
1119 myconvlv(quickNoise,NFOUR,fdiode_real[4],mindiodeconvl[4],onediodeconvl[4],power_noise_eachband[4],tempdiodeoutput[i]);
1122 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1123 bwslice_diodemean_fullband_allchan[ipol][iant][ituff]+=tempdiodeoutput[i][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1130 for (
int i=0;i<ngeneratedevents;i++) {
1132 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1133 bwslice_dioderms_fullband_allchan[ipol][iant][ituff]+=(tempdiodeoutput[i][m]-bwslice_diodemean_fullband_allchan[ipol][iant][ituff])*(tempdiodeoutput[i][m]-bwslice_diodemean_fullband_allchan[ipol][iant][ituff])/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1138 bwslice_dioderms_fullband_allchan[ipol][iant][ituff]=sqrt(bwslice_dioderms_fullband_allchan[ipol][iant][ituff]);
1146 }
else if (settings1->WHICH==10){
1148 double quickNoise2[2][HALFNFOUR];
1149 double lcprcpNoise[2][HALFNFOUR];
1151 static double tempdiodeoutput2[1000][NFOUR];
1153 for (
int iant=0; iant<48; iant++){
1155 std::cout <<
"Using noise from flight to get rms of channel pair " << iant + 1 <<
" of 48\r" << std::flush;
1156 if( iant + 1 == 48 ){std::cout << std::endl;}
1158 for (
int ituff=0; ituff<ntuffs; ituff++){
1160 memset(tempdiodeoutput, 0,
sizeof(tempdiodeoutput) );
1161 memset(tempdiodeoutput2, 0,
sizeof(tempdiodeoutput2) );
1163 for (
int i=0;i<ngeneratedevents;i++) {
1165 for (
int ipol=0; ipol<2; ipol++){
1166 getQuickTrigNoiseFromFlight(settings1, quickNoise2[ipol], ipol, iant, ituff);
1170 myconvlv(lcprcpNoise[0],NFOUR,fdiode_real[4],mindiodeconvl[4],onediodeconvl[4],power_noise_eachband[4],tempdiodeoutput[i]);
1171 myconvlv(lcprcpNoise[1],NFOUR,fdiode_real[4],mindiodeconvl[4],onediodeconvl[4],power_noise_eachband[4],tempdiodeoutput2[i]);
1174 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1175 bwslice_diodemean_fullband_allchan[0][iant][ituff]+=tempdiodeoutput[i][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1176 bwslice_diodemean_fullband_allchan[1][iant][ituff]+=tempdiodeoutput2[i][m]/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1184 for (
int i=0;i<ngeneratedevents;i++) {
1186 for (
int m=(
int)(maxt_diode/TIMESTEP);m<NFOUR/2;m++) {
1187 bwslice_dioderms_fullband_allchan[0][iant][ituff]+=(tempdiodeoutput[i][m]-bwslice_diodemean_fullband_allchan[0][iant][ituff])*(tempdiodeoutput[i][m]-bwslice_diodemean_fullband_allchan[0][iant][ituff])/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1188 bwslice_dioderms_fullband_allchan[1][iant][ituff]+=(tempdiodeoutput2[i][m]-bwslice_diodemean_fullband_allchan[1][iant][ituff])*(tempdiodeoutput2[i][m]-bwslice_diodemean_fullband_allchan[1][iant][ituff])/((double)ngeneratedevents*((
double)NFOUR/2-maxt_diode/TIMESTEP));
1193 bwslice_dioderms_fullband_allchan[0][iant][ituff]=sqrt(bwslice_dioderms_fullband_allchan[0][iant][ituff]);
1194 bwslice_dioderms_fullband_allchan[1][iant][ituff]=sqrt(bwslice_dioderms_fullband_allchan[1][iant][ituff]);
1213 TCanvas *c4=
new TCanvas(
"c4",
"c4",880,800);
1215 for (
int j=0;j<5;j++) {
1219 frice[j]=
new TF1(
"frice",
"[2]*(-1.*x-[1])/[0]^2*exp(-1.*(-1.*x-[1])^2/2/[0]^2)",-50.,50.);
1220 frice[j]->SetParameter(0,4.);
1222 frice[j]->SetParameter(1,5.);
1223 frice[j]->SetParameter(2,400.);
1229 if ((BANDING==2 && j!=3) ||
1231 (BANDING!=2 && BANDING!=4) ||
1232 ((BANDING==4||BANDING==5) && j==4) ){
1235 if (j==0 && BANDING==2)
1236 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,1.);
1237 if (j==1 && BANDING==2)
1238 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,2.);
1239 if (j==2 && BANDING==2)
1240 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,10.);
1241 if (j==4 && (BANDING==2 || BANDING==4 || BANDING==5))
1242 hnoise[j]->Fit(frice[j],
"Q",
"",-15.,15.);
1244 if (j==0 && BANDING==0)
1245 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,5.);
1246 if (j==1 && BANDING==0)
1247 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,5.);
1248 if (j==2 && BANDING==0)
1249 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,15.);
1250 if (j==3 && BANDING==0)
1251 hnoise[j]->Fit(frice[j],
"Q",
"",-20.,20.);
1253 frice[j]->GetHistogram()->SetLineWidth(3);
1255 hnoise[j]->SetLineWidth(3);
1256 hnoise[j]->SetXTitle(
"Diode Output (10^{-15} Joules)");
1257 hnoise[j]->SetYTitle(
"Number of Noise Waveforms");
1258 hnoise[j]->SetTitleSize(0.05,
"X");
1259 hnoise[j]->SetTitleSize(0.05,
"Y");
1262 frice[j]->Draw(
"same");
1267 stemp=string(outputdir.Data())+
"/hnoise.eps";
1268 c4->Print((TString)stemp);
1276 #ifdef ANITA_UTIL_EXISTS 1277 void Anita::getQuickTrigNoiseFromFlight(
Settings *settings1,
double justNoise[HALFNFOUR],
int ipol,
int iant,
int ituff){
1280 phasorsTrig[0].setMagPhase(0,0);
1281 Double_t sigma, realPart, imPart, norm;
1283 if (iant<16) iring=0;
1284 else if (iant<32) iring=1;
1286 int iphi = iant - (iring*16);
1288 TRandom * fRand = getRNG(RNG_NOISE);
1289 for(
int i=1;i<numFreqs;i++) {
1291 if (freqs[i]*1e6>=settings1->FREQ_LOW_SEAVEYS && freqs[i]*1e6<=settings1->FREQ_HIGH_SEAVEYS){
1292 norm = fRatioTriggerToA3DigitizerFreqDomain[ipol][iring][iphi][ituff][i];
1293 sigma = RayleighFits[ipol][iant]->Eval(freqs[i])*4./TMath::Sqrt(numFreqs);
1295 realPart = fRand->Gaus(0,sigma);
1296 imPart = fRand->Gaus(0,sigma);
1305 Double_t *justNoiseTemp = rfNoiseTrig->GetY();
1307 for (
int i=0; i<HALFNFOUR; i++){
1308 justNoise[i] = justNoiseTemp[i]*THERMALNOISE_FACTOR;
1311 delete[] phasorsTrig;
1316 void Anita::getPulserData(){
1318 TFile *fpulser=
new TFile((ICEMC_DATA_DIR+
"/pulser.root").c_str());
1320 TGraph *gpulser=(TGraph*)fpulser->Get(
"pulser");
1321 TGraph *gphases=(TGraph*)fpulser->Get(
"phases");
1322 TGraph *gnoise=(TGraph*)fpulser->Get(
"noise");
1326 double *temp1=gpulser->GetX();
1327 for (
int i=0;i<NFOUR/4;i++) {
1328 f_pulser[i]=temp1[i];
1330 double *temp2=gphases->GetX();
1331 for (
int i=0;i<NFOUR/4;i++) {
1332 f_phases[i]=temp2[i];
1334 double *temp3=gpulser->GetY();
1335 double *temp4=gnoise->GetY();
1338 for (
int i=0;i<NFOUR/4;i++) {
1339 v_pulser[i]=sqrt(temp3[i]);
1340 v_noise[i]=sqrt(temp4[i]);
1341 if (f_phases[i]<75.E6)
1346 TGraph *gpulser_eachband;
1347 TGraph *gnoise_eachband;
1348 TCanvas *cpulser=
new TCanvas(
"cpulser",
"cpulser",880,800);
1349 cpulser->Divide(1,5);
1351 for (
int i=0;i<5;i++) {
1355 cpulser->cd(iplot+1);
1357 gpulser_eachband=
new TGraph(NFOUR/4,f_pulser,v_pulser);
1359 gpulser_eachband->Draw(
"al");
1363 cpulser->Print(
"pulser.eps");
1365 TCanvas *cnoise=
new TCanvas(
"cnoise",
"cnoise",880,800);
1366 cnoise->Divide(1,5);
1367 for (
int i=0;i<5;i++) {
1371 cnoise->cd(iplot+1);
1372 gnoise_eachband=
new TGraph(NFOUR/4,f_pulser,v_noise);
1374 gnoise_eachband->Draw(
"al");
1378 cnoise->Print(
"noise.eps");
1386 double sumpulserpower=0.;
1387 double sumnoisepower=0.;
1389 for (
int i=0;i<NFOUR/4;i++) {
1390 sumpulserpower+=v_pulser[i]*v_pulser[i];
1391 sumnoisepower+=v_noise[i]*v_noise[i];
1394 double *temp5=gphases->GetY();
1395 for (
int i=0;i<NFOUR/4;i++) {
1396 v_phases[i]=temp5[i];
1413 void Anita::ReadGains(
void) {
1418 gainsfile.open((ICEMC_DATA_DIR+
"/hh_0").c_str());
1419 if(gainsfile.fail()) {
1420 cout <<
"can't open `$ICEMC_DATA_DIR`/hh_0\n";
1423 for(iii = 0; iii < NPOINTS_GAIN; iii++)
1424 gainsfile >> frequency_forgain_measured[iii] >> gainh_measured[iii];
1427 gainsfile.open((ICEMC_DATA_DIR+
"/vv_0").c_str());
1428 if(gainsfile.fail()) {
1429 cout <<
"can't open `$ICEMC_DATA_DIR`/vv_0\n";
1432 for(iii = 0; iii < NPOINTS_GAIN; iii++) {
1433 gainsfile >> sfrequency >> gainv_measured[iii];
1434 if(sfrequency != frequency_forgain_measured[iii])
1435 cout <<
"warning: sfrequency = " << sfrequency <<
", frequency_forgain_measured[iii] = " << frequency_forgain_measured[iii] << endl;
1439 gainsfile.open((ICEMC_DATA_DIR+
"/hv_0").c_str());
1440 if(gainsfile.fail()) {
1441 cout <<
"can't open `$ICEMC_DATA_DIR`/hv_0\n";
1444 for(iii = 0; iii < NPOINTS_GAIN; iii++) {
1445 gainsfile >> sfrequency >> gainhv_measured[iii];
1446 if(sfrequency != frequency_forgain_measured[iii])
1447 cout <<
"warning: sfrequency = " << sfrequency <<
", frequency_forgain_measured[iii] = " << frequency_forgain_measured[iii] << endl;
1451 gainsfile.open((ICEMC_DATA_DIR+
"/vh_0").c_str());
1452 if(gainsfile.fail()) {
1453 cout <<
"can't open `$ICEMC_DATA_DIR`/vh_0\n";
1456 for(iii = 0; iii < NPOINTS_GAIN; iii++) {
1457 gainsfile >> sfrequency >> gainvh_measured[iii];
1458 if(sfrequency != frequency_forgain_measured[iii])
1459 cout <<
"warning: sfrequency = " << sfrequency <<
", frequency_forgain_measured[iii] = " << frequency_forgain_measured[iii] << endl;
1467 void Anita::AntennaGain(
Settings *settings1,
double hitangle_e,
double hitangle_h,
double e_component,
double h_component,
int k,
double &vsignalarray_e,
double &vsignalarray_h) {
1469 if (freq[k]>=settings1->FREQ_LOW_SEAVEYS && freq[k]<=settings1->FREQ_HIGH_SEAVEYS) {
1471 double relativegains[4];
1473 for (
int pols=0;pols<2;pols++) {
1474 if (fabs(hitangle_e)<PI/2)
1475 relativegains[pols]=Get_gain_angle(pols,k,hitangle_e);
1477 relativegains[pols]=0.;
1486 vsignalarray_e = settings1->IGNORE_CROSSPOL ? 0.5*vsignalarray_e * vvGaintoHeight[k] * e_component * sqrt(relativegains[0])
1487 : vsignalarray_e * 0.5 * sqrt(vvGaintoHeight[k] * vvGaintoHeight[k] * e_component * e_component * relativegains[0] + hvGaintoHeight[k] * hvGaintoHeight[k] * h_component * h_component * relativegains[1]);
1495 for (
int pols=2;pols<4;pols++) {
1496 if (fabs(hitangle_h)<PI/2)
1497 relativegains[pols]=Get_gain_angle(pols,k,hitangle_h);
1499 relativegains[pols]=0.;
1507 vsignalarray_h= settings1->IGNORE_CROSSPOL ? vsignalarray_h * 0.5 * hhGaintoHeight[k] * h_component * sqrt(relativegains[2])
1508 : vsignalarray_h*0.5* sqrt(hhGaintoHeight[k]*hhGaintoHeight[k]*h_component*h_component*relativegains[2] + vhGaintoHeight[k]*vhGaintoHeight[k]*e_component*e_component*relativegains[3]);
1511 if (settings1->POL_SIGN_HACK && !settings1->IGNORE_CROSSPOL)
1513 if (e_component < 0) vsignalarray_e *=-1;
1514 if (h_component < 0) vsignalarray_h *=-1;
1527 void Anita::SetDiffraction() {
1528 const double cc = 299792458.0;
1529 const double height[2] = {3.21571, 2.25625};
1530 const double radius[2] = {1.40185, 1.5677};
1531 const int ntau = 200;
1532 double ww, xx, ss, theta, sintheta, squigglyC, squigglyS, tau, dtau;
1533 for(
int jj = 0; jj < 2; jj++)
1534 for(
int kk = 0; kk < 89; kk++) {
1535 sintheta = 0.37 + 0.005*double(kk);
1536 theta = asin(sintheta);
1537 ss = height[jj]/cos(theta);
1538 xx = height[jj]*tan(theta)-radius[jj];
1539 for(
int ll = 0; ll < NFREQ; ll++) {
1540 ww = sqrt(2./cc*freq[ll]/ss)*xx*sintheta;
1541 dtau = ww/double(ntau);
1544 for(
int ii = 0; ii < ntau; ii++) {
1545 tau = dtau*(double(ii)+0.5);
1546 squigglyC += cos(M_PI*0.5*tau*tau);
1547 squigglyS += sin(M_PI*0.5*tau*tau);
1551 diffraction[jj][kk][ll] = sqrt(0.5*((0.5+squigglyC)*(0.5+squigglyC)+(0.5+squigglyS)*(0.5+squigglyS)));
1552 if(jj == 0 && kk > 66) diffraction[jj][kk][ll] = 1.0;
1558 double Anita::GetDiffraction(
int ilayer,
double zenith_angle,
int ifreq) {
1559 double reference1 = (sin(zenith_angle)-0.37)*200.0;
1560 int whichbin = int(reference1);
1561 double factor = reference1 - double(whichbin);
1562 return factor*diffraction[ilayer][whichbin+1][ifreq] + (1.-factor)*diffraction[ilayer][whichbin][ifreq];
1565 int Anita::SurfChanneltoBand(
int ichan) {
1568 if (ichan<0 || ichan>31) {
1569 cout <<
"surf channel out of range!\n";
1573 int iband= (ichan%8-ichan%2)/2;
1589 int Anita::GetAntennaNumber(
int ilayer,
int ifold) {
1591 return 8*(ilayer)+ifold+1;
1594 int Anita::GetLayer(
int rx) {
1597 else if (rx>=8 && rx<16)
1599 else if (rx>=16 && rx<32)
1604 int Anita::GetIfold(
int rx) {
1612 int Anita::AntennaWaveformtoSurf(
int ilayer,
int ifold) {
1614 int antenna=GetAntennaNumber(ilayer,ifold);
1616 return antennatosurf[antenna-1];
1619 int Anita::AntennaNumbertoSurfNumber(
int ilayer,
int ifold) {
1620 int antenna=GetAntennaNumber(ilayer,ifold);
1622 return (antenna-1-(antenna-1)%4)/4+1;
1626 int Anita::GetSurfChannel(
int antenna,
int ibw,
int ipol) {
1628 return ((antenna-1)%4)*8+WhichBand(ibw,ipol);
1631 int Anita::WhichBand(
int ibw,
int ipol) {
1633 return 2*ibw+ipol+1;
1635 void Anita::Banding(
int j,
double *freq_noise,
double *vmmhz,
int NPOINTS_NOISE) {
1638 cout <<
"Band out of range.\n";
1643 for (
int i=0;i<NPOINTS_NOISE;i++) {
1645 iband=Tools::findIndex(freq_bands[j],freq_noise[i],NPOINTS_BANDS,freq_bands[j][0],freq_bands[j][NPOINTS_BANDS-1]);
1647 vmmhz[i]=vmmhz[i]*sqrt(bandsattn[j][iband]);
1652 else if (BANDING==1) {
1654 for (
int i=0;i<NPOINTS_NOISE;i++) {
1655 if (freq_noise[i]<bwslice_min[j] || freq_noise[i]>bwslice_max[j])
1661 void Anita::RFCMs(
int ilayer,
int ifold,
double *vmmhz) {
1663 int irx=Anita::GetAntennaNumber(ilayer,ifold)-1;
1666 for (
int i=0;i<NFREQ;i++) {
1668 iampl=Tools::findIndex(freq_ampl[irx],freq[i],NPOINTS_AMPL,freq_ampl[irx][0],freq_ampl[irx][NPOINTS_AMPL-1]);
1670 vmmhz[i]=vmmhz[i]*sqrt(ampl_notdb[irx][iampl]);
1679 void Anita::Set_gain_angle(
Settings *settings1,
double nmedium_receiver) {
1680 string gain_null1, gain_null2;
1684 for(jjj = 0; jjj < 4; jjj++)
1685 for(iii = 0; iii < 131; iii++)
1686 gain_angle[jjj][iii][0] = 1.;
1688 anglefile.open((ICEMC_DATA_DIR+
"/vv_az").c_str());
1689 if(anglefile.fail()) {
1690 cout <<
"can't open `$ICEMC_DATA_DIR`/vv_az\n";
1693 for(jjj = 1; jjj < 7; jjj++)
1694 for(iii = 0; iii < 131; iii++) {
1695 anglefile >> sfrequency >> gain_angle[0][iii][jjj];
1696 if(sfrequency != frequency_forgain_measured[iii]) cout <<
"check frequencies for vv_az\n";
1702 anglefile.open((ICEMC_DATA_DIR+
"/hh_az").c_str());
1703 if(anglefile.fail()) {
1704 cout <<
"can't open `$ICEMC_DATA_DIR`/hh_az\n";
1707 for(jjj = 1; jjj < 7; jjj++)
1708 for(iii = 0; iii < 131; iii++) {
1709 anglefile >> sfrequency >> gain_angle[1][iii][jjj];
1710 if(sfrequency != frequency_forgain_measured[iii]) cout <<
"check frequencies for hh_az\n";
1714 anglefile.open((ICEMC_DATA_DIR+
"/hh_el").c_str());
1715 if(anglefile.fail()) {
1716 cout <<
"can't open `$ICEMC_DATA_DIR`/hh_el\n";
1719 for(jjj = 1; jjj < 7; jjj++)
1720 for(iii = 0; iii < 131; iii++) {
1721 anglefile >> sfrequency >> gain_angle[2][iii][jjj];
1722 if(sfrequency != frequency_forgain_measured[iii]) cout <<
"check frequencies for hh_el\n";
1726 anglefile.open((ICEMC_DATA_DIR+
"/vv_el").c_str());
1727 if(anglefile.fail()) {
1728 cout <<
"can't open `$ICEMC_DATA_DIR`/vv_el\n";
1731 for(jjj = 1; jjj < 7; jjj++)
1732 for(iii = 0; iii < 131; iii++) {
1733 anglefile >> sfrequency >> gain_angle[3][iii][jjj];
1734 if(sfrequency != frequency_forgain_measured[iii]) cout <<
"check frequencies for vv_el\n";
1737 for(jjj = 0; jjj < 6; jjj++) inv_angle_bin_size[jjj] = 1. /
1738 (reference_angle[jjj+1] - reference_angle[jjj]);
1740 double gainhv, gainhh, gainvh, gainvv;
1741 double gain_step = frequency_forgain_measured[1]-frequency_forgain_measured[0];
1743 cout <<
"GAINS is " << GAINS <<
"\n";
1744 for (
int k = 0; k < NFREQ; ++k) {
1745 whichbin[k] = int((freq[k] - frequency_forgain_measured[0]) / gain_step);
1746 if((whichbin[k] >= NPOINTS_GAIN || whichbin[k] < 0) && !settings1->FORSECKEL) {
1747 cout <<
"Set_gain_angle out of range, freq = " << freq[k] << endl;
1752 scalef2[k] = (freq[k] - frequency_forgain_measured[whichbin[k]]) / gain_step;
1754 scalef1[k] = 1. - scalef2[k];
1757 if(whichbin[k] == NPOINTS_GAIN - 1) {
1758 gainhv = gainhv_measured[whichbin[k]];
1759 gainhh = gainh_measured[whichbin[k]];
1760 gainvh = gainvh_measured[whichbin[k]];
1761 gainvv = gainv_measured[whichbin[k]];
1764 gainhv = scalef1[k] * gainhv_measured[whichbin[k]] + scalef2[k] * gainhv_measured[whichbin[k] + 1];
1765 gainhh = scalef1[k] * gainh_measured[whichbin[k]] + scalef2[k] * gainh_measured[whichbin[k] + 1];
1766 gainvh = scalef1[k] * gainvh_measured[whichbin[k]] + scalef2[k] * gainvh_measured[whichbin[k] + 1];
1767 gainvv = scalef1[k] * gainv_measured[whichbin[k]] + scalef2[k] * gainv_measured[whichbin[k] + 1];
1779 hvGaintoHeight[k] = GaintoHeight(gainhv,freq[k],nmedium_receiver);
1780 hhGaintoHeight[k] = GaintoHeight(gainhh,freq[k],nmedium_receiver);
1781 vhGaintoHeight[k] = GaintoHeight(gainvh,freq[k],nmedium_receiver);
1782 vvGaintoHeight[k] = GaintoHeight(gainvv,freq[k],nmedium_receiver);
1799 int Anita::GetBeamWidths(
Settings *settings1) {
1809 double freq_specs[5];
1812 if (settings1->WHICH==7) {
1814 freq_specs[0]=265.E6;
1815 freq_specs[1]=435.E6;
1816 freq_specs[2]=650.E6;
1817 freq_specs[3]=992.5E6;
1821 else if (settings1->WHICH==11) {
1823 freq_specs[0]=265.E6;
1824 freq_specs[1]=435.E6;
1825 freq_specs[2]=650.E6;
1826 freq_specs[3]=992.5E6;
1832 freq_specs[0]=300.E6;
1833 freq_specs[1]=600.E6;
1834 freq_specs[2]=900.E6;
1835 freq_specs[3]=1200.E6;
1836 freq_specs[4]=1500.E6;
1844 if (settings1->WHICH==7) {
1907 double specs2[5][2];
1909 if (settings1->WHICH==7) {
1929 else if (settings1->WHICH==11) {
1986 for (
int i=0;i<4;i++) {
1987 for (
int j=0;j<2;j++) {
1988 specs2[i][j]=pow(10.,specs2[i][j]/10.);
1998 for (
int k=0;k<NFREQ;k++) {
2000 if (freq[k]<freq_specs[0]) {
2001 for (
int j=0;j<4;j++) {
2002 flare[j][k]=specs[0][j]*RADDEG;
2006 else if (freq[k]>=freq_specs[NFREQ_FORGAINS-1]) {
2007 for (
int j=0;j<4;j++) {
2008 flare[j][k]=specs[NFREQ_FORGAINS-1][j]*RADDEG;
2014 for (
int i=0;i<NFREQ_FORGAINS;i++) {
2015 if (freq[k]>=freq_specs[i] && freq[k]<freq_specs[i+1]) {
2016 scale = (freq[k]-freq_specs[i])/(freq_specs[i+1]-freq_specs[i]);
2018 for (
int j=0;j<4;j++) {
2019 flare[j][k]=(specs[i][j]+scale*(specs[i+1][j]-specs[i][j]))*RADDEG;
2029 for (
int k=0;k<NFREQ;k++) {
2031 if (freq[k]<freq_specs[0]) {
2032 for (
int j=0;j<2;j++) {
2033 gain[j][k]=specs2[0][j];
2037 else if (freq[k]>=freq_specs[NFREQ_FORGAINS-1]) {
2038 for (
int j=0;j<2;j++) {
2039 gain[j][k]=specs2[NFREQ_FORGAINS-1][j];
2044 for (
int i=0;i<NFREQ_FORGAINS;i++) {
2045 if (freq[k]>=freq_specs[i] && freq[k]<freq_specs[i+1]) {
2046 scale = (freq[k]-freq_specs[i])/(freq_specs[i+1]-freq_specs[i]);
2048 for (
int j=0;j<2;j++) {
2049 gain[j][k]=specs2[i][j]+scale*(specs2[i+1][j]-specs2[i][j]);
2060 double Anita::Get_gain_angle(
int gain_type,
int k,
double hitangle) {
2061 double scaleh1, scaleh2;
2062 if(gain_type < 0 || gain_type > 3) {
2063 cout <<
"gain_type out of range\n";
2067 hitangle = fabs(hitangle)*DEGRAD;
2068 flare[gain_type][k]=flare[gain_type][k]*DEGRAD;
2069 if(hitangle > 90.00001) {
2070 cout <<
"hitangle out of range\n";
2073 if(hitangle >= 90.) hitangle = 89.99999;
2083 return exp(-1.*(hitangle*hitangle)/(2*flare[gain_type][k]*flare[gain_type][k]));
2085 for(
int iii = 1; iii < 7; iii++) {
2086 if(hitangle <= reference_angle[iii]) {
2087 scaleh2 = (hitangle - reference_angle[iii-1]) *
2088 inv_angle_bin_size[iii-1];
2089 scaleh1 = 1. - scaleh2;
2091 if(whichbin[k] == NPOINTS_GAIN - 1)
2092 return scaleh1 * gain_angle[gain_type][whichbin[k]][iii-1] +
2093 scaleh2 * gain_angle[gain_type][whichbin[k]][iii];
2095 return scaleh1 * scalef1[k] * gain_angle[gain_type][whichbin[k]][iii-1] +
2096 scaleh1 * scalef2[k] * gain_angle[gain_type][whichbin[k]+1][iii-1] +
2097 scaleh2 * scalef1[k] * gain_angle[gain_type][whichbin[k]][iii] +
2098 scaleh2 * scalef2[k] * gain_angle[gain_type][whichbin[k]+1][iii];
2105 cout <<
"Get_gain_angle should have returned a value\n";
2110 void Anita::getDiodeModel( ) {
2114 TF1 *fdown1=
new TF1(
"fl_down1",
"[3]+[0]*exp(-1.*(x-[1])*(x-[1])/(2*[2]*[2]))",-300.E-9,300.E-9);
2115 fdown1->SetParameter(0,-0.8);
2117 fdown1->SetParameter(1,15.E-9);
2118 fdown1->SetParameter(2,2.3E-9);
2120 fdown1->SetParameter(3,0.);
2122 TF1 *fdown2=
new TF1(
"fl_down2",
"[3]+[0]*exp(-1.*(x-[1])*(x-[1])/(2*[2]*[2]))",-300.E-9,300.E-9);
2123 fdown2->SetParameter(0,-0.2);
2125 fdown2->SetParameter(1,15.E-9);
2126 fdown2->SetParameter(2,4.0E-9);
2128 fdown2->SetParameter(3,0.);
2132 idelaybeforepeak[0]=(int)(5.E-9/TIMESTEP);
2133 iwindow[0]=(int)(20.E-9/TIMESTEP);
2134 idelaybeforepeak[1]=(int)(5.E-9/TIMESTEP);
2135 iwindow[1]=(int)(20.E-9/TIMESTEP);
2136 idelaybeforepeak[2]=(int)(5.E-9/TIMESTEP);
2137 iwindow[2]=(int)(20.E-9/TIMESTEP);
2138 idelaybeforepeak[3]=(int)(5.E-9/TIMESTEP);
2139 iwindow[3]=(int)(20.E-9/TIMESTEP);
2140 idelaybeforepeak[4]=(int)(13.E-9/TIMESTEP);
2141 iwindow[4]=(int)(4.E-9/TIMESTEP);
2144 fdown1->Copy(fdiode);
2146 TF1 *f_up=
new TF1(
"f_up",
"[0]*([3]*(x-[1]))^2*exp(-(x-[1])/[2])",-200.E-9,100.E-9);
2148 f_up->SetParameter(2,7.0E-9);
2149 f_up->SetParameter(0,1.);
2150 f_up->SetParameter(1,18.E-9);
2151 f_up->SetParameter(3,1.E9);
2153 f_up->SetParameter(0,-1.*sqrt(2.*PI)*(fdiode.GetParameter(0)*fdiode.GetParameter(2)+fdown2->GetParameter(0)*fdown2->GetParameter(2))/(2.*pow(f_up->GetParameter(2),3.)*1.E18));
2156 for (
int j=0;j<5;j++) {
2159 f_up->SetParameter(0,0.00275);
2161 f_up->SetParameter(0,0.004544);
2163 f_up->SetParameter(0,-1.*sqrt(2.*PI)*(fdiode.GetParameter(0)*fdiode.GetParameter(2)+fdown2->GetParameter(0)*fdown2->GetParameter(2))/(2.*pow(f_up->GetParameter(2),3.)*1.E18));
2165 for (
int i=0;i<NFOUR/2;i++) {
2167 if (time[i]>0. && time[i]<maxt_diode) {
2169 diode_real[j][i]=fdiode.Eval(time[i])+fdown2->Eval(time[i]);
2170 if (time[i]>f_up->GetParameter(1))
2171 diode_real[j][i]+=f_up->Eval(time[i]);
2173 sum+=diode_real[j][i];
2176 diode_real[j][i]=0.;
2186 void Anita::myconvlv(
double *data,
const int NFOUR,
double *fdiode,
double &mindiodeconvl,
double &onediodeconvl,
double *power_noise,
double *diodeconv) {
2194 const int length=NFOUR;
2197 double power_noise_copy[length];
2200 for (
int i=0;i<NFOUR/2;i++) {
2201 power_noise_copy[i]=(data[i]*data[i])/impedence*TIMESTEP;
2203 for (
int i=NFOUR/2;i<NFOUR;i++) {
2204 power_noise_copy[i]=0.;
2216 Tools::realft(power_noise_copy,1,length);
2219 double ans_copy[length];
2227 for (
int j=1;j<length/2;j++) {
2228 ans_copy[2*j]=(power_noise_copy[2*j]*fdiode[2*j]-power_noise_copy[2*j+1]*fdiode[2*j+1])/((
double)length/2);
2229 ans_copy[2*j+1]=(power_noise_copy[2*j+1]*fdiode[2*j]+power_noise_copy[2*j]*fdiode[2*j+1])/((
double)length/2);
2231 ans_copy[0]=power_noise_copy[0]*fdiode[0]/((double)length/2);
2232 ans_copy[1]=power_noise_copy[1]*fdiode[1]/((double)length/2);
2236 Tools::realft(ans_copy,-1,length);
2240 for (
int i=0;i<NFOUR;i++) {
2241 power_noise[i]=power_noise_copy[i];
2242 diodeconv[i]=ans_copy[i];
2247 int iminsamp,imaxsamp;
2249 iminsamp=(int)(maxt_diode/TIMESTEP);
2257 if (imaxsamp<iminsamp) {
2258 cout <<
"Noise waveform is not long enough for this diode response.\n";
2262 int ibin=((iminsamp+imaxsamp)-(iminsamp+imaxsamp)%2)/2;
2266 onediodeconvl=diodeconv[ibin];
2271 for (
int i=iminsamp;i<imaxsamp;i++) {
2273 if (diodeconv[i]<mindiodeconvl)
2274 mindiodeconvl=diodeconv[i];
2295 void Anita::GetPhases() {
2299 double phase_corr,phase_uncorr;
2300 double phasor_x,phasor_y;
2301 TRandom * rng = getRNG(RNG_PHASES);
2303 for (
int k=0;k<NFOUR/4;k++) {
2304 iband=Tools::findIndex(freq_bands[0],freq_forfft[2*k],NPOINTS_BANDS,freq_bands[0][0],freq_bands[0][NPOINTS_BANDS-1]);
2307 phases_rfcm[0][k]=2*PI*rng->Rndm();
2308 phases_rfcm[1][k]=2*PI*rng->Rndm();
2313 if(iband < 0) corr = 0;
2314 else corr=correl_lab[iband];
2316 phase_corr=phases_rfcm[0][k];
2317 phase_uncorr=2*PI*rng->Rndm();
2318 phasor_x=corr*cos(phase_corr)+uncorr*cos(phase_uncorr);
2319 phasor_y=corr*sin(phase_corr)+uncorr*sin(phase_uncorr);
2320 phases_lab[0][k]=TMath::ATan2(phasor_y,phasor_x);
2324 phase_corr=phases_rfcm[1][k];
2325 phase_uncorr=2*PI*rng->Rndm();
2326 phasor_x=corr*cos(phase_corr)+uncorr*cos(phase_uncorr);
2327 phasor_y=corr*sin(phase_corr)+uncorr*sin(phase_uncorr);
2328 phases_lab[1][k]=TMath::ATan2(phasor_y,phasor_x);
2332 for (
int j=0;j<5;j++) {
2334 if(iband < 0) corr = 0;
2335 else corr=correl_banding[j][iband];
2337 phase_corr=phases_rfcm[0][k];
2338 phase_uncorr=2*PI*rng->Rndm();
2339 phasor_x=corr*cos(phase_corr)+uncorr*cos(phase_uncorr);
2340 phasor_y=corr*sin(phase_corr)+uncorr*sin(phase_uncorr);
2341 phases_rfcm_banding[0][j][k]=TMath::ATan2(phasor_y,phasor_x);
2342 phase_corr=phases_rfcm[1][k];
2343 phase_uncorr=2*PI*rng->Rndm();
2344 phasor_x=corr*cos(phase_corr)+uncorr*cos(phase_uncorr);
2345 phasor_y=corr*sin(phase_corr)+uncorr*sin(phase_uncorr);
2346 phases_rfcm_banding[1][j][k]=TMath::ATan2(phasor_y,phasor_x);
2356 void Anita::normalize_for_nsamples(
double *spectrum,
double nsamples,
double nsamp){
2357 for (
int k = 0; k < NFOUR / 4; k++){
2358 spectrum[2 * k] *= sqrt((
double) nsamples / (
double) nsamp);
2359 spectrum[2 * k + 1] *= sqrt((
double) nsamples / (
double) nsamp);
2364 void Anita::convert_power_spectrum_to_voltage_spectrum_for_fft(
int length,
double *spectrum,
double domain[],
double phase[]){
2365 double current_amplitude, current_phase;
2367 for (
int k = 0; k < length/2 ; k++){
2368 current_amplitude = domain[k];
2369 current_phase = phase[k];
2372 Tools::get_random_rician(0., 0., sqrt(2. / M_PI) * domain[k], current_amplitude, current_phase);
2375 spectrum[2 * k] = sqrt(current_amplitude) * cos(phase[k]) / (( (double) NFOUR / 2) / 2);
2376 spectrum[2 * k + 1] = sqrt(current_amplitude) * sin(phase[k]) / (( (double) NFOUR / 2) / 2);
2381 void Anita::GetNoiseWaveforms() {
2383 int nsamples = NFOUR / 2;
2385 double sumfreqdomain = 0.;
2386 double sumtimedomain = 0.;
2388 count_getnoisewaveforms++;
2397 for (
int ipol=0;ipol<2;ipol++)
2398 convert_power_spectrum_to_voltage_spectrum_for_fft(nsamples, timedomainnoise_rfcm[ipol], freqdomain_rfcm, phases_rfcm[ipol] );
2399 for (
int ipol=0;ipol<2;ipol++)
2400 convert_power_spectrum_to_voltage_spectrum_for_fft(nsamples, timedomainnoise_lab[ipol], avgfreqdomain_lab, phases_lab[ipol] );
2415 for (
int ipol=0;ipol<2;ipol++){
2416 normalize_for_nsamples(timedomainnoise_rfcm[ipol], (
double) nsamples, (
double) nsamp);
2417 normalize_for_nsamples(timedomainnoise_lab[ipol], (
double) nsamples, (
double) nsamp);
2422 for (
int k = 0; k < NFOUR / 4; k++){
2423 sumfreqdomain += avgfreqdomain_lab[k];
2426 Tools::realft(timedomainnoise_rfcm[ipol], -1, NFOUR / 2);
2427 Tools::realft(timedomainnoise_lab[ipol], -1, NFOUR / 2);
2432 for (
int k = 0; k < NFOUR / 2; k++) {
2433 timedomainnoise_lab[ipol][k] *=THERMALNOISE_FACTOR;
2434 timedomainnoise_rfcm[ipol][k]*=THERMALNOISE_FACTOR;
2437 sumtimedomain += timedomainnoise_lab[ipol][k] * timedomainnoise_lab[ipol][k];
2438 rms_rfcm_e_single_event += timedomainnoise_rfcm[ipol][k] * timedomainnoise_rfcm[ipol][k];
2440 rms_rfcm[ipol] += timedomainnoise_rfcm[ipol][k] * timedomainnoise_rfcm[ipol][k] / ((double) NFOUR / 2);
2441 rms_lab[ipol] += timedomainnoise_lab[ipol][k] * timedomainnoise_lab[ipol][k] / ((double) NFOUR / 2);
2447 for (
int iband=0; iband<5; iband++) {
2448 for (
int ipol=0;ipol<2;ipol++)
2449 convert_power_spectrum_to_voltage_spectrum_for_fft(NFOUR/2,timedomainnoise_rfcm_banding[ipol][iband], freqdomain_rfcm_banding[iband], phases_rfcm_banding[ipol][iband]);
2450 for (
int ipol=0;ipol<2;ipol++)
2451 normalize_for_nsamples(timedomainnoise_rfcm_banding[ipol][iband], (
double) nsamples, (double) nsamp);
2452 for (
int ipol=0;ipol<2;ipol++)
2453 Tools::realft(timedomainnoise_rfcm_banding[ipol][iband], -1, NFOUR / 2);
2464 void Anita::GetArrayFromFFT(
double *tmp_fftvhz,
double *vhz_rx){
2466 int firstNonZero = Tools::Getifreq(freq[0],freq_forfft[0],freq_forfft[NFOUR/2-1],NFOUR/4);
2467 int lastNonZero = Tools::Getifreq(freq[NFREQ-1],freq_forfft[0],freq_forfft[NFOUR/2-1],NFOUR/4);
2468 double norm=TMath::Sqrt(
double(lastNonZero-firstNonZero)/
double(NFREQ));
2471 for (
int ifreq=0;ifreq<NFOUR/4;ifreq++){
2472 tmp_fftvhz[ifreq]=TMath::Sqrt(tmp_fftvhz[2*ifreq]*tmp_fftvhz[2*ifreq] + tmp_fftvhz[2*ifreq+1]*tmp_fftvhz[2*ifreq+1]);
2475 for (
int ifreq=0; ifreq<NFREQ; ifreq++){
2477 int ifour=Tools::Getifreq(freq[ifreq],freq_forfft[0],freq_forfft[NFOUR/2-1],NFOUR/4);
2478 vhz_rx[ifreq]=tmp_fftvhz[ifour]*norm;
2485 void Anita::GetPhasesFromFFT(
double *tmp_fftvhz,
double *phases){
2487 for (
int ifreq=0; ifreq<NFOUR/4; ifreq++){
2488 phases[ifreq]=TMath::ATan2(tmp_fftvhz[ifreq+1], tmp_fftvhz[ifreq])*180./PI;
2494 void Anita::FromTimeDomainToIcemcArray(
double *vsignalarray,
double vhz[NFREQ]){
2497 Tools::realft(vsignalarray,1,NFOUR/2);
2499 GetPhasesFromFFT(vsignalarray, v_phases);
2502 GetArrayFromFFT(vsignalarray, vhz);
2508 void Anita::MakeArrayforFFT(
double *vsignalarray_e,
double *vsignal_e_forfft,
double phasedelay,
bool useconstantdelay) {
2510 Tools::Zero(vsignal_e_forfft,NFOUR/2);
2512 double previous_value_e_even=0.;
2513 double previous_value_e_odd=0.;
2514 int count_nonzero=0;
2516 int ifirstnonzero=-1;
2517 int ilastnonzero=2000;
2518 for (
int i=0;i<NFREQ;i++) {
2522 int ifour=Tools::Getifreq(freq[i],freq_forfft[0],freq_forfft[NFOUR/2-1],NFOUR/4);
2524 if (ifour!=-1 && 2*ifour+1<NFOUR/2) {
2526 if (ifirstnonzero==-1){
2527 ifirstnonzero=ifour;
2530 vsignal_e_forfft[2*ifour]=vsignalarray_e[i]*2/((double)NFOUR/2);
2534 vsignal_e_forfft[2*ifour+1]=vsignalarray_e[i]*2/((double)NFOUR/2);
2540 for (
int j=iprevious+1;j<ifour;j++) {
2541 vsignal_e_forfft[2*j]=previous_value_e_even+(vsignal_e_forfft[2*ifour]-previous_value_e_even)*(
double)(j-iprevious)/(
double)(ifour-iprevious);
2544 vsignal_e_forfft[2*j+1]=previous_value_e_odd+(vsignal_e_forfft[2*ifour+1]-previous_value_e_odd)*(
double)(j-iprevious)/(
double)(ifour-iprevious);
2549 previous_value_e_even=vsignal_e_forfft[2*ifour];
2550 previous_value_e_odd=vsignal_e_forfft[2*ifour+1];
2558 for (
int j=0;j<NFOUR/4;j++) {
2559 vsignal_e_forfft[2*j]*=sqrt((
double)count_nonzero/(
double)(ilastnonzero-ifirstnonzero));
2560 vsignal_e_forfft[2*j+1]*=sqrt((
double)count_nonzero/(
double)(ilastnonzero-ifirstnonzero));
2565 if (useconstantdelay){
2566 double cosphase=cos(phasedelay*PI/180.);
2567 double sinphase=sin(phasedelay*PI/180.);
2568 for (
int ifour=0;ifour<NFOUR/4;ifour++) {
2570 cosphase = cos(v_phases[ifour]*PI/180.);
2571 sinphase = sin(v_phases[ifour]*PI/180.);
2573 vsignal_e_forfft[2*ifour]*=cosphase;
2574 vsignal_e_forfft[2*ifour+1]*=sinphase;
2580 void Anita::BoxAverageComplex(
double *array,
const int n,
int navg) {
2582 double array_temp[2*n];
2583 for (
int i=0;i<n;i++) {
2586 array_temp[2*i+1]=0.;
2589 for (
int k=i;k<i+navg;k++) {
2591 array_temp[2*i]+=array[2*k];
2592 array_temp[2*i+1]+=array[2*k+1];
2596 array[2*i]=array_temp[2*i]/(double)navg;
2597 array[2*i+1]=array_temp[2*i+1]/(double)navg;
2599 array_temp[2*i]=array[2*i];
2600 array_temp[2*i+1]=array[2*i+1];
2604 void Anita::BoxAverage(
double *array,
const int n,
int navg) {
2606 double array_temp[n];
2607 for (
int i=0;i<n;i++) {
2611 for (
int k=i;k<i+navg;k++) {
2613 array_temp[i]+=array[k];
2617 array[i]=array_temp[i]/(double)navg;
2620 array_temp[i]=array[i];
2626 void Anita::labAttn(
double *vhz) {
2627 for (
int i=0;i<NFREQ;i++) {
2629 int ilab=Tools::findIndex(freqlab,freq[i],NPOINTS_LAB,freqlab[0],freqlab[NPOINTS_LAB-1]);
2631 vhz[i]*=sqrt(labattn[ilab]);
2632 vhz[i]*=sqrt(labattn[ilab]);
2635 cout <<
"Lab attenuation outside of band.\n";
2639 int Anita::getLabAttn(
int NPOINTS_LAB,
double *freqlab,
double *labattn) {
2641 ifstream flab((ICEMC_DATA_DIR+
"/surfatten_run294_ch23v.dat").c_str());
2643 cout <<
"Cannot open lab data file.\n";
2652 float ffreqlab,flabattn;
2655 while (!flab.eof() && index<NPOINTS_LAB) {
2657 flab >> ffreqlab >> flabattn;
2658 labattn[index]=(double)pow(10.,flabattn/10.);
2662 freqlab[index]=(double)ffreqlab;
2676 double Anita::GaintoHeight(
double gain,
double freq,
double nmedium_receiver) {
2681 return 2*sqrt(gain/4/PI*CLIGHT*CLIGHT/(freq*freq)*Zr/(Z0*nmedium_receiver));
2685 void Anita::fill_coherent_waveform_sum_tree(
unsigned event_number,
unsigned center_phi_sector_index,
Settings* settings1,
double rms_noise,
double actual_rms,
unsigned window_start,
unsigned window_end,
double deg_theta,
double deg_phi,
double actual_deg_theta,
double actual_deg_phi, vector <double>& summed_wfm, vector <double>& power_of_summed_wfm,
double power){
2687 cwst_event_number = event_number;
2688 cwst_center_phi_sector = center_phi_sector_index;
2689 cwst_rms_noise = rms_noise;
2690 cwst_actual_rms = actual_rms;
2691 cwst_threshold = settings1->COHERENT_THRESHOLD;
2692 cwst_window_start = window_start;
2693 cwst_window_end = window_end;
2695 cwst_deg_theta = deg_theta;
2696 cwst_deg_phi = deg_phi;
2698 cwst_actual_deg_theta = actual_deg_theta;
2699 cwst_actual_deg_phi = actual_deg_phi;
2702 for (
int i = 0; i < HALFNFOUR; i++){
2703 cwst_timesteps[i] = i;
2706 cwst_summed_wfm = summed_wfm;
2707 cwst_power_of_summed_wfm = power_of_summed_wfm;
2710 coherent_waveform_sum_tree->Fill();
2720 const double gps_offset = atan2(-0.7042,0.71), MINCH = 0.0254, phase_center = 0.17;
2722 const double phase_center_anita2_analysis=.2;
2724 const double gps_offset_anita2=atan2(-0.7085,0.7056);
2725 const double gps_offset_anita3= 45*RADDEG;
2726 const double phase_center_anita3=0.20;
2729 if (settings1->WHICH==0) {
2733 settings1->CYLINDRICALSYMMETRY=0;
2734 PHI_EACHLAYER[0][0]=0.;
2735 PHI_EACHLAYER[0][1]=22.5*RADDEG;
2738 THETA_ZENITH[0]=PI/2+10.*RADDEG;
2739 LAYER_VPOSITION[0]=0.;
2740 LAYER_HPOSITION[0]=0.;
2741 LAYER_PHIPOSITION[0]=0.;
2743 for (
int i=0;i<5;i++) {
2747 for (
int i=0;i<NRX_PHI[0];i++) {
2753 else if (settings1->WHICH==1) {
2755 settings1->CYLINDRICALSYMMETRY=1;
2764 PHI_OFFSET[1]=2*PI/(double)NRX_PHI[1]/2;
2766 PHI_OFFSET[3]=2*PI/(double)NRX_PHI[3]/2;
2769 THETA_ZENITH[0]=PI/2+10.*RADDEG;
2770 THETA_ZENITH[1]=PI/2+10.*RADDEG;
2771 THETA_ZENITH[2]=PI/2+10.*RADDEG;
2772 THETA_ZENITH[3]=PI/2+10.*RADDEG;
2773 THETA_ZENITH[4]=3*PI/4;
2777 LAYER_VPOSITION[0]=3.5;
2778 LAYER_VPOSITION[1]=2.0;
2779 LAYER_VPOSITION[2]=-0.5;
2780 LAYER_VPOSITION[3]=-2.0;
2781 LAYER_VPOSITION[4]=-3.5;
2783 LAYER_HPOSITION[0]=0.;
2784 LAYER_HPOSITION[1]=0.;
2785 LAYER_HPOSITION[2]=0.;
2786 LAYER_HPOSITION[3]=0.;
2787 LAYER_HPOSITION[4]=0.;
2789 LAYER_PHIPOSITION[0]=0.;
2790 LAYER_PHIPOSITION[1]=0.;
2791 LAYER_PHIPOSITION[2]=0.;
2792 LAYER_PHIPOSITION[3]=0.;
2793 LAYER_PHIPOSITION[4]=0.;
2797 for (
int i=0;i<5;i++) {
2803 else if (settings1->WHICH==2) {
2804 settings1->CYLINDRICALSYMMETRY=1;
2819 PHI_OFFSET[1]=-2.*PI/(double)NRX_PHI[0]/2.;
2820 PHI_OFFSET[2]=-2.*PI/(double)NRX_PHI[0]/2.;
2821 PHI_OFFSET[3]=-2.*PI/(double)NRX_PHI[0]/4.;
2826 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
2827 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
2828 THETA_ZENITH[2]=PI/2+INCLINE_TOPTHREE*RADDEG;
2829 THETA_ZENITH[3]=PI/2+INCLINE_NADIR*RADDEG;
2838 LAYER_VPOSITION[0]=0;
2839 LAYER_VPOSITION[1] = -0.9670034;
2840 LAYER_VPOSITION[2] = -3.730752;
2841 LAYER_VPOSITION[3]=(-3.175-0.948-0.889);
2843 LAYER_HPOSITION[0]=0.;
2844 LAYER_HPOSITION[1] = 0.;
2845 LAYER_HPOSITION[2] = 0.;
2846 LAYER_HPOSITION[3]=0.;
2850 else if (settings1->WHICH==3) {
2852 cout <<
"Is this configuration cylindrically symmetric? Yes(1) or No(0)\n";
2853 cin >> settings1->CYLINDRICALSYMMETRY;
2855 cout <<
"How many layers?\n";
2856 cin >> settings1->NLAYERS;
2858 for (
int i=0;i<settings1->NLAYERS;i++) {
2860 cout <<
"How many antennas in the " << i <<
"th layer?\n";
2863 cout <<
"What is the offset in phi for the " << i <<
"th layer?\n";
2864 cin >> PHI_OFFSET[i];
2866 cout <<
"What is the theta ascent for the " << i <<
"th layer (0 if pointed straight upwards, PI if pointed straight downwards)?\n";
2867 cin >> THETA_ZENITH[i];
2869 cout <<
"What is the vertical position of this layer relative to the vertical center of the payload?";
2870 cin >> LAYER_VPOSITION[i];
2872 cout <<
"What is the distance between of the vertical axis of the payload and the center of this layer?";
2873 cin >> LAYER_HPOSITION[i];
2875 cout <<
"What is the phi of this layer relative to the vertical center of the payload in the horizontal plane?";
2876 cin >> LAYER_PHIPOSITION[i];
2880 if (settings1->CYLINDRICALSYMMETRY==0) {
2881 for (
int j=0;j<NRX_PHI[i];j++) {
2882 cout <<
"What is the phi of the " << j <<
"th antenna is this layer?\n";
2883 cin >> PHI_EACHLAYER[i][j];
2888 cout <<
"How many polarizations must pass a voltage threshold?\n";
2889 cin >> settings1->NFOLD;
2891 cout <<
"How many times the expected noise level should the voltage threshold be?\n";
2892 cin >> maxthreshold;
2895 else if (settings1->WHICH==4) {
2900 if (settings1->NLAYERS!=2)
2901 cout <<
"Warning!!! Did not enter the right number of layers in the input file. For Anita Hill, it's 2.";
2903 settings1->CYLINDRICALSYMMETRY=1;
2913 cout <<
"phi_offsets are " << PHI_OFFSET[0] <<
" " << PHI_OFFSET[1] <<
"\n";
2918 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
2919 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
2926 LAYER_VPOSITION[0]=0.;
2927 LAYER_VPOSITION[1] = 0.;
2929 LAYER_HPOSITION[0]=0.;
2930 LAYER_HPOSITION[1] = 100.;
2932 LAYER_PHIPOSITION[0]=0.;
2933 LAYER_PHIPOSITION[1] = 30.*RADDEG;
2936 else if(settings1->WHICH==6) {
2938 settings1->CYLINDRICALSYMMETRY=0;
2949 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
2950 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
2951 THETA_ZENITH[2]=PI/2+INCLINE_TOPTHREE*RADDEG;
2957 ANTENNA_POSITION_START[0][0][0] = MINCH *
Vector(40.957,-39.29,125.38).RotateZ(-gps_offset);
2958 ANTENNA_POSITION_START[0][0][1] = MINCH *
Vector(57.608,0.606,124.97).RotateZ(-gps_offset);
2959 ANTENNA_POSITION_START[0][0][2] = MINCH *
Vector(41.049,40.605,124.896).RotateZ(-gps_offset);
2960 ANTENNA_POSITION_START[0][0][3] = MINCH *
Vector(1.032,57.128,124.93).RotateZ(-gps_offset);
2961 ANTENNA_POSITION_START[0][0][4] = MINCH *
Vector(-38.832,40.508,125.607).RotateZ(-gps_offset);
2962 ANTENNA_POSITION_START[0][0][5] = MINCH *
Vector(-55.545,0.549,125.851).RotateZ(-gps_offset);
2963 ANTENNA_POSITION_START[0][0][6] = MINCH *
Vector(-38.793,-39.423,126.105).RotateZ(-gps_offset);
2964 ANTENNA_POSITION_START[0][0][7] = MINCH *
Vector(1.113,-55.918,125.731).RotateZ(-gps_offset);
2965 ANTENNA_POSITION_START[0][1][0] = MINCH *
Vector(19.841,-45.739,87.738).RotateZ(-gps_offset);
2966 ANTENNA_POSITION_START[0][1][1] = MINCH *
Vector(46.959,-18.601,87.364).RotateZ(-gps_offset);
2967 ANTENNA_POSITION_START[0][1][2] = MINCH *
Vector(46.983,19.646,87.208).RotateZ(-gps_offset);
2968 ANTENNA_POSITION_START[0][1][3] = MINCH *
Vector(19.823,46.633,87.194).RotateZ(-gps_offset);
2969 ANTENNA_POSITION_START[0][1][4] = MINCH *
Vector(-18.429,46.496,87.486).RotateZ(-gps_offset);
2970 ANTENNA_POSITION_START[0][1][5] = MINCH *
Vector(-45.439,19.34,88.0).RotateZ(-gps_offset);
2971 ANTENNA_POSITION_START[0][1][6] = MINCH *
Vector(-45.446,-18.769,88.183).RotateZ(-gps_offset);
2972 ANTENNA_POSITION_START[0][1][7] = MINCH *
Vector(-18.297,-45.857,88.066).RotateZ(-gps_offset);
2973 ANTENNA_POSITION_START[0][2][0] = MINCH *
Vector(38.622,-94.184,-20.615).RotateZ(-gps_offset);
2974 ANTENNA_POSITION_START[0][2][1] = MINCH *
Vector(71.662,-72.036,-20.966).RotateZ(-gps_offset);
2975 ANTENNA_POSITION_START[0][2][2] = MINCH *
Vector(93.857,-39.130,-21.512).RotateZ(-gps_offset);
2976 ANTENNA_POSITION_START[0][2][3] = MINCH *
Vector(101.664,-0.202,-21.942).RotateZ(-gps_offset);
2977 ANTENNA_POSITION_START[0][2][4] = MINCH *
Vector(93.993,38.733,-22.351).RotateZ(-gps_offset);
2978 ANTENNA_POSITION_START[0][2][5] = MINCH *
Vector(71.92,71.815,-22.386).RotateZ(-gps_offset);
2979 ANTENNA_POSITION_START[0][2][6] = MINCH *
Vector(38.944,93.885,-22.274).RotateZ(-gps_offset);
2980 ANTENNA_POSITION_START[0][2][7] = MINCH *
Vector(0.036,101.619,-21.813).RotateZ(-gps_offset);
2981 ANTENNA_POSITION_START[0][2][8] = MINCH *
Vector(-38.991,93.809,-21.281).RotateZ(-gps_offset);
2982 ANTENNA_POSITION_START[0][2][9] = MINCH *
Vector(-71.899,71.704,-20.777).RotateZ(-gps_offset);
2983 ANTENNA_POSITION_START[0][2][10] = MINCH *
Vector(-94.121,38.754,-20.825).RotateZ(-gps_offset);
2984 ANTENNA_POSITION_START[0][2][11] = MINCH *
Vector(-101.986,-0.133,-20.71).RotateZ(-gps_offset);
2985 ANTENNA_POSITION_START[0][2][12] = MINCH *
Vector(-94.175,-39.024,-20.671).RotateZ(-gps_offset);
2986 ANTENNA_POSITION_START[0][2][13] = MINCH *
Vector(-72.138,-72.132,-20.295).RotateZ(-gps_offset);
2987 ANTENNA_POSITION_START[0][2][14] = MINCH *
Vector(-39.111,-94.25,-20.23).RotateZ(-gps_offset);
2988 ANTENNA_POSITION_START[0][2][15] = MINCH *
Vector(-0.163,-101.975,-20.229).RotateZ(-gps_offset);
2989 PHI_EACHLAYER[0][0] = -45.103 * RADDEG - gps_offset;
2990 PHI_EACHLAYER[0][1] = -0.14 * RADDEG - gps_offset;
2991 PHI_EACHLAYER[0][2] = 44.559 * RADDEG - gps_offset;
2992 PHI_EACHLAYER[0][3] = 89.959 * RADDEG - gps_offset;
2993 PHI_EACHLAYER[0][4] = 135.555 * RADDEG - gps_offset;
2994 PHI_EACHLAYER[0][5] = 179.651 * RADDEG - gps_offset;
2995 PHI_EACHLAYER[0][6] = -135.14 * RADDEG - gps_offset;
2996 PHI_EACHLAYER[0][7] = -90.18 * RADDEG - gps_offset;
2997 PHI_EACHLAYER[1][0] = -67.283 * RADDEG - gps_offset;
2998 PHI_EACHLAYER[1][1] = -23.004 * RADDEG - gps_offset;
2999 PHI_EACHLAYER[1][2] = 22.72 * RADDEG - gps_offset;
3000 PHI_EACHLAYER[1][3] = 67.82 * RADDEG - gps_offset;
3001 PHI_EACHLAYER[1][4] = 112.698 * RADDEG - gps_offset;
3002 PHI_EACHLAYER[1][5] = 157.565 * RADDEG - gps_offset;
3003 PHI_EACHLAYER[1][6] = -157.376 * RADDEG - gps_offset;
3004 PHI_EACHLAYER[1][7] = -112.449 * RADDEG - gps_offset;
3005 PHI_EACHLAYER[2][0] = -67.26 * RADDEG - gps_offset;
3006 PHI_EACHLAYER[2][1] = -45.284 * RADDEG - gps_offset;
3007 PHI_EACHLAYER[2][2] = -22.457 * RADDEG - gps_offset;
3008 PHI_EACHLAYER[2][3] = 0.227 * RADDEG - gps_offset;
3009 PHI_EACHLAYER[2][4] = 22.318 * RADDEG - gps_offset;
3010 PHI_EACHLAYER[2][5] = 45.008 * RADDEG - gps_offset;
3011 PHI_EACHLAYER[2][6] = 67.751 * RADDEG - gps_offset;
3012 PHI_EACHLAYER[2][7] = 89.913 * RADDEG - gps_offset;
3013 PHI_EACHLAYER[2][8] = 113.016 * RADDEG - gps_offset;
3014 PHI_EACHLAYER[2][9] = 135.608 * RADDEG - gps_offset;
3015 PHI_EACHLAYER[2][10] = 157.487 * RADDEG - gps_offset;
3016 PHI_EACHLAYER[2][11] = 179.709 * RADDEG - gps_offset;
3017 PHI_EACHLAYER[2][12] = -157.569 * RADDEG - gps_offset;
3018 PHI_EACHLAYER[2][13] = -135.021 * RADDEG - gps_offset;
3019 PHI_EACHLAYER[2][14] = -112.773 * RADDEG - gps_offset;
3020 PHI_EACHLAYER[2][15] = -89.959 * RADDEG - gps_offset;
3021 ANTENNA_DOWN[0][0] = 10.422 * RADDEG;
3022 ANTENNA_DOWN[0][1] = 10.207 * RADDEG;
3023 ANTENNA_DOWN[0][2] = 10.714 * RADDEG;
3024 ANTENNA_DOWN[0][3] = 10.381 * RADDEG;
3025 ANTENNA_DOWN[0][4] = 10.026 * RADDEG;
3026 ANTENNA_DOWN[0][5] = 9.515 * RADDEG;
3027 ANTENNA_DOWN[0][6] = 9.677 * RADDEG;
3028 ANTENNA_DOWN[0][7] = 9.544 * RADDEG;
3029 ANTENNA_DOWN[1][0] = 10.183 * RADDEG;
3030 ANTENNA_DOWN[1][1] = 10.44 * RADDEG;
3031 ANTENNA_DOWN[1][2] = 10.562 * RADDEG;
3032 ANTENNA_DOWN[1][3] = 10.655 * RADDEG;
3033 ANTENNA_DOWN[1][4] = 10.265 * RADDEG;
3034 ANTENNA_DOWN[1][5] = 9.77 * RADDEG;
3035 ANTENNA_DOWN[1][6] = 9.422 * RADDEG;
3036 ANTENNA_DOWN[1][7] = 9.526 * RADDEG;
3037 ANTENNA_DOWN[2][0] = 9.364 * RADDEG;
3038 ANTENNA_DOWN[2][1] = 9.712 * RADDEG;
3039 ANTENNA_DOWN[2][2] = 9.892 * RADDEG;
3040 ANTENNA_DOWN[2][3] = 10.253 * RADDEG;
3041 ANTENNA_DOWN[2][4] = 10.574 * RADDEG;
3042 ANTENNA_DOWN[2][5] = 10.62 * RADDEG;
3043 ANTENNA_DOWN[2][6] = 10.416 * RADDEG;
3044 ANTENNA_DOWN[2][7] = 10.189 * RADDEG;
3045 ANTENNA_DOWN[2][8] = 9.776 * RADDEG;
3046 ANTENNA_DOWN[2][9] = 9.596 * RADDEG;
3047 ANTENNA_DOWN[2][10] = 9.561 * RADDEG;
3048 ANTENNA_DOWN[2][11] = 9.695 * RADDEG;
3049 ANTENNA_DOWN[2][12] = 9.445 * RADDEG;
3050 ANTENNA_DOWN[2][13] = 9.387 * RADDEG;
3051 ANTENNA_DOWN[2][14] = 9.398 * RADDEG;
3052 ANTENNA_DOWN[2][15] = 9.288 * RADDEG;
3053 for(
int iii = 0; iii < 3; iii++)
3054 for(
int jjj = 0; jjj < NRX_PHI[iii]; jjj++)
3055 ANTENNA_POSITION_START[1][iii][jjj] = ANTENNA_POSITION_START[0][iii][jjj] = ANTENNA_POSITION_START[0][iii][jjj] - phase_center *
Vector(cos(PHI_EACHLAYER[iii][jjj])*sin(90.*RADDEG+ANTENNA_DOWN[iii][jjj]), sin(PHI_EACHLAYER[iii][jjj])*sin(90.*RADDEG+ANTENNA_DOWN[iii][jjj]), cos(90.*RADDEG+ANTENNA_DOWN[iii][jjj]));
3057 else if (settings1->WHICH==7) {
3065 settings1->CYLINDRICALSYMMETRY=1;
3088 THETA_ZENITH[0]=PI/2+5.5*RADDEG;
3089 THETA_ZENITH[1]=PI/2+7.5*RADDEG;
3090 THETA_ZENITH[2]=PI/2+9.5*RADDEG;
3091 THETA_ZENITH[3]=PI/2+11.5*RADDEG;
3092 THETA_ZENITH[4]=PI/2+13.5*RADDEG;
3103 LAYER_VPOSITION[0]=0;
3104 LAYER_VPOSITION[1]=10.;
3105 LAYER_VPOSITION[2]=20.;
3106 LAYER_VPOSITION[3]=30.;
3107 LAYER_VPOSITION[4]=40.;
3109 LAYER_HPOSITION[0]=0.;
3110 LAYER_HPOSITION[1]=0.;
3111 LAYER_HPOSITION[2]=0.;
3112 LAYER_HPOSITION[3]=0.;
3113 LAYER_HPOSITION[4]=0.;
3117 else if (settings1->WHICH==8) {
3118 cout<<
"initializing and using anitaII payload geometry"<<endl;
3127 settings1->CYLINDRICALSYMMETRY=0;
3144 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
3145 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
3146 THETA_ZENITH[2]=PI/2+INCLINE_TOPTHREE*RADDEG;
3147 THETA_ZENITH[3]=PI/2+INCLINE_TOPTHREE*RADDEG;
3149 ANTENNA_POSITION_START[0][0][0] = MINCH *
Vector(40.438,-36.958,147.227);
3150 ANTENNA_POSITION_START[0][0][1] = MINCH * Vector(57.134,3.109,146.476);
3151 ANTENNA_POSITION_START[0][0][2] = MINCH * Vector(40.549,43.106,145.871);
3152 ANTENNA_POSITION_START[0][0][3] = MINCH * Vector(0.624,59.688,145.361);
3153 ANTENNA_POSITION_START[0][0][4] = MINCH * Vector(-39.455,43.147,145.928);
3154 ANTENNA_POSITION_START[0][0][5] = MINCH * Vector(-56.096,3.177,146.894);
3155 ANTENNA_POSITION_START[0][0][6] = MINCH * Vector(-39.355,-36.753,147.757);
3156 ANTENNA_POSITION_START[0][0][7] = MINCH * Vector(0.645,-53.539,147.876);
3157 ANTENNA_POSITION_START[0][1][0] = MINCH * Vector(19.554,-43.890,109.531);
3158 ANTENNA_POSITION_START[0][1][1] = MINCH * Vector(46.600,-16.625,108.889);
3159 ANTENNA_POSITION_START[0][1][2] = MINCH * Vector(46.587,21.659,108.220);
3160 ANTENNA_POSITION_START[0][1][3] = MINCH * Vector(19.476,48.539,107.671);
3161 ANTENNA_POSITION_START[0][1][4] = MINCH * Vector(-18.798,48.502,107.852);
3162 ANTENNA_POSITION_START[0][1][5] = MINCH * Vector(-45.899,21.424,108.516);
3163 ANTENNA_POSITION_START[0][1][6] = MINCH * Vector(-45.895,-16.821,109.354);
3164 ANTENNA_POSITION_START[0][1][7] = MINCH * Vector(-18.691,-43.864,109.843);
3165 ANTENNA_POSITION_START[0][2][0] = MINCH * Vector(38.636,-93.988,2.636);
3166 ANTENNA_POSITION_START[0][2][1] = MINCH * Vector(71.690,-72.108,1.953);
3167 ANTENNA_POSITION_START[0][2][2] = MINCH * Vector(93.897,-39.211,0.498);
3168 ANTENNA_POSITION_START[0][2][3] = MINCH * Vector(101.790,-0.212,-0.661);
3169 ANTENNA_POSITION_START[0][2][4] = MINCH * Vector(94.047,38.773,-1.788);
3170 ANTENNA_POSITION_START[0][2][5] = MINCH * Vector(72.080,71.816,-2.223);
3171 ANTENNA_POSITION_START[0][2][6] = MINCH * Vector(39.065,93.999,-2.561);
3172 ANTENNA_POSITION_START[0][2][7] = MINCH * Vector(0.121,101.815,-2.314);
3173 ANTENNA_POSITION_START[0][2][8] = MINCH * Vector(-38.815,94.002,-2.034);
3174 ANTENNA_POSITION_START[0][2][9] = MINCH * Vector(-71.809,71.912,-1.102);
3175 ANTENNA_POSITION_START[0][2][10] = MINCH * Vector(-93.886,39.000,-0.673);
3176 ANTENNA_POSITION_START[0][2][11] = MINCH * Vector(-101.885,0.048,0.102);
3177 ANTENNA_POSITION_START[0][2][12] = MINCH * Vector(-94.017,-38.841,0.865);
3178 ANTENNA_POSITION_START[0][2][13] = MINCH * Vector(-72.079,-71.902,1.864);
3179 ANTENNA_POSITION_START[0][2][14] = MINCH * Vector(-39.152,-93.935,2.464);
3180 ANTENNA_POSITION_START[0][2][15] = MINCH * Vector(-0.290,-101.771,2.991);
3181 ANTENNA_POSITION_START[0][3][0] = MINCH * Vector(32.625,-82.045,-71.140);
3182 ANTENNA_POSITION_START[0][3][1] = MINCH * Vector(79.071,-35.639,-72.809);
3183 ANTENNA_POSITION_START[0][3][2] = MINCH * Vector(79.172,30.988,-74.893);
3184 ANTENNA_POSITION_START[0][3][3] = MINCH * Vector(32.608,77.414,-75.342);
3185 ANTENNA_POSITION_START[0][3][4] = MINCH * Vector(-33.398,78.088,-74.957);
3186 ANTENNA_POSITION_START[0][3][5] = MINCH * Vector(-79.367,31.568,-73.922);
3187 ANTENNA_POSITION_START[0][3][6] = MINCH * Vector(-78.900,-34.192,-72.645);
3188 ANTENNA_POSITION_START[0][3][7] = MINCH * Vector(-33.046,-81.696,-70.907);
3189 PHI_EACHLAYER[0][0] = -45.012 * RADDEG ;
3190 PHI_EACHLAYER[0][1] = -0.588 * RADDEG ;
3191 PHI_EACHLAYER[0][2] = 45.694 * RADDEG ;
3192 PHI_EACHLAYER[0][3] = 90.310 * RADDEG ;
3193 PHI_EACHLAYER[0][4] = 135.161 * RADDEG ;
3194 PHI_EACHLAYER[0][5] = 179.861 * RADDEG ;
3195 PHI_EACHLAYER[0][6] = -134.930 * RADDEG ;
3196 PHI_EACHLAYER[0][7] = -90.638 * RADDEG ;
3197 PHI_EACHLAYER[1][0] = -67.412 * RADDEG ;
3198 PHI_EACHLAYER[1][1] = -23.005 * RADDEG ;
3199 PHI_EACHLAYER[1][2] = 22.503 * RADDEG ;
3200 PHI_EACHLAYER[1][3] = 67.722 * RADDEG ;
3201 PHI_EACHLAYER[1][4] = 112.614 * RADDEG ;
3202 PHI_EACHLAYER[1][5] = 157.685 * RADDEG ;
3203 PHI_EACHLAYER[1][6] = -156.639 * RADDEG ;
3204 PHI_EACHLAYER[1][7] = -112.587 * RADDEG ;
3205 PHI_EACHLAYER[2][0] = -67.365 * RADDEG ;
3206 PHI_EACHLAYER[2][1] = -45.135 * RADDEG ;
3207 PHI_EACHLAYER[2][2] = -23.002 * RADDEG ;
3208 PHI_EACHLAYER[2][3] = -1.013 * RADDEG ;
3209 PHI_EACHLAYER[2][4] = 21.934 * RADDEG ;
3210 PHI_EACHLAYER[2][5] = 44.467 * RADDEG ;
3211 PHI_EACHLAYER[2][6] = 67.288 * RADDEG ;
3212 PHI_EACHLAYER[2][7] = 89.971 * RADDEG ;
3213 PHI_EACHLAYER[2][8] = 112.390 * RADDEG ;
3214 PHI_EACHLAYER[2][9] = 134.988 * RADDEG ;
3215 PHI_EACHLAYER[2][10] = 157.387 * RADDEG ;
3216 PHI_EACHLAYER[2][11] = 179.843 * RADDEG ;
3217 PHI_EACHLAYER[2][12] = -157.444 * RADDEG ;
3218 PHI_EACHLAYER[2][13] = -134.877 * RADDEG ;
3219 PHI_EACHLAYER[2][14] = -112.406 * RADDEG ;
3220 PHI_EACHLAYER[2][15] = -90.081 * RADDEG ;
3221 PHI_EACHLAYER[3][0] = -67.997 * RADDEG ;
3222 PHI_EACHLAYER[3][1] = -22.948 * RADDEG ;
3223 PHI_EACHLAYER[3][2] = 22.382 * RADDEG ;
3224 PHI_EACHLAYER[3][3] = 67.583 * RADDEG ;
3225 PHI_EACHLAYER[3][4] = 112.844 * RADDEG ;
3226 PHI_EACHLAYER[3][5] = 157.761 * RADDEG ;
3227 PHI_EACHLAYER[3][6] = -157.896 * RADDEG ;
3228 PHI_EACHLAYER[3][7] = -112.791 * RADDEG ;
3229 ANTENNA_DOWN[0][0] = 9.637 * RADDEG;
3230 ANTENNA_DOWN[0][1] = 10.108 * RADDEG;
3231 ANTENNA_DOWN[0][2] = 11.245 * RADDEG;
3232 ANTENNA_DOWN[0][3] = 11.291 * RADDEG;
3233 ANTENNA_DOWN[0][4] = 10.988 * RADDEG;
3234 ANTENNA_DOWN[0][5] = 9.491 * RADDEG;
3235 ANTENNA_DOWN[0][6] = 9.027 * RADDEG;
3236 ANTENNA_DOWN[0][7] = 8.743 * RADDEG;
3237 ANTENNA_DOWN[1][0] = 9.445 * RADDEG;
3238 ANTENNA_DOWN[1][1] = 10.061 * RADDEG;
3239 ANTENNA_DOWN[1][2] = 10.772 * RADDEG;
3240 ANTENNA_DOWN[1][3] = 11.484 * RADDEG;
3241 ANTENNA_DOWN[1][4] = 11.122 * RADDEG;
3242 ANTENNA_DOWN[1][5] = 10.376 * RADDEG;
3243 ANTENNA_DOWN[1][6] = 9.410 * RADDEG;
3244 ANTENNA_DOWN[1][7] = 9.039 * RADDEG;
3245 ANTENNA_DOWN[2][0] = 8.233 * RADDEG;
3246 ANTENNA_DOWN[2][1] = 8.807 * RADDEG;
3247 ANTENNA_DOWN[2][2] = 9.120 * RADDEG;
3248 ANTENNA_DOWN[2][3] = 10.352 * RADDEG;
3249 ANTENNA_DOWN[2][4] = 10.889 * RADDEG;
3250 ANTENNA_DOWN[2][5] = 11.315 * RADDEG;
3251 ANTENNA_DOWN[2][6] = 11.402 * RADDEG;
3252 ANTENNA_DOWN[2][7] = 11.379 * RADDEG;
3253 ANTENNA_DOWN[2][8] = 10.842 * RADDEG;
3254 ANTENNA_DOWN[2][9] = 10.725 * RADDEG;
3255 ANTENNA_DOWN[2][10] = 10.143 * RADDEG;
3256 ANTENNA_DOWN[2][11] = 10.067 * RADDEG;
3257 ANTENNA_DOWN[2][12] = 9.503 * RADDEG;
3258 ANTENNA_DOWN[2][13] = 9.021 * RADDEG;
3259 ANTENNA_DOWN[2][14] = 8.453 * RADDEG;
3260 ANTENNA_DOWN[2][15] = 8.268 * RADDEG;
3261 ANTENNA_DOWN[3][0] = 8.007 * RADDEG;
3262 ANTENNA_DOWN[3][1] = 9.817 * RADDEG;
3263 ANTENNA_DOWN[3][2] = 10.259 * RADDEG;
3264 ANTENNA_DOWN[3][3] = 11.648 * RADDEG;
3265 ANTENNA_DOWN[3][4] = 10.271 * RADDEG;
3266 ANTENNA_DOWN[3][5] = 10.015 * RADDEG;
3267 ANTENNA_DOWN[3][6] = 10.889 * RADDEG;
3268 ANTENNA_DOWN[3][7] = 7.314 * RADDEG;
3270 SIMON_DELTA_R[0][0] = -0.0384839;
3271 SIMON_DELTA_R[0][1] = 0.00634697;
3272 SIMON_DELTA_R[0][2] = -0.0861167;
3273 SIMON_DELTA_R[0][3] = 0.0461873;
3274 SIMON_DELTA_R[0][4] = 0.0153388;
3275 SIMON_DELTA_R[0][5] = -0.00927728;
3276 SIMON_DELTA_R[0][6] = 0.0239867;
3277 SIMON_DELTA_R[0][7] = 0.0125282;
3278 SIMON_DELTA_R[1][0] = -0.0111636;
3279 SIMON_DELTA_R[1][1] = -0.0959452;
3280 SIMON_DELTA_R[1][2] = -0.0330808;
3281 SIMON_DELTA_R[1][3] = -0.0475617;
3282 SIMON_DELTA_R[1][4] = 0.0196292;
3283 SIMON_DELTA_R[1][5] = -0.0190837;
3284 SIMON_DELTA_R[1][6] = -0.00922367;
3285 SIMON_DELTA_R[1][7] = -0.0294811;
3286 SIMON_DELTA_R[2][0] = 0.0140245;
3287 SIMON_DELTA_R[2][1] = -0.0621836;
3288 SIMON_DELTA_R[2][2] = -0.0379325;
3289 SIMON_DELTA_R[2][3] = -0.0108062;
3290 SIMON_DELTA_R[2][4] = -0.0601935;
3291 SIMON_DELTA_R[2][5] = -0.0968276;
3292 SIMON_DELTA_R[2][6] = -0.0348523;
3293 SIMON_DELTA_R[2][7] = 0.0121726;
3294 SIMON_DELTA_R[2][8] = 0.0405193;
3295 SIMON_DELTA_R[2][9] = 0.0239992;
3296 SIMON_DELTA_R[2][10] = -0.0405203;
3297 SIMON_DELTA_R[2][11] = -0.00401756;
3298 SIMON_DELTA_R[2][12] = -0.0362955;
3299 SIMON_DELTA_R[2][13] = -0.00587152;
3300 SIMON_DELTA_R[2][14] = -0.00611182;
3301 SIMON_DELTA_R[2][15] = -0.00321244;
3302 SIMON_DELTA_R[3][0] = -0.0437687;
3303 SIMON_DELTA_R[3][1] = -0.0643475;
3304 SIMON_DELTA_R[3][2] = -0.0804245;
3305 SIMON_DELTA_R[3][3] = -0.0112675;
3306 SIMON_DELTA_R[3][4] = 0.0337428;
3307 SIMON_DELTA_R[3][5] = -0.0525977;
3308 SIMON_DELTA_R[3][6] = -0.101587;
3309 SIMON_DELTA_R[3][7] = -0.0401037;
3311 SIMON_DELTA_PHI[0][0] = -0.0100608;
3312 SIMON_DELTA_PHI[0][1] = -0.00313443;
3313 SIMON_DELTA_PHI[0][2] = -0.015312;
3314 SIMON_DELTA_PHI[0][3] = 0.00206827;
3315 SIMON_DELTA_PHI[0][4] = -0.0227948;
3316 SIMON_DELTA_PHI[0][5] = 0.00750385;
3317 SIMON_DELTA_PHI[0][6] = 0.00388065;
3318 SIMON_DELTA_PHI[0][7] = -0.00131021;
3319 SIMON_DELTA_PHI[1][0] = -0.0299233;
3320 SIMON_DELTA_PHI[1][1] = -0.00165365;
3321 SIMON_DELTA_PHI[1][2] = -0.0107407;
3322 SIMON_DELTA_PHI[1][3] = 0.0145914;
3323 SIMON_DELTA_PHI[1][4] = -0.0150373;
3324 SIMON_DELTA_PHI[1][5] = -0.0121967;
3325 SIMON_DELTA_PHI[1][6] = -0.0038106;
3326 SIMON_DELTA_PHI[1][7] = 0.0106842;
3327 SIMON_DELTA_PHI[2][0] = -0.0087849;
3328 SIMON_DELTA_PHI[2][1] = 0.000682206;
3329 SIMON_DELTA_PHI[2][2] = -0.00516052;
3330 SIMON_DELTA_PHI[2][3] = -0.00770935;
3331 SIMON_DELTA_PHI[2][4] = -0.00862535;
3332 SIMON_DELTA_PHI[2][5] = -0.00920648;
3333 SIMON_DELTA_PHI[2][6] = 0.00037431;
3334 SIMON_DELTA_PHI[2][7] = 0.00310935;
3335 SIMON_DELTA_PHI[2][8] = -0.00546085;
3336 SIMON_DELTA_PHI[2][9] = -0.00901249;
3337 SIMON_DELTA_PHI[2][10] = -0.0145529;
3338 SIMON_DELTA_PHI[2][11] = -0.00666063;
3339 SIMON_DELTA_PHI[2][12] = -0.00372999;
3340 SIMON_DELTA_PHI[2][13] = 0.00197442;
3341 SIMON_DELTA_PHI[2][14] = -0.000789595;
3342 SIMON_DELTA_PHI[2][15] = 0.000188257;
3343 SIMON_DELTA_PHI[3][0] = -0.00289577;
3344 SIMON_DELTA_PHI[3][1] = -0.0203117;
3345 SIMON_DELTA_PHI[3][2] = -0.00503387;
3346 SIMON_DELTA_PHI[3][3] = -0.000220575;
3347 SIMON_DELTA_PHI[3][4] = -0.00416114;
3348 SIMON_DELTA_PHI[3][5] = -0.0223176;
3349 SIMON_DELTA_PHI[3][6] = 0.0058874;
3350 SIMON_DELTA_PHI[3][7] = 0.00899651;
3352 for(
int iii = 0; iii < 4; iii++){
3353 for(
int jjj = 0; jjj < NRX_PHI[iii]; jjj++){
3356 ANTENNA_POSITION_START[0][iii][jjj] = ANTENNA_POSITION_START[0][iii][jjj] - phase_center_anita2_analysis * Vector(cos(PHI_EACHLAYER[iii][jjj])*cos(-1*ANTENNA_DOWN[iii][jjj]), sin(PHI_EACHLAYER[iii][jjj])*cos(-1*ANTENNA_DOWN[iii][jjj]), sin(-1*ANTENNA_DOWN[iii][jjj]));
3367 for(
int iii = 0; iii < 4; iii++){
3368 for(
int jjj = 0; jjj < NRX_PHI[iii]; jjj++){
3369 x = ANTENNA_POSITION_START[0][iii][jjj][0];
3370 y = ANTENNA_POSITION_START[0][iii][jjj][1];
3371 z = ANTENNA_POSITION_START[0][iii][jjj][2];
3373 r = sqrt(pow(x,2)+pow(y,2));
3376 ANTENNA_POSITION_START[0][iii][jjj]= Vector((r+SIMON_DELTA_R[iii][jjj])*cos(phi+SIMON_DELTA_PHI[iii][jjj]),(r+SIMON_DELTA_R[iii][jjj])*sin(phi+SIMON_DELTA_PHI[iii][jjj]),z);
3378 ANTENNA_POSITION_START[1][iii][jjj]=ANTENNA_POSITION_START[0][iii][jjj]=ANTENNA_POSITION_START[0][iii][jjj].RotateZ(-gps_offset_anita2);
3379 PHI_EACHLAYER[iii][jjj]=atan2(ANTENNA_POSITION_START[0][iii][jjj][1],ANTENNA_POSITION_START[0][iii][jjj][0]);
3387 else if (settings1->WHICH==9 || settings1->WHICH==10) {
3390 string whichANITAroman=
"";
3391 if (settings1->WHICH==9) whichANITAroman+=
"III";
3392 else whichANITAroman+=
"IV";
3393 cout<<
"Initializing and using ANITA-" << whichANITAroman <<
" payload geometry"<<endl;
3401 settings1->CYLINDRICALSYMMETRY=0;
3422 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
3423 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
3424 THETA_ZENITH[2]=PI/2+INCLINE_TOPTHREE*RADDEG;
3425 THETA_ZENITH[3]=PI/2+INCLINE_TOPTHREE*RADDEG;
3428 #ifdef ANITA_UTIL_EXISTS 3429 photoFile += ( (string)getenv(
"ANITA_UTIL_INSTALL_DIR") +
"/share/anitaCalib/anita"+whichANITAroman+
"Photogrammetry.csv");
3431 photoFile += (ICEMC_DATA_DIR+
"/anita"+whichANITAroman+
"Photogrammetry.csv");
3434 std::ifstream Anita3PhotoFile(photoFile.c_str());
3435 if (!Anita3PhotoFile){
3436 std::cerr <<
"Couldn't open photogrammetry!" << std::endl;
3442 for(
int i=0;i<2;i++) {
3443 line.ReadLine(Anita3PhotoFile);
3448 Double_t xAntPhoto[48];
3449 Double_t yAntPhoto[48];
3450 Double_t zAntPhoto[48];
3451 Double_t rAntPhoto[48];
3452 Double_t azCentrePhoto[48];
3453 Double_t apertureAzPhoto[48];
3454 Double_t apertureElPhoto[48];
3456 for(
int ant=0;ant<48;ant++) {
3457 line.ReadLine(Anita3PhotoFile);
3459 TObjArray *tokens = line.Tokenize(
",");
3460 for(
int j=0;j<8;j++) {
3461 const TString subString = ((TObjString*)tokens->At(j))->GetString();
3466 if (ant+1 != subString.Atoi()) {
3467 std::cerr <<
"Antenna number mismatch\n";
3471 xAntPhoto[ant]=subString.Atof();
3474 yAntPhoto[ant]=subString.Atof();
3477 zAntPhoto[ant]=subString.Atof();
3480 rAntPhoto[ant]=subString.Atof();
3483 azCentrePhoto[ant]=subString.Atof();
3486 apertureAzPhoto[ant]=subString.Atof();
3489 apertureElPhoto[ant]=subString.Atof()*(-1);
3499 Anita3PhotoFile.close();
3502 for (
int iant=0; iant<8;iant++){
3503 ANTENNA_POSITION_START[1][0][iant] = ANTENNA_POSITION_START[0][0][iant] = MINCH *
Vector(xAntPhoto[iant*2], yAntPhoto[iant*2], zAntPhoto[iant*2]).RotateZ(-gps_offset_anita3);
3504 ANTENNA_POSITION_START[1][1][iant] = ANTENNA_POSITION_START[0][1][iant] = MINCH *
Vector(xAntPhoto[iant*2+1], yAntPhoto[iant*2+1], zAntPhoto[iant*2+1]).RotateZ(-gps_offset_anita3);
3506 PHI_EACHLAYER[0][iant] = azCentrePhoto[iant*2] * RADDEG - gps_offset_anita3;
3507 PHI_EACHLAYER[1][iant] = azCentrePhoto[iant*2+1] * RADDEG - gps_offset_anita3;
3508 ANTENNA_DOWN[0][iant] = apertureElPhoto[iant*2] * RADDEG;
3509 ANTENNA_DOWN[1][iant] = apertureElPhoto[iant*2+1] * RADDEG;
3514 for (
int iant=0; iant<16;iant++){
3515 ANTENNA_POSITION_START[1][2][iant] = ANTENNA_POSITION_START[0][2][iant] = MINCH *
Vector(xAntPhoto[iant+16], yAntPhoto[iant+16], zAntPhoto[iant+16]).RotateZ(-gps_offset_anita3);
3516 ANTENNA_POSITION_START[1][3][iant] = ANTENNA_POSITION_START[0][3][iant] = MINCH *
Vector(xAntPhoto[iant+32], yAntPhoto[iant+32], zAntPhoto[iant+32]).RotateZ(-gps_offset_anita3);
3518 PHI_EACHLAYER[2][iant] = azCentrePhoto[iant+16] * RADDEG - gps_offset_anita3;
3519 ANTENNA_DOWN[2][iant] = apertureElPhoto[iant+16] * RADDEG;
3521 PHI_EACHLAYER[3][iant] = azCentrePhoto[iant+32] * RADDEG - gps_offset_anita3;
3522 ANTENNA_DOWN[3][iant] = apertureElPhoto[iant+32] * RADDEG;
3527 string whichANITAcard=
"";
3528 if (settings1->WHICH==9) whichANITAcard+=
"3";
3529 else whichANITAcard+=
"4";
3530 string phaseCenterName;
3531 #ifdef ANITA_UTIL_EXISTS 3532 phaseCenterName += ( (string)getenv(
"ANITA_UTIL_INSTALL_DIR") +
"/share/anitaCalib/phaseCenterPositionsRelativeToPhotogrammetryAnita"+whichANITAcard+
".dat");
3534 phaseCenterName += (ICEMC_DATA_DIR+
"/phaseCenterPositionsRelativeToPhotogrammetryAnita"+whichANITAcard+
".dat");
3537 std::ifstream PhaseCenterFile(phaseCenterName.c_str());
3538 Int_t antNum, tpol, pol;
3539 Double_t deltaR,deltaPhi,deltaZ;
3540 char firstLine[180];
3541 Double_t deltaRPhaseCentre[2][4][16];
3542 Double_t deltaZPhaseCentre[2][4][16];
3543 Double_t deltaPhiPhaseCentre[2][4][16];
3545 PhaseCenterFile.getline(firstLine,179);
3547 while(PhaseCenterFile >> antNum >> tpol >> deltaR >> deltaPhi >> deltaZ) {
3548 int ilayer = (antNum<16)*((antNum%2==0)*0 + (antNum%2==1)*1)+ (antNum>15)*(antNum<32)*2+(antNum>31)*3;
3549 int ifold = (ilayer<2)*((antNum-ilayer)/2)+(ilayer>1)*(antNum%16);
3552 else if (tpol==0) pol=1;
3554 deltaRPhaseCentre[pol][ilayer][ifold]=deltaR;
3555 deltaPhiPhaseCentre[pol][ilayer][ifold]=deltaPhi*TMath::DegToRad();
3556 deltaZPhaseCentre[pol][ilayer][ifold]=deltaZ;
3558 PhaseCenterFile.close();
3560 std::ifstream relativePhaseCenterToAmpaDelaysFile((ICEMC_DATA_DIR+
"/relativePhaseCenterToAmpaDelaysAnita"+whichANITAcard+
".dat").c_str());
3562 #ifdef ANITA_UTIL_EXISTS 3565 int tempAnt, intTempPol;
3567 for(Int_t surf=0; surf<NUM_SURF; surf++){
3568 for(Int_t chan=0; chan<NUM_CHAN; chan++){
3572 intTempPol = (tempPol==0) ? 1 : 0;
3580 for(
int ipol=0; ipol<2; ipol++){
3581 for (
int iant=0; iant<48; iant++){
3582 extraCableDelays[ipol][iant] = 0;
3589 double x, y, z, r, phi;
3590 for(
int ilayer = 0; ilayer < 4; ilayer++){
3591 for(
int ifold = 0; ifold < NRX_PHI[ilayer]; ifold++){
3592 for (
int ipol = 1; ipol >= 0; ipol--){
3596 ANTENNA_POSITION_START[ipol][ilayer][ifold] = ANTENNA_POSITION_START[ipol][ilayer][ifold] - phase_center_anita3 *
Vector(cos(PHI_EACHLAYER[ilayer][ifold])*cos(ANTENNA_DOWN[ilayer][ifold]), sin(PHI_EACHLAYER[ilayer][ifold])*cos(ANTENNA_DOWN[ilayer][ifold]), sin(ANTENNA_DOWN[ilayer][ifold]));
3597 x = ANTENNA_POSITION_START[ipol][ilayer][ifold].GetX();
3598 y = ANTENNA_POSITION_START[ipol][ilayer][ifold].GetY();
3600 r = sqrt(pow(x,2)+pow(y,2)) + deltaRPhaseCentre[ipol][ilayer][ifold];
3601 phi = atan2(y,x) + deltaPhiPhaseCentre[ipol][ilayer][ifold];
3602 z = ANTENNA_POSITION_START[ipol][ilayer][ifold].GetZ() + deltaZPhaseCentre[ipol][ilayer][ifold];
3604 if(phi<0) phi+=TMath::TwoPi();
3605 if(phi>TMath::TwoPi()) phi-=TMath::TwoPi();
3607 ANTENNA_POSITION_START[ipol][ilayer][ifold]= Vector(r*cos(phi),r*sin(phi),z);
3609 if (ipol==0) PHI_EACHLAYER[ilayer][ifold]=phi;
3616 if (settings1->WHICH==10) ANTENNA_POSITION_START[1][ilayer][ifold] = ANTENNA_POSITION_START[0][ilayer][ifold];
3622 else if (settings1->WHICH==11) {
3627 settings1->CYLINDRICALSYMMETRY=1;
3639 PHI_OFFSET[1]=-2.*PI/(double)NRX_PHI[0]/2.;
3642 THETA_ZENITH[0]=PI/2+INCLINE_TOPTHREE*RADDEG;
3643 THETA_ZENITH[1]=PI/2+INCLINE_TOPTHREE*RADDEG;
3650 LAYER_VPOSITION[0]=0;
3651 LAYER_VPOSITION[1] = -7.5;
3653 LAYER_HPOSITION[0]=0.;
3654 LAYER_HPOSITION[1] = 0.;
3659 settings1->NANTENNAS=0;
3660 for (
int i=0;i<settings1->NLAYERS;i++)
3661 settings1->NANTENNAS+=NRX_PHI[i];
3663 cout <<
"nantennas is " << settings1->NANTENNAS <<
"\n";
3664 number_all_antennas=settings1->NANTENNAS;
3668 if (settings1->WHICH==0) {
3669 temp_eachrx[0]=919.4;
3670 temp_eachrx[1]=1051.8;
3671 for (
int j=2;j<16;j++) {
3676 for (
int j=0;j<16;j++) {
3678 temp_eachrx[j]=(240.+200.);
3682 for (
int i=0;i<NRX_PHI[0];i++) {
3687 void Anita::calculate_all_offsets(
void) {
3689 double angle_phi, angle_theta;
3691 double hypothesis_offset[3][3];
3693 vector<double> angles_tmp;
3694 vector< vector <double> > angles_diffthetas_tmp;
3696 double step_phi=(MAX_PHI_HYPOTHESIS-MIN_PHI_HYPOTHESIS)/(
double)N_STEPS_PHI;
3697 double step_theta=(MAX_THETA_HYPOTHESIS-MIN_THETA_HYPOTHESIS)/(
double)N_STEPS_THETA;
3699 cout <<
"step_theta is " << step_theta <<
"\n";
3701 for (
unsigned center_phi_sector_index = 0; center_phi_sector_index < 1; ++center_phi_sector_index) {
3703 for (
unsigned index_phi = 0; index_phi < N_STEPS_PHI; ++index_phi) {
3706 angle_phi = (double)center_phi_sector_index * 22.5 + MIN_PHI_HYPOTHESIS + (
double)index_phi * step_phi;
3709 angles_diffthetas_tmp.clear();
3710 for (
unsigned index_theta = 0; index_theta < N_STEPS_THETA; ++index_theta) {
3711 angle_theta = MIN_THETA_HYPOTHESIS + (double)index_theta*step_theta;
3717 angles_tmp.push_back(angle_phi);
3718 angles_tmp.push_back(angle_theta);
3720 angles_diffthetas_tmp.push_back(angles_tmp);
3722 calculate_single_offset(center_phi_sector_index, angle_phi, angle_theta, hypothesis_offset);
3724 for (
unsigned i_layer = 0; i_layer < N_SUMMED_LAYERS; ++i_layer) {
3725 for (
unsigned i_sector = 0; i_sector < N_SUMMED_PHI_SECTORS; ++i_sector) {
3726 hypothesis_offsets[center_phi_sector_index][index_phi][index_theta][i_sector][i_layer] = int(Tools::round(hypothesis_offset[i_sector][i_layer] / TRIG_TIMESTEP));
3732 hypothesis_angles.push_back(angles_diffthetas_tmp);
3737 getDifferentOffsets();
3738 printDifferentOffsets();
3741 void Anita::printDifferentOffsets() {
3742 ofstream ofile(
"outputs/offsets.txt");
3743 ofile <<
"number of offsets is " << vdifferent_offsets.size() <<
"\n";
3746 for (
unsigned int i=0;i<vdifferent_offsets.size();i++) {
3747 for (
int j=0;j<2;j++) {
3748 ofile << vdifferent_angles[i][j] <<
"\t";
3750 for (
unsigned int j=0;j<N_SUMMED_PHI_SECTORS;j++) {
3751 for (
unsigned int k=0;k<N_SUMMED_LAYERS;k++) {
3753 ofile << vdifferent_offsets[i][N_SUMMED_LAYERS*j+k] <<
" ";
3762 void Anita::getDifferentOffsets() {
3765 vector<double> vangles_tmp;
3767 for (
int center_phi_sector_index=0;center_phi_sector_index<1;center_phi_sector_index++) {
3768 for (
unsigned index_phi = 0; index_phi < N_STEPS_PHI; ++index_phi) {
3769 for (
unsigned index_theta = 0; index_theta < N_STEPS_THETA; ++index_theta) {
3771 vangles_tmp.clear();
3772 vangles_tmp.push_back(hypothesis_angles[index_phi][index_theta][0]);
3773 vangles_tmp.push_back(hypothesis_angles[index_phi][index_theta][1]);
3775 for (
unsigned i_sector = 0; i_sector < N_SUMMED_PHI_SECTORS; ++i_sector) {
3776 for (
unsigned i_layer = 0; i_layer < N_SUMMED_LAYERS; ++i_layer) {
3777 vtmp.push_back(hypothesis_offsets[center_phi_sector_index][index_phi][index_theta][i_sector][i_layer]);
3788 for (
unsigned int i=0;i<vdifferent_offsets.size();i++) {
3789 if (vtmp==vdifferent_offsets[i]) {
3799 vdifferent_offsets.push_back(vtmp);
3800 vdifferent_angles.push_back(vangles_tmp);
3808 void Anita::calculate_single_offset(
const unsigned center_phi_sector_index,
const double angle_phi,
const double angle_theta,
double hypothesis_offset[][3]) {
3809 double maximum_time = -2000E-9;
3811 double to_center_of_summed_phi_sectors=((double)N_SUMMED_PHI_SECTORS/2.)*22.5-11.25;
3813 Vector normal_vector =
Vector(cos(angle_theta * RADDEG) * cos((angle_phi+to_center_of_summed_phi_sectors) * RADDEG), cos(angle_theta * RADDEG) * sin((angle_phi+to_center_of_summed_phi_sectors) * RADDEG), sin(angle_theta * RADDEG));
3819 Vector one_antenna_pos = antenna_positions[0][2*16+center_phi_sector_index];
3823 int phi_start=-1*(int)((
double)N_SUMMED_PHI_SECTORS/2.)+1;
3828 for (
signed int phi_sector_offset = phi_start; phi_sector_offset < (int)(phi_start+N_SUMMED_PHI_SECTORS); phi_sector_offset++) {
3829 unsigned i_sector = (phi_sector_offset + center_phi_sector_index + 16)%16;
3831 for (
unsigned i_layer = 0; i_layer < N_SUMMED_LAYERS; ++i_layer) {
3834 Vector antenna_pos = antenna_positions[0][16*i_layer+i_sector];
3839 double offset = (-1. / CLIGHT) * normal_vector * (antenna_pos - one_antenna_pos);
3842 if (offset >= maximum_time) {
3843 maximum_time = offset;
3852 hypothesis_offset[phi_sector_offset-phi_start][i_layer] = offset;
3856 for (
unsigned i_layer = 0; i_layer < N_SUMMED_LAYERS; ++i_layer) {
3857 for (
unsigned i_sector = 0; i_sector < N_SUMMED_PHI_SECTORS; ++i_sector) {
3858 hypothesis_offset[i_sector][i_layer] -= maximum_time;
3859 hypothesis_offset[i_sector][i_layer]*=-1.;
3870 for (
int ipol=0; ipol<2; ipol++){
3872 for (
int antenna_index = 0; antenna_index < (number_all_antennas); antenna_index++) {
3873 arrival_times[ipol][antenna_index] = (antenna_positions[ipol][antenna_index] * rf_direction) / CLIGHT;
3883 if( settings1->WHICH==8 ){
3887 double theta_deg =rf_tmp_dir.Theta() * DEGRAD;
3889 double phi_deg = rf_tmp_dir.Phi() *DEGRAD;
3890 double totalAngledeg;
3893 double phi_eachlayer;
3894 double theta_offset;
3899 theta_deg = theta_deg -90;
3902 theta_deg = theta_deg - theta_offset;
3903 for(
int iii = 0; iii < 4; iii++){
3904 for(
int jjj = 0; jjj < NRX_PHI[iii]; jjj++){
3906 phi_deg = rf_tmp_dir.Phi();
3908 phi_eachlayer =atan2(ANTENNA_POSITION_START[ipol][iii][jjj][1],ANTENNA_POSITION_START[ipol][iii][jjj][0]);
3910 phi_deg =phi_deg- phi_eachlayer;
3912 if(fabs(phi_deg) > fabs(phi_deg+2*PI)) phi_deg+=2*PI;
3913 if(fabs(phi_deg) > fabs(phi_deg-2*PI)) phi_deg-=2*PI;
3914 phi_deg =phi_deg*DEGRAD;
3915 totalAngledeg = phi_deg*phi_deg + theta_deg*theta_deg;
3916 if(totalAngledeg > 2500) totalAngledeg=2500;
3918 extra_delay = (totalAngledeg*totalAngledeg)*1.45676e-8;
3919 extra_delay -= (totalAngledeg)*5.01452e-6;
3921 arrival_times[ipol][ant_ctr]+=extra_delay*1E-9;
3931 double minV = Tools::dMin(arrival_times[0],(number_all_antennas));
3932 double minH = Tools::dMin(arrival_times[1],(number_all_antennas));
3933 double first_trigger_time = Tools::dMin(minV, minH);
3934 for (
int ipol=0; ipol<2; ipol++){
3935 for (
int i=0;i<(number_all_antennas);i++){
3941 arrival_times[ipol][i] -= first_trigger_time;
3954 void Anita::GetArrivalTimesBoresights(
const Vector rf_direction[NLAYERS_MAX][NPHI_MAX],
Balloon *bn1,
Settings *settings1) {
3956 for (
int ipol=0; ipol<2; ipol++){
3957 for (
int antenna_index = 0; antenna_index < (number_all_antennas); antenna_index++) {
3958 int ilayer = (antenna_index<8)*0 + (antenna_index>7)*(antenna_index<16)*1+ (antenna_index>15)*(antenna_index<32)*2+(antenna_index>31)*3;
3959 int ifold = (ilayer<2)*(antenna_index%8)+(ilayer>1)*(antenna_index%16);
3960 arrival_times[ipol][antenna_index] = (antenna_positions[ipol][antenna_index] * rf_direction[ilayer][ifold]) / CLIGHT;
3969 if(settings1->WHICH==8 ){
3973 double theta_deg =rf_tmp_dir.Theta() * DEGRAD;
3975 double phi_deg = rf_tmp_dir.Phi() *DEGRAD;
3976 double totalAngledeg;
3979 double phi_eachlayer;
3980 double theta_offset;
3985 theta_deg = theta_deg -90;
3988 theta_deg = theta_deg - theta_offset;
3990 phi_deg = rf_tmp_dir.Phi();
3992 phi_eachlayer =atan2(ANTENNA_POSITION_START[ipol][ilayer][ifold][1],ANTENNA_POSITION_START[ipol][ilayer][ifold][0]);
3994 phi_deg =phi_deg- phi_eachlayer;
3996 if(fabs(phi_deg) > fabs(phi_deg+2*PI)) phi_deg+=2*PI;
3997 if(fabs(phi_deg) > fabs(phi_deg-2*PI)) phi_deg-=2*PI;
3998 phi_deg =phi_deg*DEGRAD;
3999 totalAngledeg = phi_deg*phi_deg + theta_deg*theta_deg;
4000 if(totalAngledeg > 2500) totalAngledeg=2500;
4002 extra_delay = (totalAngledeg*totalAngledeg)*1.45676e-8;
4003 extra_delay -= (totalAngledeg)*5.01452e-6;
4005 arrival_times[ipol][ant_ctr]+=extra_delay*1E-9;
4012 double minV = Tools::dMin(arrival_times[0],(number_all_antennas));
4013 double minH = Tools::dMin(arrival_times[1],(number_all_antennas));
4014 double first_trigger_time = Tools::dMin(minV, minH);
4015 for (
int ipol=0; ipol<2; ipol++){
4016 for (
int i=0;i<(number_all_antennas);i++){
4018 arrival_times[ipol][i] -= first_trigger_time;
4025 void Anita::GetArrivalTimesBoresights(
const Vector rf_direction[NLAYERS_MAX][NPHI_MAX]) {
4027 for (
int ipol=0; ipol<2; ipol++){
4028 for (
int antenna_index = 0; antenna_index < (number_all_antennas); antenna_index++) {
4029 int ilayer = (antenna_index<8)*0 + (antenna_index>7)*(antenna_index<16)*1+ (antenna_index>15)*(antenna_index<32)*2+(antenna_index>31)*3;
4030 int ifold = (ilayer<2)*(antenna_index%8)+(ilayer>1)*(antenna_index%16);
4031 arrival_times[ipol][antenna_index] = (antenna_positions[ipol][antenna_index] * rf_direction[ilayer][ifold]) / CLIGHT;
4042 double minV = Tools::dMin(arrival_times[0],(number_all_antennas));
4043 double minH = Tools::dMin(arrival_times[1],(number_all_antennas));
4044 double first_trigger_time = Tools::dMin(minV, minH);
4045 for (
int ipol=0; ipol<2; ipol++){
4046 for (
int i=0;i<(number_all_antennas);i++){
4048 arrival_times[ipol][i] = arrival_times[ipol][i] - first_trigger_time + additionalDt;
4057 void Anita::setphiTrigMask(UInt_t realTime_flightdata) {
4059 if (realTime_flightdata<realTime_tr_min || realTime_flightdata>realTime_tr_max) {
4068 iturf=turfratechain->GetEntryNumberWithBestIndex(realTime_flightdata);
4076 turfratechain->GetEvent(iturf);
4084 void Anita::setTimeDependentThresholds(UInt_t realTime_flightdata){
4086 if (realTime_flightdata<realTime_surf_min || realTime_flightdata>realTime_surf_max) {
4087 for(
int ipol=0;ipol<2;ipol++){
4088 for (
int iant=0;iant<48;iant++){
4089 scalers[ipol][iant]=thresholds[ipol][iant]=0.;
4095 isurf=surfchain->GetEntryNumberWithBestIndex(realTime_flightdata);
4097 for(
int ipol=0;ipol<2;ipol++){
4098 for (
int iant=0;iant<48;iant++){
4099 scalers[ipol][iant]=thresholds[ipol][iant]=0.;
4103 surfchain->GetEvent(isurf);
4111 #ifdef ANITA_UTIL_EXISTS 4112 void Anita::readImpulseResponseDigitizer(
Settings *settings1){
4115 deltaT = 1./(2.6*16.);
4116 string graphNames[2][3][16];
4123 if (settings1->WHICH==8){
4124 fileName = ICEMC_DATA_DIR+
"/sumPicoImpulse.root";
4126 for (
int iring=0;iring<3;iring++){
4127 for (
int iphi=1;iphi<17;iphi++){
4128 graphNames[0][iring][iphi]=
"grImpRespV";
4129 graphNames[1][iring][iphi]=
"grImpRespH";
4134 }
else if(settings1->WHICH==9 || settings1->WHICH==10){
4136 fileName = ICEMC_DATA_DIR+
"/Anita3_ImpulseResponseDigitizer.root";
4138 string spol[2] ={
"V",
"H"};
4139 string sring[3]={
"T",
"M",
"B"};
4141 for (
int ipol=0;ipol<2;ipol++){
4142 for (
int iring=0;iring<3;iring++){
4143 for (
int iphi=0;iphi<16;iphi++){
4144 graphNames[ipol][iring][iphi] = Form(
"g%02d%s%s", iphi+1, sring[iring].c_str(), spol[ipol].c_str() ) ;
4151 norm *= TMath::Power(10., -3./20.);
4153 norm *= TMath::Power(10., +1./20.);
4158 TFile fImpulse(fileName.c_str());
4160 if(!fImpulse.IsOpen()) {
4161 std::cerr <<
"Couldn't read siganl chain impulse response from " << fileName <<
"\n";
4165 for (
int ipol=0;ipol<2;ipol++){
4166 for (
int iring=0;iring<3;iring++){
4167 for (
int iphi=0;iphi<16;iphi++){
4169 TGraph *grTemp = (TGraph*) fImpulse.Get(graphNames[ipol][iring][iphi].c_str());
4171 std::cerr <<
"Couldn't read signal chain impulse response" << graphNames[ipol][iring][iphi] <<
" from file " << fileName <<
"\n";
4176 Int_t nPoints = grInt->GetN();
4177 Double_t *newx = grInt->GetX();
4178 Double_t *newy = grInt->GetY();
4180 for (
int i=0;i<nPoints;i++){
4181 newy[i]=newy[i]*norm;
4183 newx[i]=newx[i]*1E-9;
4187 grTemp =
new TGraph(nPoints, newx, newy);
4194 TGraph *gDig = fSignalChainResponseDigitizer[ipol][iring][iphi]->getFreqMagGraph();
4196 double temparray[512];
4197 for(
int i=0;i<numFreqs;i++) {
4198 temparray[i] = gDig->Eval(freqs[i]*1e6);
4202 for (
int i=0; i<numFreqs;i++){
4204 fSignalChainResponseA3DigitizerFreqDomain[ipol][iring][iphi][i] = temparray[i];
4206 fSignalChainResponseA3DigitizerFreqDomain[ipol][iring][iphi][i] = (temparray[i-2] + temparray[i-1] + temparray[i] + temparray[i+1] + temparray[i+2])/5.;
4208 fSignalChainResponseDigitizerFreqDomain[ipol][iring][iphi][0][i] = fSignalChainResponseA3DigitizerFreqDomain[ipol][iring][iphi][i];
4220 void Anita::readTuffResponseDigitizer(
Settings *settings1){
4227 string snotch_dir[6]={
"notches_260_0_0",
"notches_260_375_0",
"notches_260_0_460",
"notches_260_385_0",
"notches_260_365_0",
"notches_260_375_460"};
4228 string spol[2] = {
"V",
"H"};
4229 string sring[3] = {
"T",
"M",
"B"};
4231 deltaT = 1./(2.6*16.);
4248 for(
int ipol=0; ipol<=1; ipol++) {
4249 for(
int iring = 0; iring<=2; iring++){
4250 for(
int iphi=0; iphi<=15; iphi++) {
4251 for(
int ituff=0; ituff <=6; ituff++) {
4254 filename = Form(
"%s/share/AnitaAnalysisFramework/responses/A4noNotches/%02d%s%s.imp",getenv(
"ANITA_UTIL_INSTALL_DIR"), iphi+1, sring[iring].c_str(), spol[ipol].c_str());
4257 filename = Form(
"%s/share/AnitaAnalysisFramework/responses/A4ImpulseTUFFs/%s/%02d%s%s.imp",getenv(
"ANITA_UTIL_INSTALL_DIR"), snotch_dir[ituff].c_str(), iphi+1, sring[iring].c_str(), spol[ipol].c_str());
4260 TGraph *gtemp =
new TGraph(filename);
4262 TGraph *gint = Tools::getInterpolatedGraph(gtemp,deltaT);
4264 Int_t nPoints = gint->GetN();
4265 Double_t *newx = gint->GetX();
4266 Double_t *newy = gint->GetY();
4272 for (
int i=0;i<nPoints;i++){
4274 newx[i]=newx[i]*1E-9;
4275 newy[i]=newy[i]*norm;
4278 *gint = TGraph(nPoints,newx,newy);
4285 TGraph *gDig = fSignalChainResponseDigitizerTuffs[ipol][iring][iphi][ituff]->getFreqMagGraph();
4287 double temparray[512];
4288 for(
int i=0;i<numFreqs;i++) {
4289 temparray[i] = gDig->Eval(freqs[i]*1e6);
4293 for (
int i=0; i<numFreqs;i++){
4295 fSignalChainResponseDigitizerFreqDomain[ipol][iring][iphi][ituff][i] = temparray[i];
4297 fSignalChainResponseDigitizerFreqDomain[ipol][iring][iphi][ituff][i] = (temparray[i-2] + temparray[i-1] + temparray[i] + temparray[i+1] + temparray[i+2])/5.;
4309 void Anita::readTuffResponseTrigger(
Settings *settings1){
4312 string snotch_dir[7]={
"trigconfigA.imp",
"trigconfigB.imp",
"trigconfigC.imp",
"trigconfigG.imp",
"trigconfigO.imp",
"trigconfigP.imp",
"trigconfigK.imp"};
4314 deltaT = 1./(2.6*16.);
4315 for(
int ipol=0; ipol<=1; ipol++) {
4316 for(
int iring = 0; iring<=2; iring++){
4317 for(
int iphi=0; iphi<=15; iphi++) {
4318 for(
int ituff=0; ituff <=6; ituff++) {
4319 filename = Form(
"%s/share/AnitaAnalysisFramework/responses/A4ImpulseTUFFs/%s",getenv(
"ANITA_UTIL_INSTALL_DIR"), snotch_dir[ituff].c_str());
4322 TGraph *gtemp =
new TGraph(filename);
4324 TGraph *gint = Tools::getInterpolatedGraph(gtemp,deltaT);
4326 Int_t nPoints = gint->GetN();
4327 Double_t *newx = gint->GetX();
4328 Double_t *newy = gint->GetY();
4330 for (
int i=0;i<nPoints;i++){
4332 newx[i]=newx[i]*1E-9;
4334 *gint = TGraph(nPoints,newx,newy);
4342 TGraph *gTrig = fSignalChainResponseTriggerTuffs[ipol][iring][iphi][ituff]->getFreqMagGraph();
4344 double temparray[512];
4345 for(
int i=0;i<numFreqs;i++) {
4346 temparray[i] = gTrig->Eval(freqs[i]*1e6);
4350 for (
int i=0; i<numFreqs;i++){
4352 fSignalChainResponseTriggerFreqDomain[ipol][iring][iphi][ituff][i] = temparray[i];
4354 fSignalChainResponseTriggerFreqDomain[ipol][iring][iphi][ituff][i] = (temparray[i-2] + temparray[i-1] + temparray[i] + temparray[i+1] + temparray[i+2])/5.;
4365 void Anita::readNoiseFromFlight(
Settings *settings1){
4367 TFile *fRayleighAnita3 =
new TFile((ICEMC_DATA_DIR+
"/RayleighAmplitudesAnita3_noSun_Interp.root").c_str(),
"read");
4369 for (
int iant=0;iant<48;iant++){
4370 RayleighFits[0][iant] = (TGraph*)fRayleighAnita3->Get(Form(
"grSigma%dV_interp", iant+1));
4371 RayleighFits[1][iant] = (TGraph*)fRayleighAnita3->Get(Form(
"grSigma%dH_interp", iant+1));
4374 Double_t *timeVals =
new Double_t [780];
4375 Double_t *voltVals =
new Double_t [780];
4376 for(
int i=0;i<780;i++){
4377 timeVals[i] = i*1./2.6;
4383 numFreqs=rfTemplate->getNumFreqs();
4384 freqs=rfTemplate->getFreqs();
4391 void Anita::readImpulseResponseTrigger(
Settings *settings1){
4396 deltaT = 1./(2.6*16.);
4397 string graphNames[2][3][16];
4401 if(settings1->WHICH==9 || settings1->WHICH==10){
4402 if(settings1->WHICH==9){
4403 fileName = ICEMC_DATA_DIR+
"/Anita3_ImpulseResponseTrigger.root";
4406 fileName = ICEMC_DATA_DIR+
"/Anita4_ImpulseResponseTrigger.root";
4408 string spol[2] ={
"V",
"H"};
4409 string sring[3]={
"T",
"M",
"B"};
4411 for (
int ipol=0;ipol<2;ipol++){
4412 for (
int iring=0;iring<3;iring++){
4413 for (
int iphi=0;iphi<16;iphi++){
4414 graphNames[ipol][iring][iphi]= Form(
"gTrigPath") ;
4424 if (!settings1->NOISEFROMFLIGHTTRIGGER) norm *= TMath::Power(10, -7/20.);
4428 TFile fImpulse(fileName.c_str());
4430 if(!fImpulse.IsOpen()) {
4431 std::cerr <<
"Couldn't read signal chain impulse response from " << fileName <<
"\n";
4435 for (
int ipol=0; ipol<2; ipol++){
4436 for (
int iring=0; iring<3; iring++){
4437 for (
int iphi=0; iphi<16; iphi++){
4439 TGraph *grTemp = (TGraph*) fImpulse.Get(graphNames[ipol][iring][iphi].c_str());
4441 std::cerr <<
"Couldn't read signal chain impulse response" << graphNames[ipol][iring][iphi] <<
" from file " << fileName <<
"\n";
4446 Int_t nPoints = grInt->GetN();
4447 Double_t *newx = grInt->GetX();
4448 Double_t *newy = grInt->GetY();
4450 for (
int i=0;i<nPoints;i++){
4451 newy[i]=newy[i]*norm;
4453 newx[i]=newx[i]*1E-9;
4457 grTemp =
new TGraph(nPoints, newx, newy);
4464 if (settings1->TUFFSTATUS==0){
4465 TGraph *gTrig = fSignalChainResponseTrigger[ipol][iring][iphi]->getFreqMagGraph();
4466 for(
int i=0;i<numFreqs;i++) {
4467 fSignalChainResponseTriggerFreqDomain[ipol][iring][iphi][0][i] = gTrig->Eval(freqs[i]*1e6);
4479 void Anita::calculateImpulseResponsesRatios(
Settings *settings1){
4481 double denom, dig, trig;
4486 if (settings1->WHICH==10) norm=0.85;
4488 for (
int ipol=0; ipol<2; ipol++){
4489 for (
int iring=0; iring<3; iring++){
4490 for (
int iphi=0; iphi<16; iphi++){
4491 for(
int ituff=0; ituff<ntuffs; ituff++){
4493 for(
int i=0;i<numFreqs;i++){
4494 denom = fSignalChainResponseA3DigitizerFreqDomain[ipol][iring][iphi][i];
4495 trig = fSignalChainResponseTriggerFreqDomain[ipol][iring][iphi][ituff][i];
4496 dig = fSignalChainResponseDigitizerFreqDomain[ipol][iring][iphi][ituff][i];
4498 if (freqs[i]<160.) {
4499 fRatioTriggerToA3DigitizerFreqDomain[ipol][iring][iphi][ituff][i] = 0.1;
4501 fRatioTriggerToA3DigitizerFreqDomain[ipol][iring][iphi][ituff][i] = (trig/denom)*norm;
4504 fRatioDigitizerToA3DigitizerFreqDomain[ipol][iring][iphi][ituff][i] = (dig/denom)*norm;
4522 void Anita::readTriggerEfficiencyScanPulser(
Settings *settings1){
4524 if(settings1->WHICH==10 || settings1->WHICH==9){
4526 if(settings1->WHICH==10){
4527 string fileName = ICEMC_DATA_DIR+
"/TriggerEfficiencyScanPulser_anita4_33dB_avg_trimmed.root";
4528 TFile *f =
new TFile(fileName.c_str(),
"read");
4529 gPulseAtAmpa = (TGraph*)f->Get(
"Phisector_3_33dBCh1_trimmed");
4532 Int_t nPoints = gPulseAtAmpa->GetN();
4533 Double_t *newx = gPulseAtAmpa->GetX();
4534 Double_t *newy = gPulseAtAmpa->GetY();
4535 Double_t meany = TMath::Mean(nPoints/10, newy);
4537 for (
int i=0;i<nPoints;i++){
4539 newx[i]=newx[i]*1E9;
4542 *gPulseAtAmpa = TGraph(nPoints,newx,newy);
4550 string fileName = ICEMC_DATA_DIR+
"/TriggerEfficiencyScanPulser_anita3.root";
4551 TFile *f =
new TFile(fileName.c_str(),
"read");
4553 gPulseAtAmpa = (TGraph*)f->Get(
"gAvgPulseAtAmpa");
4561 bool useDelayGenerator =
false;
4563 double maxDelays = (Tools::dMax(trigEffScanRingDelay, 3) + Tools::dMax(trigEffScanPhiDelay,5) );
4564 maxDelays -= (Tools::dMin(trigEffScanRingDelay, 3) + Tools::dMin(trigEffScanPhiDelay,5) );
4566 if (maxDelays!=0) useDelayGenerator=
true;
4568 for (
int i=0;i<gPulseAtAmpa->GetN();i++){
4569 if(settings1->WHICH==9){
4571 gPulseAtAmpa->GetY()[i]*=TMath::Power(10,-7./20.);
4572 }
else if(settings1->WHICH==10){
4580 gPulseAtAmpa->GetY()[i]*=TMath::Power(10,(-25.0+33.0)/20.);
4589 gPulseAtAmpa->GetY()[i]*=TMath::Power(10, trigEffScanAtt[2]*1./20.);
4591 if(settings1->WHICH==9){
4593 gPulseAtAmpa->GetY()[i]*=TMath::Power(10, -10.8/20.);
4594 }
else if(settings1->WHICH==10){
4596 gPulseAtAmpa->GetY()[i]*=TMath::Power(10, -12./20.);
4600 if (useDelayGenerator){
4601 gPulseAtAmpa->GetY()[i]*=TMath::Power(10, -12./20.);
4605 gPulseAtAmpa->GetY()[i]*=TMath::Power(10,-3./20.);
4616 double *x = gPulseAtAmpa->GetX();
4617 double *y = gPulseAtAmpa->GetY();
4618 double xnew[10000], ynew[10000];
4619 int N = gPulseAtAmpa->GetN();
4623 for (
int j=6; j<N; j++){
4628 TGraph *gtemp =
new TGraph (newn, xnew, ynew);
4632 for (
int i=0;i<HALFNFOUR;i++){
4633 trigEffScanPulseAtAmpa[i] = gPulseAtAmpaInt->Eval(fTimes[i]);
4635 if(settings1->WHICH==9){
4642 delete gPulseAtAmpaInt;
4645 if(settings1->WHICH==9){
4646 string fileName = ICEMC_DATA_DIR+
"/TriggerEfficiencyScanPulser_anita3.root";
4647 TFile *f =
new TFile(fileName.c_str(),
"read");
4649 for (
int isample=0;isample<250;isample++){
4651 TGraph *gPulseAtSurf = (TGraph*)f->Get(Form(
"gSamplePulseAtSurf_%i", isample));
4654 double *y2 = gPulseAtSurfInt->GetY();
4656 for (
int i=0;i<HALFNFOUR;i++){
4657 trigEffScanPulseAtSurf[isample][i]=y2[i]/10.;
4660 delete gPulseAtSurfInt;
4661 delete gPulseAtSurf;
4668 cout <<
"Impulse response on trigger path can only be used with ANITA-3 or ANITA-4" << endl;
4677 void Anita::calculateDelaysForEfficiencyScan(){
4681 for (
int iant=0; iant<48; iant++){
4683 phiIndex = trigEffScanPhi - (iant%16);
4684 if (phiIndex>8) phiIndex=phiIndex-16;
4686 if(TMath::Abs(phiIndex)<=2){
4690 if (iant%2==0) irx = iant/2;
4691 else irx = 8 + iant/2;
4695 arrival_times[0][irx] += trigEffScanPhiDelay[phiIndex+2];
4698 if (trigEffScanApplyRingDelay[phiIndex+2]>0){
4700 if (iant<16) arrival_times[0][irx] += trigEffScanRingDelay[0] + trigEffScanRingDelay[2];
4701 else if (iant<32) arrival_times[0][irx] += trigEffScanRingDelay[1];
double phi_bn
theta,phi of balloon wrt south pole
static AnitaEventCalibrator * Instance(int version=0)
Instance generator.
int GetRxTriggerNumbering(int ilayer, int ifold)
get antenna number based on which layer and position it is
This is a wrapper class for an RF Signal.
const char * ICEMC_SRC_DIR()
void Initialize(Settings *settings1, ofstream &foutput, int inu, TString outputdir)
initialize a bunch of stuff
AnitaEventCalibrator – The ANITA Event Calibrator.
Reads in and stores input settings for the run.
static double GetNoise(Settings *settings1, double altitude_bn, double geoid, double theta, double bw, double temp)
Get Noise.
double BN_LONGITUDE
balloon longitude for fixed balloon location
This is a wrapper class for a complex number.
Vector unRotatePayload(Vector ant_pos)
This function UN-rotates the payload.
double surface_under_balloon
distance between center of the earth and the surface of earth under balloon
static const int NLAYERS_MAX
max number of layers (in smex design, it's 4)
int GetRx(int ilayer, int ifold)
get antenna number based on which layer and position it is
Handles everything related to balloon positions, payload orientation over the course of a flight...
This class represents a three-vector. Operators are overloaded to provide for the familiar operations...
static const int NPHI_MAX
max number of antennas around in phi (in smex, 16)
Double_t relativePhaseCenterToAmpaDelays[12][9]
From phase center to AMPAs (hopefully)
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
Ice thicknesses and water depth.