18 #include "TTreeIndex.h" 24 #include "icemc_random.h" 29 #include "TPostScript.h" 34 #include "TGraphErrors.h" 35 #include "TGraphAsymmErrors.h" 40 #include "TRotation.h" 42 #include "Math/InterpolationTypes.h" 43 #include "Math/Interpolator.h" 46 #include "EnvironmentVariable.h" 49 #include "Constants.h" 51 #include "position.hh" 53 #include "earthmodel.hh" 56 #include "roughness.hh" 59 #include "icemodel.hh" 63 #include "secondaries.hh" 65 #include "counting.hh" 66 #include "Primaries.h" 67 #include "Taumodel.hh" 69 #include "GlobalTrigger.h" 70 #include "ChanTrigger.h" 75 #if __cplusplus > 199711L 76 #include <type_traits> 81 #ifdef ANITA_UTIL_EXISTS 82 #include "UsefulAnitaEvent.h" 83 #include "AnitaGeomTool.h" 84 #include "AnitaConventions.h" 85 #include "RawAnitaHeader.h" 91 #ifdef ANITA3_EVENTREADER 92 #include "TruthAnitaEvent.h" 112 #ifdef ANITA_UTIL_EXISTS 113 int GetIceMCAntfromUsefulEventAnt(
Settings *settings1,
int UsefulEventAnt);
119 bool ABORT_EARLY =
false;
122 double ScaleVmMHz(
double vmmhz1m_max,
const Position &posnu1,
const Position &r_bn);
124 void interrupt_signal_handler(
int sig);
128 void read_pulser_electric_field(
string efield_file_name, vector<double> &time, vector<double> &voltsperm);
129 void read_pulser_electric_field(
string efield_file_name, vector<double> &time, vector<double> &voltsperm){
131 ifstream input_stream(efield_file_name.c_str());
136 while(!input_stream.eof())
138 getline(input_stream,buffer,
'\n');
145 float v=-999., t=-999.;
157 voltsperm.push_back(v);
160 cout << c-1 <<
"\t" << time[c-1] <<
"\t" << voltsperm[c-1] << endl;
164 if(!input_stream.eof())
167 cout <<
"Counted " << c <<
" rows from electric field file" << efield_file_name.c_str() << endl;
169 input_stream.close();
172 int main(
int argc,
char **argv) {
178 string input=
"inputs.txt";
183 if( (argc%3!=1)&&(argc%2!=1)) {
184 cout <<
"Syntax for options: -i inputfile -o outputdir -r run_number\n";
189 double trig_thresh=0.;
192 while ((clswitch = getopt(argc, argv,
"t:i:o:r:n:e:")) != EOF) {
195 nnu_tmp=atoi(optarg);
196 cout <<
"Changed number of simulated neutrinos to " << nnu_tmp << endl;
199 trig_thresh=atof(optarg);
203 cout <<
"Changed input file to: " << input << endl;
207 cout <<
"Changed output directory to: " << outputdir.Data() << endl;
208 stemp=
"mkdir -p " + string(outputdir.Data());
209 system(stemp.c_str());
212 exp_tmp=atof(optarg);
213 cout <<
"Changed neutrino energy exponent to " << exp_tmp << endl;
217 stringstream convert(run_num);
225 settings1->SEED=settings1->SEED +run_no;
226 cout <<
"seed is " << settings1->SEED << endl;
228 setSeed(settings1->SEED);
231 Anita *anita1=
new Anita();
241 double vmmhz[Anita::NFREQ];
243 double vmmhz_em[Anita::NFREQ];
248 stemp=string(outputdir.Data())+
"/output"+run_num+
".txt";
249 ofstream foutput(stemp.c_str(), ios::app);
252 double RANDOMISEPOL=0.;
254 int neutrinos_passing_all_cuts=0;
256 int discones_passing=0;
258 settings1->ReadInputs(input.c_str(), foutput, NNU, RANDOMISEPOL);
259 settings1->ApplyInputs(anita1, sec1, sig1, bn1, ray1);
262 settings1->SEED=settings1->SEED + run_no;
263 setSeed(settings1->SEED);
266 anita1->Initialize(settings1, foutput, inu, outputdir);
269 anita1->powerthreshold[4]=trig_thresh;
273 settings1->EXPONENT=exp_tmp;
281 Screen *panel1 =
new Screen(0);
283 time_t raw_start_time = time(NULL);
284 struct tm * start_time = localtime(&raw_start_time);
286 cout <<
"Date and time at start of run are: " << asctime (start_time) <<
"\n";
293 Tools::Zero(anita1->PHI_OFFSET, Anita::NLAYERS_MAX);
294 Tools::Zero(anita1->THETA_ZENITH, Anita::NLAYERS_MAX);
295 Tools::Zero(anita1->LAYER_VPOSITION, Anita::NLAYERS_MAX);
296 Tools::Zero(anita1->RRX, Anita::NLAYERS_MAX);
298 double volts_rx_rfcm_lab_e_all[48][512];
299 double volts_rx_rfcm_lab_h_all[48][512];
302 Vector n_eplane = const_z;
303 Vector n_hplane = -const_y;
304 Vector n_normal = const_x;
310 double e_component[Anita::NANTENNAS_MAX]={0};
311 double h_component[Anita::NANTENNAS_MAX]={0};
312 double n_component[Anita::NANTENNAS_MAX]={0};
314 double e_component_kvector[Anita::NANTENNAS_MAX]={0};
315 double h_component_kvector[Anita::NANTENNAS_MAX]={0};
316 double n_component_kvector[Anita::NANTENNAS_MAX]={0};
321 double hitangle_e, hitangle_h;
322 double hitangle_e_all[Anita::NANTENNAS_MAX];
323 double hitangle_h_all[Anita::NANTENNAS_MAX];
333 int l2trig[
Anita::NPOL][Anita::NTRIGGERLAYERS_MAX];
335 int l1trig[
Anita::NPOL][Anita::NTRIGGERLAYERS_MAX];
342 int nchannels_triggered = 0;
343 int nchannels_perrx_triggered[48];
346 Tools::Zero(count1->npass, 2);
350 #ifdef ANITA_UTIL_EXISTS 352 string outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaEventFile"+run_num+
".root";
353 TFile *anitafileEvent =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
355 TTree *eventTree =
new TTree(
"eventTree",
"eventTree");
356 eventTree->Branch(
"event", &realEvPtr );
357 eventTree->Branch(
"run", &run_no,
"run/I" );
358 eventTree->Branch(
"weight", &weight,
"weight/D");
360 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaHeadFile"+run_num+
".root";
361 TFile *anitafileHead =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
363 TTree *headTree =
new TTree(
"headTree",
"headTree");
364 headTree->Branch(
"header", &rawHeaderPtr );
365 headTree->Branch(
"weight", &weight,
"weight/D");
367 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaGpsFile"+run_num+
".root";
368 TFile *anitafileGps =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
370 TTree *adu5PatTree =
new TTree(
"adu5PatTree",
"adu5PatTree");
371 adu5PatTree->Branch(
"pat", &Adu5PatPtr );
372 adu5PatTree->Branch(
"eventNumber", &eventNumber,
"eventNumber/I");
373 adu5PatTree->Branch(
"weight", &weight,
"weight/D" );
377 #ifdef ANITA3_EVENTREADER 380 AnitaVersion::set(settings1->ANITAVERSION);
382 outputAnitaFile =string(outputdir.Data())+
"/SimulatedAnitaTruthFile"+run_num+
".root";
383 TFile *anitafileTruth =
new TFile(outputAnitaFile.c_str(),
"RECREATE");
385 TString icemcgitversion = TString::Format(
"%s", EnvironmentVariable::ICEMC_VERSION(outputdir));
386 printf(
"ICEMC GIT Repository Version: %s\n", icemcgitversion.Data());
387 unsigned int timenow = time(NULL);
389 TTree *configAnitaTree =
new TTree(
"configIcemcTree",
"Config file and settings information");
390 configAnitaTree->Branch(
"gitversion", &icemcgitversion );
391 configAnitaTree->Branch(
"startTime", &timenow );
393 configAnitaTree->Fill();
395 TTree *triggerSettingsTree =
new TTree(
"triggerSettingsTree",
"Trigger settings");
396 triggerSettingsTree->Branch(
"dioderms", anita1->bwslice_dioderms_fullband_allchan,
"dioderms[2][48][7]/D");
397 triggerSettingsTree->Branch(
"diodemean", anita1->bwslice_diodemean_fullband_allchan,
"diodemean[2][48][7]/D");
398 triggerSettingsTree->Fill();
400 TTree *truthAnitaTree =
new TTree(
"truthAnitaTree",
"Truth Anita Tree");
401 truthAnitaTree->Branch(
"truth", &truthEvPtr );
409 IceModel *antarctica =
new IceModel(settings1->ICE_MODEL + settings1->NOFZ*10, settings1->CONSTANTICETHICKNESS * 1000 + settings1->CONSTANTCRUST * 100 + settings1->FIXEDELEVATION * 10 + 0, settings1->WEIGHTABSORPTION);
412 anita1->GetBeamWidths(settings1);
415 anita1->Set_gain_angle(settings1, sig1->NMEDIUM_RECEIVER);
424 anita1->SetNoise(settings1, bn1, antarctica);
428 antarctica->GetMAXHORIZON(bn1);
431 antarctica->CreateHorizons(settings1, bn1, bn1->theta_bn, bn1->
phi_bn, bn1->altitude_bn, foutput);
432 cout <<
"Done with CreateHorizons.\n";
435 anita1->GetPayload(settings1, bn1);
437 if (settings1->TRIGGERSCHEME == 3 || settings1->TRIGGERSCHEME == 4 || settings1->TRIGGERSCHEME==5) {
440 anita1->calculate_all_offsets();
441 double angle_theta=16.;
443 Vector x =
Vector(cos(angle_theta * RADDEG) * cos((angle_phi+11.25) * RADDEG),
444 cos(angle_theta * RADDEG) * sin((angle_phi+11.25) * RADDEG),
445 sin(angle_theta * RADDEG));
446 anita1->GetArrivalTimes(x,bn1,settings1);
447 cout <<
"end of getarrivaltimes\n";
450 time_t raw_loop_start_time = time(NULL);
451 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;
453 signal(SIGINT, interrupt_signal_handler);
455 int passes_thisevent=0;
462 double justNoise_trig[2][48][512];
463 double justSignal_trig[2][48][512];
464 double justNoise_dig[2][48][512];
465 double justSignal_dig[2][48][512];
467 double thresholdsAnt[48][2][5];
471 Double_t latWAIS = sourceLat = - ( 79 + (27.93728/60) ) ;
472 Double_t lonWAIS = sourceLon = - (112 + ( 6.74974/60) ) ;
473 Double_t altWAIS = sourceAlt = 1775.68;
475 #ifdef ANITA_UTIL_EXISTS 476 latWAIS = AnitaLocations::getWaisLatitude() ;
477 lonWAIS = AnitaLocations::getWaisLongitude() ;
478 altWAIS = AnitaLocations::getWaisAltitude() ;
481 Double_t phiWAIS = EarthModel::LongtoPhi_0isPrimeMeridian(lonWAIS);
482 Double_t thetaWAIS = (90.+latWAIS)*RADDEG;
483 Double_t elevationWAIS = altWAIS + antarctica->Geoid(latWAIS);
484 Double_t distanceFromWAIS = 0.;
488 Vector surfaceNormalWAIS = antarctica->GetSurfaceNormal(positionWAIS);
497 cout <<
"Reading pulser model: " <<endl;
511 string fname = ICEMC_SRC_DIR +
"/data/var31_minialfa_icemc2icemc_input_electric_field_1m_511points_window.dat";
512 cout << fname << endl;
515 vector<double> voltsperm;
516 read_pulser_electric_field(fname,time,voltsperm);
517 RFSignal *wais_pulser =
new RFSignal(time.size(), &time[0], &voltsperm[0], 0);
519 Double_t *wais_pulser_freqs = wais_pulser->getFreqs();
520 Double_t *wais_pulser_mags = wais_pulser->getMags();
521 Double_t *wais_pulser_phases = wais_pulser->getPhases();
522 Int_t wais_nfreqs = wais_pulser->getNumFreqs() ;
524 Double_t dt = time[1]-time[0];
525 Double_t df = wais_pulser_freqs[1] - wais_pulser_freqs[0];
526 cout <<
"Frequency spacing of the wais pulser model : "<< df << endl;
527 cout <<
"DeltaT of wais pulser model " << dt << endl;
528 cout <<
"N " << time.size() <<
" NFREQS " << wais_pulser->getNumFreqs() <<
" " << endl;
529 TGraph *gwaisFreqMagGraph = wais_pulser->getFreqMagGraph();
530 gwaisFreqMagGraph->Print();
531 cout <<
"Phases " << wais_pulser_phases[0] <<
" " << wais_pulser_phases[10] <<
" " << wais_pulser_phases[100] << endl;
537 for (inu = 0; inu < NNU; inu++) {
538 settings1->MINBIAS=1;
540 if (inu % (NNU / 100) == 0)
541 cout << inu <<
" neutrinos. " << (double(inu)/double(NNU)) * 100 <<
"% complete.\n";
544 cout << inu <<
" neutrinos. " << (double(inu) / double(NNU)) * 100 <<
"% complete.\n";
547 eventNumber=(UInt_t)(run_no)*NNU+inu;
550 setSeed(eventNumber);
552 anita1->passglobtrig[0]=0;
553 anita1->passglobtrig[1]=0;
560 for (
int i=0; i<Anita::NFREQ;i++) {
566 interaction1->posnu = positionWAIS;
567 interaction1->posnu_down = positionWAIS;
570 bn1->
PickBalloonPosition(antarctica, settings1, inu, anita1, getRNG(RNG_BALLOON_POSITION)->Rndm());
572 distanceFromWAIS = (interaction1->posnu.
Distance(bn1->
r_bn));
575 if (distanceFromWAIS > 10e6) {
579 interaction1->
nnu = (bn1->
r_bn - interaction1->posnu);
580 interaction1->
nnu = interaction1->
nnu.Unit();
585 if (settings1->USEDEADTIME){
587 if ( (getRNG(RNG_DEADTIME)->Uniform(1)<anita1->deadTime) ){
590 if (settings1->MINBIAS!=1) {
603 for (
int i=0; i<wais_nfreqs; i++) {
604 if (wais_pulser_mags[i]>vmmhz1m) {
605 vmmhz1m = wais_pulser_mags[i];
617 vmmhz_max = ScaleVmMHz(vmmhz1m, interaction1->posnu, bn1->
r_bn);
630 for (
int i=0;i<Anita::NFREQ;i++) {
631 vmmhz[i]=vmmhz_max*wais_pulser_mags[i]/vmmhz1m;
636 for (
int i=0; i<anita1->NFOUR/4; i++){
640 anita1->v_phases[i]=wais_pulser_phases[i];
648 n_pol = interaction1->
nnu.Cross(surfaceNormalWAIS);
650 n_pol = n_pol.Unit();
652 if (settings1->BORESIGHTS) {
653 for(
int ilayer=0;ilayer<settings1->NLAYERS;ilayer++) {
654 for(
int ifold=0;ifold<anita1->NRX_PHI[ilayer];ifold++) {
655 n_pol_eachboresight[ilayer][ifold]=n_pol;
662 ray1->GetRFExit(settings1, anita1, 0, interaction1->posnu, interaction1->posnu_down, bn1->
r_bn, bn1->
r_boresights, 2, antarctica);
667 Tools::Zero(anita1->arrival_times[0], Anita::NLAYERS_MAX*
Anita::NPHI_MAX);
668 Tools::Zero(anita1->arrival_times[1], Anita::NLAYERS_MAX*
Anita::NPHI_MAX);
670 if(settings1->BORESIGHTS)
671 anita1->GetArrivalTimesBoresights( ray1->n_exit2bn_eachboresight[2]);
673 anita1->GetArrivalTimes( ray1->n_exit2bn[2], bn1, settings1);
675 anita1->rx_minarrivaltime=Tools::WhichIsMin(anita1->arrival_times[0], settings1->NANTENNAS);
678 globaltrig1->volts_rx_rfcm_trigger.assign(16, vector <vector <double> >(3, vector <double>(0)));
679 anita1->rms_rfcm_e_single_event = 0;
684 panel1->ResetParameters();
686 panel1->SetNvalidPoints(1);
688 for (
int k=0;k<Anita::NFREQ;k++) {
689 panel1->AddVmmhz_freq(vmmhz[k]);
691 panel1->AddDelay( 0. );
692 panel1->AddVec2bln(ray1->n_exit2bn[2]);
694 panel1->AddPol(n_pol);
695 panel1->AddWeight( 1. );
696 panel1->SetWeightNorm( 1. );
700 for (
int ilayer=0; ilayer < settings1->NLAYERS; ilayer++) {
701 for (
int ifold=0;ifold<anita1->NRX_PHI[ilayer];ifold++) {
711 if (!settings1->BORESIGHTS) {
712 bn1->
GetEcompHcompkvector(n_eplane, n_hplane, n_normal, ray1->n_exit2bn[2], e_component_kvector[count_rx], h_component_kvector[count_rx], n_component_kvector[count_rx]);
713 bn1->
GetEcompHcompEvector(settings1, n_eplane, n_hplane, n_pol, e_component[count_rx], h_component[count_rx], n_component[count_rx]);
716 bn1->
GetEcompHcompkvector(n_eplane, n_hplane, n_normal, ray1->n_exit2bn_eachboresight[2][ilayer][ifold], e_component_kvector[count_rx], h_component_kvector[count_rx], n_component_kvector[count_rx]);
717 bn1->
GetEcompHcompEvector(settings1, n_eplane, n_hplane, n_pol_eachboresight[ilayer][ifold], e_component[count_rx], h_component[count_rx], n_component[count_rx]);
719 bn1->
GetHitAngles(e_component_kvector[count_rx], h_component_kvector[count_rx], n_component_kvector[count_rx], hitangle_e, hitangle_h);
721 hitangle_h_all[count_rx]=hitangle_h;
722 hitangle_e_all[count_rx]=hitangle_e;
726 antNum = anita1->GetRxTriggerNumbering(ilayer, ifold);
728 chantrig1->
ApplyAntennaGain(settings1, anita1, bn1, panel1, antNum, n_eplane, n_hplane, n_normal);
730 chantrig1->
TriggerPath(settings1, anita1, antNum, bn1);
734 chantrig1->
TimeShiftAndSignalFluct(settings1, anita1, ilayer, ifold, volts_rx_rfcm_lab_e_all, volts_rx_rfcm_lab_h_all);
736 chantrig1->
saveTriggerWaveforms(anita1, justSignal_trig[0][antNum], justSignal_trig[1][antNum], justNoise_trig[0][antNum], justNoise_trig[1][antNum]);
737 chantrig1->
saveDigitizerWaveforms(anita1, justSignal_dig[0][antNum], justSignal_dig[1][antNum], justNoise_dig[0][antNum], justNoise_dig[1][antNum]);
740 chantrig1->
WhichBandsPass(settings1, anita1, globaltrig1, bn1, ilayer, ifold, 0, 0, 0, thresholdsAnt[antNum]);
750 anita1->rms_rfcm_e_single_event = sqrt(anita1->rms_rfcm_e_single_event / (anita1->HALFNFOUR * settings1->NANTENNAS));
752 for (
int irx=0;irx<settings1->NANTENNAS;irx++) {
753 nchannels_perrx_triggered[irx]=globaltrig1->nchannels_perrx_triggered[irx];
756 nchannels_triggered=Tools::iSum(globaltrig1->nchannels_perrx_triggered, settings1->NANTENNAS);
770 globaltrig1->
PassesTrigger(settings1, anita1, discones_passing, 2, l3trignoise, l2trig, l1trig, settings1->antennaclump, loctrig, loctrig_nadironly, inu,
771 thispassesnoise,
true);
773 globaltrig1->
PassesTrigger(settings1, anita1, discones_passing, 2, l3trig, l2trig, l1trig, settings1->antennaclump, loctrig, loctrig_nadironly, inu,
775 if ( (l3trignoise[0]>0 && l3trignoise[0]==l3trig[0]) || (l3trignoise[1]>0 && l3trignoise[1]==l3trig[1] ) ){
776 cout <<
"A thermal noise fluctuation generated this trigger!" << l3trignoise[0] <<
" " << l3trig[0] <<
" " << l3trignoise[1] <<
" " << l3trig[1] << endl;
782 for (
int i=0;i<2;i++) {
783 for (
int j=0;j<16;j++) {
784 for (
int k=0;k<anita1->HALFNFOUR;k++) {
785 count1->nl1triggers[i][0]+=anita1->l1trig_anita3and4_inanita[i][j][k];
799 if ( (thispasses[0]==1 && anita1->pol_allowed[0]==1)
800 || (thispasses[1]==1 && anita1->pol_allowed[1]==1)
801 || (settings1->MINBIAS==1)) {
805 anita1->passglobtrig[0]=thispasses[0];
806 anita1->passglobtrig[1]=thispasses[1];
810 count1->npassestrigger[0]++;
811 cout << count1->npassestrigger[0] << endl;
816 #ifdef ANITA_UTIL_EXISTS 821 Adu5PatPtr->
latitude= bn1->latitude;
825 Adu5PatPtr->
heading = bn1->heading;
826 Adu5PatPtr->
pitch = bn1->pitch;
827 Adu5PatPtr->roll = bn1->roll;
828 Adu5PatPtr->run = run_no;
831 memset(realEvPtr->
fVolts, 0,
sizeof(realEvPtr->
fVolts) );
832 memset(realEvPtr->
fTimes, 0,
sizeof(realEvPtr->
fTimes) );
834 int fNumPoints = 260;
836 for (
int iant = 0; iant < settings1->NANTENNAS; iant++){
838 int IceMCAnt = GetIceMCAntfromUsefulEventAnt(settings1, iant);
841 realEvPtr->
fNumPoints[UsefulChanIndexV] = fNumPoints;
842 realEvPtr->
fNumPoints[UsefulChanIndexH] = fNumPoints;
843 realEvPtr->
chanId[UsefulChanIndexV] = UsefulChanIndexV;
844 realEvPtr->
chanId[UsefulChanIndexH] = UsefulChanIndexH;
846 for (
int j = 0; j < fNumPoints; j++) {
848 realEvPtr->
fTimes[UsefulChanIndexV][j] = j * anita1->TIMESTEP * 1.0E9;
849 realEvPtr->
fTimes[UsefulChanIndexH][j] = j * anita1->TIMESTEP * 1.0E9;
851 realEvPtr->
fVolts[UsefulChanIndexH][j] = volts_rx_rfcm_lab_h_all[IceMCAnt][j+128]*1000;
853 realEvPtr->
fVolts[UsefulChanIndexV][j] = volts_rx_rfcm_lab_e_all[IceMCAnt][j+128]*1000;
863 if (settings1->MINBIAS==1){
865 cout <<
"MINBIASis one" << endl;
869 cout <<
"MINBIAS isn't one" << endl;
871 rawHeaderPtr->
run = run_no;
881 if (settings1->WHICH<9){
882 rawHeaderPtr->
phiTrigMask = (short) anita1->phiTrigMask;
888 Adu5PatPtr->
latitude= bn1->latitude;
892 Adu5PatPtr->
heading = bn1->heading;
893 Adu5PatPtr->
pitch = bn1->pitch;
894 Adu5PatPtr->roll = bn1->roll;
895 Adu5PatPtr->run = run_no;
897 #ifdef ANITA3_EVENTREADER 898 if (settings1->WHICH==9 || settings1->WHICH==10) {
901 rawHeaderPtr->setMask( (
short) anita1->l1TrigMask, (
short) anita1->phiTrigMask,
AnitaPol::kVertical);
902 rawHeaderPtr->setMask( (
short) anita1->l1TrigMaskH, (
short) anita1->phiTrigMaskH,
AnitaPol::kHorizontal);
908 truthEvPtr->
run = run_no;
909 truthEvPtr->
nuMom = 0;
911 memcpy(truthEvPtr->
e_component, e_component,
sizeof(e_component));
912 memcpy(truthEvPtr->
h_component, h_component,
sizeof(h_component));
913 memcpy(truthEvPtr->
n_component, n_component,
sizeof(n_component));
914 memcpy(truthEvPtr->
e_component_k ,e_component_kvector,
sizeof(e_component_kvector));
915 memcpy(truthEvPtr->
h_component_k ,h_component_kvector,
sizeof(h_component_kvector));
916 memcpy(truthEvPtr->
n_component_k ,n_component_kvector,
sizeof(n_component_kvector));
920 truthEvPtr->
weight = weight;
921 for (
int i=0;i<3;i++){
924 truthEvPtr->
nuPos[i] = interaction1->posnu[i];
925 truthEvPtr->
nuDir[i] = interaction1->
nnu[i];
927 for (
int i=0;i<5;i++){
928 for (
int j=0;j<3;j++){
929 truthEvPtr->
rfExitNor[i][j] = ray1->n_exit2bn[i][j];
930 truthEvPtr->
rfExitPos[i][j] = ray1->rfexit[i][j];
933 for (
int i=0;i<48;i++){
934 truthEvPtr->
hitangle_e[i] = hitangle_e_all[i];
935 truthEvPtr->
hitangle_h[i] = hitangle_h_all[i];
937 if(settings1->ROUGHNESS){
938 for (
int i=0;i<Anita::NFREQ;i++)
939 truthEvPtr->
vmmhz[i] = panel1->GetVmmhz_freq(i);
955 for (
int iant = 0; iant < settings1->NANTENNAS; iant++){
959 truthEvPtr->
SNRAtTrigger[UsefulChanIndexV] = Tools::calculateSNR(justSignal_trig[0][iant], justNoise_trig[0][iant]);
960 truthEvPtr->
SNRAtTrigger[UsefulChanIndexH] = Tools::calculateSNR(justSignal_trig[1][iant], justNoise_trig[1][iant]);
965 truthEvPtr->
SNRAtDigitizer[UsefulChanIndexV] = Tools::calculateSNR(justSignal_dig[0][iant], justNoise_dig[0][iant]);
966 truthEvPtr->
SNRAtDigitizer[UsefulChanIndexH] = Tools::calculateSNR(justSignal_dig[1][iant], justNoise_dig[1][iant]);
972 truthEvPtr->
thresholds[UsefulChanIndexV] = thresholdsAnt[iant][0][4];
973 truthEvPtr->
thresholds[UsefulChanIndexH] = thresholdsAnt[iant][1][4];
976 if (iant%2) irx = iant/2;
977 else irx = iant/2 + 1;
980 for (
int j = 0; j < fNumPoints; j++) {
981 truthEvPtr->
fTimes[UsefulChanIndexV][j] = j * anita1->TIMESTEP * 1.0E9;
982 truthEvPtr->
fTimes[UsefulChanIndexH][j] = j * anita1->TIMESTEP * 1.0E9;
984 truthEvPtr->
fSignalAtTrigger[UsefulChanIndexV][j] = justSignal_trig[0][iant][j+128]*1000;
985 truthEvPtr->
fSignalAtTrigger[UsefulChanIndexH][j] = justSignal_trig[1][iant][j+128]*1000;
986 truthEvPtr->
fNoiseAtTrigger[UsefulChanIndexV][j] = justNoise_trig[0][iant][j+128]*1000;
987 truthEvPtr->
fNoiseAtTrigger[UsefulChanIndexH][j] = justNoise_trig[1][iant][j+128]*1000;
988 truthEvPtr->
fSignalAtDigitizer[UsefulChanIndexV][j] = justSignal_dig[0][iant][j+128]*1000;
989 truthEvPtr->
fSignalAtDigitizer[UsefulChanIndexH][j] = justSignal_dig[1][iant][j+128]*1000;
990 truthEvPtr->
fNoiseAtDigitizer[UsefulChanIndexV][j] = justNoise_dig[0][iant][j+128]*1000;
991 truthEvPtr->
fNoiseAtDigitizer[UsefulChanIndexH][j] = justNoise_dig[1][iant][j+128]*1000;
993 truthEvPtr->
fDiodeOutput[UsefulChanIndexV][j] = anita1->timedomain_output_allantennas[0][irx][j];
994 truthEvPtr->
fDiodeOutput[UsefulChanIndexH][j] = anita1->timedomain_output_allantennas[1][irx][j];
1002 truthAnitaTree->Fill();
1008 adu5PatTree->Fill();
1011 delete rawHeaderPtr;
1015 neutrinos_passing_all_cuts++;
1038 std::cout <<
"\n***********************************************************";
1039 std::cout <<
"\n* SIGINT received, aborting loop over events early.";
1040 std::cout <<
"\n* Stopped after event " << inu <<
" instead of " << NNU;
1041 std::cout <<
"\n* Any output which relied on NNU should be corrected for.";
1042 std::cout <<
"\n***********************************************************\n";
1043 foutput <<
"\n***********************************************************";
1044 foutput <<
"\n* SIGINT received, aborting loop over events early.";
1045 foutput <<
"\n* Stopped after event " << inu <<
" instead of " << NNU;
1046 foutput <<
"\n* Any output which relied on NNU should be corrected for.";
1047 foutput <<
"\n***********************************************************\n";
1057 #ifdef ANITA_UTIL_EXISTS 1059 anitafileEvent->cd();
1060 eventTree->Write(
"eventTree");
1061 anitafileEvent->Close();
1062 delete anitafileEvent;
1064 anitafileHead->cd();
1065 headTree->Write(
"headTree");
1066 anitafileHead->Close();
1067 delete anitafileHead;
1070 adu5PatTree->Write(
"adu5PatTree");
1071 anitafileGps->Close();
1072 delete anitafileGps;
1074 #ifdef ANITA3_EVENTREADER 1075 anitafileTruth->cd();
1076 configAnitaTree->Write(
"configAnitaTree");
1077 truthAnitaTree->Write(
"truthAnitaTree");
1078 triggerSettingsTree->Write(
"triggerSettingsTree");
1079 anitafileTruth->Close();
1080 delete anitafileTruth;
1094 void interrupt_signal_handler(
int sig){
1095 signal(sig, SIG_IGN);
1101 #ifdef ANITA_UTIL_EXISTS 1103 int GetIceMCAntfromUsefulEventAnt(
Settings *settings1,
int UsefulEventAnt){
1107 int IceMCAnt = UsefulEventAnt;
1108 if ((settings1->WHICH==9 || settings1->WHICH==10) && UsefulEventAnt<16) {
1109 IceMCAnt = (UsefulEventAnt%2==0)*UsefulEventAnt/2 + (UsefulEventAnt%2==1)*(UsefulEventAnt/2+8);
1119 double ScaleVmMHz(
double vmmhz1m_max,
const Position &posnu1,
const Position &r_bn) {
1120 double dtemp= r_bn.
Distance(posnu1);
1121 vmmhz1m_max= vmmhz1m_max/dtemp;
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.
Position r_bn
position of balloon
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.
double phi_bn
theta,phi of balloon wrt south pole
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.
void ApplyAntennaGain(Settings *settings1, Anita *anita1, Balloon *bn1, Screen *panel1, int ant, Vector &n_eplane, Vector &n_hplane, Vector &n_normal)
Apply the antenna gain.
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)
void PickBalloonPosition(Vector straightup, IceModel *antarctica, Settings *settings1, Anita *anita1)
This function picks the balloon position.
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.
This is a wrapper class for an RF Signal.
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.
Vector n_bn
normalized r_bn
Functions you need to generate a primary interaction including cross sections and picking charged cur...
Double_t maxSNRAtTriggerV
Max SNR at trigger V-POL.
void InitializeBalloon()
This function initializes the balloon or the specific flight.
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.
Double_t h_component[48]
H comp along polarization.
UInt_t realTime
unixTime of readout
Stores everything about a particular neutrino interaction. Interaction.
Double_t rfExitNor[5][3]
Normal vector in direction of exit point to balloon - 5 iterations.
UsefulAnitaEvent – The Calibrated Useful Anita Event object.
void GetAntennaOrientation(Settings *settings1, Anita *anita1, int ilayer, int ifold, Vector &n_eplane, Vector &n_hplane, Vector &n_normal)
This function gets the antenna orientation.
Float_t altitude
In metres.
Double_t hitangle_h[48]
Hit angles rel. to h plane stored for each antenna.
void SetDefaultBalloonPosition(IceModel *antarctica1)
This function sets the default balloon position.
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.
void GetEcompHcompEvector(Settings *settings1, Vector n_eplane, Vector n_hplane, const Vector n_pol, double &e_component, double &h_component, double &n_component)
This function gets the e-component, h-component and e-vector.
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)
void GetHitAngles(double e_component_kvector, double h_component_kvector, double n_component_kvector, double &hitangle_e, double &hitangle_h)
This function gets the hit angles.
Float_t heading
0 is facing north, 180 is facing south
Double_t maxSNRAtTriggerH
Max SNR at trigger H-POL.
Handles event counting as cuts are made.
double dtryingposition
weighting factor: how many equivalent tries each neutrino counts for after having reduced possible in...
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.
void GetEcompHcompkvector(Vector n_eplane, Vector n_hplane, Vector n_normal, const Vector n_exit2bn, double &e_component_kvector, double &h_component_kvector, double &n_component_kvector)
This function gets the e-component, h-component and k-vector.
Double_t maxSNRAtDigitizerH
Max SNR at digitizer H-POL.
Double_t balloonDir[3]
Balloon direction.
Position r_boresights[Anita::NLAYERS_MAX][Anita::NPHI_MAX]
position of antenna boresights
Ice thicknesses and water depth.
unsigned int realTime_flightdata
realtime from the flight data file
Vector nnu
direction of neutrino (+z in south pole direction)