AnalysisConfig.cc
1 #include "AnalysisConfig.h"
2 #include "SystemResponse.h"
3 #include "TFile.h"
4 #include "TH2.h"
5 #include "AnitaVersion.h"
6 
7 static const char * peakfinders[] = {"Abby","Bicubic","Gaussian","QuadraticFit9","QuadraticFit16","QuadraticFit25", "Histogram" };
8 static const char * responses[] = {"None","SingleBRotter","IndividualBRotter","HarmSignalOnly", "TUFFs", "A4noNotches", "A4ImpulseTUFFs", "A4OldImpulseTUFFs"};
9 
10 
11 #ifdef ENABLE_LIBCONFIG
12 #include "libconfig.h++"
13 #define LOOKUP(X) cfg.lookupValue(#X,X)
14 
15 void lookupEnum(libconfig::Config * cfg, const char * key, int * val, int N, const char ** allowed)
16 {
17  if (!cfg->exists(key)) return;
18 
19  libconfig::Setting & set = cfg->lookup(key);
20 
21  for (int i = 0; i < N; i++)
22  {
23  if (!strcasecmp(set, allowed[i]))
24  {
25  *val = i;
26  return;
27  }
28  }
29 
30  fprintf(stderr,"Config Parse Error on line %d: %s must be one of: \n\t", set.getSourceLine(), key);
31 
32 
33  for (int i = 0; i < N; i++)
34  {
35  fprintf(stderr,"%s ", allowed[i]);
36  }
37 
38  fprintf(stderr, "\n But %s was given.", (const char * ) set);
39 
40 }
41 
42 
43 void UCorrelator::AnalysisConfig::loadFromFile(const char * config_file)
44 {
45 
46  libconfig::Config cfg;
47  cfg.setAutoConvert(true);
48  cfg.readFile(config_file);
49 
50 
51  LOOKUP(correlator_nphi);
52  LOOKUP(correlator_ntheta);
53  LOOKUP(correlator_theta_lowest);
54  LOOKUP(correlator_theta_highest);
55  LOOKUP(enable_group_delay);
56  LOOKUP(zoomed_nphi);
57  LOOKUP(zoomed_ntheta);
58  LOOKUP(zoomed_dphi);
59  LOOKUP(zoomed_dtheta);
60  LOOKUP(zoomed_nant);
61  LOOKUP(combine_nantennas);
62  LOOKUP(combine_npad);
63  LOOKUP(saturation_threshold);
65  LOOKUP(nmaxima);
66  LOOKUP(use_bin_center);
67  LOOKUP(bw_ndb);
68  LOOKUP(spectral_fit_start);
69  LOOKUP(spectral_fit_stop);
70  LOOKUP(noise_estimate_t0);
71  LOOKUP(noise_estimate_t1);
72  LOOKUP(response_npad);
73  LOOKUP(scale_by_cos_theta);
74  LOOKUP(use_offline_mask);
75  LOOKUP(max_mean_power_filtered);
76  LOOKUP(max_median_power_filtered);
77  LOOKUP(max_bottom_to_top_ratio);
78  LOOKUP(baseline_weight);
79  LOOKUP(max_peak_trigger_angle);
81  LOOKUP(fill_blast_fraction);
82  LOOKUP(fill_channel_info);
83  LOOKUP(compute_shape_parameters);
84  LOOKUP(trace_to_continent);
85  LOOKUP(max_theta_adjustment);
86  LOOKUP(set_bottom_first);
87  LOOKUP(delay_to_center);
88  LOOKUP(only_use_usable);
89  LOOKUP(use_antenna_level_snr);
90  LOOKUP(stokes_fracI);
91  LOOKUP(use_forced_trigger_rms);
92  LOOKUP(use_coherent_spectra);
93  LOOKUP(combine_t0);
94  LOOKUP(combine_t1);
96  LOOKUP(r_time_shift_correction);
97  LOOKUP(simulation_time_shift_correction);
98  LOOKUP(correlator_gain_correction);
99  const char * pols[] = {"horizontal", "vertical" };
100  lookupEnum(&cfg, "start_pol", (int*) &start_pol, 2,pols);
101  lookupEnum(&cfg, "end_pol", (int*) &end_pol, 2,pols);
102  lookupEnum(&cfg, "fine_peak_finding_option", (int*) &fine_peak_finding_option, sizeof(peakfinders)/sizeof(char *), peakfinders);
103  lookupEnum(&cfg, "response_option", (int*) &response_option, sizeof(responses)/sizeof(char *), responses);
104 
105 }
106 
107 #else
108 void UCorrelator::AnalysisConfig::loadFromFile(const char * config_file)
109 {
110 
111  fprintf(stderr, "Not compiled with support for reading config files. You need libconfig for that.\n");
112  (void) config_file;
113 }
114 #endif
115 
116 
117 const int wais_hpol_time_offset[5] = {0,0,0,93,11000};
118 const int wais_vpol_time_offset[5] = {0,0,0,-99757,1000};
119 const int siple_hpol_time_offset = -41;
120 const int siple_vpol_time_offset = +328;
121 
123  :
124  wais_hpol(wais_hpol_time_offset[AnitaVersion::get()], 800e3, 1e3),
125  wais_vpol(wais_vpol_time_offset[AnitaVersion::get()], 800e3, 1e3),
126  siple_hpol(siple_hpol_time_offset, 800e3, 1e3),
127  siple_vpol(siple_vpol_time_offset, 800e3, 1e3)
128 {
129  correlator_nphi = 180;
130  correlator_ntheta = 100;
134  enable_group_delay = true;
135  use_offline_mask = true;
136  zoomed_nphi = 40;
137  zoomed_ntheta = 40;
138  zoomed_dphi = 0.5;
139  zoomed_dtheta = 0.5;
140  zoomed_nant = 12;
141 
142 
143  combine_nantennas = 15;
144  combine_npad = 3;
145 
146  saturation_threshold = 1500;
147 
150 
152 
153  fine_peak_finding_option = FinePeakFindingQuadraticFit25;
154  nmaxima = 2;
155  use_bin_center = false;
156  scale_by_cos_theta = false;
159 
160  bw_ndb = 6; //let the bandwidth search stop immediately
161  spectral_fit_start = 0.22;
162  spectral_fit_stop =0.55;
163 
164  noise_estimate_t0 = 70;
165  noise_estimate_t1 = 100;
166 
167  response_option = ResponseNone;
168  response_string = 0;
169  response_npad = 50;
170 
171  max_mean_power_filtered = 1e6;
172  max_median_power_filtered = 1e6;
173  max_bottom_to_top_ratio = 5;
174  max_theta_adjustment = 3;
175 
176  baseline_weight = 0;
177 
178  if (config) loadFromFile(config);
179 
180  deconvolution_method = &AnitaResponse::kDefaultDeconvolution;
181 
182  the_ldb_hist = 0;
183 
184  ldb_max_run = 160;
185 
186  fill_blast_fraction = true;
187  fill_channel_info = true;
188  set_bottom_first = true;
189  stokes_fracI = 0.2;
190 
192  trace_to_continent = true;
193 
194  delay_to_center = true;
195  r_time_shift_correction = true;
196  simulation_time_shift_correction = false;
197  cross_correlate_hv = 0;
198 
199  use_forced_trigger_rms = true;
200 
201  only_use_usable = false;
203 
204  use_coherent_spectra = false;
205  combine_t0 = -25;
206  combine_t1 = 125;
208 
209 }
210 
211 static int nag = 0;
213 {
214  if (the_ldb_hist) return the_ldb_hist;
215 
216  TString fname;
217  fname.Form("%s/share/UCorrelator/ldbSelection.root", getenv("ANITA_UTIL_INSTALL_DIR"));
218  TFile f(fname);
219 
220  if (!f.IsOpen())
221  {
222  if (nag++ < 3)
223  fprintf(stderr,"WARNING: data/ldbSelection.root doesn't exist. This is probably because you haven't generated it.\n. If you don't care about LDB pulsers, ignore this. Otherwise, you can generate one using the makeLDBSelection.C macro.\n");
224 
225  the_ldb_hist = 0;
226  }
227  else
228  {
229  the_ldb_hist = (TH2*) f.Get("ldbHist")->Clone("LDBHistogram");
230  the_ldb_hist->SetDirectory(0);
231  }
232  return the_ldb_hist;
233 }
234 
235 
236 const char * UCorrelator::AnalysisConfig::getPeakFindingString(FinePeakFindingOption_t opt)
237 {
238  return peakfinders[opt];
239 }
240 
241 const char * UCorrelator::AnalysisConfig::getResponseString(ResponseOption_t opt)
242 {
243 
244  return opt == ResponseCustomString ? 0 : responses[opt];
245 }
246 
247 
248 UCorrelator::AnalysisConfig::~AnalysisConfig()
249 {
250  if (the_ldb_hist) delete the_ldb_hist;
251 }
252 
AnalysisConfig(const char *config_file=0)
double zoomed_dphi
number of theta bins in zoomed correlation map
double correlation_gain_correction
exponent for baseline weighting of correlation maps (since longer baselines give you better resolutio...
double noise_estimate_t1
this is used to pick parts of the waveform for calcuating the N in SNR
bool scale_by_cos_theta
this is used to pick parts of the waveform for calcuating the N in SNR
int zoomed_nant
size of theta bins in zoomed correlation map
double max_peak_trigger_angle
Minimum distance.
int zoomed_ntheta
number of phi bins in zoomed correlation map
int zoomed_nphi
enable group delay in interferometer
unsigned combine_nantennas
If non-zero, limit antennas considered in zoomed correlation map to nearest zoomed_nant antennas...
double baseline_weight
use offline phi masking / l1 triggers (default true)
AnitaResponse::DeconvolutionMethod * deconvolution_method
unsigned correlator_ntheta
Number of phi bins in rough correlation map.
double peak_isolation_requirement
End polarization for Analyer (kHORIZONTAL if you want just hpo. kVERTICAL if you want just vpol or bo...
double correlator_theta_lowest
Number of theta bins in rough correlation map.
double zoomed_dtheta
size of phi bins in zoomed correlation map
double bw_ndb
True to use bin center in interferometric map.
unsigned combine_npad
number of antennas used to create coherent / deconvolved waveforms
bool use_offline_mask
Scale peak values by cos theta when picking max (due to different bin sizes)
bool use_bin_center
number of maxima computed
int min_peak_distance_from_unmasked
Maximum distance from trigger angle to consider a peak (<=0 is any, default 0);.
bool enable_group_delay
Highest elevation considered, measured as positive above horizon. (negative would be below horizon) ...
Vertical Polarisation.
double saturation_threshold
supersampling factor for combining waveforms (i.e. how many times to pad in fourier domain...
void loadFromFile(const char *config_file)
double correlator_theta_highest
Lowest elevation considred, measured as positive below horizon. (negative would be above horizon) ...
AnitaPol::AnitaPol_t start_pol
threshold to consider a waveform saturated
Horizontal Polarisation.
double spectral_fit_start
the bandwidth of a waveform is defined as the portion of the power spectrum near the highest value ab...
AnitaPol::AnitaPol_t end_pol
Start polarization for Analyer (kHORIZONTAL if you want just hpol or both, kVERTICAL if you want just...