Logo coherent WaveBurst  
Library Reference Guide
Logo
sseries.hh
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Sergey Klimenko, Gabriele Vedovato, Valentin Necula
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 /**********************************************************
20  * Package: Sparse WSeries Class
21  * File name: sseries.hh
22  * Author: Gabriele Vedovato (vedovato@lnl.infn.it)
23  **********************************************************/
24 
25 #ifndef SSERIES_HH
26 #define SSERIES_HH
27 
28 #ifndef WSERIES_HH
29 #include "wseries.hh"
30 #endif
31 #ifndef NETCLUSTER_HH
32 #include "netcluster.hh"
33 #endif
34 #include "TBits.h"
35 
36 template<class DataType_t>
37 class SSeries : public WSeries<DataType_t>
38 {
39 public:
40 
41  // Default constructor
42  SSeries();
43 
44  // Construct SSeries for specific wavelet type
45  // default constructor
46  SSeries(const Wavelet &w);
47 
48  // Construct from wavearray
49  // param: value - data to initialize the SSeries object
50  SSeries(const wavearray<DataType_t>& value, const Wavelet &w);
51 
52  // Copy constructor - SK: this is not a copy constructor
53  // param: value - object to copy from
54  SSeries(const WSeries<DataType_t>& value);
55 
56  //SK: Copy constructor
57  //SK: SSeries(const SSeries<DataType_t>& value);
58  //SK: also need an assignment operator
59 
60  //: destructor
61  virtual ~SSeries();
62 
63  //SK: we do not need Forward methods - just use those, which are in parent class
64  //SK: we need , though, the Inverse() method to reconstruct x(t) from sparse map
65  /*
66  void Forward(int n = -1)
67  {WSeries<DataType_t>::Forward(n);this->Init();}
68  void Forward(wavearray<DataType_t> &w, int n = -1)
69  {WSeries<DataType_t>::Forward(w,n);this->Init();}
70  void Forward(wavearray<DataType_t> &w, Wavelet &s, int n = -1)
71  {WSeries<DataType_t>::Forward(w,s,n);this->Init();}
72  */
73 
74  // set an external TF map used to fill Map00/90 sparse tables
75  void SetMap(WSeries<DataType_t>* pws) {Init(pws);}
76 
77  // add core pixels index to sparse map table
78  void AddCore(size_t ifoID, netcluster* pwc, int ID=0);
79 
80  // set the halo parameters
81  void SetHalo(double maxTau=0.042, int lHalo=1, int tHalo=-1);
82 
83  // get the halo slice parameter
84  // if eslice=false the extraHalo is returned othewise the time_Halo is returned
85  int GetHaloSlice(bool eslice=false) {return eslice ? extraHalo : time_Halo;}
86  // get the time halo parameter
87  int GetHaloLayer() {return layerHalo;}
88  // get the halo delay time parameter
89  double GetHaloDelay() {return net_Delay;}
90 
91  // Get Sparse Index Size
92  int GetSparseSize(bool bcore=true);
93 
94  // Get TF pixels : core+halo with index
95  // param: index - pixel index
96  // param: pS - pointer to where pixels are stored
97  bool GetSTFdata(int index, SymmArraySSE<float>* pS);
98 
99  // GetSparseIndex
100  // Get core index list
101  wavearray<int> GetSparseIndex(bool bcore=true);
102 
103  // Reset sparse table
104  void ResetSparseTable();
105 
106  // Add cluster=core+halo pixels to sparse tables
107  void UpdateSparseTable();
108 
109  // rebuild wseries from sparse table
110  void Expand(bool bcore=true);
111 
112  // set to 0 all TF map pixels which do not belong to core+halo
113  void Clean();
114 
115  // resize to 0 the TF map : leave only the sparse map tables
117 
118  // get slice from index
119  inline int GetSlice(int index) {int nLayer=this->maxLayer()+1;return (index-index%nLayer)/nLayer;}
120 
121  // get layer from index
122  inline int GetLayer(int index) {return index%(this->maxLayer()+1);}
123 
124  //private:
125 
126  void Init(WSeries<DataType_t>* pws=NULL, bool reset=true);
127 
128  // get number of WDM layers
129  inline int GetLayers() {return this->maxLayer()+1;}
130  // get number of samples in wavelet layer
131  inline int GetSlices() {return this->sizeZero();}
132 
133  // get frequency resolution (Hz)
134  inline float GetFreqResolution() {return (float)wdm_rate/this->getLevel()/2;}
135  // get time resolution (sec)
136  inline float GetTimeResolution() {return this->getLevel()/(float)wdm_rate;}
137 
138  // get map00/90 value from index
139  inline float GetMap00(int index) {return float(this->pWavelet->pWWS[index]);}
140  inline float GetMap90(int index) {return float(this->pWavelet->pWWS[index+this->maxIndex()+1]);}
141 
142  // get map00/90 value from slice and layer
143  inline float GetMap00(int slice, int layer) {return GetMap00(slice*(this->maxLayer()+1)+layer);}
144  inline float GetMap90(int slice, int layer) {return GetMap90(slice*(this->maxLayer()+1)+layer);}
145 
146  // set map00/90 value using index
147  inline void SetMap00(int index, DataType_t value) {this->pWavelet->pWWS[index] = value;}
148  inline void SetMap90(int index, DataType_t value) {this->pWavelet->pWWS[index+this->maxIndex()+1]=value;}
149 
150  // set map00/90 value using slice and layer
151  inline void SetMap00(int slice, int layer, DataType_t value) {SetMap00(slice*(this->maxLayer()+1)+layer,value);}
152  inline void SetMap90(int slice, int layer, DataType_t value) {SetMap90(slice*(this->maxLayer()+1)+layer,value);}
153 
154  // get core type using slice and layer
155  inline short Core(int slice, int layer)
156  {return core.TestBitNumber(slice*(this->maxLayer()+1)+layer);}
157 
158  // get core type using index
159  inline short Core(int index)
160  {return core.TestBitNumber(index);}
161 
162  // search methods to search elements in the sparse table
163  int binarySearch(int array[], int start, int end, int key);
164  int binarySearch(int array[], int size, int key);
165 
166  // check if Wavelet type is WDM
167  inline void CheckWaveletType(TString method) {
168  if(this->pWavelet->m_WaveType!=WDMT) {
169  cout << "SSeries<DataType_t>::"<<method.Data()
170  <<" : wavelet type not enabled " << endl; exit(1);}
171  }
172 
173  // data members
174 
175  TBits core; // core pixel array 1/0 : core/not-core
176 
177  // sparse table
178  wavearray<int> sparseLookup; // store the index pointer to the layers
179  TBits sparseType; // store pixel type 1/0 core/halo
180  wavearray<int> sparseIndex; // store pixel index
181  wavearray<float> sparseMap00; // store pixel 00 amp
182  wavearray<float> sparseMap90; // store pixel 90 amp;
183 
184  int layerHalo; // number of sparse layers associated to a pixel [+/- layerHalo]
185  int time_Halo; // typically half length of time-delay filter
186  int extraHalo; // number of extra sparse slices associated to a pixel [+/- (time_Halo+extraHalo)]
187  double net_Delay; // delay time (sec) used to compute extraHalo = net_Delay*this->wrate()
188 
189  // WDM params (used to Expand class after Shrink or after loading from file)
190  //SK: all parameters below are stored in pWavelet
193  int wdm_KWDM;
195  int wdm_rate;
197  int wdm_nSTS;
198 
199  ClassDef(SSeries,2)
200 };
201 
202 #endif
double GetHaloDelay()
Definition: sseries.hh:89
short Core(int slice, int layer)
Definition: sseries.hh:155
TBits core
Definition: sseries.hh:175
float GetFreqResolution()
Definition: sseries.hh:134
void SetMap00(int index, DataType_t value)
Definition: sseries.hh:147
int layer(double f)
Definition: wseries.cc:167
float GetMap90(int index)
Definition: sseries.hh:140
par [0] value
int wdm_start
Definition: sseries.hh:196
void SetMap90(int slice, int layer, DataType_t value)
Definition: sseries.hh:152
int GetLayers()
Definition: sseries.hh:129
wavearray< int > GetSparseIndex(bool bcore=true)
Definition: sseries.cc:345
TString("c")
int ID
Definition: TestMDC.C:70
size_t maxIndex()
Definition: wseries.hh:149
int wdm_nSTS
Definition: sseries.hh:197
netcluster * pwc
Definition: cwb_job_obj.C:38
int GetLayer(int index)
Definition: sseries.hh:122
int wdm_m_Layer
Definition: sseries.hh:192
void UpdateSparseTable()
Definition: sseries.cc:276
int wdm_rate
Definition: sseries.hh:195
wavearray< int > sparseIndex
Definition: sseries.hh:180
int layerHalo
Definition: sseries.hh:184
TBits sparseType
Definition: sseries.hh:179
void SetMap(WSeries< DataType_t > *pws)
Definition: sseries.hh:75
wavearray< double > w
Definition: Test1.C:27
virtual size_t size() const
Definition: wavearray.hh:145
void Clean()
Definition: sseries.cc:443
int getLevel()
Definition: wseries.hh:109
void Shrink()
Definition: sseries.hh:116
SSeries()
Definition: sseries.cc:92
int wdm_KWDM
Definition: sseries.hh:193
int time_Halo
Definition: sseries.hh:185
bool GetSTFdata(int index, SymmArraySSE< float > *pS)
Definition: sseries.cc:362
void Init(WSeries< DataType_t > *pws=NULL, bool reset=true)
Definition: sseries.cc:112
wavearray< int > sparseLookup
Definition: sseries.hh:178
void ResetSparseTable()
Definition: sseries.cc:186
virtual ~SSeries()
Definition: sseries.cc:86
Definition: Wavelet.hh:49
float GetMap90(int slice, int layer)
Definition: sseries.hh:144
int GetSparseSize(bool bcore=true)
Definition: sseries.cc:335
virtual double start() const
Definition: wavearray.hh:138
void SetMap90(int index, DataType_t value)
Definition: sseries.hh:148
int GetSlices()
Definition: sseries.hh:131
void SetMap00(int slice, int layer, DataType_t value)
Definition: sseries.hh:151
float GetTimeResolution()
Definition: sseries.hh:136
float GetMap00(int slice, int layer)
Definition: sseries.hh:143
int GetHaloLayer()
Definition: sseries.hh:87
void Expand(bool bcore=true)
Definition: sseries.cc:415
int GetHaloSlice(bool eslice=false)
Definition: sseries.hh:85
void CheckWaveletType(TString method)
Definition: sseries.hh:167
wavearray< int > index
void SetHalo(double maxTau=0.042, int lHalo=1, int tHalo=-1)
Definition: sseries.cc:243
wavearray< float > sparseMap00
Definition: sseries.hh:181
wavearray< float > sparseMap90
Definition: sseries.hh:182
float GetMap00(int index)
Definition: sseries.hh:139
int GetSlice(int index)
Definition: sseries.hh:119
void AddCore(size_t ifoID, netcluster *pwc, int ID=0)
Definition: sseries.cc:203
int wdm_BetaOrder
Definition: sseries.hh:191
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:456
int extraHalo
Definition: sseries.hh:186
virtual void resize(unsigned int)
Definition: wavearray.cc:463
size_t sizeZero()
Definition: wseries.hh:144
int wdm_precision
Definition: sseries.hh:194
int maxLayer()
Definition: wseries.hh:139
int binarySearch(int array[], int start, int end, int key)
Definition: sseries.cc:461
exit(0)
short Core(int index)
Definition: sseries.hh:159
double net_Delay
Definition: sseries.hh:187