Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cluster.hh
Go to the documentation of this file.
1 // Wavelet Analysis Tool
2 // Sergey Klimenko, University of Florida
3 // universal data container for cluster analysis
4 // used with DMT and ROOT
5 //
6 
7 #ifndef WAVECLUSTER_HH
8 #define WAVECLUSTER_HH
9 
10 #include <iostream>
11 #include "wavearray.hh"
12 #include <vector>
13 #include <list>
14 #include "WaveDWT.hh"
15 #include "wseries.hh"
16 
17 typedef std::vector<int> vector_int;
18 
19 
20 class wavepixel {
21  public:
22  // need all this crap to use stl::vector<wavepixel> class
24  time = 0;
25  frequency = 0;
26  rate = 1.;
27  clusterID = 0;
28  variability = 1.;
29  noiserms = 1.;
30  index = 0;
31  neighbors.clear();
32  amplitude.clear();
33  }
34  virtual ~wavepixel(){}
35  bool operator == (const wavepixel &) const {return true;}
36  bool operator < (const wavepixel &) const {return true;}
37 
38  size_t clusterID; // cluster ID
39  size_t time; // time index
40  size_t frequency; // frequency index (layer)
41  size_t index; // position in list
42  float rate; // wavelet layer rate
43  float variability; // average noise variability
44  double noiserms; // average noise rms
45  bool core; // pixel type: true - core , false - halo
46  std::vector<int> neighbors; // vector of links to neighbors
47  std::vector<double> amplitude; // vector of pixel's amplitudes
48 };
49 
50 
52 {
53  public:
54 
55  // constructors
56 
57  //: Default constructor
58  wavecluster();
59 
60  //: initialize from binary WSeries<double>
61  //!param: input WSeries
62  //!param: true if halo, false if no halo included
63  wavecluster(WSeries<double>&, bool=false);
64 
65  //: Copy constructor
66  //!param: value - object to copy from
67  wavecluster(const wavecluster&);
68 
69  //: destructor
70  virtual ~wavecluster();
71 
72  // operators
73 
75 
76  // accessors
77 
78  //: initialize wavecluster class from binary WSeries<double>;
79  //!param: false - core only, true - core + halo
80  //!return cluster list size
81  virtual size_t init(WSeries<double>&, bool=false);
82 
83  //: initialize wavecluster class from binary WSeries<double>;
84  //!param: max number of pixels in clusters to be cleaned (<4);
85  //!param: false - core only, true - core + halo
86  //!return pixel occupancy
87  virtual double setMask(WSeries<double>&, int=1, bool=false);
88 
89  //: Get the pixel list size
90  inline size_t size() { return pList.size(); }
91 
92  //: set black pixel probability
93  inline void setbpp(double P) { bpp = P; return; }
94  //: get black pixel probability
95  inline double getbpp() { return bpp; }
96 
97  //: set low frequency for variability correction
98  inline void setlow(double f) { low = f; return; }
99  //: get low frequency
100  inline double getlow() { return low; }
101 
102  //: set high frequency for variability correction
103  inline void sethigh(double f) { high = f; return; }
104  //: get low frequency
105  inline double gethigh() { return high; }
106 
107  //: set noise array
108  inline void set(WSeries<double> &n) { nRMS = n; return; }
109  //: set variability array
110  inline void set(wavearray<float> &v) { nVAR = v; return; }
111 
112  /* set noise rms in amplitude array
113  * @memo save pixel noise rms
114  * @param rms array (WSeries<double>)
115  * @param low frequency for lowpass filter correction
116  * @param not used
117  */
118  void setrms(WSeries<double> &, double=-1., double=-1.);
119 
120  /* set noise variabilty in amplitude array
121  * @memo save pixel noise variabilty
122  * @param variability array (wavearray<float>)
123  * @param low frequency for variability correction
124  * @param high frequency for variability correction
125  */
126  void setvar(wavearray<float> &, double=-1., double=-1.);
127 
128  //: Get the the minimum size of the pixel's amplitude vector in the list
129  // return - (minimum_size) if the vector size is different
130  // for different pixels
131  inline int asize();
132 
133  //: set selection cuts vector used in mask(), occupancy(), getCluster()
134  //!param: cluster ID number
135  //!return void
136  inline void ignore(size_t i=0) {
137  if(i>0 && i<=sCuts.size()) sCuts[i-1] = true;
138  else if(i==0) { for(i=0; i<sCuts.size(); i++) sCuts[i] = false; }
139  }
140 
141  //: remove halo pixels from pixel list
142  //!param: if true - de-cluster pixels
143  //!return size of the list
144  virtual size_t cleanhalo(bool=false);
145 
146  //: push amplitudes from input WSeries to this pList.amplitude vector
147  //!param: this and WSeries objects should have the same tree type
148  //! and the approximation level size
149  //!param: start time offset: start-a.start, illegal if negative
150  //!return size of amplitude vector
151  virtual size_t apush(WSeries<double> &a, double=0.);
152 
153  //: append input cluster list
154  //!param: input cluster list
155  //!return size of appended list
156  virtual size_t append(wavecluster &);
157 
158  //: merge clusters in the list
159  //!param: non
160  //!return size of merged list
161  virtual size_t merge(double=0.);
162 
163  //: time coincidence between cluster lists
164  //!param: input cluster list
165  //!return size of the coincidence list
166  virtual size_t coincidence(wavecluster &, double=1.);
167 
168  //: set clusterID field for pixels in pList vector
169  //: create cList structure - list of references to cluster's pixels
170  //!return number of clusters
171  virtual size_t cluster();
172 
173  //: recursively calculate clusterID pixels in pList vector
174  //!param: pixel index in pList vector
175  //!return cluster volume (total number of pixels)
176  virtual size_t cluster(wavepixel*);
177 
178  //: access function to get cluster parameters passed selection cuts
179  //!param: string with parameter name
180  //!param: amplitude field index
181  //!param: rate index, if 0 ignore rate for calculation of cluster parameters
182  //!return wavearray object with parameter values for clusters
183  wavearray<float> get(char*, int=0, size_t=0);
184 
185  //: return noise RMS for selected pixel in pMask
186  //!param: pixel time, sec
187  //!param: pixel low frequency
188  //!param: pixel high frequency
189  double getNoiseRMS(double, double, double);
190 
191 // data members
192 
193  double start; // interval start GPS time
194  double stop; // interval stop GPS time
195  double low; // low frequency boubdary
196  double high; // high frequency boundary
197  double bpp; // black pixel probability
198  double shift; // time shift
199  int ifo; // detector index: 1/2/3 - L1/H1/H2
200  int run; // run ID
201 
202  //: pixel list
203  std::vector<wavepixel> pList;
204  //: selection cuts
205  std::vector<bool> sCuts;
206  //: cluster list created by cluster() with pixel reference to pList
207  std::list<vector_int> cList;
208  //: cluster type defined by rate
209  std::vector<vector_int> cRate;
210  //: calibrated noise RMS
212  //: noise variability
214 
215 }; // class wavecluster
216 
217 //: compare function to sort pixel objects
218 int compare_pix(const void*, const void*);
219 
220 inline int wavecluster::asize(){
221  size_t M = pList.size();
222  size_t n = 10000;
223  size_t N = 0;
224  size_t m,k;
225  if(!M) return 0;
226  for(k=0; k<M; k++){
227  m = (&(pList[k]))->amplitude.size();
228  if(m<n) n = m;
229  if(m>N) N = m;
230  }
231  if(N-n) {
232  printf("wavecluster::asize(): invalid size of amplitude vector: %d %d\n",(int)N,(int)n);
233  }
234  return n;
235 }
236 
237 
238 #endif // WAVECLUSTER_HH
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
std::vector< vector_int > cRate
Definition: cluster.hh:209
std::vector< int > vector_int
Definition: cluster.hh:17
virtual size_t append(wavecluster &)
param: input cluster list return size of appended list
Definition: cluster.cc:404
virtual ~wavecluster()
Definition: cluster.cc:55
size_t time
Definition: cluster.hh:39
double bpp
Definition: cluster.hh:197
virtual size_t cluster()
return number of clusters
Definition: cluster.cc:224
tuple f
Definition: cwb_online.py:91
printf("total live time: non-zero lags = %10.1f \n", liveTot)
wavearray< double > a(hp.size())
WSeries< float > v[nIFO]
Definition: cwb_net.C:62
double gethigh()
Definition: cluster.hh:105
int n
Definition: cwb_net.C:10
float variability
Definition: cluster.hh:43
std::vector< wavepixel > pList
Definition: cluster.hh:203
bool operator<(const wavepixel &) const
Definition: cluster.hh:36
wavecluster & operator=(const wavecluster &)
Definition: cluster.cc:59
void setbpp(double P)
Definition: cluster.hh:93
size_t index
Definition: cluster.hh:41
virtual double setMask(WSeries< double > &, int=1, bool=false)
param: max number of pixels in clusters to be cleaned (<4); param: false - core only, true - core + halo return pixel occupancy
Definition: cluster.cc:1117
TRandom3 P
Definition: compare_bkg.C:296
void ignore(size_t i=0)
param: cluster ID number return void
Definition: cluster.hh:136
virtual size_t init(WSeries< double > &, bool=false)
param: false - core only, true - core + halo return cluster list size
Definition: cluster.cc:86
#define M
Definition: UniqSLagsList.C:3
int m
Definition: cwb_net.C:10
i drho i
#define N
double getbpp()
Definition: cluster.hh:95
double stop
Definition: cluster.hh:194
double low
Definition: cluster.hh:195
wavecluster()
Definition: cluster.cc:26
virtual size_t coincidence(wavecluster &, double=1.)
param: input cluster list return size of the coincidence list
Definition: cluster.cc:657
void setvar(wavearray< float > &, double=-1., double=-1.)
Definition: cluster.cc:756
wavearray< float > nVAR
Definition: cluster.hh:213
void sethigh(double f)
Definition: cluster.hh:103
void set(WSeries< double > &n)
Definition: cluster.hh:108
int asize()
Definition: cluster.hh:220
double start
Definition: cluster.hh:193
void setlow(double f)
Definition: cluster.hh:98
double high
Definition: cluster.hh:196
virtual size_t merge(double=0.)
param: non return size of merged list
Definition: cluster.cc:465
void setrms(WSeries< double > &, double=-1., double=-1.)
Definition: cluster.cc:698
float rate
Definition: cluster.hh:42
int k
size_t size()
Definition: cluster.hh:90
virtual ~wavepixel()
Definition: cluster.hh:34
int compare_pix(const void *, const void *)
Definition: cluster.cc:15
double shift
Definition: cluster.hh:198
bool operator==(const wavepixel &) const
Definition: cluster.hh:35
virtual size_t apush(WSeries< double > &a, double=0.)
param: this and WSeries objects should have the same tree type and the approximation level size param...
Definition: cluster.cc:351
size_t clusterID
Definition: cluster.hh:38
virtual size_t cleanhalo(bool=false)
param: if true - de-cluster pixels return size of the list
Definition: cluster.cc:293
WSeries< double > nRMS
Definition: cluster.hh:211
double getlow()
Definition: cluster.hh:100
wavepixel()
Definition: cluster.hh:23
std::vector< double > amplitude
Definition: cluster.hh:47
double noiserms
Definition: cluster.hh:44
double getNoiseRMS(double, double, double)
param: pixel time, sec param: pixel low frequency param: pixel high frequency
Definition: cluster.cc:793
bool core
Definition: cluster.hh:45
std::vector< int > neighbors
Definition: cluster.hh:46
std::list< vector_int > cList
Definition: cluster.hh:207
void set(wavearray< float > &v)
Definition: cluster.hh:110
size_t frequency
Definition: cluster.hh:40
std::vector< bool > sCuts
Definition: cluster.hh:205