Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
detector.hh
Go to the documentation of this file.
1 //**********************************************************
2 // Wavelet Analysis Tool
3 // Sergey Klimenko, University of Florida
4 // universal data container for x-correlation analysis
5 // used with DMT and ROOT
6 //**********************************************************
7 
8 #ifndef DETECTOR_HH
9 #define DETECTOR_HH
10 
11 #include <iostream>
12 #include <vector>
13 #include "complex"
14 #include "wseries.hh"
15 #include "netcluster.hh"
16 #include "skymap.hh"
17 #include "wavecomplex.hh"
18 #include "skycoord.hh"
19 #include "TString.h"
20 #include "TNamed.h"
21 #include "sseries.hh"
22 
24 typedef std::vector<int> vector_int;
25 
26 struct delayFilter {
27  std::vector<short> index; // relative wavelet array index
28  std::vector<float> value; // amplitude
29 };
30 
32  char name[32];
33  double latitude;
34  double longitude;
35  double elevation;
36  double AltX; // elevation of the x arm
37  double AzX; // azimut of the x arm (angle-deg from nord)
38  double AltY; // elevation of the y arm
39  double AzY; // azimut of the y arm (angle-deg from nord)
40 };
41 
43  TENSOR = 0,
44  SCALAR = 1
45 };
46 
48 
49 class detector : public TNamed
50 {
51  public:
52 
53  // constructors
54 
55  //: Default constructor
56  detector();
57 
58  //: detector name constructor
59  detector(char*, double=0.);
60 
61  //: user defined detector constructor
62  detector(detectorParams, double=0.);
63 
64  //: Copy constructor
65  //!param: value - object to copy from
66  detector(const detector&); // use with caution
67 
68  //: destructor
69  virtual ~detector();
70 
71  // operators
72 
73  detector& operator= (const detector&); // use with caution
74  detector& operator= (const WSeries<double> &); // use with caution
75  detector& operator<< (detector&); // copy 'from' inj/rec stuff
76  detector& operator>> (detector&); // copy 'to' inj/rec stuff
77 
78  // accessors
79 
80  //: return antenna pattern
81  //!param: source theta,phi, polarization angle psi in degrees
82  wavecomplex antenna(double, double, double=0.);
83 
84  // returns the detector parameters
86 
87  //: return detector delay
88  // time delay convention: t_detector-tau - arrival time at the center of Earth
89  //!param: source theta,phi angles in degrees
90  double getTau(double, double);
91 
92  //: set detector radius vector
93  //!param: Rx,Ry,Rz in ECEF frame
94 // void setRV(double, double, double);
95  //: set detector x-arm unit vector
96  //!param: Ex,Ey,Ez in ECEF frame
97 // void setEx(double, double, double);
98  //: set detector y-arm unit vector
99  //!param: Ex,Ey,Ez in ECEF frame
100 // void setEy(double, double, double);
101 
102  //: initialize detector tensor
103  //!param: no parameters
104  void init();
105 
106  //: initialize delay filter for non-heterodine wavelet
107  //!param: filter length
108  //!param: filter phase delay in degrees
109  //!param: number of up-sample layers
110  //!return filter size
111  size_t setFilter(size_t, double=0., size_t=0);
112 
113  //: initialize delay filter from another detector
114  //!param: detector
115  //!return filter size
116  size_t setFilter(detector&);
117 
118  //: write/read delay filter to file in the format:
119  //: first string: wavelet filter length, number of wavelet layers
120  //!param: file name
121  void writeFilter(const char*);
122  void readFilter(const char*);
123 
124  // clear filter and release memory (need for vector class)
125  inline void clearFilter() {
126  filter.clear();
127  std::vector<delayFilter>().swap(filter); // release memory
128  }
129 
130  //: apply sample delay to timeseries stored in TFmap to adjast
131  // timing for a given theta and phy sky location.
132  //!param: theta
133  //!param: phi
134  void delay(double, double);
135 
136  //: apply sample delay to input timeseries to adjast
137  // timing for a given theta and phy sky location. Do not store in the TFmap
138  //!param: input TS
139  //!param: theta
140  //!param: phi
141  void delay(wavearray<double> &, double, double);
142 
143  //: apply delay T to input timeseries.
144  //!param: input TS
145  //!param: time delay T
146  void delay(wavearray<double> &, double);
147 
148  //: apply non-heterodine delay filter to input WSeries and put result in TFmap
149  // time delay convention: + - shift TS right
150  // - - shift TS left
151  //!param: time delay in seconds
152  //!param: WSeries which should be delayed
153  void delay(double, WSeries<double> &);
154 
155  //: get pointer to time series data
156  //!param: no parameters
157  inline wavearray<double>* getHoT() { return &HoT; }
158 
159  //: get pointer to TF data
160  //!param: no parameters
161  inline WSeries<double>* getTFmap() { return &TFmap; }
162 
163  //: get sparse map index in vSS vector for input resolution (wavelet rate r)
164  inline int getSTFind(double r) {
165  for(size_t i=0; i<vSS.size(); i++) if(int(vSS[i].wrate()-r)==0) return i;
166  return vSS.size()+1;
167  }
168  //: get pointer to sparse TF data for input index n
169  inline SSeries<double>* getSTFmap(size_t n) { return n<vSS.size() ? &vSS[n] : NULL; }
170 
171  // operations with sparse maps
172  inline size_t ssize() { return vSS.size(); } // get size of sparse TF vector (number of resolutions)
173  inline void sclear() { vSS.clear(); } // clear
174  inline void addSTFmap(netcluster* pwc, double mTau=0.042);
175 
176  //: get size of sparse TF vector (number of resolutions)
177  //!param: no parameters
178 
179  //: reconstruct wavelet series for a cluster, put it in waveForm
180  //! param: input parameter is the cluster ID in the netcluster structure
181  //! param: input netcluster structure
182  //! param: amplitude type
183  //! param: amplitude index
184  //! return: cluster average noise rms
185  double getwave(int, netcluster&, char, size_t);
186 
187  //: set tau array
188  // time delay convention: t_detector-tau - arrival time at the center of Earth
189  //!param - step on phi and theta
190  //!param - theta begin
191  //!param - theta end
192  //!param - phi begin
193  //!param - phi end
194  void setTau(double,double=0.,double=180.,double=0.,double=360.);
195 
196  //: set tau array
197  // time delay convention: t_detector-tau - arrival time at the center of Earth
198  //!param - healpix order
199  void setTau(int);
200 
201  //: set antenna patterns
202  //!param - step on phi and theta
203  //!param - theta begin
204  //!param - theta end
205  //!param - phi begin
206  //!param - phi end
207  void setFpFx(double,double=0.,double=180.,double=0.,double=360.);
208 
209  //: set antenna patterns
210  //!param - healpix order
211  void setFpFx(int);
212 
213  //: return noise variance for selected wavelet layer or pixel
214  //: used in coherence() and Rank() functions
215  //!param: wavelet layer index (frequency)
216  //!param: wavelet time index
217  //!if param 2 is specified - return noise rms for specified pixel location
218  //!if param 2 is not specified - return rms averaged over the layer
219  double getNoise(size_t,int=-1);
220 
221  /* calculate and save average noise rms for each pixel in netcluster wc
222  * @memo save pixel noise rms
223  * @param input netcluster
224  * @param detector index in tne netcluster
225  */
226  bool setrms(netcluster*, size_t=0);
227 
228  //: return pointer to noise array
229 // WSeries<double>* getNoise();
230 
231  //: whiten data in TFmap and save noise RMS in nRMS
232  // param 1 - time window dT. if = 0 - dT=T, where T is wavearray duration
233  // param 2 - 0 - no whitening, 1 - single whitening, >1 - double whitening
234  // param 3 - boundary offset
235  // param 4 - noise sampling interval (window stride)
236  // the number of measurements is k=int((T-2*offset)/stride)
237  // if stride=0, then stride is set to dT
238  // output: save array of noise RMS in nRMS
239  //!what it does: see algorithm description in wseries.hh
240  void white(double dT=0, int wtype=1,double offset=0.,double stride=0.) {
241  nRMS = TFmap.white(dT, wtype, offset, stride); return;
242  }
243 
244  // set constant time shift
245  inline void shift(double s) {
246  int I = TFmap.maxLayer()+1;
247  double R = TFmap.wavearray<double>::rate();
248  if(TFmap.size()<2 || R<=0.) this->sHIFt = s;
249  else this->sHIFt = int(s*R/I+0.1)*I/R;
250  }
251  // get constant time shift
252  inline double shift() { return this->sHIFt; }
253 
254  // rotate arms in the detector plane by angle a in degrees
255  void rotate(double);
256 
257  // apply band pass filter with cut-offs specified by parameters
258  // f1>=0 && f2>=0 : band pass
259  // f1<0 && f2<0 : band cut
260  // f1<0 && f2>=0 : low pass
261  // f1>=0 && f2<0 : high pass
262  // f1==0 : f1 = TFmap.getlow()
263  // f2==0 : f2 = TFmap.gethigh()
264  void bandPass1G(double f1=0.,double f2=0.); // used by 1G
265  void bandPass(double f1,double f2, double a=0.){
266  this->TFmap.bandpass(f1,f2,a);
267  };
268  void bandCut(double f1,double f2) {bandPass(-fabs(f1),-fabs(f2));}
269  void lowPass(double f1) {bandPass(-fabs(f1),0);}
270  void highPass(double f2) {bandPass(0,-fabs(f2));}
271 
272  // calculate hrss of injected responses
273  // param 1 - injection wavelet series
274  // param 2 - array with injection time
275  // param 3 - integration window in seconds
276  // param 4 - save input waveform
277  size_t setsim(WSeries<double> &, std::vector<double>*, double=5., double=8., bool saveWF=false);
278 
279  // modify input signals (wi) at times pT according the factor pF
280  size_t setsnr(wavearray<double> &, std::vector<double>*, std::vector<double>*, double=5., double=8.);
281 
282  // print detector parameters
283  void print(); // *MENU*
284  virtual void Browse(TBrowser *b) {print();}
285 
286  bool isBuiltin() {return TString(dP.name).Sizeof()>1 ? false : true;}
287 
290 
291  inline double get_SS(){double rms=waveForm.rms(); return rms*rms*waveForm.size();}
292  inline double get_XX(){double rms=waveBand.rms(); return rms*rms*waveBand.size();}
293  inline double get_NN(){double rms=waveNull.rms(); return rms*rms*waveNull.size();}
294  inline double get_XS(){double rmx=waveBand.rms(); double rms=waveForm.rms(); return rmx*rms*waveBand.size();}
295  double getWFfreq(char atype='S');
296  double getWFtime(char atype='S');
297 
298  int wfsave() {return this->wfSAVE;}
299  void wfsave(int wfSAVE) {this->wfSAVE = (wfSAVE>=0)&&(wfSAVE<=3) ? wfSAVE : 0;}
300  // 0 : save detector definitions
301  // 1 : save injected waveforms
302  // 2 : save reconstructed waveforms
303  // 3 : save injected & reconstructed waveforms
304 
305 // data members
306 
307 //: position in ECEF frame
308 
309  char Name[16]; // detector name
310  size_t ifoID; // detector ID in the network - set up by network method
311  detectorParams dP; // user detector parameters
312  double Rv[3]; // radius vector to beam splitter
313  double Ex[3]; // vector along x-arm
314  double Ey[3]; // vector along y-arm
315  double DT[9]; // detector tenzor
316  double ED[5]; // network energy disbalance
317  double sHIFt; // time shifts for background analysis
318  double null; // unbiased null stream
319  double enrg; // total energy of PC components
320  double sSNR; // reconstructed response s-SNR
321  double xSNR; // reconstructed response x-SNR
322  double ekXk; // mean of reconstructed detector response
323  double rate; // original data rate (before downsampling)
324  size_t nDFS; // number of Delay Filter Samples
325  size_t nDFL; // number of Delay Filter Layers
326  int wfSAVE; // used in streamer method to save waveforms stuff
327 
328  skymap tau; // detector delay with respect to ECEF
329  skymap mFp; // F+ skymap
330  skymap mFx; // Fx skymap
331 
332  wavearray<double> HoT; // detector time series
333 
334  std::vector<SSeries<double> > vSS; // sparse TFmap
335 
336  WSeries<double> TFmap; // wavelet data
337  WSeries<double> waveForm; // buffer for a waveform
338  WSeries<double> waveBand; // buffer for a bandlimited waveform
339  WSeries<double> waveNull; // buffer for noise = data - signal
340  WSeries<double> nRMS; // noise RMS
341  WSeries<float> nVAR; // noise variability
342 
343  std::vector<delayFilter> filter; // delay filter
344 
345  wavearray<double> fp; // sorted F+ pattern
346  wavearray<double> fx; // sorted Fx pattern
347  wavearray<double> ffp; // sorted F+ * F+ + Fx * Fx
348  wavearray<double> ffm; // sorted F+ * F+ - Fx * Fx
349  wavearray<double> fpx; // sorted F+ * Fx * 2
350  wavearray<short> index; // index array for delayed amplitude (network)
351  wavearray<double> lagShift; // time shifts for background analysis
352 
353  wavearray<double> HRSS; // hrss of injected signals
354  wavearray<double> ISNR; // injected SNR
355  wavearray<double> FREQ; // frequency of injected signals
356  wavearray<double> BAND; // bandwith of injected signals
357  wavearray<double> TIME; // central time of injected signals
358  wavearray<double> TDUR; // duration of injected signals
359 
360  std::vector<int> IWFID; // injected waveforms ID
361  std::vector<wavearray<double>*> IWFP; // injected waveforms pointers
362 
363  std::vector<int> RWFID; // reconstructed waveforms ID
364  std::vector<wavearray<double>*> RWFP; // reconstructed waveforms pointers
365 
366  POLARIZATION polarization; // gw polarization states : TENSOR (fp,fx) SCALAR (fo)
367 
368  ClassDef(detector,4)
369 
370 }; // class detector
371 
372 
373 inline void detector::addSTFmap(netcluster* pwc, double mTau){
374  SSeries<double> SS; vSS.push_back(SS);
375  int j = vSS.size()-1;
376  vSS[j].SetMap(&TFmap);
377  vSS[j].SetHalo(mTau);
378  vSS[j].AddCore(ifoID,pwc);
379  vSS[j].UpdateSparseTable();
380 }
381 
382 inline size_t minDFindex(delayFilter &F){
383  size_t n = F.value.size();
384  if(!n) return 0;
385  size_t j = 0;
386  double x = 1.e13;
387  for(size_t i=0; i<n; i++){
388  if(x>fabs(F.value[i])) { x = fabs(F.value[i]); j=i; }
389  }
390  return j+1;
391 }
392 
393 #endif // DETECTOR_HH
394 
detectorParams dP
Definition: detector.hh:311
void writeFilter(const char *)
param: file name
Definition: detector.cc:930
double sHIFt
Definition: detector.hh:317
detectorParams getDetectorParams()
Definition: detector.cc:201
virtual size_t size() const
Definition: wavearray.hh:127
int wfSAVE
Definition: detector.hh:326
double getWFfreq(char atype='S')
Definition: detector.cc:1750
void white(double dT=0, int wtype=1, double offset=0., double stride=0.)
what it does: see algorithm description in wseries.hh
Definition: detector.hh:240
void highPass(double f2)
Definition: detector.hh:270
void setFpFx(double, double=0., double=180., double=0., double=360.)
param - step on phi and theta param - theta begin param - theta end param - phi begin param - phi end...
Definition: detector.cc:692
wavearray< double > HoT
Definition: detector.hh:332
size_t setsnr(wavearray< double > &, std::vector< double > *, std::vector< double > *, double=5., double=8.)
Definition: detector.cc:1641
int offset
Definition: TestSTFT_2.C:19
double sSNR
Definition: detector.hh:320
char name[32]
Definition: detector.hh:32
wavearray< double > a(hp.size())
double Ey[3]
Definition: detector.hh:314
double AzX
Definition: detector.hh:37
double getWFtime(char atype='S')
Definition: detector.cc:1735
int n
Definition: cwb_net.C:10
void wfsave(int wfSAVE)
Definition: detector.hh:299
void shift(double s)
Definition: detector.hh:245
TString("c")
wavearray< double > fx
Definition: detector.hh:346
WSeries< double > WSeriesD
Definition: detector.hh:47
void bandpass(wavearray< DataType_t > &ts, double flow, double fhigh, int n=-1)
Definition: wseries.cc:295
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
std::vector< delayFilter > filter
Definition: detector.hh:343
std::vector< wavearray< double > * > RWFP
Definition: detector.hh:364
wavearray< double > HRSS
Definition: detector.hh:353
size_t nDFS
Definition: detector.hh:324
netcluster * pwc
Definition: cwb_job_obj.C:20
void lowPass(double f1)
Definition: detector.hh:269
double get_SS()
Definition: detector.hh:291
wavearray< short > index
Definition: detector.hh:350
size_t setFilter(size_t, double=0., size_t=0)
param: filter length param: filter phase delay in degrees param: number of up-sample layers return fi...
Definition: detector.cc:742
double AltX
Definition: detector.hh:36
double AzY
Definition: detector.hh:39
void setPolarization(POLARIZATION polarization=TENSOR)
Definition: detector.hh:288
WSeries< double > waveBand
Definition: detector.hh:338
bool setrms(netcluster *, size_t=0)
Definition: detector.cc:1208
std::vector< int > vector_int
Definition: detector.hh:24
int j
Definition: cwb_net.C:10
size_t minDFindex(delayFilter &F)
Definition: detector.hh:382
double rate
Definition: detector.hh:323
void delay(double, double)
param: theta param: phi
Definition: detector.cc:1682
i drho i
double longitude
Definition: detector.hh:34
skymap tau
Definition: detector.hh:328
double get_XX()
Definition: detector.hh:292
void init()
param: Rx,Ry,Rz in ECEF frame
Definition: detector.cc:451
size_t ssize()
Definition: detector.hh:172
double DT[9]
Definition: detector.hh:315
double getNoise(size_t, int=-1)
param: wavelet layer index (frequency) param: wavelet time index if param 2 is specified - return noi...
Definition: detector.cc:1112
skymap mFx
Definition: detector.hh:330
virtual double rms()
Definition: wavearray.cc:1188
wavearray< double > ffp
Definition: detector.hh:347
POLARIZATION getPolarization()
Definition: detector.hh:289
void readFilter(const char *)
Definition: detector.cc:969
wavecomplex antenna(double, double, double=0.)
param: source theta,phi, polarization angle psi in degrees
Definition: detector.cc:473
void clearFilter()
Definition: detector.hh:125
detector & operator=(const detector &)
Definition: detector.cc:351
void bandPass1G(double f1=0., double f2=0.)
Definition: detector.cc:1281
double ED[5]
Definition: detector.hh:316
WSeries< double > nRMS
Definition: detector.hh:340
wavearray< double > TIME
Definition: detector.hh:357
i() int(T_cor *100))
wavearray< double > * getHoT()
param: no parameters
Definition: detector.hh:157
TF1 * f2
Definition: cbc_plots.C:1710
wavearray< double > fpx
Definition: detector.hh:349
wavearray< double > fp
Definition: detector.hh:345
double get_XS()
Definition: detector.hh:294
double elevation
Definition: detector.hh:35
POLARIZATION polarization
Definition: detector.hh:366
std::vector< int > RWFID
Definition: detector.hh:363
detector & operator>>(detector &)
Definition: detector.cc:421
std::vector< wavearray< double > * > IWFP
Definition: detector.hh:361
detector()
Definition: detector.cc:90
double F
Definition: skymap.hh:45
double latitude
Definition: detector.hh:33
wavearray< double > lagShift
Definition: detector.hh:351
void bandPass(double f1, double f2, double a=0.)
Definition: detector.hh:265
wavearray< double > TDUR
Definition: detector.hh:358
std::vector< int > IWFID
Definition: detector.hh:360
wavearray< double > BAND
Definition: detector.hh:356
double Ex[3]
Definition: detector.hh:313
regression r
Definition: Regression_H1.C:44
double Rv[3]
Definition: detector.hh:312
double ekXk
Definition: detector.hh:322
s s
Definition: cwb_net.C:137
wavearray< double > ffm
Definition: detector.hh:348
WSeries< double > TFmap
Definition: detector.hh:336
void sclear()
Definition: detector.hh:173
virtual void Browse(TBrowser *b)
Definition: detector.hh:284
WSeries< double > waveForm
Definition: detector.hh:337
double AltY
Definition: detector.hh:38
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:161
double xSNR
Definition: detector.hh:321
char Name[16]
Definition: detector.hh:309
skymap mFp
Definition: detector.hh:329
double fabs(const Complex &x)
Definition: numpy.cc:37
void rotate(double)
Definition: detector.cc:274
virtual ~detector()
Definition: detector.cc:326
wavecomplex d_complex
Definition: detector.hh:23
double mTau
double get_NN()
Definition: detector.hh:293
void print()
Definition: detector.cc:1768
std::vector< short > index
Definition: detector.hh:27
double getTau(double, double)
param: source theta,phi angles in degrees
Definition: detector.cc:681
double getwave(int, netcluster &, char, size_t)
param: no parameters
Definition: detector.cc:544
double null
Definition: detector.hh:318
wavearray< double > FREQ
Definition: detector.hh:355
double dT
Definition: testWDM_5.C:12
SSeries< double > * getSTFmap(size_t n)
Definition: detector.hh:169
POLARIZATION
Definition: detector.hh:42
std::vector< SSeries< double > > vSS
Definition: detector.hh:334
WSeries< double > waveNull
Definition: detector.hh:339
WSeries< float > nVAR
Definition: detector.hh:341
std::vector< float > value
Definition: detector.hh:28
double shift()
Definition: detector.hh:252
size_t ifoID
Definition: detector.hh:310
int getSTFind(double r)
Definition: detector.hh:164
size_t setsim(WSeries< double > &, std::vector< double > *, double=5., double=8., bool saveWF=false)
Definition: detector.cc:1348
wavearray< double > ISNR
Definition: detector.hh:354
size_t nDFL
Definition: detector.hh:325
int maxLayer()
Definition: wseries.hh:121
detector & operator<<(detector &)
Definition: detector.cc:394
void setTau(double, double=0., double=180., double=0., double=360.)
param - step on phi and theta param - theta begin param - theta end param - phi begin param - phi end...
Definition: detector.cc:637
int wfsave()
Definition: detector.hh:298
void bandCut(double f1, double f2)
Definition: detector.hh:268
virtual WSeries< double > white(double, int, double=0., double=0.)
what it does: each wavelet layer is devided into k intervals.
Definition: wseries.cc:1128
double enrg
Definition: detector.hh:319
bool isBuiltin()
Definition: detector.hh:286
void addSTFmap(netcluster *pwc, double mTau=0.042)
Definition: detector.hh:373