Settings.cc
1 #include "TF1.h"
2 #include <array>
3 #include "position.hh"
4 #include "Constants.h"
5 #include "Settings.h"
6 #include "Tools.h"
7 #include "vector.hh"
8 #include "roughness.hh"
9 #include "anita.hh"
10 #include "balloon.hh"
11 #include "icemodel.hh"
12 #include "Spectra.h"
13 #include "signal.hh"
14 #include "secondaries.hh"
15 #include "ray.hh"
16 #include "counting.hh"
17 #include "Primaries.h"
18 
19 
20 #include <string.h>
21 
22 #include "TString.h"
23 #include "TRegexp.h"
24 #include "TObjString.h"
25 
26 
27 
28 // Prettify warnings because, why not?
29 #define ANSI_COLOR_RED "\x1b[31m"
30 #define ANSI_COLOR_GREEN "\x1b[32m"
31 #define ANSI_COLOR_YELLOW "\x1b[33m"
32 #define ANSI_COLOR_BLUE "\x1b[34m"
33 #define ANSI_COLOR_MAGENTA "\x1b[35m"
34 #define ANSI_COLOR_CYAN "\x1b[36m"
35 #define ANSI_COLOR_RESET "\x1b[0m"
36 
37 ClassImp(Settings);
38 
43 Settings::Settings() : jamieFactor(0), medium(0), askaryanParameterization(0)
44 {
45  Initialize();
46 }
47 
48 
54 
55 }
56 
57 
58 
59 
60 
61 
68 void Settings::parseSettingsFile(const char* fileName, std::ofstream& outputFile){
69 
70  std::ifstream settingsFile(fileName);
71 
72  // Print error message if I can't read the file
73  if(!settingsFile.is_open()){
74  std::cerr << "Error in " << ANSI_COLOR_BLUE << __FILE__ << ANSI_COLOR_RESET
75  << ", could not open file " << ANSI_COLOR_RED << fileName << ANSI_COLOR_RESET << std::endl;
76  exit(1);
77  }
78  else{
79 
80  time_t rawtime;
81  struct tm * timeinfo;
82  time (&rawtime);
83  timeinfo = localtime (&rawtime);
84  outputFile << "Current date and time are: " << asctime(timeinfo) << std::endl;
85 
86 
87  int lineNum = 1;
88 
89  // Read every line in the file...
90  while(!settingsFile.eof()){
91 
92  std::string thisLine;
93  std::getline(settingsFile, thisLine);
94 
95  // Copy to output file
96  outputFile << thisLine << std::endl;
97 
98  // First cut out the comment, which is all characters after the first #, including the #
99  std::size_t found = thisLine.find("#");
100 
101 
102  // Here we switch to TString because of its lovely tokenization methods
103  TString thisLineCommentsRemoved(thisLine.substr(0, found));
104 
105  // Now have a TObjArray of TObjStrings split by out delimeter :
106  TObjArray* tokens = thisLineCommentsRemoved.Tokenize(":");
107 
108  int nTokens = tokens->GetEntries();
109 
110  // If there are two tokens, then there was one delimeter
111  if(nTokens == 2){
112 
113  TString key = ((TObjString*) tokens->At(0))->GetString();
114  TString value = ((TObjString*) tokens->At(1))->GetString();
115 
116  Bool_t addVariable = newKvpPassesSanityChecks(key, value, fileName, lineNum);
117 
118  if(addVariable){
119  keyValuePairStrings[key.Data()] = value.Data();
120  }
121 
122  }
123  else{
124 
125  TRegexp reggie("[a-zA-Z0-9]");
126  Ssiz_t len = thisLineCommentsRemoved.Length();
127 
128  Bool_t isAlphaNumeric = reggie.Index(thisLineCommentsRemoved, &len) != -1;
129 
130  if(nTokens > 2 || isAlphaNumeric){
131  // complain if there are more than two tokens, i.e. more that one colon.
132  // complain if there are non whitespace characters but no colon.
133  std::cerr << "Warning in " ANSI_COLOR_RED << __FILE__ << ANSI_COLOR_RESET
134  << ". I couldn't parse line " << ANSI_COLOR_RED << lineNum << ANSI_COLOR_RESET
135  << " in " << fileName << ". It said: " << std::endl;
136  std::cerr << ANSI_COLOR_BLUE << thisLine << ANSI_COLOR_RESET << std::endl;
137  }
138  }
139  delete tokens;
140 
141  lineNum++;
142  }
143  }
144 
145 
146  outputFile << std::endl << std::endl;
147  outputFile << __FILE__ << " has finished parsing " << fileName << std::endl;
148  outputFile << std::endl << std::endl;
149 
150 }
151 
152 
153 
165 Bool_t Settings::newKvpPassesSanityChecks(const TString& key, const TString& value, const char* fileName, int lineNum){
166 
167  Bool_t isGood = true;
168 
169  if(key.Length()==0){
170  std::cerr << "Warning in " << ANSI_COLOR_BLUE << __FILE__ << ANSI_COLOR_RESET << ", "
171  << ANSI_COLOR_BLUE << fileName << ANSI_COLOR_RESET
172  << " has a variable with no name at " << ANSI_COLOR_RED << "line " << lineNum
173  << ANSI_COLOR_RESET << "." << std::endl;
174  isGood = false;
175  }
176 
177  else if(value.Length()==0){
178  std::cerr << "Warning in " << ANSI_COLOR_BLUE << __FILE__ << ANSI_COLOR_RESET << ", "
179  << ANSI_COLOR_BLUE << fileName << ANSI_COLOR_RESET
180  << " has a variable with no value at " << ANSI_COLOR_RED << "line " << lineNum
181  << ANSI_COLOR_RESET << "." << std::endl;
182  isGood = false;
183  }
184  else{
185  kvpMap::iterator it = keyValuePairStrings.find(key);
186 
187  if(it!=keyValuePairStrings.end()){
188  std::cerr << "Warning in " << ANSI_COLOR_BLUE << __FILE__ << ANSI_COLOR_RESET << ", "
189  << ANSI_COLOR_BLUE << fileName << ANSI_COLOR_RESET
190  << " already has a variable named " << ANSI_COLOR_RED << key.Data()
191  << ANSI_COLOR_RESET << "." << std::endl;
192 
193  isGood = false;
194  }
195  }
196 
197  if(!isGood){
198  std::cerr << "Will ignore " << ANSI_COLOR_RED << "line " << lineNum << ANSI_COLOR_RESET << std::endl;
199  }
200 
201  return isGood;
202 }
203 
204 
205 
213 
214  kvpMap::iterator it;
215  for(it = keyValuePairStrings.begin(); it!=keyValuePairStrings.end(); ++it){
216  std::cout << it->first << "\t" << it->second << std::endl;
217  }
218 }
219 
220 
221 
227  NDISCONES_PASS=3;
228  DEBUG=false; // debugging option
229  // outputdir="outputs"; // directory where outputs go
230  FREQ_LOW_SEAVEYS=200.E6;
231  FREQ_HIGH_SEAVEYS=1200.E6;
232  BW_SEAVEYS=FREQ_HIGH_SEAVEYS-FREQ_LOW_SEAVEYS;
233  SIGMAPARAM=1; // Connolly et al. 2011 default cross section parametrization
234  YPARAM=1; // Connolly et al. 2011 default y parametrization
235  UNBIASED_SELECTION=1.; // (0) pick neutrino interaction in the ice and neutrino from any direction or (1) choose neutrino interaction point in the horizon on the balloon in the ice and neutrino direction on the cerenkov cone
236  UNBIASED_PS_MAX_DISTANCE_KM =1e3;
237  UNBIASED_CHORD_STEP_M =50;
238  SIGMA_FACTOR=1;
239  USEDARTBOARD=0;
240  EXPONENT=18.; // Initialize energy exponent
241 
242  // Bunch of variables which were global in icemc.cc but are settings:
243  SEED=65540; // random number seed.
244  THETA_TH_FACTOR=1.0; // factor to multiply theta_th to check code is working properly
245  CHANCEINHELL_FACTOR=1.0; // loosen chance in hell cuts to check code is working properly
246  CONSTANTY=0; // whether or not to set y to a constant=0.2
247  VARIABLE_ATTEN=0; // 0=depth dependent attenuation length, 1=fixed
248  TRIGTYPE=1; //1=Trigger scheme as in the SMEX proposal or 0= Just at least 8 channels pass with 2.3 sigma signal
249  ATMOSPHERE=1;// include atmosphere
250  SCALEDOWNLCPRX1=1; // scale down lcp voltage of antenna 1 by sqrt(2)
251  SCALEDOWNEPOLRX1=1; // scale down power of e pol. of antenna 1 by factor of 2
252  SCALEDOWNHPOLRX1=1; // scale down power of h pol. of antenna 1 by factor of 2
253  SCALEDOWNEPOLRX2=1; // scale down power of e pol. of antenna 2 by factor of user's choice
254  SCALEFACTOREPOLRX2=0.05; // scale power of e pol. of antenna 2 by this factor
255  SCALEDOWNHPOLRX2=1; // scale down power of h pol. of antenna 2 by factor of 2
256  EPOLRX2ZERO=1; // lcp channel on anita-lite is not considered for triggering.
257  HPOLRX2ZERO=1; // h pol. of 2nd antenna set to zero.
258  RCPRX2ZERO=1; // rcp of 2nd antenna set to zero.
259  LCPRX2ZERO=1; // lcp of 2nd antenna set to zero.
260  FLATSURFACE=0; // Normals of all positions on the surface are straight up.
261  WRITEPOSFILE=0; //Write neutrino position information to file
262  SKIPCUTS=0; //See every neutrino through to the end - don't make any of the various cuts designed to speed up the program. (For checking distributions.)
263  USEDIRECTIONWEIGHTS=1;// whether or not to restrict the neutrino angle so that the viewing angle is near the cerenkov cone
264  SHOWERTYPE=0; // Type of shower for previous option
265  // End of the once-global varibles.
266  taumodes = 1; //Taumodes =1, taucreated in the rock.
267  SCREENEDGELENGTH=25.;
268  TUFFSTATUS=0;
269  ADDCW=0;
270  PAYLOAD_USE_SPECIFIC_TIME = 0;
271  PAYLOAD_USE_SPECIFIC_TIME_DELTA = 3600;
272 
273  SPECIFIC_NU_POSITION = 0;
274  SPECIFIC_NU_POSITION_LATITUDE = -77.7;
275  SPECIFIC_NU_POSITION_LONGITUDE = 166.7;
276  SPECIFIC_NU_POSITION_ALTITUDE = 0;
277  SPECIFIC_NU_POSITION_DISTANCE = 100e3;
278  HORIZON_OFFSET = -999;
279  SAVE_TRUTH_NU_TREE = 0;
280 
281  // Source options
282  SOURCE = "None";
283  SOURCE_USE_EXPONENT = 0;
284  SOURCE_MIN_E = 18;
285  SOURCE_MAX_E = 21;
286  WHICH_SOURCES = "All";
287  WHICH_SUBTYPE = "All";
288  WHICH_START_TIME = "0";
289  WHICH_END_TIME = "MAX";
290  SOURCE_SKIP_WHEN_NONE = 0;
291 
292  // Extras
293  IGNORE_CROSSPOL = 0;
294  POL_SIGN_HACK = 1;
295  CUTONWEIGHTS = 0.;
296  CUTONWEIGHTPROBS = 0.;
297  DEC_CUT = 30; // Declination cut 999 is default: no declination cut
298  // If you specify a value, then only use sources within from declination = -DEC_CUT to DEC_CUT
299  ALL_SKY_MAP = 0; // Draw all-sky map?
300 
301  // Custom source options
302  CUSTOM_NAME = "customObject";
303  CUSTOM_RA = 0; // in decimal degrees
304  CUSTOM_DEC = 0; // in decimal degrees
305  CUSTOM_GAMMA = 2;
306 
307 }
308 
309 
310 
311 
312 
313 
314 
315 
316 
317 void Settings::ReadInputs(const char* inputFileName, std::ofstream &foutput,
318  // Anita* anita1, Secondaries* sec1, Signal* sig1,
319  // Balloon* bn1, Ray* ray1,
320  int& NNU, double& RANDOMISEPOL) {
321 
322  parseSettingsFile(inputFileName, foutput);
323 
324  getSetting("Number of neutrinos", NNU);
325  getSetting("Energy exponent", EXPONENT);
326  getSetting("Energy CDF or dartboard", USEDARTBOARD);
327 
328  getSetting("Neutrino position", UNBIASED_SELECTION);
329  getSetting("Neutrino Point Source Max Distance", UNBIASED_PS_MAX_DISTANCE_KM,true);
330  getSetting("Neutrino Point Source Ice Chord Step", UNBIASED_CHORD_STEP_M,true);
331  getSetting("Write hists and trees", HIST);
332  getSetting("Write ray", FILLRAYTREES);
333 
334  getSetting("Only final tree", ONLYFINAL);
335  getSetting("Max histogram entries", HIST_MAX_ENTRIES);
336  getSetting("Random seed", SEED);
337  std::cout << "INITIAL SEED is " << SEED << std::endl;
338  gRandom->SetSeed(SEED);
339 
340  getSetting("Write neutrino position", WRITEPOSFILE);
341 
342  if (WRITEPOSFILE==1){
343  std::cout << "Non-default setting: WRITEPOSFILE= " << WRITEPOSFILE << std::endl;
344  }
345  getSetting("Events map", EVENTSMAP);
346 
347 
348 
349 // ################################################################################################
350 // # Balloon and payload
351 // ################################################################################################
352 
353 
354 
355  getSetting("Which payload", WHICH);
356  getSetting("Antenna layers", NLAYERS);
357 
358  if (WHICH==9) ANITAVERSION=3;
359  else if (WHICH==10) ANITAVERSION=4;
360  else ANITAVERSION=0;
361 
362  if(((WHICH==1 || WHICH==6) && NLAYERS!=4) || (WHICH==0 && NLAYERS!=1) || (WHICH==7 && NLAYERS!=1)){
363  std::cout << "Non-default setting: WHICH = " << WHICH << " and NLAYERS= " << NLAYERS << std::endl;
364  }
365 
366 
367  getSetting("Inclination top three layers", INCLINE_TOPTHREE);
368 
369  if(INCLINE_TOPTHREE!=10){
370  std::cout << "Non-default setting: INCLINE_TOPTHREE= " << INCLINE_TOPTHREE << std::endl;
371  }
372 
373  getSetting("Inclination fourth layer", INCLINE_NADIR);
374 
375  if(INCLINE_NADIR!=10){
376  std::cout << "Non-default setting: INCLINE_NADIR= " << INCLINE_NADIR << std::endl;
377  }
378 
379  getSetting("Flight path", WHICHPATH);
380 
381  if((WHICH==0 && WHICHPATH!=2) || (WHICH==2 && WHICHPATH!=6)){
382  std::cout << "Non-default setting: WHICHPATH = " << WHICHPATH << " and WHICH = "
383  << WHICH << std::endl;
384  }
385 
386  getSetting("Balloon latitude", BN_LATITUDE);
387  getSetting("Balloon longitude", BN_LONGITUDE);
388 
389  if(WHICHPATH==0)
390  {
391  if(BN_LONGITUDE!=999 && BN_LATITUDE!=999)
392  {
393  std::cout << "Setting the payload position to a custom **fixed** position: BN_LATITUDE: "<< BN_LATITUDE << ", BN_LONGITUDE: " << BN_LONGITUDE << std::endl;
394  }
395  else
396  {
397  std::cout << "Setting the payload position to the default **fixed** position: BN_LATITUDE: "<< BN_LATITUDE << ", BN_LONGITUDE: " << BN_LONGITUDE << std::endl;
398  }
399 
400  }
401 
402  if (BN_LONGITUDE>180. && BN_LONGITUDE!=999){
403  std::cout << "Entered balloon longitude wrong! Should be between -180 and 180 degrees." << std::endl;
404  }
405  getSetting("Balloon orientation", RANDOMIZE_BN_ORIENTATION);
406 
407 
408  if (RANDOMIZE_BN_ORIENTATION==1 && (WHICHPATH==2 || WHICHPATH==6 ||
409  WHICHPATH==7 || WHICHPATH==8 || WHICHPATH==9)){
410  std::cout << "Warning:: Strangely you asked for a real flight path but a randomized balloon orientation. WILL BE OVERRIDDEN." << std::endl;
411  }
412 
413  getSetting("Balloon altitude", BN_ALTITUDE);
414 
415 
416  // whether to use constant gains as entered in GetBeamWidths (0) or to use Ped's measurements as entered in ReadGains (1)
417  // GAINS is actually an int, not a double...
418  getSetting("Gain setting", GAINS);
419 
420 
421 
422  getSetting("Trigger scheme", TRIGGERSCHEME);
423 
424  // Ben S, leaving this here... should it get its own config file entry?
425  TRIGTYPE=1; // ANITA, not anita-lite. But the anita-lite code back in later
426 
427  getSetting("Band thresholds", tempThresholds);
428 
429  getSetting("Banding", BANDING);
430 
431 
432  if(BANDING !=0 && BANDING!= 1 && BANDING!=2 && BANDING!=4) {
433  std::cout << "Banding should be set to 0 (Anita 1), 1 (custum), 2 (Anita 2), 3 (Satellite) or 4 (Anita 3)."
434  << std::endl;
435  exit(1);
436  }
437 
438  if ((TRIGGERSCHEME==0 || TRIGGERSCHEME==1) && BANDING!=1) {
439  std::cout << "Frequency domain trigger schemes can only be used with user-set sub-bands." << std::endl;
440  exit(1);
441  }
442 
443  if (TRIGGERSCHEME==2 && BANDING==1) {
444  std::cout << "Time domain trigger scheme only works with Anita 1, Anita 2 or Anita 3 banding data, you can't set your own bands." << std::endl;
445  exit(1);
446  }
447 
448 
449  getSetting("Lower band edges", bandLowEdgesMHz);
450  getSetting("Upper band edges", bandHighEdgesMHz);
451  getSetting("Required bands", requiredBands);
452  getSetting("Allowed bands", allowedBands);
453  getSetting("Number of bands", NBANDS);
454  getSetting("Percent bandwidth", PERCENTBW);
455 
456  getSetting("Notch filter limits", notchFilterLimitsMHz);
457 
458  getSetting("Num antenna channels for L1 trigger", trigRequirements[0]);
459  getSetting("Num L1 hits to pass L2", trigRequirements[1]);
460  getSetting("Num antenna for L2 trigger", antennaclump);
461  getSetting("Require centre antenna", REQUIRE_CENTRE);
462  getSetting("L3 trigger requirement", trigRequirements[2]);
463  getSetting("LCP/RCP or V/H", LCPRCP);
464  getSetting("Channels required polarization", channelRequirePol);
465  getSetting("Channels allowed polarization", channelAllowedPol);
466 
467  getSetting("Exta antennas in trigger", DISCONES);
468  getSetting("Nadir only trigger", INCLUDE_NADIRONLY);
469 
470  if (INCLUDE_NADIRONLY!=0){
471  std::cout << "Non-default setting: INCLUDE_NADIRONLY = " << INCLUDE_NADIRONLY << std::endl;
472  }
473 
474  getSetting("ANITA-1 channel masking", CHMASKING);
475 
476  if (WHICHPATH!=6 && CHMASKING==1) {
477  std::cout << "Cannot include masking for flights other than the ANITA-1 flight." << std::endl;
478  std::cout << "For the ANITA-3 channel masking, it is implemented together with the phi masking and it's turned on whenever the PHIMASKING is ON." << std::endl;
479  std::cout << "CHMASKING set to 0." << std::endl;
480  CHMASKING=0;
481  }
482 
483  getSetting("ANITA-2 channel masking", PHIMASKING);
484 
485 
486 
487  getSetting("Scale down LCP voltage 1st ant", SCALEDOWNLCPRX1);
488  getSetting("Scale down E pol 1st ant", SCALEDOWNEPOLRX1);
489  getSetting("Scale down H pol 1st ant", SCALEDOWNHPOLRX1);
490  getSetting("Scale down E pol 2nd ant", SCALEDOWNEPOLRX2);
491  getSetting("E pol scale down factor 2nd ant", SCALEFACTOREPOLRX2);
492  getSetting("H pol scale down factor 2nd ant", SCALEDOWNHPOLRX2);
493  getSetting("E pol 2nd ant dead", EPOLRX2ZERO);
494  getSetting("H pol 2nd ant dead", HPOLRX2ZERO);
495  getSetting("RCP 2nd ant dead", RCPRX2ZERO);
496  getSetting("LCP 2nd ant dead", LCPRX2ZERO);
497 
498  if (WHICH==0 && !(SCALEDOWNEPOLRX1==1 && RCPRX2ZERO==1)){
499  std::cout << "Non-default setting: WHICH= " << WHICH << " and EPOLRX2ZERO= " << EPOLRX2ZERO << std::endl;
500  }
501 
502 
503 
504 
505 
506 
507 
508 
509 
510 
511 
512 
513 
514  getSetting("Add noise to signal", SIGNAL_FLUCT);
515 
516  if (SIGNAL_FLUCT!=1){
517  std::cout << "Non-default setting: SIGNAL_FLUCT= " << SIGNAL_FLUCT << std::endl;
518  }
519 
520  getSetting("Zero signal", ZEROSIGNAL);
521  if (ZEROSIGNAL!=0){
522  std::cout << "Non-default setting: ZEROSIGNAL= " << ZEROSIGNAL << std::endl;
523  }
524 
525  getSetting("Random rotation polarization", RANDOMISEPOL);
526 
527  getSetting("LPM effect", useLPM);
528  getSetting("E-field factor", jamieFactor);
529  getSetting("Thermal noise factor", THERMALNOISE_FACTOR);
530 
531  if (THERMALNOISE_FACTOR!=1){
532  std::cout << "Non-default setting: THERMALNOISE_FACTOR= " << THERMALNOISE_FACTOR << std::endl;
533  }
534 
535  getSetting("Disable polarization vectors", REMOVEPOLARIZATION);
536 
537  if (REMOVEPOLARIZATION==1){
538  std::cout << "Non-default setting: Polarizations turned off!" << std::endl;
539  }
540  getSetting("Use pulser spectrum", PULSER);
541  if (PULSER!=0){
542  std::cout << "Warning! Injecting a pulser spectrum- not simulating neutrinos! PULSER = "
543  << PULSER << std::endl;
544  }
545 
546  getSetting("Centre one phi-sector", CENTER);
547 
548  if (CENTER!=0){
549  std::cout << "WARNING!! Rotating payload to center one phi sector on the incoming signal for each event."
550  << std::endl;
551  }
552 
553  getSetting("Force vertical polarization", MAKEVERTICAL);
554 
555  if (MAKEVERTICAL!=0){
556  std::cout << "WARNING!! Rotating polarization so it is always vertical approaching the payload" << std::endl;
557  }
558 
559 
560 
561 
562 
563 
564 
565 
566 
567  getSetting("Slopeyness", SLOPEYSIZE);
568  if (SLOPEYSIZE!=0.012){
569  std::cout << "Non-default setting: SLOPEYSIZE= " << SLOPEYSIZE << std::endl;
570  }
571  getSetting("Enable slopeyness", SLOPEY);
572  if (SLOPEY!=1){
573  std::cout << "Non-default setting: SLOPEY= " << SLOPEY << std::endl;
574  }
575  getSetting("Depth dependent refractive index", NOFZ);
576  if (NOFZ!=1){
577  std::cout << "Non-default setting: NOFZ= " << NOFZ << std::endl;
578  }
579  getSetting("Variable attenuation length", VARIABLE_ATTEN);
580  if (VARIABLE_ATTEN!=0){
581  std::cout << "Non-default setting: VARIABLE_ATTEN= " << VARIABLE_ATTEN << std::endl;
582  }
583  getSetting("Constant ice thickness", CONSTANTICETHICKNESS);
584 
585  if (CONSTANTICETHICKNESS==1){
586  std::cout << "Non-default setting: CONSTANTICETHICKNESS= " << CONSTANTICETHICKNESS << std::endl;
587  }
588 
589  getSetting("Fixed ice elevation", FIXEDELEVATION);
590  if (FIXEDELEVATION==1){
591  std::cout << "Non-default setting: FIXEDELEVATION= " << FIXEDELEVATION << std::endl;
592  }
593 
594  getSetting("Antarctic ice model", ICE_MODEL);
595  if ((CONSTANTICETHICKNESS || FIXEDELEVATION) && ICE_MODEL != 0) {
596  ICE_MODEL=0;
597  std::cout << "Constant ice thickness and/or fixed elevation requested. Using Crust 2.0 ice model." << std::endl;
598  } //use the Crust 2.0 data if set to constant icethickness or ground elevation
599 
600  if (ICE_MODEL==0){
601  std::cout << "Using Crust 2.0 ice model." << std::endl;
602  }
603  else if (ICE_MODEL==1){
604  std::cout << "Using BEDMAP ice model." << std::endl;
605  }
606 
607  getSetting("Flat surface", FLATSURFACE);
608  if (FLATSURFACE==1){
609  std::cout << "Non-default setting: all surface segments are flat." << std::endl;
610  }
611 
612  getSetting("Medium", medium);
613 
614  getSetting("Enable surface roughness", ROUGHNESS);
615  getSetting("Surface roughness", ROUGHSIZE);
616  getSetting("Screen edge length [meters]", SCREENEDGELENGTH);
617 
618  getSetting("Screen step size [meters]", SCREENSTEPSIZE);
619 
620  getSetting("FIRN", FIRN);
621  if (FIRN==0){
622  std::cout << "Warning! Non-standard parameter setting. FIRN = " << FIRN << std::endl;
623  }
624  getSetting("Which attenuation length", MOOREBAY);
625 
626  getSetting("Source Option", SOURCE,true);
627  getSetting("Source Use Exponent", SOURCE_USE_EXPONENT,true);
628  getSetting("Source Max Energy", SOURCE_MAX_E,true);
629  getSetting("Source Min Energy", SOURCE_MIN_E,true);
630  getSetting("Which Sources", WHICH_SOURCES,true);
631  getSetting("Which Subtype", WHICH_SUBTYPE,true);
632  getSetting("Which Start Time", WHICH_START_TIME,true);
633  getSetting("Which End Time", WHICH_END_TIME,true);
634  getSetting("Source Skip When None", SOURCE_SKIP_WHEN_NONE, true);
635  getSetting("Fixed Horizon Offset",HORIZON_OFFSET,true);
636  if (SOURCE_SKIP_WHEN_NONE)
637  {
638  std::cout << "Non-default setting: settings->SOURCE_SKIP_WHEN_NONE= " << SOURCE_SKIP_WHEN_NONE << std::endl;
639  }
640 
641  getSetting("Save Truth Nu Tree",SAVE_TRUTH_NU_TREE,true);
642 
643  getSetting("Cross-section factor", SIGMA_FACTOR);
644  if (SIGMA_FACTOR!=1){
645  std::cout << "Non-default setting: settings->SIGMA_FACTOR= " << SIGMA_FACTOR << std::endl;
646  }
647  getSetting("Theta_th factor", THETA_TH_FACTOR);
648  if (THETA_TH_FACTOR!=1){
649  std::cout << "Non-default setting: THETA_TH_FACTOR= " << THETA_TH_FACTOR << std::endl;
650  }
651  getSetting("Chance in hell factor", CHANCEINHELL_FACTOR);
652  if (CHANCEINHELL_FACTOR!=1){
653  std::cout << "Non-default setting: CHANCEINHELL_FACTOR= " << CHANCEINHELL_FACTOR << std::endl;
654  }
655  getSetting("Skip neutrinos", SKIPCUTS);
656  if (SKIPCUTS==1){
657  std::cout << "Non-default setting: Skipping all cuts!" << std::endl;
658  }
659  getSetting("Restrict neutrino directions", USEDIRECTIONWEIGHTS);
660  getSetting("Restrict neutrino positions", USEPOSITIONWEIGHTS);
661  if (USEPOSITIONWEIGHTS==0){
662  std::cout << "Non-default setting: Not selecting events within the horizon." << std::endl;
663  }
664  getSetting("Weight on absorption", WEIGHTABSORPTION);
665  getSetting("Phi points banana", horizontal_banana_points);
666  getSetting("Theta points banana", vertical_banana_points);
667  getSetting("Signal across frequencies", FORSECKEL);
668  getSetting("Shower type", SHOWERTYPE);
669  getSetting("Loop over boresights", BORESIGHTS);
670  if (BORESIGHTS==0){
671  std::cout << "Warning! Non-standard parameter setting. BORESIGHTS = " << BORESIGHTS << std::endl;
672  }
673 
674 
675 
676 
677 
678 
679 
680  getSetting("Askaryan parameterization", askaryanParameterization);
681 
682  getSetting("Cross-section parameterization", SIGMAPARAM);
683  getSetting("Inelasticity parameterization", YPARAM);
684  getSetting("Secondary interactions", SECONDARIES);
685  if (SECONDARIES!=1){
686  std::cout << "Non-default setting: SECONDARIES= " << SECONDARIES << std::endl;
687  }
688  getSetting("Tau decay as secondary interaction", TAUDECAY);
689  if (TAUDECAY!=1){
690  std::cout << "Non-default setting: TAUDECAY= " << TAUDECAY << std::endl;
691  }
692  getSetting("Include atmosphere", ATMOSPHERE);
693  if (ATMOSPHERE!=1){
694  std::cout << "Non-default setting: ATMOSPHERE= " << ATMOSPHERE << std::endl;
695  }
696  getSetting("Constant crust density", CONSTANTCRUST);
697  if (CONSTANTCRUST==1){
698  std::cout << "Non-default setting: CONSTANTCRUST= " << CONSTANTCRUST << std::endl;
699  }
700  getSetting("Constant y", CONSTANTY);
701  getSetting("Max interaction distance", MAXHORIZON);
702  getSetting("Set tau modes", taumodes);
703 
704  getSetting("Which rays", WHICHRAYS);
705  if (WHICHRAYS!=1){
706  std::cout << "Non-default setting: WHICHRAYS= " << WHICHRAYS << std::endl;
707  }
708  getSetting("CreateHorizons file", WRITE_FILE);
709  if (WRITE_FILE){
710  std::cout<<"Writing CreateHorizons input file." << std::endl;
711  }
712  getSetting("Theta resolution", SIGMA_THETA);
713  if (SIGMA_THETA==1){
714  std::cout << "Non-default setting: SIGMA_THETA = 1" << std::endl;
715  }
716  SIGMA_THETA*=RADDEG; // immediately convert degrees to radians
717 
718  getSetting("Seavey Low Frequency",FREQ_LOW_SEAVEYS,true);
719  BW_SEAVEYS=FREQ_HIGH_SEAVEYS-FREQ_LOW_SEAVEYS;
720 
721  getSetting("Low frequency", FREQ_LOW);
722 
723  // if (FREQ_LOW_SEAVEYS>anita1->FREQ_LOW){
724  // FREQ_LOW_SEAVEYS=anita1->FREQ_LOW;
725  // }
726  getSetting("High frequency", FREQ_HIGH);
727  BW = FREQ_HIGH - FREQ_LOW; // total bandwidth of simulation
728 
729 
730 
731 
732 
733 
734  getSetting("SLAC run", SLAC);
735  // this rotates surface slope 10 degrees away from south pole
736  if (SLAC==1){
737  std::cout << "Warning! Non-standard parameter setting. SLAC = " << SLAC << std::endl;
738  }
739  if (SLAC) {
740  foutput << "!!!!SLAC setting causes some settings to be superseded:" << std::endl;
741  FIRN=0; // no firn
742  foutput << "FIRN=0" << std::endl;
743  SLOPEY=0; // slopeyness off
744  foutput << "SLOPEY=0" << std::endl;
745  BORESIGHTS=1; // loop over boresights
746  foutput << "BORESIGHTS=1" << std::endl;
747  BN_ALTITUDE=4.22/0.3; // balloon altitude in ft.!!
748  foutput << "BN_ALTITUDE=4.22/0.3" << std::endl;
749  RANDOMIZE_BN_ORIENTATION=0; // don't randomize the balloon orientation
750  foutput << "RANDOMIZE_BN_ORIENTATION=0" << std::endl;
751  SKIPCUTS=1; // don't make chance in hell cuts
752  foutput << "SKIPCUTS=1" << std::endl;
753  SLACSLOPE=5.8; // slope of the ice in degrees
754  foutput << "SLACSLOPE=5.8" << std::endl;
755  SLACICELENGTH=5.02; // length of the block of ice
756  foutput << "SLACICELENGTH=5.02" << std::endl;
757  }
758  getSetting("SLAC horizontal distance", SLAC_HORIZDIST);
759  getSetting("SLAC ice slope", SLACSLOPE);
760  getSetting("SLAC block length", SLACICELENGTH);
761  getSetting("SLAC interaction depth", SLAC_HORIZ_DEPTH);
762  SLAC_DEPTH=tan(SLACSLOPE*RADDEG)*(SLACICELENGTH-SLAC_HORIZ_DEPTH) // height from lowest point of ice
763  +21.375*CMINCH/100.; // height from beam to lowest point of ice
764 
765 
766 
767 
768 
769 
770 
771 
772  getSetting("Coherent power threshold", COHERENT_THRESHOLD );
773 
774 
775 
776  // default values are 0
777  APPLYIMPULSERESPONSEDIGITIZER=0;
778  APPLYIMPULSERESPONSETRIGGER=0;
779  USETIMEDEPENDENTTHRESHOLDS=0;
780  USEDEADTIME=0;
781  getSetting("Digitizer path impulse response", APPLYIMPULSERESPONSEDIGITIZER);
782  std::cout << "Apply impulse response to digitizer path: " << APPLYIMPULSERESPONSEDIGITIZER << std::endl;
783  getSetting("Trigger path impulse response", APPLYIMPULSERESPONSETRIGGER);
784  std::cout << "Apply impulse response to trigger path: " << APPLYIMPULSERESPONSETRIGGER << std::endl;
785 
786 #ifdef ANITA_UTIL_EXISTS
787  if ( (APPLYIMPULSERESPONSEDIGITIZER || APPLYIMPULSERESPONSETRIGGER) && WHICH!=8 && WHICH!=9 && WHICH!=10) {
788  std::cout << "Signal chain impulse response is only available for anita-2 and anita-3." << std::endl;
789  exit(1);
790  }
791 #endif
792 #ifndef ANITA_UTIL_EXISTS
793  if (APPLYIMPULSERESPONSEDIGITIZER || APPLYIMPULSERESPONSETRIGGER){
794  std::cout << "Signal chain impulse response can only be applied when the Anita tools are sourced." << std::endl;
795  exit(1);
796  }
797 #endif
798  getSetting("Time dependent thresholds", USETIMEDEPENDENTTHRESHOLDS);
799  std::cout << "Use time-dependent thresholds: " << USETIMEDEPENDENTTHRESHOLDS << std::endl;
800  getSetting("Dead time", USEDEADTIME);
801  std::cout << "Use dead time from flight: " << USEDEADTIME << std::endl;
802 
803  if ( (USETIMEDEPENDENTTHRESHOLDS || USEDEADTIME) && WHICH!=9 && WHICH!=10) {
804  std::cout << "Time-dependent thresholds are only available for anita-3." << std::endl;
805  exit(1);
806  }
807 
808 
809  getSetting("Digitizer noise from flight", NOISEFROMFLIGHTDIGITIZER);
810  std::cout << "Use noise from flight for digitizer path: " << NOISEFROMFLIGHTDIGITIZER << std::endl;
811 
812  getSetting("Trigger noise from flight", NOISEFROMFLIGHTTRIGGER);
813  std::cout << "Use noise from flight for trigger path: " << NOISEFROMFLIGHTTRIGGER << std::endl;
814 
815 #ifdef ANITA3_EVENTREADER
816  if ( (NOISEFROMFLIGHTDIGITIZER || NOISEFROMFLIGHTTRIGGER) && (WHICH!=9 && WHICH!=10)) {
817  std::cout << "Noise from flight only available for anita-3." << std::endl;
818  exit(1);
819  }
820  if (!APPLYIMPULSERESPONSETRIGGER && NOISEFROMFLIGHTTRIGGER ){
821  std::cout << "Noise from flight can only be applied to trigger path if impulse reponse is also used " << std::endl;
822  exit(1);
823  }
824 #endif
825 
826 #ifndef ANITA_UTIL_EXISTS
827  if (NOISEFROMFLIGHTDIGITIZER || NOISEFROMFLIGHTTRIGGER){
828  std::cout << "Noise from flight can only be applied when the Anita tools are sourced." << std::endl;
829  exit(1);
830  }
831 #endif
832 
833  getSetting("Min bias", MINBIAS);
834  if (MINBIAS){
835  std::cout << "Generate Minimum Bias sample: " << MINBIAS << std::endl;
836  }
837 
838 
839  getSetting("Efficiency scan", TRIGGEREFFSCAN );
840  if (TRIGGEREFFSCAN==1){
841  getSetting("Central phi-sector", trigEffScanPhi );
842  getSetting("Apply pulse at surf", TRIGGEREFFSCAPULSE );
843  getSetting("Off-axis attenuation", efficiencyScanOffAxisAttenuations );
844  getSetting("Rings used", efficiencyScanRingsUsed );
845  getSetting("Phi-sectors delays", efficiencyScanPhiSectorDelay );
846  getSetting("Ring delays", efficiencyScanRingDelay );
847  getSetting("Ring delays to phi", efficiencyScanApplyRingDelay );
848  }
849 
850  getSetting("Simulate TUFFs", TUFFSTATUS);
851  getSetting("Which TUFFs are on", whichTUFFsON);
852  if (TUFFSTATUS>0) cout << "TUFFs are simulated with status " << TUFFSTATUS << endl;
853 
854  getSetting("Add CW", ADDCW);
855  if(ADDCW) cout << "Adding CW " << endl;
856 
857  getSetting("Specific Payload Unix Time", PAYLOAD_USE_SPECIFIC_TIME);
858  getSetting("Specific Payload Delta Time", PAYLOAD_USE_SPECIFIC_TIME_DELTA);
859 
860  getSetting("Use Specific Interaction Location", SPECIFIC_NU_POSITION);
861  std::vector<double> specific_place;
862  getSetting("Specific Interaction Location", specific_place);
863  if (specific_place.size() == 3)
864  {
865  SPECIFIC_NU_POSITION_LATITUDE = specific_place[0];
866  SPECIFIC_NU_POSITION_LONGITUDE = specific_place[1];
867  SPECIFIC_NU_POSITION_ALTITUDE = specific_place[2];
868  }
869 
870  getSetting("Specific Interaction Location Maximum Distance", SPECIFIC_NU_POSITION_DISTANCE);
871 
872 
873  getSetting("Ignore Cross-Pol", IGNORE_CROSSPOL);
874  getSetting("Polarization Sign Hack", POL_SIGN_HACK);
875  getSetting("Minimum weight", CUTONWEIGHTS);
876  getSetting("Minimum probability weight", CUTONWEIGHTPROBS,1);
877  getSetting("Absolute declination cut", DEC_CUT);
878  getSetting("Draw all-sky map", ALL_SKY_MAP);
879 
880  //Custom sources
881  getSetting("Custom Name",CUSTOM_NAME);
882  getSetting("Custom RA",CUSTOM_RA);
883  getSetting("Custom Dec",CUSTOM_DEC);
884  getSetting("Custom Gamma",CUSTOM_GAMMA);
885 
886 } //method ReadInputs
887 
888 
889 
890 
891 
892 void Settings::ApplyInputs(Anita* anita1, Secondaries* sec1, Signal* sig1,
893  Balloon* bn1, Ray* ray1){
894 
895  //When you look at the Anita payload there are 4 layers, with 8,8,16 and 8 antennas each. But in the trigger, the top two become one layer of 16 antennas.
896  if (WHICH==2 || WHICH==6 || WHICH==8 || WHICH==9 || WHICH==10){
897  anita1->NTRIGGERLAYERS = NLAYERS - 1;
898  }
899  else{
900  anita1->NTRIGGERLAYERS=NLAYERS;
901  }
902 
903 
904  anita1->INCLINE_TOPTHREE=INCLINE_TOPTHREE;
905  anita1->INCLINE_NADIR=INCLINE_NADIR;
906 
907  bn1->WHICHPATH=WHICHPATH;
908 
909 
910  if(bn1->WHICHPATH==2){
911  anita1->LIVETIME=45.*24.*3600.*0.75; // 45 days for anita-lite
912  }
913  else if (bn1->WHICHPATH==0){
914  anita1->LIVETIME=6.02*24.*3600.; // anita-lite
915  } else if (bn1->WHICHPATH==6){
916  // kim's livetime for anita
917  anita1->LIVETIME=17.*24.*3600.; // for anita, take 34.78 days * 0.75 efficiency
918  }
919  else if (bn1->WHICHPATH==7){
920  anita1->LIVETIME=28.5*24*3600; // Anita-2 livetime taken from paper
921  }
922  else if (bn1->WHICHPATH==8){
923  anita1->LIVETIME=17.4*24*3600; // Anita-3 livetime taken from Ben Strutt's thesis (elog note 698)
924  } else {
925  anita1->LIVETIME=14.*24.*3600.; // otherwise use 2 weeks by default
926  }
927 
928  if (WHICH==7){
929  // EeVEX
930  anita1->LIVETIME=100.*24.*3600.; // ultra-long duration balloon flight of 100 days
931  }
932 
933  bn1->BN_LATITUDE = BN_LATITUDE;
934  bn1->BN_LONGITUDE = BN_LONGITUDE;
935  bn1->BN_ALTITUDE = BN_ALTITUDE;
936  bn1->RANDOMIZE_BN_ORIENTATION = RANDOMIZE_BN_ORIENTATION;
937  bn1->MAXHORIZON = MAXHORIZON;
938 
939  anita1->GAINS = GAINS;
940  anita1->BANDING = BANDING;
941  anita1->NBANDS = NBANDS;
942  anita1->PERCENTBW = PERCENTBW;
943  anita1->SIGMA_THETA = SIGMA_THETA;
944  anita1->FREQ_LOW = FREQ_LOW;
945  anita1->FREQ_HIGH = FREQ_HIGH;
946 
947  for (unsigned int i=0;i<tempThresholds.size();i++) {
948  anita1->bwslice_thresholds[i] = tempThresholds.at(i);
949  }
950 
951 
952  for (unsigned int i=0; i < bandLowEdgesMHz.size(); i++) {
953  anita1->bwslice_min[i] = 1e6*bandLowEdgesMHz.at(i);
954  anita1->bwslice_max[i] = 1e6*bandHighEdgesMHz.at(i);
955  anita1->bwslice_center[i] = 0.5*(anita1->bwslice_min[i] + anita1->bwslice_max[i]);
956  anita1->bwslice_width[i] = anita1->bwslice_max[i] - anita1->bwslice_min[i];
957  }
958 
959 for(unsigned int i=0; i < requiredBands.size(); i++){
960  anita1->bwslice_required[i] = requiredBands.at(i);
961  }
962 
963  for(unsigned int i=0; i < allowedBands.size(); i++){
964  anita1->bwslice_allowed[i] = allowedBands.at(i);
965  }
966 
967  anita1->maxthreshold=0.;
968  anita1->bwmin=1.E10;
969  if (anita1->BANDING!=1){
970  anita1->bwmin=200.E6;
971  }
972 
973  const int numBands = 5;
974  for (int i=0; i<numBands; i++) {
975  if (anita1->bwslice_thresholds[i]>anita1->maxthreshold && anita1->bwslice_allowed[i]==1){
976  anita1->maxthreshold = anita1->bwslice_thresholds[i];
977  }
978  if (anita1->BANDING==1) {
979  if ((anita1->bwslice_max[i] - anita1->bwslice_min[i]) < anita1->bwmin && anita1->bwslice_allowed[i] == 1){
980 
981  anita1->bwmin = anita1->bwslice_max[i] - anita1->bwslice_min[i];
982  }
983  }
984  }
985 
986 
987  anita1->NOTCH_MIN = 1e6*notchFilterLimitsMHz.at(0);
988  anita1->NOTCH_MAX = 1e6*notchFilterLimitsMHz.at(1);
989 
990  if (anita1->NOTCH_MIN>anita1->NOTCH_MAX) {
991  std::cout << "Min of notch filter is greater than max. Try again." << std::endl;
992  }
993  if (anita1->NOTCH_MIN!=0 || anita1->NOTCH_MAX!=0){
994  std::cout << "Applying a notch filter from " << anita1->NOTCH_MIN << " Hz to "
995  << anita1->NOTCH_MAX << " Hz" << std::endl;
996  }
997  anita1->trigRequirements[0] = trigRequirements[0];
998  anita1->trigRequirements[1] = trigRequirements[1];
999  anita1->trigRequirements[2] = trigRequirements[2];
1000  anita1->REQUIRE_CENTRE = REQUIRE_CENTRE;
1001  for(unsigned int i=0; i < channelRequirePol.size(); i++){
1002  anita1->pol_required[i] = channelRequirePol.at(i);
1003  }
1004  for(unsigned int i=0; i < channelAllowedPol.size(); i++){
1005  anita1->pol_allowed[i] = channelAllowedPol.at(i);
1006  }
1007 
1008 
1009 
1010  sig1->SetLPM(useLPM);
1011  if (sig1->GetLPM()!=1){
1012  std::cout << "Non-default setting: LPM= " << sig1->GetLPM() << std::endl;
1013  }
1014  sig1->SetParameterization(askaryanParameterization);
1015  sig1->SetJaime_Factor(jamieFactor);
1016  sig1->SetMedium(medium);
1017 
1018 
1019  sec1->SECONDARIES=SECONDARIES;
1020  sec1->TAUDECAY=TAUDECAY;
1021 
1022  anita1->trigEffScanPhi = trigEffScanPhi;
1023  for (unsigned int i=0; i < efficiencyScanOffAxisAttenuations.size(); i++){
1024  anita1->trigEffScanAtt[i] = efficiencyScanOffAxisAttenuations.at(i);
1025  }
1026 
1027  for (unsigned int i=0; i < efficiencyScanPhiSectorDelay.size(); i++){
1028  //convert ns to s
1029  anita1->trigEffScanPhiDelay[i] = efficiencyScanPhiSectorDelay.at(i)*1e-9;
1030  }
1031 
1032  for (unsigned int i=0; i < efficiencyScanRingDelay.size(); i++){
1033  //convert ns to s
1034  anita1->trigEffScanRingDelay[i] = efficiencyScanRingDelay.at(i)*1e-9;
1035  }
1036 
1037  for (unsigned int i=0; i < efficiencyScanApplyRingDelay.size(); i++){
1038  anita1->trigEffScanApplyRingDelay[i] = efficiencyScanApplyRingDelay.at(i);
1039  }
1040 
1041  for (unsigned int i=0; i < efficiencyScanRingsUsed.size(); i++){
1042  anita1->trigEffScanRingsUsed[i] = efficiencyScanRingsUsed.at(i);
1043  }
1044 
1045 
1046 
1047  if (TRIGGEREFFSCAN){
1048  std::cout << "Let's do a trigger efficiency scan!" << std::endl;
1049  std::cout << "Apply pulse at AMPA (0) or SURF (1) : " << TRIGGEREFFSCAPULSE << std::endl;
1050  std::cout << "Central phi sector is " << anita1->trigEffScanPhi << std::endl;
1051  std::cout << "Attenuations are ";
1052  for (int i=0;i<5;i++) std::cout << anita1->trigEffScanAtt[i] << " ";
1053  std::cout << std::endl;
1054  std::cout << "Phi sector delays are ";
1055  for (int i=0;i<5;i++) std::cout << anita1->trigEffScanPhiDelay[i] << " ";
1056  std::cout << std::endl;
1057  std::cout << "The rings used in this scan are ";
1058  for (int i=0;i<3;i++) std::cout << anita1->trigEffScanRingsUsed[i] << " ";
1059  std::cout << std::endl;
1060  std::cout << "Ring delays are applie to : ";
1061  for (int i=0;i<5;i++) std::cout << anita1->trigEffScanApplyRingDelay[i] << " ";
1062  std::cout << std::endl;
1063  std::cout << "Ring delays are for T-M, M-B, T-B : ";
1064  for (int i=0;i<3;i++) std::cout << anita1->trigEffScanRingDelay[i] << " ";
1065  std::cout << std::endl;
1066  }
1067 
1068 
1069 
1070  for (unsigned int i=0; i< whichTUFFsON.size(); i++){
1071  anita1->TUFFstatus[i] = whichTUFFsON.at(i);
1072  }
1073 
1074  if (TUFFSTATUS){
1075  std::cout << "The TUFFs are simulated for the whole flight with status " << TUFFSTATUS << " ! " << std::endl;
1076  if (TUFFSTATUS==3){
1077  std::cout << "Using Butterworth filters approximation " << std::endl;
1078  std::cout << "Notch 0 status " << anita1->TUFFstatus[0] << std::endl;
1079  std::cout << "Notch 1 status " << anita1->TUFFstatus[1] << std::endl;
1080  std::cout << "Notch 2 status " << anita1->TUFFstatus[2] << std::endl;
1081  }
1082  }
1083 
1084 
1085 }
1086 
1087 
1088 
1089 
1090 
1091 
1092 
1093 
1094 
1095 
1096 void Settings::complainAboutNotFindingKey(const TString& key){
1097  std::cerr << "Warning in " << ANSI_COLOR_BLUE << __FILE__ << ANSI_COLOR_RESET
1098  << ", unable to find setting " << ANSI_COLOR_RED << key << ANSI_COLOR_RESET << std::endl;
1099 }
1100 
1101 
1102 void Settings::getSetting(const char* key, int& value, bool nonag){
1103 
1104  kvpMap::iterator it = keyValuePairStrings.find(key);
1105  if(it == keyValuePairStrings.end()){
1106  if(!nonag) complainAboutNotFindingKey(key);
1107  }
1108  else{
1109  // found a match for the key
1110  value = atoi(it->second.Data());
1111  }
1112 }
1113 
1114 void Settings::getSetting(const char* key, float& value, bool nonag){
1115 
1116  kvpMap::iterator it = keyValuePairStrings.find(key);
1117  if(it == keyValuePairStrings.end()){
1118  complainAboutNotFindingKey(key);
1119  }
1120  else{
1121  // found a match for the key
1122  value = atof(it->second.Data());
1123  }
1124 }
1125 
1126 
1127 void Settings::getSetting(const char * key, std::string & value, bool nonag)
1128 {
1129  kvpMap::iterator it = keyValuePairStrings.find(key);
1130  if(it == keyValuePairStrings.end()){
1131  if (!nonag) complainAboutNotFindingKey(key);
1132  }
1133  else{
1134  // found a match for the key
1135  value = it->second.Data();
1136  }
1137 }
1138 
1139 
1140 void Settings::getSetting(const char* key, double& value, bool nonag){
1141 
1142  kvpMap::iterator it = keyValuePairStrings.find(key);
1143  if(it == keyValuePairStrings.end()){
1144  if (!nonag) complainAboutNotFindingKey(key);
1145  }
1146  else{
1147  // found a match for the key
1148  value = atof(it->second.Data());
1149  }
1150 }
1151 
1152 void Settings::getSetting(const char* key, std::vector<int>& valueArray, bool nonag){
1153 
1154  kvpMap::iterator it = keyValuePairStrings.find(key);
1155  if(it == keyValuePairStrings.end()){
1156  if (!nonag) complainAboutNotFindingKey(key);
1157  }
1158  else{
1159  // found a match for the key
1160  parseValueArray(it->second.Data(), valueArray);
1161  }
1162 }
1163 
1164 void Settings::getSetting(const char* key, std::vector<float>& valueArray, bool nonag){
1165 
1166  kvpMap::iterator it = keyValuePairStrings.find(key);
1167  if(it == keyValuePairStrings.end()){
1168  if (!nonag) complainAboutNotFindingKey(key);
1169  }
1170  else{
1171  // found a match for the key
1172  parseValueArray(it->second.Data(), valueArray);
1173  }
1174 }
1175 
1176 void Settings::getSetting(const char* key, std::vector<double>& valueArray, bool nonag){
1177 
1178  kvpMap::iterator it = keyValuePairStrings.find(key);
1179  if(it == keyValuePairStrings.end()){
1180  if (!nonag) complainAboutNotFindingKey(key);
1181  }
1182  else{
1183  // found a match for the key
1184  parseValueArray(it->second.Data(), valueArray);
1185  }
1186 }
1187 
1188 void Settings::parseValueArray(const char* valueString, std::vector<int>& values){
1189  TString theValueString(valueString);
1190 
1191  TObjArray* theValues = theValueString.Tokenize(",");
1192  for(int i=0; i < theValues->GetEntries(); ++i){
1193 
1194  TObjString* token = (TObjString*) theValues->At(i);
1195  int value = atoi(token->GetString().Data());
1196  values.push_back(value);
1197  }
1198 }
1199 
1200 void Settings::parseValueArray(const char* valueString, std::vector<float>& values){
1201  TString theValueString(valueString);
1202 
1203  TObjArray* theValues = theValueString.Tokenize(",");
1204  for(int i=0; i < theValues->GetEntries(); ++i){
1205 
1206  TObjString* token = (TObjString*) theValues->At(i);
1207  float value = atof(token->GetString().Data());
1208  values.push_back(value);
1209  }
1210 }
1211 
1212 void Settings::parseValueArray(const char* valueString, std::vector<double>& values){
1213  TString theValueString(valueString);
1214 
1215  TObjArray* theValues = theValueString.Tokenize(",");
1216  for(int i=0; i < theValues->GetEntries(); ++i){
1217 
1218  TObjString* token = (TObjString*) theValues->At(i);
1219  double value = atof(token->GetString().Data());
1220  values.push_back(value);
1221  }
1222 }
int WHICHPATH
0=fixed balloon position,1=randomized,2=ANITA-lite GPS data,3=banana plot
Definition: balloon.hh:57
double FREQ_LOW
lowest frequency
Definition: Settings.h:91
void printAllKeyValuePairStrings()
Definition: Settings.cc:212
double MAXHORIZON
pick the interaction within this distance from the balloon so that it is within the horizon ...
Definition: balloon.hh:78
Radiation from interaction.
Definition: signal.hh:13
double BN_LATITUDE
balloon latitude for fixed balloon location
Definition: balloon.hh:89
int PERCENTBW
percent bandwidth
Definition: anita.hh:124
Reads in and stores input settings for the run.
Definition: Settings.h:35
double BN_ALTITUDE
pick balloon altitude
Definition: balloon.hh:59
double BN_LONGITUDE
balloon longitude for fixed balloon location
Definition: balloon.hh:88
int CENTER
whether or not to center one phi sector of the payload on the incoming signal (for making signal effi...
Definition: Settings.h:105
Secondary interactions.
Definition: secondaries.hh:28
int NBANDS
number of frequency sub-bands (not counting full band)
Definition: anita.hh:122
int RANDOMIZE_BN_ORIENTATION
0=fixed balloon orientation,1=randomized
Definition: balloon.hh:58
void Initialize()
Definition: Settings.cc:226
Contains everything about positions within payload and signals it sees for each event, in both the trigger and signal paths.
Definition: anita.hh:32
~Settings()
Definition: Settings.cc:53
double FREQ_HIGH
highest frequency
Definition: anita.hh:313
double FREQ_LOW
lowest frequency
Definition: anita.hh:312
Settings()
Definition: Settings.cc:43
Handles everything related to balloon positions, payload orientation over the course of a flight...
Definition: balloon.hh:30
Ray tracing.
Definition: ray.hh:20
double NOTCH_MIN
low edge of notch filter. This is set in the input file
Definition: anita.hh:315