icemc
 All Classes Namespaces Files Functions Variables Friends Macros Pages
trigger.hh
Go to the documentation of this file.
1 #ifndef TRIGGER_HH_
2 #define TRIGGER_HH_
3 
5 //class Trigger:
7 
8 class RX;
9 class Anita;
10 using std::vector;
11 class Balloon;
12 class IceModel;
13 class Settings;
14 class TRandom3;
15 
18 
19 private:
20 
21 public:
22  GlobalTrigger(Settings *settings1,Anita *anita1,UShort_t phiTrigMask_bn); // constructor
23  void GetArrivalTimes(int inu,Anita *anita1, const Vector &rf_direction);
24 
25  // these are not really used now that we bin in frequency, but we keep them anyway.
26 
27  vector<int> flag_e_L1[Anita::NPHI_MAX];
28  vector<int> flag_h_L1[Anita::NPHI_MAX];
29 
30 
31  UShort_t phiTrigMask; // which phi sector is masked for Anita 2
32 
33  double volts[2][Anita::NLAYERS_MAX][Anita::NPHI_MAX]; // voltage (1st index=antenna,2nd index=pol., lcp=0. rcp=1)
34  double volts_em[2][Anita::NLAYERS_MAX][Anita::NPHI_MAX]; // component of voltage from em shower (1st index=antenna,2nd index=pol., lcp=0. rcp=1)
36  // e and h polarizations for each antenna summed across bandwidth
37 
38 
39  int nchannels_perrx_triggered[48]; //Records number of first level triggers on each antenna for a single neutrino
40 
41  int nchannels_perband_triggered[48][8]; //Records individual channel triggers for each antenna. (Either a 0 or a 1.) Channels 0-3 are lcp, 4-7 are rcp.
42 
43 
44 
45 
46 
47  // which channels on the payload pass.
48  // 1st component: layers on the payload
49  // 2nd component: counting around the payload in phi
50  // 3rd component: which polarization
51  // 4th component: slices of bandwidth
52  // int channels_passing[4][16][2][5]; // keeps track of which channels pass
53  int channels_passing[Anita::NLAYERS_MAX][Anita::NPHI_MAX][2][Anita::NBANDS_MAX]; // keeps track of which channels pass
54  // make this an array of vectors instead so that we can have an arbitrary number of bands for satellite
56  int triggerbits[Anita::NTRIG]; // keeps track of which trigger scenarios pass
57  // for the nadir studies
58 
59  // this is L2 and L3 triggers
60  int PassesTrigger(Settings *settings1,Anita *anita1,int discones_passing,int mode,int &l3trig,int *l2trig,int *l1trig,int antennaclump,int loctrig[Anita::NLAYERS_MAX][Anita::NPHI_MAX],int *loctrig_nadironly,int inu);
61  int PassesTrigger(Settings *settings1,Anita *anita1,int discones_passing,int mode,int &l3trig,int *l2trig,int *l1trig,int antennaclump,int loctrig[Anita::NLAYERS_MAX][Anita::NPHI_MAX],int *loctrig_nadironly,int inu,double this_threshold);
62  int L3Trigger(Settings *settings1,Anita *anita1,int loctrig[Anita::NLAYERS_MAX][Anita::NPHI_MAX],int *loctrig_nadironly,int discones_passing,int &l3trigy);
63 
64 
65  int GetPhiSector(Settings *settings1,int i,int j); // given trigger layer and index, get phi sector.
66  // for the upper two layers, the phi sector is just j
67  // for the nadir layer, the phi sector is 2*j+1
68  void GetAnitaLayerPhiSector(Settings *settings1,int i,int j,int &whichlayer,int &whichphisector);
69  void FillInNadir(Anita *anita1,int *ant);
70  void FillInNadir(Settings *settings1,Anita *anita1,int ant);
71 
72  // The following functions are related to the coherent-sum trigger
73  vector < vector < vector <double> > > volts_rx_rfcm_trigger; // This is used for easy access to the waveforms of specific phi sectors and layers, and it combines physical layers into their trigger layer.
74  // Accessed by volts_rx_rfcm_trigger[phi_sector][layer][timestep]
75  int first_phi_sector_hit; // This is used by the coherent waveform sum trigger scheme to make processing more efficient
76  double three_bit_round(double input, bool round_zero_up = true, bool allow_zero = false);
77  void convert_wfm_to_3_bit(const vector <double>& wfm, double rms, vector <double>& output);
78  void delay_align_antenna_waveforms(const vector< vector < vector <double> > >& waveforms, const vector < vector <unsigned int> >& delays, vector < vector <double> >& output);
79  void sum_aligned_waveforms(const vector < vector <double> >& waveforms, vector <double>& output);
80  void square_waveform_elements(const vector <double>& waveform, vector <double>& output);
81  double summed_power_window(const vector <double>& waveform, unsigned int start_index, unsigned int length);
82  // End of functions relating to coherent-sum trigger
83 };
85 class AntTrigger {
86 
87 private:
88 
89  TRandom3 Rand3;
90  const static int NSURF=9; // number of surfs
91  const static int NSURFPLUSONE=10; // for some reason the threshold array is 1 longer
92  const static int NSURFMINUSONE=8; // for some reason the threshold array is 1 longer
93  const static int NCHANNELS=32; // number of channels on each surf
94  const static int NPOINTS=4073; // max number of points from surf measurements
95 
96  static const unsigned NFOUR = 1024;
97  static const unsigned HALFNFOUR = 512;
98 
99  // these are from Ryan's threshold scans
100  int threshold[NSURFPLUSONE][NCHANNELS][NPOINTS];
101  int rate[NSURFMINUSONE][NCHANNELS][NPOINTS];
102 
103  int minadcthresh[NSURFMINUSONE][NCHANNELS];
104  int maxadcthresh[NSURFMINUSONE][NCHANNELS];
105 
106 
107  //int Getiangle(double viewangle);
108 
109  double ADCCountstoPowerThreshold(int threshadc,int isurf,int ichan);
110 
111  double thisrate;// set when getFunction is called for each channel. this is in MHz
112  double thispowerthresh;// set when getFunction is called for each channel
113 
114 public:
115 
116  AntTrigger(); // constructor
117  AntTrigger(Settings *settings1,int ilayer,int ifold,double *vmmhz,Anita *anita1,double hitangle_e,double hitangle_h,double e_component,double h_component,double *arrival_times,int rx_minarrivaltime_temp,double volts_rx_rfcm_lab_e_all[48][512],double volts_rx_rfcm_lab_h_all[48][512],int inu);
118  //AntTrigger(int ilayer,int ifold,double *vmmhz,Anita *anita1,double hitangle_e,double hitangle_h,double e_component,double h_component,double *arrival_times,int rx_minarrivaltime_temp);
119  static void ConvertEHtoLREfield(double,double,double&,double&);
120  static void ConvertEHtoLREnergy(double,double,double&,double&);
121  void ConvertHVtoLRTimedomain(const int nfour,double *vvolts,
122  double *hvolts,
123  double *left,double *right);
124  //int Passes(double strength,double angle,int trigger_band); // whether a particular channel passes or not
125  void L1Trigger(Anita *anita1,Settings *settings1,int ilayer, int ifold,double timedomain_output_1[5][Anita::NFOUR],double timedomain_output_2[5][Anita::NFOUR],double *powerthreshold,int *channels_passing_e_forglob,int *channels_passing_h_forglob,int &npass);
126 
127  vector<int> flag_e[5];
128  vector<int> flag_h[5];
129 
130  // inputs are: signal strength, angle off cone, and the trigger band
131  //void getFunctions(int thresh,int isurf,int ichan,double viewangle);
132  double getRate();
133  double rateToThreshold(double rate, int band); // converts a single channel rate to threshold in p/<p>
134  static double GetNoise(Settings *settings1,double altitude_bn,double geoid,double theta,double bw,double temp);
135  void WhichBandsPass(Settings *settings1, Anita *anita1, GlobalTrigger *globaltrig1, Balloon *bn1, int ilayer, int ifold,int inu, double dangle, double emfrac, double hadfrac);
136  static double FindPeak(double *waveform,int n); // find peak voltage of a waveform
137  void GetThresholds(Settings *settings1,Anita *anita1,int ilayer,double *thresholds); // get thresholds for this layer
138 
139  double bwslice_volts_pol0[5]; // sum voltage for each slice in bandwidth for the lcp polarization
140  double bwslice_volts_pol1[5]; // same, for rcp polarization
141 
142  double bwslice_energy_pol0[5]; // square the sum of voltage for each slice in bandwidth for the 0th polarization
143  double bwslice_energy_pol1[5]; // same, for 1st polarization
144 
145  double bwslice_volts_pol0_em[5]; // component of the voltage that comes from the em shower
146  double bwslice_volts_pol1_em[5]; // same, for 1st polarization
147 
149  double bwslice_energy_pole[5]; // square the sum of voltage for each slice in bandwidth. The 5th element is the full band
152 
153 
154 
155  double vm_banding_rfcm_e[5][Anita::NFREQ];// this is Volts/m as a function of frequency after rfcm's and banding
157 
158  double v_banding_rfcm_e[5][Anita::NFREQ];// this is Volts/m as a function of frequency after rfcm's and banding
160 
161 
162 
163  //static const double bwslice_center[4]; // center frequencies
164  //static const double bwslice_width[4]; // 3 dB bandwidths, without overlap
165 
166  // these are filled for triggerscheme==0 and triggerscheme==1
167  // frequency domain voltage and energy based
172 
173  vector<double> vsignal_eachband[2];
174  vector<double> vthreshold_eachband[2];
175  vector<double> vnoise_eachband[2];
176  vector<int> vpasses_eachband[2];
177 
178  // Used for AntTrigger::PrepareBandWaveforms(...) and AntTrigger::WhichBandsPass(...)
179  double v_banding_rfcm_e_forfft[5][HALFNFOUR]; // starts out as V/s vs. freq after banding, rfcm, after fft it is V vs. t
180  double v_banding_rfcm_h_forfft[5][HALFNFOUR];
181  double vm_banding_rfcm_1_forfft[5][HALFNFOUR];
182  double vm_banding_rfcm_2_forfft[5][HALFNFOUR];
183  double v_banding_rfcm_e_forfft_temp[5][HALFNFOUR];
184  double v_banding_rfcm_h_forfft_temp[5][HALFNFOUR];
185  // End of band waveform triggering arrays
186 
188 
189 
190  // this increments the bwslice_volts_...'s at each frequency
191  void addToChannelSums(Settings *settings1,Anita *anita1,int ibw,int k);
192 
193  static int IsItUnmasked(unsigned short surfTrigBandMask[9][2],int ibw,int ilayer, int ifold, int ipol);
194 
195  int unwarned; // whether we have warned the user about resetting thresholds when they are beyond the measured bounds
196 }; //class AntTrigger
197 
198 //namespace Bands {
199  // double bwslice_max[4]=; //maximum of each bandwidth slice
200  // for (int i=0;i<4;i++) {
201  // bwslice_min[i]=bwslice_center[i]-bwslice_width[i]/2; // get low edge of bandwidth slices
202  // bwslice_max[i]=bwslice_center[i]+bwslice_width[i]/2; // get upper edge of bandwidth slices
203  // } //for
204 //}
205 
206 
207 // This is just a place holder
208 //double power_thresholds[5]={3.,3.,3.,3.,3.};
209 
210 #endif
211