12 #include "TTreeIndex.h" 18 #include "icemc_random.h" 23 #include "TPostScript.h" 28 #include "TGraphErrors.h" 29 #include "TGraphAsymmErrors.h" 34 #include "TRotation.h" 36 #include "Math/InterpolationTypes.h" 37 #include "Math/Interpolator.h" 41 #include "Constants.h" 43 #include "position.hh" 45 #include "earthmodel.hh" 48 #include "roughness.hh" 51 #include "icemodel.hh" 55 #include "secondaries.hh" 57 #include "counting.hh" 58 #include "Primaries.h" 59 #include "Taumodel.hh" 61 #include "GlobalTrigger.h" 62 #include "ChanTrigger.h" 63 #include "SimulatedSignal.h" 64 #include "EnvironmentVariable.h" 69 #if __cplusplus > 199711L 70 #include <type_traits> 75 #ifdef ANITA_UTIL_EXISTS 76 #include "UsefulAnitaEvent.h" 77 #include "AnitaGeomTool.h" 78 #include "AnitaConventions.h" 79 #include "RawAnitaHeader.h" 85 #ifdef ANITA3_EVENTREADER 86 #include "TruthAnitaEvent.h" 106 const int NVIEWANGLE=100;
110 double eventsfound_beforetrigger=0.;
111 double eventsfound_crust=0;
112 double eventsfound_weightgt01=0;
113 double eventsfound_belowhorizon=0;
114 double eventsfound=0;
115 double eventsfound_prob=0;
118 double poissonerror_minus[21] = {0.-0.00, 1.-0.37, 2.-0.74, 3.-1.10, 4.-2.34, 5.-2.75, 6.-3.82, 7.-4.25, 8.-5.30, 9.-6.33, 10.-6.78, 11.-7.81, 12.-8.83, 13.-9.28, 14.-10.30, 15.-11.32, 16.-12.33, 17.-12.79, 18.-13.81, 19.-14.82, 20.-15.83};
119 double poissonerror_plus[21] = {1.29-0., 2.75-1., 4.25-2., 5.30-3., 6.78-4., 7.81-5., 9.28-6., 10.30-7., 11.32-8., 12.79-9., 13.81-10., 14.82-11., 16.29-12., 17.30-13., 18.32-14., 19.32-15., 20.80-16., 21.81-17., 22.82-18., 23.82-19., 25.30-20.};
122 double MIN_LOGWEIGHT=-3;
123 double MAX_LOGWEIGHT=-1;
125 double eventsfound_binned[NBINS];
126 double eventsfound_binned_e[NBINS];
127 double eventsfound_binned_mu[NBINS];
128 double eventsfound_binned_tau[NBINS];
134 double error_e_plus=0;
135 double error_mu_plus=0;
136 double error_tau_plus=0;
137 double error_minus=0;
138 double error_e_minus=0;
139 double error_mu_minus=0;
140 double error_tau_minus=0;
142 double gain_dipole=2.15;
143 double changle_deg=0;
147 double RANDOMISEPOL=0.;
151 double volume_thishorizon;
153 double longitude_this;
154 double latitude_this;
155 double altitude_this;
156 double heading_this=0.;
161 double pnu=pow(10., 20);
166 double SIGNALRADIUS=2.;
169 double bwslice_vnoise_thislayer[4];
170 int passes_thisevent=0;
171 int unmasked_thisevent=0;
173 int discones_passing;
175 double heff_discone=0;
176 double polarfactor_discone=0.;
178 double volts_discone=0.;
179 double vnoise_discone=0.;
182 double BW_DISCONES=300.E6-120.E6;
191 double t_coeff_pokey, t_coeff_slappy;
194 double e_comp_max1=0;
195 double h_comp_max1=0;
196 double e_comp_max2=0;
197 double h_comp_max2=0;
198 double e_comp_max3=0;
199 double h_comp_max3=0;
202 double diff_3tries=0;
205 double costheta_inc=0;
206 double costheta_exit=0;
207 double theta_rf_atbn;
208 double theta_rf_atbn_measured;
210 double costhetanu=-1000;
215 double nearthlayers=0;
216 double weight_prob=0.;
221 double pieceofkm2sr=0;
223 double CUTONWEIGHTS=1.E-10;
226 int count_inthisloop1=0;
227 int count_inthisloop2=0;
228 int count_inthisloop3=0;
229 double averaging_thetas1=0;
230 double averaging_thetas2=0;
231 double averaging_thetas3=0;
236 int count_asktrigger=0;
237 int count_asktrigger_nfb=0;
240 double count_passestrigger_w=0;
243 int allcuts[2]={0, 0};
245 double allcuts_weighted[2]={0, 0};
246 double allcuts_weighted_polarization[3]={0, 0, 0};
250 int count_chanceofsurviving=0;
252 int count_chanceinhell0=0;
256 double count_chanceinhell2_w=0;
260 int count_chordgoodlength=0;
261 int count_d2goodlength=0;
265 double sum_frac_db[3];
267 const int NBINS_DISTANCE=28;
268 double eventsfound_binned_distance[NBINS_DISTANCE] = {0.};
269 int index_distance=0;
270 double km3sr_distance[NBINS_DISTANCE] = {0.};
271 double error_distance_plus[NBINS_DISTANCE] = {0.};
272 double error_distance_minus[NBINS_DISTANCE] = {0.};
273 int eventsfound_binned_distance_forerror[NBINS_DISTANCE][NBINS] = {{0}};
279 int count_passestrigger_nfb=0;
280 double percent_increase_db=0;
281 double percent_increase_nfb=0;
282 double percent_increase_total=0;
284 double error_km3sr_nfb=0;
285 double error_percent_increase_nfb=0;
290 int count_dbexitsice=0;
293 double eventsfound_nfb_binned[NBINS];
296 double heff_max=0.62639;
299 double scalefactor_distance=0;
300 double scalefactor_attenuation=0;
301 double MAX_ATTENLENGTH=1671;
304 double dviewangle_deg=0;
306 double forseckel[NVIEWANGLE][Anita::NFREQ];
307 double viewangles[NVIEWANGLE];
308 double GetAirDistance(
double altitude_bn,
double beta);
316 int max_antenna0 = -1;
317 int max_antenna1 = -1;
318 int max_antenna2 = -1;
319 double max_antenna_volts0 = 0;
320 double max_antenna_volts0_em = 0;
322 double max_antenna_volts1 = 0;
323 double max_antenna_volts2 = 0;
325 double rx0_signal_eachband[2][5];
326 double rx0_threshold_eachband[2][5];
327 double rx0_noise_eachband[2][5];
328 int rx0_passes_eachband[2][5];
335 double vmmhz1m_visible = 0;
336 int freq_bins = Anita::NFREQ;
337 double total_kgm2 = 0;
339 double r_in_array[3];
340 double nsurf_rfexit_array[3];
341 double nsurf_rfexit_db_array[3];
342 double r_bn_array[3];
343 double n_bn_array[3];
344 double posnu_array[3];
345 double nrf_iceside_array[5][3];
346 double nrf_iceside_db_array[5][3];
347 double ant_max_normal0_array[3];
348 double ant_max_normal1_array[3];
349 double ant_max_normal2_array[3];
350 double n_pol_array[3];
351 double n_exit2bn_array[5][3];
352 double r_enterice_array[3];
353 double n_exit2bn_db_array[5][3];
354 double rfexit_array[5][3];
355 double rfexit_db_array[5][3];
357 int times_crust_entered_det=0;
358 int times_mantle_entered_det=0;
359 int times_core_entered_det=0;
361 int mantle_entered=0;
363 int neutrinos_passing_all_cuts=0;
364 double sum_weights=0;
367 double justNoise_trig[2][48][512];
368 double justSignal_trig[2][48][512];
369 double justNoise_dig[2][48][512];
370 double justSignal_dig[2][48][512];
376 void SetupViewangles(
Signal *sig1);
378 void GetAir(
double *col1);
379 double GetThisAirColumn(
Settings*,
Position r_in,
Vector nnu,
Position posnu,
double *col1,
double& cosalpha,
double& mytheta,
double& cosbeta0,
double& mybeta);
381 double ScaleVmMHz(
double vmmhz1m_max,
const Position &posnu,
const Position &r_bn);
384 double IsItDoubleBang(
double exitlength,
double plepton);
387 void GetCurrent(
string& current);
390 double GetAverageVoltageFromAntennasHit(
Settings *settings1,
int *nchannels_perrx_triggered,
double *voltagearray,
double& volts_rx_sum);
395 void Attenuate(
IceModel *antartica1,
Settings *settings1,
double& vmmhz_max,
double rflength,
const Position &posnu);
399 void IsAbsorbed(
double chord_kgm2,
double len_int_kgm2,
double& weight);
402 int GetRayIceSide(
const Vector &n_exit2rx,
const Vector &nsurf_rfexit,
double nexit,
double nenter,
Vector &nrf2_iceside);
404 double GetViewAngle(
const Vector &nrf2_iceside,
const Vector &nnu);
405 int TIR(
const Vector &n_surf,
const Vector &nrf2_iceside,
double N_IN,
double N_OUT);
407 void IntegrateBands(Anita *anita1,
int k, Screen *panel1,
double *freq,
double scalefactor,
double *sumsignal);
409 void Integrate(Anita *anita1,
int j,
int k,
double *vmmhz,
double *freq,
double scalefactor,
double sumsignal);
411 void interrupt_signal_handler(
int);
413 bool ABORT_EARLY =
false;
417 void CloseTFile(TFile *hfile);
419 int Getmine(
double*,
double*,
double*,
double*);
421 void Getearth(
double*,
double*,
double*,
double*);
424 #ifdef ANITA_UTIL_EXISTS 425 int GetIceMCAntfromUsefulEventAnt(
Settings *settings1,
int UsefulEventAnt);
432 double thresholdsAnt[48][2][5];
433 double thresholdsAntPass[48][2][5];
437 double threshold_start=-1.;
438 double threshold_end=-6.;
439 const int NTHRESHOLDS=20;
440 double threshold_step=(threshold_end-threshold_start)/(
double)NTHRESHOLDS;
442 double npass_v_thresh[NTHRESHOLDS]={0.};
443 double denom_v_thresh[NTHRESHOLDS]={0.};
444 double npass_h_thresh[NTHRESHOLDS]={0.};
445 double denom_h_thresh[NTHRESHOLDS]={0.};
446 double thresholds[NTHRESHOLDS];
448 int main(
int argc,
char **argv) {
464 string input= ICEMC_SRC_DIR +
"/inputs.conf";
469 if( (argc%3!=1)&&(argc%2!=1)) {
470 cout <<
"Syntax for options: -i inputfile -o outputdir -r run_number\n";
475 double trig_thresh=0.;
478 while ((clswitch = getopt(argc, argv,
"t:i:o:r:n:e:")) != EOF) {
481 nnu_tmp=atoi(optarg);
482 cout <<
"Changed number of simulated neutrinos to " << nnu_tmp << endl;
485 trig_thresh=atof(optarg);
489 cout <<
"Changed input file to: " << input << endl;
493 cout <<
"Changed output directory to: " << string(outputdir.Data()) << endl;
494 stemp=
"mkdir -p " + string(outputdir.Data());
495 system(stemp.c_str());
498 exp_tmp=atof(optarg);
499 cout <<
"Changed neutrino energy exponent to " << exp_tmp << endl;
503 stringstream convert(run_num);
511 settings1->SEED=settings1->SEED +run_no;
512 cout <<
"seed is " << settings1->SEED << endl;
514 setSeed(settings1->SEED);
516 stemp=string(outputdir.Data())+
"/nu_position"+run_num+
".txt";
517 ofstream nu_out(stemp.c_str(), ios::app);
519 stemp=string(outputdir.Data())+
"/veff"+run_num+
".txt";
520 ofstream veff_out(stemp.c_str(), ios::app);
522 stemp=string(outputdir.Data())+
"/distance"+run_num+
".txt";
523 ofstream distanceout(stemp.c_str());
525 stemp=string(outputdir.Data())+
"/debug"+run_num+
".txt";
526 fstream outfile(stemp.c_str(), ios::out);
528 stemp=string(outputdir.Data())+
"/forbrian"+run_num+
".txt";
529 fstream forbrian(stemp.c_str(), ios::out);
531 stemp=string(outputdir.Data())+
"/al_voltages_direct"+run_num+
".dat";
532 fstream al_voltages_direct(stemp.c_str(), ios::out);
534 stemp=string(outputdir.Data())+
"/events"+run_num+
".txt";
535 ofstream eventsthatpassfile(stemp.c_str());
537 stemp=string(outputdir.Data())+
"/numbers"+run_num+
".txt";
538 ofstream fnumbers(stemp.c_str());
540 stemp=string(outputdir.Data())+
"/output"+run_num+
".txt";
541 ofstream foutput(stemp.c_str(), ios::app);
543 stemp=string(outputdir.Data())+
"/slacviewangles"+run_num+
".dat";
544 ofstream fslac_viewangles(stemp.c_str());
546 stemp=string(outputdir.Data())+
"/slac_hitangles"+run_num+
".dat";
547 ofstream fslac_hitangles(stemp.c_str());
550 Anita *anita1=
new Anita();
558 settings1->ReadInputs(input.c_str(), foutput, NNU, RANDOMISEPOL);
559 settings1->ApplyInputs(anita1, sec1, sig1, bn1, ray1);
562 settings1->SEED=settings1->SEED + run_no;
563 setSeed(settings1->SEED);
565 bn1->InitializeBalloon();
566 anita1->Initialize(settings1, foutput, inu, outputdir);
571 settings1->EXPONENT=exp_tmp;
573 time_t raw_start_time = time(NULL);
574 struct tm * start_time = localtime(&raw_start_time);
576 cout <<
"Date and time at start of run are: " << asctime (start_time) <<
"\n";
579 Tools::Zero(sum_frac, 3);
580 Tools::Zero(sum_frac_db, 3);
585 Tools::Zero(anita1->PHI_OFFSET, Anita::NLAYERS_MAX);
586 Tools::Zero(anita1->THETA_ZENITH, Anita::NLAYERS_MAX);
587 Tools::Zero(anita1->LAYER_VPOSITION, Anita::NLAYERS_MAX);
588 Tools::Zero(anita1->RRX, Anita::NLAYERS_MAX);
592 al_voltages_direct<<
"antenna #"<<
" "<<
"volts chan 1"<<
" "<<
"volts chan 2"<<
" "<<
"volts chan 3"<<
" "<<
"volts chan 4"<<
" "<<
"noise chan 1"<<
" "<<
"noise chan 2"<<
" "<<
"noise chan 3"<<
" "<<
"noise chan 4"<<
" "<<
"weight"<<endl;
599 int beyondhorizon = 0;
602 double vmmhz1m_max=0;
603 double vmmhz_lowfreq=0.;
604 double vmmhz[Anita::NFREQ];
607 double vmmhz_em[Anita::NFREQ];
608 double vmmhz_min_thatpasses=1000;
611 double deltheta_em_max, deltheta_had_max;
614 double emfrac, hadfrac, sumfrac;
619 double volts_rx_max=0;
620 double volts_rx_ave=0;
621 double volts_rx_sum=0;
623 double volts_rx_max_highband;
624 double volts_rx_max_lowband;
625 double volts_rx_rfcm_lab_e_all[48][512];
626 double volts_rx_rfcm_lab_h_all[48][512];
629 double e_component[Anita::NANTENNAS_MAX]={0};
630 double h_component[Anita::NANTENNAS_MAX]={0};
631 double n_component[Anita::NANTENNAS_MAX]={0};
633 double e_component_kvector[Anita::NANTENNAS_MAX]={0};
634 double h_component_kvector[Anita::NANTENNAS_MAX]={0};
635 double n_component_kvector[Anita::NANTENNAS_MAX]={0};
645 double hitangle_e_all[Anita::NANTENNAS_MAX];
646 double hitangle_h_all[Anita::NANTENNAS_MAX];
648 double eventsfound_db=0;
649 double eventsfound_nfb=0;
655 double dist_int_bn_2d=0;
662 double theta_pol_measured;
673 Vector n_nutraject_ontheground;
680 int l2trig[
Anita::NPOL][Anita::NTRIGGERLAYERS_MAX];
682 int l1trig[
Anita::NPOL][Anita::NTRIGGERLAYERS_MAX];
689 int nchannels_triggered = 0;
690 int nchannels_perrx_triggered[48];
694 Tools::Zero(count1->npass, 2);
699 Tools::Zero(eventsfound_binned, NBINS);
700 Tools::Zero(eventsfound_binned_e, NBINS);
701 Tools::Zero(eventsfound_binned_mu, NBINS);
702 Tools::Zero(eventsfound_binned_tau, NBINS);
703 Tools::Zero(eventsfound_nfb_binned, NBINS);
710 stemp=string(outputdir.Data())+
"/icefinal"+run_num+
".root";
711 TFile *hfile =
new TFile(stemp.c_str(),
"RECREATE",
"ice");
714 TTree *finaltree =
new TTree(
"passing_events",
"passing_events");
715 finaltree->Branch(
"inu", &inu,
"inu/I");
716 finaltree->Branch(
"vmmhz_min", &vmmhz_min,
"vmmhz_min/D");
717 finaltree->Branch(
"vmmhz_max", &vmmhz_max,
"vmmhz_max/D");
718 finaltree->Branch(
"thresholdsAnt", &thresholdsAnt,
"thresholdsAnt[48][2][5]/D");
719 finaltree->Branch(
"thresholdsAntPass", &thresholdsAntPass,
"thresholdsAntPass[48][2][5]/D");
720 finaltree->Branch(
"deadTime", &anita1->deadTime,
"deadTime/D");
721 finaltree->Branch(
"horizcoord", &horizcoord,
"horizcoord/D");
722 finaltree->Branch(
"vertcoord", &vertcoord,
"vertcoord/D");
723 finaltree->Branch(
"horizcoord_bn", &bn1->horizcoord_bn,
"horizcoord_bn/D");
724 finaltree->Branch(
"vertcoord_bn", &bn1->vertcoord_bn,
"vertcoord_bn/D");
725 finaltree->Branch(
"r_bn", &r_bn_array,
"r_bn_array[3]/D");
726 finaltree->Branch(
"n_bn", &n_bn_array,
"n_bn_array[3]/D");
727 finaltree->Branch(
"longitude_bn", &longitude_this,
"longitude_bn/D");
728 finaltree->Branch(
"heading_bn", &heading_this,
"heading_bn/D");
729 finaltree->Branch(
"gps_offset", &gps_offset,
"gps_offset/D");
731 finaltree->Branch(
"weight1", &weight1,
"weight1/D");
733 finaltree->Branch(
"weight", &weight,
"weight/D");
734 finaltree->Branch(
"logweight", &logweight,
"logweight/D");
735 finaltree->Branch(
"posnu", &posnu_array,
"posnu_array[3]/D");
736 finaltree->Branch(
"nnu", &nnu_array,
"nnu_array[3]/D");
737 finaltree->Branch(
"n_exit2bn", &n_exit2bn_array,
"n_exit2bn_array[5][3]/D");
738 finaltree->Branch(
"n_exit_phi", &n_exit_phi,
"n_exit_phi/D");
739 finaltree->Branch(
"rfexit", &rfexit_array,
"rfexit_array[5][3]/D");
741 finaltree->Branch(
"pnu", &pnu,
"pnu/D");
742 finaltree->Branch(
"elast_y", &elast_y,
"elast_y/D");
743 finaltree->Branch(
"emfrac", &emfrac,
"emfrac/D");
744 finaltree->Branch(
"hadfrac", &hadfrac,
"hadfrac/D");
745 finaltree->Branch(
"sumfrac", &sumfrac,
"sumfrac/D");
746 finaltree->Branch(
"nuexitice", &nuexitice,
"nuexitice/D");
747 finaltree->Branch(
"l3trig", &l3trig,
"l3trig[2]/I");
748 finaltree->Branch(
"l2trig", &l2trig,
"l2trig[2][3]/I");
749 finaltree->Branch(
"l1trig", &l1trig,
"l1trig[2][3]/I");
750 finaltree->Branch(
"phiTrigMask", &anita1->phiTrigMask,
"phiTrigMask/s");
751 finaltree->Branch(
"phiTrigMaskH", &anita1->phiTrigMaskH,
"phiTrigMaskH/s");
752 finaltree->Branch(
"l1TrigMask", &anita1->l1TrigMask,
"l1TrigMask/s");
753 finaltree->Branch(
"l1TrigMaskH", &anita1->l1TrigMaskH,
"l1TrigMaskH/s");
754 finaltree->Branch(
"max_antenna0", &max_antenna0,
"max_antenna0/I");
755 finaltree->Branch(
"max_antenna1", &max_antenna1,
"max_antenna1/I");
756 finaltree->Branch(
"max_antenna2", &max_antenna2,
"max_antenna2/I");
758 finaltree->Branch(
"viewangle", &viewangle,
"viewangle/D");
759 finaltree->Branch(
"offaxis", &offaxis,
"offaxis/D");
760 finaltree->Branch(
"rx0_signal_eachband", &rx0_signal_eachband,
"rx0_signal_eachband[2][5]/D");
761 finaltree->Branch(
"rx0_threshold_eachband", &rx0_threshold_eachband,
"rx0_threshold_eachband[2][5]/D");
762 finaltree->Branch(
"rx0_noise_eachband", &rx0_noise_eachband,
"rx0_noise_eachband[2][5]/D");
763 finaltree->Branch(
"rx0_passes_eachband", &rx0_passes_eachband,
"rx0_passes_eachband[2][5]/I");
764 finaltree->Branch(
"e_component", &e_component,
"e_component[48]/D");
765 finaltree->Branch(
"h_component", &h_component,
"h_component[48]/D");
766 finaltree->Branch(
"dist_int_bn_2d", &dist_int_bn_2d,
"dist_int_bn_2d/D");
768 finaltree->Branch(
"cosalpha", &cosalpha,
"cosalpha/D");
769 finaltree->Branch(
"mytheta", &mytheta,
"mytheta/D");
770 finaltree->Branch(
"cosbeta0", &cosbeta0,
"cosbeta0/D");
771 finaltree->Branch(
"mybeta", &mybeta,
"mybeta/D");
774 finaltree->Branch(
"fresnel1", &fresnel1,
"fresnel1/D");
775 finaltree->Branch(
"fresnel2", &fresnel2,
"fresnel2/D");
776 finaltree->Branch(
"mag1", &mag1,
"mag1/D");
777 finaltree->Branch(
"mag2", &mag2,
"mag2/D");
778 finaltree->Branch(
"t_coeff_pokey", &t_coeff_pokey,
"t_coeff_pokey/D");
779 finaltree->Branch(
"t_coeff_slappy", &t_coeff_slappy,
"t_coeff_slappy/D");
781 finaltree->Branch(
"hitangle_e_all", &hitangle_e_all,
"hitangle_e_all[48]/D");
782 finaltree->Branch(
"hitangle_h_all", &hitangle_h_all,
"hitangle_h_all[48]/D");
784 finaltree->Branch(
"e_comp_max1", &e_comp_max1,
"e_comp_max1/D");
785 finaltree->Branch(
"h_comp_max1", &h_comp_max1,
"h_comp_max1/D");
786 finaltree->Branch(
"e_comp_max2", &e_comp_max2,
"e_comp_max2/D");
787 finaltree->Branch(
"h_comp_max2", &h_comp_max2,
"h_comp_max2/D");
788 finaltree->Branch(
"e_comp_max3", &e_comp_max3,
"e_comp_max3/D");
789 finaltree->Branch(
"h_comp_max3", &h_comp_max3,
"h_comp_max3/D");
790 finaltree->Branch(
"max_antenna_volts0", &max_antenna_volts0,
"max_antenna_volts0/D");
791 finaltree->Branch(
"max_antenna_volts0_em", &max_antenna_volts0_em,
"max_antenna_volts0_em/D");
792 finaltree->Branch(
"max_antenna_volts1", &max_antenna_volts1,
"max_antenna_volts1/D");
793 finaltree->Branch(
"max_antenna_volts2", &max_antenna_volts2,
"max_antenna_volts2/D");
794 finaltree->Branch(
"triggers", &nchannels_perrx_triggered,
"nchannels_perrx_triggered[48]/I");
795 finaltree->Branch(
"nchannels_triggered", &nchannels_triggered,
"nchannels_triggered/I");
796 finaltree->Branch(
"volts_rx_max", &volts_rx_max,
"volts_rx_max/D");
797 finaltree->Branch(
"volts_rx_ave", &volts_rx_ave,
"volts_rx_ave/D");
798 finaltree->Branch(
"volts_rx_sum", &volts_rx_sum,
"volts_rx_sum/D");
800 finaltree->Branch(
"volts_rx_max_highband", &volts_rx_max_highband,
"volts_rx_max_highband/D");
801 finaltree->Branch(
"volts_rx_max_lowband", &volts_rx_max_lowband,
"volts_rx_max_lowband/D");
802 finaltree->Branch(
"theta_pol_measured", &theta_pol_measured,
"theta_pol_measured/D");
803 finaltree->Branch(
"theta_rf_atbn", &theta_rf_atbn,
"theta_rf_atbn/D");
804 finaltree->Branch(
"theta_rf_atbn_measured", &theta_rf_atbn_measured,
"theta_rf_atbn_measured/D");
805 finaltree->Branch(
"voltage", &voltagearray,
"voltagearray[48]/D");
806 finaltree->Branch(
"vmmhz1m_max", &vmmhz1m_max,
"vmmhz1m_max/D");
807 finaltree->Branch(
"vmmhz_lowfreq", &vmmhz_lowfreq,
"vmmhz_lowfreq/D");
809 finaltree->Branch(
"deltheta_em_max", &deltheta_em_max,
"deltheta_em_max/D");
810 finaltree->Branch(
"deltheta_had_max", &deltheta_had_max,
"deltheta_had_max/D");
811 finaltree->Branch(
"r_enterice", &r_enterice_array,
"r_enterice_array[3]/D");
812 finaltree->Branch(
"n_exit2bn_db", &n_exit2bn_db_array,
"n_exit2bn_db_array[5][3]/D");
814 finaltree->Branch(
"rfexit_db", &rfexit_db_array,
"rfexit_db_array[5][3]/D");
815 finaltree->Branch(
"r_in", &r_in_array,
"r_in_array[3]/D");
816 finaltree->Branch(
"nsurf_rfexit", &nsurf_rfexit_array,
"nsurf_rfexit_array[3]/D");
817 finaltree->Branch(
"nsurf_rfexit_db", &nsurf_rfexit_db_array,
"nsurf_rfexit_db_array[3]/D");
819 finaltree->Branch(
"ant_normal0", &ant_max_normal0_array,
"ant_max_normal0_array[3]/D");
820 finaltree->Branch(
"ant_normal1", &ant_max_normal1_array,
"ant_max_normal1_array[3]/D");
821 finaltree->Branch(
"ant_normal2", &ant_max_normal2_array,
"ant_max_normal2_array[3]/D");
822 finaltree->Branch(
"vmmhz1m_visible", &vmmhz1m_visible,
"vmmhz1m_visible/D");
823 finaltree->Branch(
"freq_bins", &freq_bins,
"freq_bins/I");
824 finaltree->Branch(
"vmmhz", &vmmhz,
"vmmhz[freq_bins]/D");
826 finaltree->Branch(
"n_pol", &n_pol_array,
"n_pol_array[3]/D");
827 finaltree->Branch(
"vmmhz_min_thatpasses", &vmmhz_min_thatpasses,
"vmmhz_min_thatpasses/D");
829 finaltree->Branch(
"anita1->PHI_OFFSET", &anita1->PHI_OFFSET,
"anita1->PHI_OFFSET/D");
830 finaltree->Branch(
"igps", &bn1->igps,
"igyps/I");
831 finaltree->Branch(
"volts_rx_rfcm_lab_e_all", &volts_rx_rfcm_lab_e_all,
"volts_rx_rfcm_lab_e_all[48][512]/D");
832 finaltree->Branch(
"volts_rx_rfcm_lab_h_all", &volts_rx_rfcm_lab_h_all,
"volts_rx_rfcm_lab_h_all[48][512]/D");
833 finaltree->Branch(
"ptaui", &ptaui,
"ptaui/D");
834 finaltree->Branch(
"ptauf", &ptauf,
"ptauf/D");
835 finaltree->Branch(
"sourceLon", &sourceLon,
"sourceLon/D");
836 finaltree->Branch(
"sourceLat", &sourceLat,
"sourceLat/D");
837 finaltree->Branch(
"sourceAlt", &sourceAlt,
"sourceAlt/D");
838 finaltree->Branch(
"sourceMag", &sourceMag,
"sourceMag/D");
845 double avgfreq_rfcm[Anita::NFREQ];
846 double avgfreq_rfcm_lab[Anita::NFREQ];
847 double freq[Anita::NFREQ];
852 #ifdef ANITA_UTIL_EXISTS 854 string outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaEventFile"+run_num+
".root";
855 TFile *anitafileEvent =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
857 TTree *eventTree =
new TTree(
"eventTree",
"eventTree");
858 eventTree->Branch(
"event", &realEvPtr );
859 eventTree->Branch(
"run", &run_no,
"run/I" );
860 eventTree->Branch(
"weight", &weight,
"weight/D");
862 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaHeadFile"+run_num+
".root";
863 TFile *anitafileHead =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
865 TTree *headTree =
new TTree(
"headTree",
"headTree");
866 headTree->Branch(
"header", &rawHeaderPtr );
867 headTree->Branch(
"weight", &weight,
"weight/D");
869 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaGpsFile"+run_num+
".root";
870 TFile *anitafileGps =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
872 TTree *adu5PatTree =
new TTree(
"adu5PatTree",
"adu5PatTree");
873 adu5PatTree->Branch(
"pat", &Adu5PatPtr );
874 adu5PatTree->Branch(
"eventNumber", &eventNumber,
"eventNumber/I");
875 adu5PatTree->Branch(
"weight", &weight,
"weight/D" );
877 #ifdef ANITA3_EVENTREADER 880 AnitaVersion::set(settings1->ANITAVERSION);
882 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaTruthFile"+run_num+
".root";
883 TFile *anitafileTruth =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
885 TString icemcgitversion = TString::Format(
"%s", EnvironmentVariable::ICEMC_VERSION(outputdir));
886 printf(
"ICEMC GIT Repository Version: %s\n", icemcgitversion.Data());
887 unsigned int timenow = time(NULL);
889 TTree *configAnitaTree =
new TTree(
"configIcemcTree",
"Config file and settings information");
890 configAnitaTree->Branch(
"gitversion", &icemcgitversion );
891 configAnitaTree->Branch(
"startTime", &timenow );
893 configAnitaTree->Fill();
895 TTree *triggerSettingsTree =
new TTree(
"triggerSettingsTree",
"Trigger settings");
896 triggerSettingsTree->Branch(
"dioderms", anita1->bwslice_dioderms_fullband_allchan,
"dioderms[2][48][7]/D");
897 triggerSettingsTree->Branch(
"diodemean", anita1->bwslice_diodemean_fullband_allchan,
"diodemean[2][48][7/D");
898 triggerSettingsTree->Fill();
900 TTree *truthAnitaTree =
new TTree(
"truthAnitaTree",
"Truth Anita Tree");
901 truthAnitaTree->Branch(
"truth", &truthEvPtr );
909 IceModel *antarctica =
new IceModel(settings1->ICE_MODEL + settings1->NOFZ*10, settings1->CONSTANTICETHICKNESS * 1000 + settings1->CONSTANTCRUST * 100 + settings1->FIXEDELEVATION * 10 + 0, settings1->WEIGHTABSORPTION);
910 cout <<
"area of the earth's surface covered by antarctic ice is " << antarctica->ice_area <<
"\n";
913 anita1->GetBeamWidths(settings1);
916 anita1->Set_gain_angle(settings1, sig1->NMEDIUM_RECEIVER);
917 if(settings1->WHICH == 2 || settings1->WHICH == 6) anita1->SetDiffraction();
924 bn1->SetDefaultBalloonPosition(antarctica);
926 anita1->SetNoise(settings1, bn1, antarctica);
930 antarctica->GetMAXHORIZON(bn1);
933 antarctica->CreateHorizons(settings1, bn1, bn1->theta_bn, bn1->phi_bn, bn1->altitude_bn, foutput);
934 cout <<
"Done with CreateHorizons.\n";
937 anita1->GetPayload(settings1, bn1);
939 if (settings1->TRIGGERSCHEME == 3 || settings1->TRIGGERSCHEME == 4 || settings1->TRIGGERSCHEME==5) {
941 bn1->PickBalloonPosition(plusz, antarctica, settings1, anita1);
942 anita1->calculate_all_offsets();
943 double angle_theta=16.;
945 Vector x =
Vector(cos(angle_theta * RADDEG) * cos((angle_phi+11.25) * RADDEG),
946 cos(angle_theta * RADDEG) * sin((angle_phi+11.25) * RADDEG),
947 sin(angle_theta * RADDEG));
948 anita1->GetArrivalTimes(x,bn1,settings1);
949 cout <<
"end of getarrivaltimes\n";
952 time_t raw_loop_start_time = time(NULL);
953 cout<<
"Starting loop over events. Time required for setup is "<<(int)((raw_loop_start_time - raw_start_time)/60)<<
":"<< ((raw_loop_start_time - raw_start_time)%60)<<endl;
958 double average_altitude=0.;
959 double average_rbn=0.;
961 signal(SIGINT, interrupt_signal_handler);
964 if (settings1->WHICH==7){
965 gps_offset=atan2(-0.7042,0.71)*DEGRAD;
966 }
else if(settings1->WHICH==8){
967 gps_offset=atan2(-0.7085,0.7056)*DEGRAD;
968 }
else if (settings1->WHICH==9 || settings1->WHICH==10){
975 for (inu = 0; inu < NNU; inu++) {
978 if (inu % (NNU / 100) == 0)
979 cout << inu <<
" neutrinos. " << (double(inu)/double(NNU)) * 100 <<
"% complete.\n";
982 cout << inu <<
" neutrinos. " << (double(inu) / double(NNU)) * 100 <<
"% complete.\n";
984 eventNumber=(UInt_t)(run_no)*NNU+inu;
988 setSeed(eventNumber);
989 anita1->passglobtrig[0]=0;
990 anita1->passglobtrig[1]=0;
992 unmasked_thisevent=1;
993 vmmhz_min_thatpasses=1000;
999 sec1->secondbang=
false;
1002 bn1->dtryingposition=0;
1003 for (
int i=0; i<Anita::NFREQ;i++) {
1009 bn1->PickBalloonPosition(antarctica, settings1, inu, anita1, getRNG(RNG_BALLOON_POSITION)->Rndm());
1013 average_altitude+=bn1->altitude_bn/(double)NNU;
1014 average_rbn+=bn1->r_bn.Mag()/(double)NNU;
1016 realtime_this=bn1->realTime_flightdata;
1017 longitude_this=bn1->longitude;
1018 latitude_this=bn1->latitude;
1019 altitude_this=bn1->altitude;
1020 heading_this=bn1->heading;
1033 Tools::Zero(anita1->arrival_times[0], Anita::NLAYERS_MAX*
Anita::NPHI_MAX);
1034 Tools::Zero(anita1->arrival_times[1], Anita::NLAYERS_MAX*
Anita::NPHI_MAX);
1036 anita1->calculateDelaysForEfficiencyScan();
1038 globaltrig1->volts_rx_rfcm_trigger.assign(16, vector <vector <double> >(3, vector <double>(0)));
1039 anita1->rms_rfcm_e_single_event = 0;
1042 for (
int ilayer=0; ilayer < settings1->NLAYERS; ilayer++) {
1043 for (
int ifold=0;ifold<anita1->NRX_PHI[ilayer];ifold++) {
1045 antNum = anita1->GetRxTriggerNumbering(ilayer, ifold);
1051 #ifdef ANITA_UTIL_EXISTS 1052 if (settings1->SIGNAL_FLUCT && (settings1->NOISEFROMFLIGHTDIGITIZER || settings1->NOISEFROMFLIGHTTRIGGER) )
1061 chantrig1->
TriggerPath(settings1, anita1, antNum, bn1);
1065 chantrig1->
WhichBandsPass(settings1, anita1, globaltrig1, bn1, ilayer, ifold, viewangle-sig1->changle, emfrac, hadfrac, thresholdsAnt[antNum]);
1067 chantrig1->
TimeShiftAndSignalFluct(settings1, anita1, ilayer, ifold, volts_rx_rfcm_lab_e_all, volts_rx_rfcm_lab_h_all);
1069 chantrig1->
saveTriggerWaveforms(anita1, justSignal_trig[0][antNum], justSignal_trig[1][antNum], justNoise_trig[0][antNum], justNoise_trig[1][antNum]);
1070 chantrig1->
saveDigitizerWaveforms(anita1, justSignal_dig[0][antNum], justSignal_dig[1][antNum], justNoise_dig[0][antNum], justNoise_dig[1][antNum]);
1078 anita1->rms_rfcm_e_single_event = sqrt(anita1->rms_rfcm_e_single_event / (anita1->HALFNFOUR * settings1->NANTENNAS));
1081 for (
int irx=0;irx<settings1->NANTENNAS;irx++) {
1082 nchannels_perrx_triggered[irx]=globaltrig1->nchannels_perrx_triggered[irx];
1085 nchannels_triggered=Tools::iSum(globaltrig1->nchannels_perrx_triggered, settings1->NANTENNAS);
1086 volts_rx_ave=GetAverageVoltageFromAntennasHit(settings1, globaltrig1->nchannels_perrx_triggered, voltagearray, volts_rx_sum);
1096 globaltrig1->
PassesTrigger(settings1, anita1, discones_passing, 2, l3trig, l2trig, l1trig, settings1->antennaclump, loctrig, loctrig_nadironly, inu,
1099 for (
int i=0;i<2;i++) {
1100 for (
int j=0;j<16;j++) {
1101 for (
int k=0;k<anita1->HALFNFOUR;k++) {
1102 count1->nl1triggers[i][whichray]+=anita1->l1trig_anita3and4_inanita[i][j][k];
1116 if ( (thispasses[0]==1 && anita1->pol_allowed[0]==1)
1117 || (thispasses[1]==1 && anita1->pol_allowed[1]==1)
1118 || (settings1->TRIGTYPE==0 && count_pass>=settings1->NFOLD)
1119 || (settings1->MINBIAS==1)) {
1120 if (bn1->WHICHPATH==4)
1121 cout <<
"This event passes.\n";
1125 anita1->passglobtrig[0]=thispasses[0];
1126 anita1->passglobtrig[1]=thispasses[1];
1129 n_exit_phi = Tools::AbbyPhiCalc(ray1->n_exit2bn[2][0], ray1->n_exit2bn[2][1]);
1141 #ifdef ANITA_UTIL_EXISTS 1146 Adu5PatPtr->
latitude= bn1->latitude;
1148 Adu5PatPtr->
altitude=bn1->altitude;
1149 Adu5PatPtr->
realTime=bn1->realTime_flightdata;
1150 Adu5PatPtr->
heading = bn1->heading;
1151 Adu5PatPtr->
pitch = bn1->pitch;
1152 Adu5PatPtr->roll = bn1->roll;
1153 Adu5PatPtr->run = run_no;
1156 memset(realEvPtr->
fVolts, 0,
sizeof(realEvPtr->
fVolts) );
1157 memset(realEvPtr->
fTimes, 0,
sizeof(realEvPtr->
fTimes) );
1159 int fNumPoints = 260;
1161 for (
int iant = 0; iant < settings1->NANTENNAS; iant++){
1163 int IceMCAnt = GetIceMCAntfromUsefulEventAnt(settings1, iant);
1166 realEvPtr->
fNumPoints[UsefulChanIndexV] = fNumPoints;
1167 realEvPtr->
fNumPoints[UsefulChanIndexH] = fNumPoints;
1168 realEvPtr->
chanId[UsefulChanIndexV] = UsefulChanIndexV;
1169 realEvPtr->
chanId[UsefulChanIndexH] = UsefulChanIndexH;
1171 for (
int j = 0; j < fNumPoints; j++) {
1173 realEvPtr->
fTimes[UsefulChanIndexV][j] = j * anita1->TIMESTEP * 1.0E9;
1174 realEvPtr->
fTimes[UsefulChanIndexH][j] = j * anita1->TIMESTEP * 1.0E9;
1176 realEvPtr->
fVolts[UsefulChanIndexH][j] = volts_rx_rfcm_lab_h_all[IceMCAnt][j+64]*1000;
1177 realEvPtr->
fVolts[UsefulChanIndexV][j] = volts_rx_rfcm_lab_e_all[IceMCAnt][j+64]*1000;
1189 if (settings1->MINBIAS==1)
1194 rawHeaderPtr->
run = run_no;
1204 if (settings1->WHICH<9){
1205 rawHeaderPtr->
phiTrigMask = (short) anita1->phiTrigMask;
1210 rawHeaderPtr->
realTime = bn1->realTime_flightdata;
1211 rawHeaderPtr->
triggerTime = bn1->realTime_flightdata;
1212 Adu5PatPtr->
latitude= bn1->latitude;
1214 Adu5PatPtr->
altitude=bn1->altitude;
1215 Adu5PatPtr->
realTime=bn1->realTime_flightdata;
1216 Adu5PatPtr->
heading = bn1->heading;
1217 Adu5PatPtr->
pitch = bn1->pitch;
1218 Adu5PatPtr->roll = bn1->roll;
1219 Adu5PatPtr->run = run_no;
1221 #ifdef ANITA3_EVENTREADER 1222 if (settings1->WHICH==9 || settings1->WHICH==10) {
1225 rawHeaderPtr->setMask( (
short) anita1->l1TrigMask, (
short) anita1->phiTrigMask,
AnitaPol::kVertical);
1226 rawHeaderPtr->setMask( (
short) anita1->l1TrigMaskH, (
short) anita1->phiTrigMaskH,
AnitaPol::kHorizontal);
1231 truthEvPtr->
realTime = bn1->realTime_flightdata;
1232 truthEvPtr->
run = run_no;
1233 truthEvPtr->
nuMom = pnu;
1234 truthEvPtr->
nu_pdg = pdgcode;
1235 memcpy(truthEvPtr->
e_component, e_component,
sizeof(e_component));
1236 memcpy(truthEvPtr->
h_component, h_component,
sizeof(h_component));
1237 memcpy(truthEvPtr->
n_component, n_component,
sizeof(n_component));
1238 memcpy(truthEvPtr->
e_component_k ,e_component_kvector,
sizeof(e_component_kvector));
1239 memcpy(truthEvPtr->
h_component_k ,h_component_kvector,
sizeof(h_component_kvector));
1240 memcpy(truthEvPtr->
n_component_k ,n_component_kvector,
sizeof(n_component_kvector));
1245 truthEvPtr->
weight = weight;
1246 for (
int i=0;i<3;i++){
1249 truthEvPtr->
nuPos[i] = -999;
1250 truthEvPtr->
nuDir[i] = -999;
1252 for (
int i=0;i<5;i++){
1253 for (
int j=0;j<3;j++){
1254 truthEvPtr->
rfExitNor[i][j] = ray1->n_exit2bn[i][j];
1255 truthEvPtr->
rfExitPos[i][j] = ray1->rfexit[i][j];
1258 for (
int i=0;i<48;i++){
1259 truthEvPtr->
hitangle_e[i] = hitangle_e_all[i];
1260 truthEvPtr->
hitangle_h[i] = hitangle_h_all[i];
1262 if(settings1->ROUGHNESS){
1263 for (
int i=0;i<Anita::NFREQ;i++)
1264 truthEvPtr->
vmmhz[i] = -999;
1279 for (
int iant = 0; iant < settings1->NANTENNAS; iant++){
1283 truthEvPtr->
SNRAtTrigger[UsefulChanIndexV] = Tools::calculateSNR(justSignal_trig[0][iant], justNoise_trig[0][iant]);
1284 truthEvPtr->
SNRAtTrigger[UsefulChanIndexH] = Tools::calculateSNR(justSignal_trig[1][iant], justNoise_trig[1][iant]);
1289 truthEvPtr->
SNRAtDigitizer[UsefulChanIndexV] = Tools::calculateSNR(justSignal_dig[0][iant], justNoise_dig[0][iant]);
1290 truthEvPtr->
SNRAtDigitizer[UsefulChanIndexH] = Tools::calculateSNR(justSignal_dig[1][iant], justNoise_dig[1][iant]);
1296 truthEvPtr->
thresholds[UsefulChanIndexV] = thresholdsAnt[iant][0][4];
1297 truthEvPtr->
thresholds[UsefulChanIndexH] = thresholdsAnt[iant][1][4];
1300 if (iant%2) irx = iant/2;
1301 else irx = iant/2 + 1;
1304 for (
int j = 0; j < fNumPoints; j++) {
1305 truthEvPtr->
fTimes[UsefulChanIndexV][j] = j * anita1->TIMESTEP * 1.0E9;
1306 truthEvPtr->
fTimes[UsefulChanIndexH][j] = j * anita1->TIMESTEP * 1.0E9;
1308 truthEvPtr->
fSignalAtTrigger[UsefulChanIndexV][j] = justSignal_trig[0][iant][j]*1000;
1309 truthEvPtr->
fSignalAtTrigger[UsefulChanIndexH][j] = justSignal_trig[1][iant][j]*1000;
1310 truthEvPtr->
fNoiseAtTrigger[UsefulChanIndexV][j] = justNoise_trig[0][iant][j]*1000;
1311 truthEvPtr->
fNoiseAtTrigger[UsefulChanIndexH][j] = justNoise_trig[1][iant][j]*1000;
1312 truthEvPtr->
fSignalAtDigitizer[UsefulChanIndexV][j] = justSignal_dig[0][iant][j]*1000;
1313 truthEvPtr->
fSignalAtDigitizer[UsefulChanIndexH][j] = justSignal_dig[1][iant][j]*1000;
1314 truthEvPtr->
fNoiseAtDigitizer[UsefulChanIndexV][j] = justNoise_dig[0][iant][j]*1000;
1315 truthEvPtr->
fNoiseAtDigitizer[UsefulChanIndexH][j] = justNoise_dig[1][iant][j]*1000;
1317 truthEvPtr->
fDiodeOutput[UsefulChanIndexV][j] = anita1->timedomain_output_allantennas[0][irx][j];
1318 truthEvPtr->
fDiodeOutput[UsefulChanIndexH][j] = anita1->timedomain_output_allantennas[1][irx][j];
1324 truthAnitaTree->Fill();
1330 adu5PatTree->Fill();
1333 delete rawHeaderPtr;
1337 sum_weights+=weight;
1338 neutrinos_passing_all_cuts++;
1339 anita1->tdata->Fill();
1348 std::cout <<
"\n***********************************************************";
1349 std::cout <<
"\n* SIGINT received, aborting loop over events early.";
1350 std::cout <<
"\n* Stopped after event " << inu <<
" instead of " << NNU;
1351 std::cout <<
"\n* Any output which relied on NNU should be corrected for.";
1352 std::cout <<
"\n***********************************************************\n";
1353 foutput <<
"\n***********************************************************";
1354 foutput <<
"\n* SIGINT received, aborting loop over events early.";
1355 foutput <<
"\n* Stopped after event " << inu <<
" instead of " << NNU;
1356 foutput <<
"\n* Any output which relied on NNU should be corrected for.";
1357 foutput <<
"\n***********************************************************\n";
1365 #ifdef ANITA_UTIL_EXISTS 1367 anitafileEvent->cd();
1368 eventTree->Write(
"eventTree");
1369 anitafileEvent->Close();
1370 delete anitafileEvent;
1372 anitafileHead->cd();
1373 headTree->Write(
"headTree");
1374 anitafileHead->Close();
1375 delete anitafileHead;
1378 adu5PatTree->Write(
"adu5PatTree");
1379 anitafileGps->Close();
1380 delete anitafileGps;
1382 #ifdef ANITA3_EVENTREADER 1383 anitafileTruth->cd();
1384 configAnitaTree->Write(
"configAnitaTree");
1385 truthAnitaTree->Write(
"truthAnitaTree");
1386 triggerSettingsTree->Write(
"triggerSettingsTree");
1387 anitafileTruth->Close();
1388 delete anitafileTruth;
1394 anita1->rms_rfcm[0] = sqrt(anita1->rms_rfcm[0] / (
double)anita1->count_getnoisewaveforms)*1000.;
1395 anita1->rms_rfcm[1] = sqrt(anita1->rms_rfcm[1] / (
double)anita1->count_getnoisewaveforms)*1000.;
1396 anita1->rms_lab[0] = sqrt(anita1->rms_lab[0] / (
double)anita1->count_getnoisewaveforms)*1000.;
1397 anita1->rms_lab[1] = sqrt(anita1->rms_lab[1] / (
double)anita1->count_getnoisewaveforms)*1000.;
1399 cout <<
"RMS noise in rfcm e-pol is " << anita1->rms_rfcm[0] <<
" mV.\n";
1400 cout <<
"RMS noise in rfcm h-pol is " << anita1->rms_rfcm[1] <<
" mV.\n";
1401 cout <<
"RMS noise in lab e-pol is " << anita1->rms_lab[0] <<
"mV.\n";
1402 cout <<
"RMS noise in lab h-pol is " << anita1->rms_lab[1] <<
"mV.\n";
1403 for (
int i=0;i<Anita::NFREQ;i++) {
1404 anita1->avgfreq_rfcm[i]/=(double)anita1->count_getnoisewaveforms;
1405 anita1->avgfreq_rfcm_lab[i]/=(
double)anita1->count_getnoisewaveforms;
1408 rms_rfcm_e=anita1->rms_rfcm[0];
1409 rms_rfcm_h=anita1->rms_rfcm[1];
1410 rms_lab_e=anita1->rms_lab[0];
1411 rms_lab_h=anita1->rms_lab[1];
1412 for (
int i=0;i<Anita::NFREQ;i++) {
1413 avgfreq_rfcm[i]=anita1->avgfreq_rfcm[i];
1414 avgfreq_rfcm_lab[i]=anita1->avgfreq_rfcm_lab[i];
1415 freq[i]=anita1->freq[i];
1420 sum_frac[0]=sum[0]/eventsfound;
1421 sum_frac[1]=sum[1]/eventsfound;
1422 sum_frac[2]=sum[2]/eventsfound;
1425 sum_frac_db[0]=sum[0]/(eventsfound+eventsfound_db+eventsfound_nfb);
1426 sum_frac_db[1]=sum[1]/(eventsfound+eventsfound_db+eventsfound_nfb);
1427 sum_frac_db[2]=(sum[2]+eventsfound_db+eventsfound_nfb)/(eventsfound+eventsfound_db+eventsfound_nfb);
1432 cout <<
"closing file.\n";
1435 time_t raw_end_time = time(NULL);
1436 struct tm * end_time = localtime(&raw_end_time);
1437 cout <<
"Date and time at end of run are: " << asctime (end_time) <<
"\n";
1438 cout<<
"Total time elapsed is "<<(int)((raw_end_time - raw_start_time)/60)<<
":"<< ((raw_end_time - raw_start_time)%60)<<endl;
1440 foutput <<
"\nTotal time elapsed in run is " <<(int)((raw_end_time - raw_start_time)/60)<<
":"<< ((raw_end_time - raw_start_time)%60)<<endl;
1441 anita1->fdata->Write();
1442 anita1->fdata->Close();
1467 void IntegrateBands(Anita *anita1,
int k, Screen *panel1,
double *freq,
double scalefactor,
double *sumsignal) {
1468 for (
int j=0;j<5;j++) {
1470 for (
int jpt=0; jpt<panel1->GetNvalidPoints(); jpt++){
1471 if (anita1->bwslice_min[j]<=freq[k] && anita1->bwslice_max[j]>freq[k])
1472 sumsignal[j]+=panel1->GetVmmhz_freq(jpt*Anita::NFREQ + k)*(freq[k+1]-freq[k])*scalefactor;
1479 void Integrate(Anita *anita1,
int j,
int k,
double *vmmhz,
double *freq,
double scalefactor,
double sumsignal) {
1481 if (anita1->bwslice_min[j]<=freq[k] && anita1->bwslice_max[j]>freq[k])
1482 sumsignal+=vmmhz[k]*(freq[k+1]-freq[k])*scalefactor;
1487 void WriteNeutrinoInfo(
Position &posnu,
Vector &nnu,
Position &r_bn,
double altitude_int,
string nuflavor,
string current,
double elast_y, ofstream &nu_out) {
1488 nu_out <<
"\n" << inu <<
"\t" << posnu[0] <<
" " << posnu[1] <<
" " << posnu[2] <<
"\t" << altitude_int <<
"\t" << nnu[0] <<
" " << nnu[1] <<
" " << nnu[2] <<
"\t" << r_bn[0] <<
" " << r_bn[1] <<
" " << r_bn[2] <<
"\t" << nuflavor <<
"\t" << current <<
"\t" << elast_y <<
"\n\n";
1494 double GetAirDistance(
double altitude_bn,
double beta) {
1495 return EarthModel::R_EARTH*acos((altitude_bn+EarthModel::R_EARTH)/EarthModel::R_EARTH*(1-sin(beta)*sin(beta))+1/EarthModel::R_EARTH*sin(beta)*sqrt((altitude_bn+EarthModel::R_EARTH)*(altitude_bn+EarthModel::R_EARTH)*sin(beta)*sin(beta)-2*EarthModel::R_EARTH*altitude_bn-altitude_bn*altitude_bn));
1500 double GetAverageVoltageFromAntennasHit(
Settings *settings1,
int *nchannels_perrx_triggered,
double *voltagearray,
double& volts_rx_sum) {
1502 int count_hitantennas=0;
1503 for (
int i=0;i<settings1->NANTENNAS;i++) {
1504 if (nchannels_perrx_triggered[i]>=3) {
1505 sum+=voltagearray[i];
1506 count_hitantennas++;
1510 sum = sum/(double)count_hitantennas;
1521 Vector n_bfield = nnu.Cross(nrf2_iceside);
1523 Vector n_pol = n_bfield.Cross(nrf2_iceside);
1524 n_pol = n_pol.Unit();
1526 if (nnu*nrf2_iceside>0 && n_pol*nnu>0){
1527 cout <<
"error in GetPolarization. Event is " << inu <<
"\n";
1534 void CloseTFile(TFile *hfile) {
1542 double IsItDoubleBang(
double exitlength,
double plepton) {
1543 double gamma=plepton/MTAU;
1544 return 1-exp(-1*exitlength/(TAUDECAY_TIME*CLIGHT*gamma));
1552 double gamma=pnu/MTAU;
1554 if (exp(-1*nuexitlength/(TAUDECAY_TIME*CLIGHT*gamma))>0.999){
1555 rnd1=getRNG(RNG_SECOND_BANG)->Rndm()*nuexitlength;
1558 while (rnd2>1-exp(-1*rnd1/(TAUDECAY_TIME*CLIGHT*gamma))) {
1559 rnd1=getRNG(RNG_SECOND_BANG)->Rndm()*nuexitlength;
1560 rnd2=getRNG(RNG_SECOND_BANG)->Rndm();
1563 posnu2 = posnu + rnd1*nnu;
1564 rfexit_db = antarctica1->Surface(posnu2)*posnu2.Unit();
1567 n_exit2bn_db = (r_bn - rfexit_db) / r_bn.
Distance(rfexit_db);
1569 double cosangle=(n_exit2bn_db * posnu2) / posnu2.Mag();
1580 double ATTENLENGTH=700;
1581 if(!settings1->VARIABLE_ATTEN){
1582 ATTENLENGTH=antarctica1->EffectiveAttenuationLength(settings1, posnu, 1);
1585 int position_in_iceshelves=antarctica1->IceOnWater(posnu);
1586 int position_in_rossexcept=antarctica1->RossExcept(posnu);
1589 double dtemp=posnu_down.
Distance(rfexit2)/ATTENLENGTH;
1593 if(position_in_iceshelves && (!position_in_rossexcept)){
1596 scalefactor_attenuation=0.71*exp(-dtemp);
1597 vmmhz_max=vmmhz_max*0.71*exp(-dtemp);
1599 else if(position_in_rossexcept){
1600 scalefactor_attenuation=0.1*exp(-dtemp);
1601 vmmhz_max=0.1*vmmhz_max*exp(-dtemp);
1604 scalefactor_attenuation=sqrt(0.001)*exp(-dtemp);
1605 vmmhz_max=sqrt(0.001)*vmmhz_max*exp(-dtemp);
1609 scalefactor_attenuation=0;
1616 void Attenuate(
IceModel *antarctica1,
Settings *settings1,
double& vmmhz_max,
double rflength,
const Position &posnu) {
1617 double ATTENLENGTH=700;
1618 if (!settings1->VARIABLE_ATTEN){
1619 ATTENLENGTH = antarctica1->EffectiveAttenuationLength(settings1, posnu, 0);
1622 double dtemp=(rflength/ATTENLENGTH);
1623 if(!settings1->ROUGHNESS){
1625 scalefactor_attenuation=exp(-dtemp);
1626 vmmhz_max=vmmhz_max*exp(-dtemp);
1629 scalefactor_attenuation=0;
1635 scalefactor_attenuation=exp(-dtemp);
1636 vmmhz_max=vmmhz_max*exp(-dtemp);
1639 scalefactor_attenuation=0;
1647 void IsAbsorbed(
double chord_kgm2,
double len_int_kgm2,
double &weight1) {
1653 rtemp=chord_kgm2/len_int_kgm2;
1655 weight1=exp(-rtemp);
1662 void GetSmearedIncidentAngle(
Vector &specular,
Vector &nrf_iceside,
Vector &n_exit2bn,
double SMEARINCIDENTANGLE){
1665 specular+=nrf_iceside;
1666 Vector parallel_to_surface;
1667 parallel_to_surface+=n_exit2bn;
1668 parallel_to_surface.Cross(specular);
1669 nrf_iceside.Rotate(SMEARINCIDENTANGLE*(2*getRNG(RNG_SMEARED_INCIDENT_ANGLE)->Rndm()-1.), parallel_to_surface);
1675 int GetRayIceSide(
const Vector &n_exit2rx,
const Vector &nsurf_rfexit,
double nexit,
double nenter,
Vector &nrf2_iceside) {
1678 double NRATIO=nexit/nenter;
1679 costh=(n_exit2rx*nsurf_rfexit)/(n_exit2rx.Mag() * nsurf_rfexit.Mag());
1685 double sinth=sqrt(1 - costh*costh);
1686 double factor=NRATIO*costh-sqrt(1-(NRATIO*sinth*NRATIO*sinth));
1687 nrf2_iceside = -factor*nsurf_rfexit + NRATIO*n_exit2rx;
1688 nrf2_iceside = nrf2_iceside.Unit();
1695 double ScaleVmMHz(
double vmmhz1m_max,
const Position &posnu1,
const Position &r_bn) {
1696 double dtemp= r_bn.
Distance(posnu1);
1697 vmmhz1m_max= vmmhz1m_max/dtemp;
1698 scalefactor_distance=1/dtemp;
1705 void SetupViewangles(
Signal *sig1) {
1706 double viewangle_max=90.*RADDEG;
1707 double viewangle_min=30.*RADDEG;
1708 for (
int i=0;i<NVIEWANGLE-2;i++) {
1709 viewangles[i]=viewangle_max-(viewangle_max-viewangle_min)/(
double)(NVIEWANGLE-2)*(
double)i;
1711 viewangles[NVIEWANGLE-2]=acos(1/sig1->N_DEPTH);
1712 viewangles[NVIEWANGLE-1]=90.*RADDEG;
1717 double GetThisAirColumn(
Settings* settings1,
Position r_in,
Vector nnu,
Position posnu,
double *col1,
double& cosalpha,
double& mytheta,
double& cosbeta0,
double& mybeta) {
1720 cosalpha=(r_in * nnu) / r_in.Mag();
1721 mytheta=(double)(acos(cosalpha)*DEGRAD)-90.;
1724 if (settings1->ATMOSPHERE) {
1725 int index11=int(mytheta*10.);
1726 int index12=index11+1;
1728 myair=(col1[index11]+(col1[index12]-col1[index11])*(mytheta*10.-
double(index11)))*10.;
1735 cosbeta0= (posnu * nnu) / posnu.Mag();
1736 mybeta=(double)(acos(cosbeta0)*DEGRAD)-90.;
1742 void GetAir(
double *col1) {
1744 ifstream air1(ICEMC_SRC_DIR+
"/data/atmosphere.dat");
1747 for(
int iii=0;iii<900;iii++) {
1748 air1>>nothing>>col1[iii];
1754 int TIR(
const Vector &n_surf,
const Vector &nrf2_iceside,
double N_IN,
double N_OUT) {
1755 double test=sin(nrf2_iceside.Angle(n_surf))*N_IN/N_OUT;
1766 double GetViewAngle(
const Vector &nrf2_iceside,
const Vector &nnu) {
1768 double dtemp=nrf2_iceside*nnu;
1769 if (dtemp>=1 && dtemp<1.02)
1771 if (dtemp<=-1 && dtemp>-1.02)
1779 TStyle* RootStyle() {
1780 TStyle *RootStyle =
new TStyle(
"Root-Style",
"The Perfect Style for Plots ;-)");
1790 RootStyle->SetPaperSize(TStyle::kUSLetter);
1793 RootStyle->SetCanvasColor (0);
1794 RootStyle->SetCanvasBorderSize(10);
1795 RootStyle->SetCanvasBorderMode(0);
1796 RootStyle->SetCanvasDefH (600);
1797 RootStyle->SetCanvasDefW (600);
1798 RootStyle->SetCanvasDefX (10);
1799 RootStyle->SetCanvasDefY (10);
1802 RootStyle->SetPadColor (0);
1803 RootStyle->SetPadBorderSize (10);
1804 RootStyle->SetPadBorderMode (0);
1806 RootStyle->SetPadBottomMargin(0.16);
1807 RootStyle->SetPadTopMargin (0.08);
1808 RootStyle->SetPadLeftMargin (0.18);
1809 RootStyle->SetPadRightMargin (0.05);
1810 RootStyle->SetPadGridX (0);
1811 RootStyle->SetPadGridY (0);
1812 RootStyle->SetPadTickX (1);
1813 RootStyle->SetPadTickY (1);
1816 RootStyle->SetFrameFillStyle ( 0);
1817 RootStyle->SetFrameFillColor ( 0);
1818 RootStyle->SetFrameLineColor ( 1);
1819 RootStyle->SetFrameLineStyle ( 0);
1820 RootStyle->SetFrameLineWidth ( 2);
1821 RootStyle->SetFrameBorderSize(10);
1822 RootStyle->SetFrameBorderMode( 0);
1826 RootStyle->SetHistFillColor(0);
1827 RootStyle->SetHistFillStyle(1);
1828 RootStyle->SetHistLineColor(1);
1829 RootStyle->SetHistLineStyle(0);
1830 RootStyle->SetHistLineWidth(2);
1833 RootStyle->SetFuncColor(1);
1834 RootStyle->SetFuncStyle(0);
1835 RootStyle->SetFuncWidth(1);
1838 RootStyle->SetStatBorderSize(2);
1839 RootStyle->SetStatFont (42);
1841 RootStyle->SetOptStat (0);
1842 RootStyle->SetStatColor (0);
1843 RootStyle->SetStatX (0.93);
1844 RootStyle->SetStatY (0.90);
1845 RootStyle->SetStatFontSize (0.07);
1850 RootStyle->SetTickLength ( 0.015,
"X");
1851 RootStyle->SetTitleSize ( 0.10,
"X");
1852 RootStyle->SetTitleOffset( 1.20,
"X");
1853 RootStyle->SetTitleBorderSize(0);
1855 RootStyle->SetLabelOffset( 0.015,
"X");
1856 RootStyle->SetLabelSize ( 0.050,
"X");
1857 RootStyle->SetLabelFont ( 42 ,
"X");
1858 RootStyle->SetTickLength ( 0.015,
"Y");
1859 RootStyle->SetTitleSize ( 0.10,
"Y");
1860 RootStyle->SetTitleOffset( 0.600,
"Y");
1861 RootStyle->SetLabelOffset( 0.015,
"Y");
1862 RootStyle->SetLabelSize ( 0.050,
"Y");
1863 RootStyle->SetLabelFont ( 42 ,
"Y");
1864 RootStyle->SetTitleFont (42,
"XY");
1865 RootStyle->SetTitleColor (1);
1868 RootStyle->SetOptFit (0);
1869 RootStyle->SetMarkerStyle(20);
1870 RootStyle->SetMarkerSize(0.4);
1881 void interrupt_signal_handler(
int sig){
1882 signal(sig, SIG_IGN);
1889 #ifdef ANITA_UTIL_EXISTS 1891 int GetIceMCAntfromUsefulEventAnt(
Settings *settings1,
int UsefulEventAnt){
1895 int IceMCAnt = UsefulEventAnt;
1896 if ((settings1->WHICH==9 || settings1->WHICH==10) && UsefulEventAnt<16) {
1897 IceMCAnt = (UsefulEventAnt%2==0)*UsefulEventAnt/2 + (UsefulEventAnt%2==1)*(UsefulEventAnt/2+8);
UInt_t eventNumber
Event number from software.
Double_t h_component_k[48]
Component of the e-field along the rx h-plane.
Double_t rfExitPos[5][3]
Position where the RF exits the ice- 5 iterations, 3 dimensions each.
Double_t fNoiseAtDigitizer[12 *9][260]
Array of noise at digitizer.
void PassesTrigger(Settings *settings1, Anita *anita1, int discones_passing, int mode, int *l3trig, int l2trig[Anita::NPOL][Anita::NTRIGGERLAYERS_MAX], int l1trig[Anita::NPOL][Anita::NTRIGGERLAYERS_MAX], int antennaclump, int loctrig[Anita::NPOL][Anita::NLAYERS_MAX][Anita::NPHI_MAX], int loctrig_nadironly[Anita::NPOL][Anita::NPHI_MAX], int inu, int *thispasses, bool noiseOnly=false)
Evaluate the full trigger simulation for a given payload configuration.
Double_t weight
Weight assigned by icemc.
Int_t nu_pdg
Neutrino PDG code.
Double_t sourceLat
RF position when leaving the ice: Latitude (using icemc model)
double fVolts[12 *9][260]
Array of unwrapped (unless kNoCalib) voltages for each channel.
void InitializeEachBand(Anita *anita1)
Initialize trigger bands.
Adu5Pat – The ADU5 Position and Attitude Data.
double Distance(const Position &second) const
Returns chord distance (direct distance between two vectors)
void TriggerPath(Settings *settings1, Anita *anita1, int ant, Balloon *bn1)
Apply trigger path.
static const int NPOL
number of polarizations
Double_t n_component_k[48]
Component of the e-field along the normal.
Double_t fDiodeOutput[12 *9][260]
Array of tunnel diode output.
Float_t latitude
In degrees.
Radiation from interaction.
double fTimes[12 *9][260]
Array of unwrapped (unless kNoCalib) times for each channel.
Double_t sourceLon
RF position when leaving the ice: Longitude (using icemc model)
Double_t sourceAlt
RF position when leaving the ice: Altitude (using icemc model)
void TimeShiftAndSignalFluct(Settings *settings1, Anita *anita1, int ilayer, int ifold, double volts_rx_rfcm_lab_e_all[48][512], double volts_rx_rfcm_lab_h_all[48][512])
Time shift and fluctuate signal.
Float_t longitude
In degrees.
Double_t thresholds[12 *9]
Channel thresholds used in icemc.
double volts_rx_forfft[2][5][Anita::HALFNFOUR]
Array of time domain after the antenna gain. Indeces stand for [ipol][iband][itime].
UInt_t realTime
Time from the GPS unit.
const char * ICEMC_SRC_DIR()
Double_t n_component[48]
Normal comp along polarization.
Double_t balloonPos[3]
Balloon position.
void saveTriggerWaveforms(Anita *anita1, double sig0[48], double sig1[48], double noise0[48], double noise1[48])
Save signal and noise waveforms at trigger.
Double_t vmmhz[128]
V/m/MHz at balloon (128 frequency bins)
Double_t SNRAtDigitizer[12 *9]
Array of SNR at digitizer.
Class that handles the channel trigger.
Reads in and stores input settings for the run.
Double_t fSignalAtTrigger[12 *9][260]
Array of signal at trigger.
Double_t maxSNRAtTriggerV
Max SNR at trigger V-POL.
This class is a 3-vector that represents a position on the Earth's surface.
void saveDigitizerWaveforms(Anita *anita1, double sig0[48], double sig1[48], double noise0[48], double noise1[48])
Save signal and noise waveforms at digitizer.
void getNoiseFromFlight(Settings *settings1, Anita *anita1, int ant, bool also_digi=true)
Add noise from ANITA-3 flight to the time domain waveforms.
Double_t h_component[48]
H comp along polarization.
UInt_t realTime
unixTime of readout
Double_t rfExitNor[5][3]
Normal vector in direction of exit point to balloon - 5 iterations.
UsefulAnitaEvent – The Calibrated Useful Anita Event object.
Float_t altitude
In metres.
Double_t hitangle_h[48]
Hit angles rel. to h plane stored for each antenna.
Double_t fSignalAtDigitizer[12 *9][260]
Array of signal at digitizer.
void DigitizerPath(Settings *settings1, Anita *anita1, int ant, Balloon *bn1)
Apply digitizer path.
TruthAnitaEvent – The Truth ANITA Event.
Double_t e_component[48]
E comp along polarization.
Shape of the earth, ice thicknesses, profiles of earth layers, densities, neutrino absorption...
static const int NLAYERS_MAX
max number of layers (in smex design, it's 4)
int fCapacitorNum[12 *9][260]
Array of capacitor numbers.
Double_t fNoiseAtTrigger[12 *9][260]
Array of noise at trigger.
Double_t nuDir[3]
Neutrino direction.
void WhichBandsPass(Settings *settings1, Anita *anita1, GlobalTrigger *globaltrig1, Balloon *bn1, int ilayer, int ifold, double dangle, double emfrac, double hadfrac, double thresholds[2][5])
Which bands passes the trigger.
Double_t e_component_k[48]
Component of e-field along the rx e-plane.
Double_t maxSNRAtDigitizerV
Max SNR at digitizer V-POL.
Double_t nuMom
Neutrino momentum.
int fNumPoints[12 *9]
Number of poins per channel.
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)
Float_t heading
0 is facing north, 180 is facing south
void injectImpulseAfterAntenna(Anita *anita1, int ant)
Inject pulse after the antenna (used for trigger efficiency scans)
Double_t maxSNRAtTriggerH
Max SNR at trigger H-POL.
Handles event counting as cuts are made.
UInt_t eventNumber
Software event number.
Double_t nuPos[3]
Neutrino position.
Double_t fTimes[12 *9][260]
Array of unwrapped (unless kNoCalib) times for each channel.
Double_t hitangle_e[48]
Hit angles rel. to e plane stored for each antenna.
Double_t SNRAtTrigger[12 *9]
Array of SNR at trigger.
Double_t maxSNRAtDigitizerH
Max SNR at digitizer H-POL.
Double_t balloonDir[3]
Balloon direction.
Ice thicknesses and water depth.