Logo coherent WaveBurst  
Library Reference Guide
Logo
netpixel.hh
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Sergey Klimenko
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // Wavelet Analysis Tool
20 // Sergey Klimenko, University of Florida
21 // universal pixel data container for network cluster analysis
22 // used with DMT and ROOT
23 //
24 
25 #ifndef NETPIXEL_HH
26 #define NETPIXEL_HH
27 
28 #include <iostream>
29 #include "wavearray.hh"
30 #include "WaveDWT.hh"
31 #include "wseries.hh"
32 #include "TNamed.h"
33 
34 struct pixdata {
35  double noiserms; // average noise rms
36  double wave; // vector of 00 pixel's wavelet amplitudes
37  double w_90; // vector of 90 pixel's wavelet amplitudes
38  double asnr; // vector of 00 pixel's whitened amplitudes
39  double a_90; // vector of 90 pixel's whitened amplitudes
40  float rank; // vector of pixel's rank amplitudes
41  int index; // index in wavearray
42 };
43 
44 class netpixel : public TNamed {
45  public:
46 
47  netpixel();
48  netpixel(size_t);
49 
50  virtual ~netpixel(){ this->clear(); }
51  bool operator == (const netpixel &) const {return true;}
52  bool operator < (const netpixel &) const {return true;}
53 
54  // operator =
55  netpixel& operator= (const netpixel&);
56 
57  // set pixel data
58  inline bool setdata(double a, char type='R', size_t n=0){
59  if(n<this->size()) {
60  if(type == 'N' || type == 'n') this->data[n].noiserms = a;
61  else if(type == 'I' || type == 'i') this->data[n].index = int(a+0.1);
62  else if(type == 'W' || type == 'w') this->data[n].wave = a;
63  else if(type == 'U' || type == 'u') this->data[n].w_90 = a;
64  else if(type == 'S' || type == 's') this->data[n].asnr = a;
65  else if(type == 'P' || type == 'p') this->data[n].a_90 = a;
66  else if(type == 'R' || type == 'r') this->data[n].rank = a;
67  else this->data[n].asnr = a;
68  return true;
69  }
70  else { return false; }
71  }
72 
73  // get pixel data
74  inline double getdata(char type='R', size_t n=0){
75  if(n<this->size()) {
76  if(type == 'N' || type == 'n') return double(this->data[n].noiserms);
77  else if(type == 'I' || type == 'i') return double(this->data[n].index);
78  else if(type == 'W' || type == 'w') return double(this->data[n].wave);
79  else if(type == 'U' || type == 'u') return double(this->data[n].w_90);
80  else if(type == 'S' || type == 's') return double(this->data[n].asnr);
81  else if(type == 'P' || type == 'p') return double(this->data[n].a_90);
82  else if(type == 'R' || type == 'r') return double(this->data[n].rank);
83  else return double(this->data[n].asnr);
84  }
85  return 0;
86  }
87 
88  // get size of pixel arrays
89  inline size_t size(){ return this->data.size(); }
90  // get capacity of pixel object
91  inline size_t capacity(){ return data.capacity(); }
92  // clear pixel
93  inline void clear(){
94  data.clear(); std::vector<pixdata>().swap(data);
95  tdAmp.clear(); std::vector<wavearray<float> >().swap(tdAmp);
96  neighbors.clear(); std::vector<int>().swap(neighbors);
97  }
98  // clear pixel
99  inline void clean(){
100  tdAmp.clear(); std::vector<wavearray<float> >().swap(tdAmp);
101  }
102  // add link to neighbors
103  inline void append(int n){ neighbors.push_back(n); }
104  // write pixel to file
105  bool write(const FILE *);
106  // read pixel from file
107  bool read(const FILE *);
108 
109  size_t clusterID; // cluster ID
110  size_t time; // time index for master detector
111  size_t frequency; // frequency index (layer)
112  size_t layers; // number of frequency layers
113  float rate; // wavelet layer rate
114  float likelihood; // likelihood
115  float null; // null
116  float theta; // source angle theta index
117  float phi; // source angle phi index
118  float ellipticity; // waveform ellipticity
119  float polarisation; // waveform polarisation
120  bool core; // pixel type: true - core , false - halo
121 
122  std::vector<pixdata> data;
123  std::vector<wavearray<float> > tdAmp;
124  std::vector<int> neighbors; // vector of links to neighbors
125 
126  ClassDef(netpixel,2)
127 };
128 
129 #endif // NETPIXEL_HH
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
float phi
Definition: netpixel.hh:117
float rank
Definition: netpixel.hh:40
size_t clusterID
Definition: netpixel.hh:109
std::vector< wavearray< float > > tdAmp
Definition: netpixel.hh:123
wavearray< double > a(hp.size())
size_t frequency
Definition: netpixel.hh:111
float likelihood
Definition: netpixel.hh:114
int n
Definition: cwb_net.C:28
std::vector< int > neighbors
Definition: netpixel.hh:124
std::vector< pixdata > data
Definition: netpixel.hh:122
Long_t size
size_t layers
Definition: netpixel.hh:112
size_t capacity()
Definition: netpixel.hh:91
wc clear()
double asnr
Definition: netpixel.hh:38
bool core
Definition: netpixel.hh:120
virtual ~netpixel()
Definition: netpixel.hh:50
double w_90
Definition: netpixel.hh:37
size_t size()
Definition: netpixel.hh:89
double wave
Definition: netpixel.hh:36
i() int(T_cor *100))
float polarisation
Definition: netpixel.hh:119
int index
Definition: netpixel.hh:41
void clear()
Definition: netpixel.hh:93
void append(int n)
Definition: netpixel.hh:103
size_t time
Definition: netpixel.hh:110
float ellipticity
Definition: netpixel.hh:118
double noiserms
Definition: netpixel.hh:35
float theta
Definition: netpixel.hh:116
DataType_t rank(double=0.5) const
Definition: wavearray.cc:1737
float rate
Definition: netpixel.hh:113
double getdata(char type='R', size_t n=0)
Definition: netpixel.hh:74
float null
Definition: netpixel.hh:115
double a_90
Definition: netpixel.hh:39
void clean()
Definition: netpixel.hh:99
bool setdata(double a, char type='R', size_t n=0)
Definition: netpixel.hh:58