Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_supercluster_bench.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
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 #define XIFO 4
20 
21 #pragma GCC system_header
22 
23 #include "cwb.hh"
24 #include "cwb2G.hh"
25 #include "config.hh"
26 #include "network.hh"
27 #include "wavearray.hh"
28 #include "TString.h"
29 #include "TObjArray.h"
30 #include "TObjString.h"
31 #include "TRandom.h"
32 #include "TComplex.h"
33 
34 //!SUPERCLUSTER
35 
36 long subNetCut(network* net, int lag, float snc, TH2F* hist);
37 inline int _sse_MRA_ps(network* net, float* amp, float* AMP, float Eo, int K);
38 void PrintElapsedTime(int job_elapsed_time, double cpu_time, TString info);
39 
40 #define USE_LOCAL_SUBNETCUT // comment to use the builtin implementation of subNetCut
41 
42 void
44 
45 // This plugin implements the standard supercluster stage & use a local implementation of subNetCut (only 2G)
46 
47  cout << endl;
48  cout << "-----> CWB_Plugin_supercluster_bench.C" << endl;
49  cout << "ifo " << ifo.Data() << endl;
50  cout << "type " << type << endl;
51  cout << endl;
52 
53  if(type==CWB_PLUGIN_CONFIG) {
54  cfg->scPlugin=true; // disable built-in supercluster function
55  }
56 
57  if(type==CWB_PLUGIN_ISUPERCLUSTER) {
58 
59  cout << "type==CWB_PLUGIN_ISUPERCLUSTER" << endl;
60 
61  TStopwatch bench;
62  bench.Stop();
63 
64  // import ifile
65  void* gIFILE=NULL; IMPORT(void*,gIFILE)
66  cout << "-----> CWB_Plugin_wavegraph.C -> " << " gIFILE : " << gIFILE << endl;
67  TFile* ifile = (TFile*)gIFILE;
68 
69  // import ifactor
70  int gIFACTOR=-1; IMPORT(int,gIFACTOR)
71  cout << "-----> CWB_Plugin_wavegraph.C -> " << " gIFACTOR : " << gIFACTOR << endl;
72  int ifactor = gIFACTOR;
73 
74  int nIFO = net->ifoListSize(); // number of detectors
75  int rateANA=cfg->inRate>>cfg->levelR;
76  int nRES = net->wdmListSize(); // number of resolution levels
77  int lags = net->getifo(0)->lagShift.size();
78 
79  wavearray<double>* hot[NIFO_MAX]; // temporary time series
80  for(int i=0; i<nIFO; i++) hot[i] = net->getifo(i)->getHoT();
81 
82  int nevt = 0;
83  int nnn = 0;
84  int mmm = 0;
85  size_t count = 0;
86  netcluster wc;
87  netcluster* pwc;
88 
89  for(int j=0; j<(int)lags; j++) {
90 
91  int cycle = cfg->simulation ? ifactor : Long_t(net->wc_List[j].shift);
92 
93  // read cluster metadata
94  if(ifile!=NULL) wc.read(ifile,"coherence","clusters",0,cycle);
95  else wc.read(jfile,"coherence","clusters",0,cycle);
96  // read clusters from temporary job file, loop over TF resolutions
97  if(ifile!=NULL) {
98  for(int i=nRES-1; i>=0; i--) // reverse loop is faster loading cluster (?)
99  wc.read(ifile,"coherence","clusters",-1,cycle,rateANA>>(i+cfg->l_low));
100  } else {
101  for(int i=nRES-1; i>=0; i--) // reverse loop is faster loading cluster (?)
102  wc.read(jfile,"coherence","clusters",-1,cycle,rateANA>>(i+cfg->l_low));
103  }
104  if(!cfg->simulation) cout<<"process lag " <<cycle<<" ..."<<endl;
105  cout<<"loaded clusters|pixels: "<<wc.csize()<<"|"<<wc.size()<<endl;
106 
107  // supercluster analysis
108  wc.supercluster('L',net->e2or,cfg->TFgap,false); //likehood2G
109  cout<<"super clusters|pixels: "<<wc.esize(0)<<"|"<<wc.psize(0)<<endl;
110 
111  // release all pixels
112  pwc = net->getwc(j);
113  pwc->cpf(wc, false);
114 
115  net->setDelayIndex(hot[0]->rate());
116  pwc->setcore(false);
117 
118  // apply cuts
119  int psel = 0;
120  while(1) {
121  count = pwc->loadTDampSSE(*net, 'a', cfg->BATCH, cfg->LOUD);
122  bench.Continue();
123 #ifdef USE_LOCAL_SUBNETCUT
124  psel += subNetCut(net,(int)j,cfg->subnet,NULL);
125 #else
126  psel += net->subNetCut((int)j,cfg->subnet,NULL);
127 #endif
128  bench.Stop();
129  PrintElapsedTime(bench.RealTime(),bench.CpuTime(),"subNetCut : Processing Time - ");
130  int ptot = pwc->psize(1)+pwc->psize(-1);
131  double pfrac = ptot>0 ? double(psel)/double(ptot) : 0.;
132  cout<<"selected pixels: "<<psel<<", fraction: "<<pfrac<< endl;
133  if(count<10000) break;
134  }
135 
136  pwc->defragment(cfg->Tgap,cfg->Fgap); // SK added defragmentation
137 
138  nevt = net->events();
139  nnn += pwc->psize(-1);
140  mmm += pwc->psize(1)+pwc->psize(-1);
141 
142  if(mmm) cout<<"events in the buffer: "<<net->events()<<"|"<<nnn<<"|"<<nnn/double(mmm)<<"\n";
143  else cout<<"events in the buffer: "<<net->events()<<"\n";
144 
145  // store cluster into temporary job file [NEWSS]
146  pwc->write(jfile,"supercluster","clusters",0,cycle);
147  pwc->write(jfile,"supercluster","clusters",-1,cycle);
148  cout<<cycle<<"|"<<pwc->csize()<<"|"<<pwc->size()<<" ";cout.flush();
149 
150  pwc->clear();
151  cout<<endl;
152  }
153  }
154 
155  return;
156 }
157 
158 void
159 PrintElapsedTime(int job_elapsed_time, double cpu_time, TString info) {
160 //
161 // convert job_elapsed_time to (hh:mm:ss) format and print it
162 //
163 // job_elapsed_time : time (seconds)
164 //
165 // info : info string added to (hh:mm:ss)
166 //
167 
168  int job_elapsed_hour = int(job_elapsed_time/3600);
169  int job_elapsed_min = int((job_elapsed_time-3600*job_elapsed_hour)/60);
170  int job_elapsed_sec = int(job_elapsed_time-3600*job_elapsed_hour-60*job_elapsed_min);
171  char buf[1024];
172  sprintf(buf,"%s %02d:%02d:%02d (hh:mm:ss) : cpu time : %f (sec)\n",info.Data(),job_elapsed_hour,job_elapsed_min,job_elapsed_sec,cpu_time);
173  cout << buf;
174 
175  return;
176 }
177 
178 long subNetCut(network* net, int lag, float snc, TH2F* hist)
179 {
180 // sub-network cut with dsp regulator
181 // lag: lag index
182 // snc: sub network threshold, if snc<0 use weak constraint
183 // hist: diagnostic histogram
184 // return number of processed pixels
185 
186  if(!net->wc_List[lag].size()) return 0;
187 
188  size_t nIFO = net->ifoList.size();
189 
190  if(nIFO>NIFO) {
191  cout<<"network::subNetCut(): invalid network.\n";
192  exit(0);
193  }
194 
195  float En = 2*net->acor*net->acor*nIFO; // network energy threshold in the sky loop
196  float Es = 2*net->e2or; // subnet energy threshold in the sky loop
197  float TH = fabs(snc); // sub network threshold
198 
199  __m128 _En = _mm_set1_ps(En);
200  __m128 _Es = _mm_set1_ps(Es);
201  __m128 _oo = _mm_set1_ps(1.e-12);
202  __m128 _0 = _mm_set1_ps(0.);
203  __m128 _05 = _mm_set1_ps(0.5);
204  __m128 _1 = _mm_set1_ps(1.);
205  __m128* _pe[NIFO];
206 
207  int f_ = NIFO/4;
208  int l,lm,Vm;
209  float Lm,Em,Am,Lo,Eo,Co,Lr,Er,ee,em,To;
210  float cc,aa,AA,rHo,stat,Ls,Ln,EE;
211 
212  size_t i,j,k,m,V,V4,id,K,M;
213  int Lsky = int(net->index.size()); // total number of source locations
214  short* mm = net->skyMask.data;
215 
216  float vvv[NIFO];
217  float* v00[NIFO];
218  float* v90[NIFO];
219  float* pe[NIFO];
220  float* pa[NIFO];
221  float* pA[NIFO];
222  short* ml[NIFO];
223  double* FP[NIFO];
224  double* FX[NIFO];
225  double xx[NIFO];
226 
227  for(i=0; i<NIFO; i++) {
228  if(i<nIFO) {
229  ml[i] = net->getifo(i)->index.data;
230  FP[i] = net->getifo(i)->fp.data;
231  FX[i] = net->getifo(i)->fx.data;
232  }
233  else {
234  ml[i] = net->getifo(0)->index.data;
235  FP[i] = net->getifo(0)->fp.data;
236  FX[i] = net->getifo(0)->fx.data;
237  }
238  }
239 
240  // allocate buffers
241  std::vector<int> pI; // buffer for pixel IDs
242  wavearray<double> cid; // buffers for cluster ID
243  netpixel* pix;
244  std::vector<int>* vint;
245  netcluster* pwc = &net->wc_List[lag];
246 
247  size_t count = 0;
248  size_t tsize = 0;
249 
250 //+++++++++++++++++++++++++++++++++++++++
251 // loop over clusters
252 //+++++++++++++++++++++++++++++++++++++++
253 
254  cid = pwc->get((char*)"ID", 0,'S',0); // get cluster ID
255 
256  K = cid.size();
257  for(k=0; k<K; k++) { // loop over clusters
258  id = size_t(cid.data[k]+0.1);
259  if(pwc->sCuts[id-1] != -2) continue; // skip rejected/processed clusters
260  vint = &(pwc->cList[id-1]); // pixel list
261  V = vint->size(); // pixel list size
262  if(!V) continue;
263 
264  pI = net->wdmMRA.getXTalk(pwc, id);
265 
266  V = pI.size(); // number of loaded pixels
267  if(!V) continue;
268 
269  pix = pwc->getPixel(id,pI[0]);
270  tsize = pix->tdAmp[0].size();
271  if(!tsize || tsize&1) { // tsize%1 = 1/0 = power/amplitude
272  cout<<"network::subNetCut() error: wrong pixel TD data\n";
273  exit(1);
274  }
275  tsize /= 2;
276  V4 = V + (V%4 ? 4 - V%4 : 0);
277 
278  //cout<<En<<" "<<Es<<" "<<lag<<" "<<id<<" "<<V4<<" "<<" "<<tsize<<endl;
279 
280  std::vector<wavearray<float> > vtd; // vectors of TD amplitudes
281  std::vector<wavearray<float> > vTD; // vectors of TD amplitudes
282  std::vector<wavearray<float> > eTD; // vectors of TD energies
283 
284  wavearray<float> tmp(tsize*V4); tmp=0; // aligned array for TD amplitudes
285  wavearray<float> fp(NIFO*V4); fp=0; // aligned array for + antenna pattern
286  wavearray<float> fx(NIFO*V4); fx=0; // aligned array for x antenna pattern
287  wavearray<float> nr(NIFO*V4); nr=0; // aligned array for inverse rms
288  wavearray<float> Fp(NIFO*V4); Fp=0; // aligned array for pattern
289  wavearray<float> Fx(NIFO*V4); Fx=0; // aligned array for patterns
290  wavearray<float> am(NIFO*V4); am=0; // aligned array for TD amplitudes
291  wavearray<float> AM(NIFO*V4); AM=0; // aligned array for TD amplitudes
292  wavearray<float> bb(NIFO*V4); bb=0; // temporary array for MRA amplitudes
293  wavearray<float> BB(NIFO*V4); BB=0; // temporary array for MRA amplitudes
294  wavearray<float> xi(NIFO*V4); xi=0; // 00 array for reconctructed responses
295  wavearray<float> XI(NIFO*V4); XI=0; // 90 array for reconstructed responses
296  wavearray<float> ww(NIFO*V4); ww=0; // 00 array for phase-shifted data vectors
297  wavearray<float> WW(NIFO*V4); WW=0; // 90 array for phase-shifted data vectors
298  wavearray<float> u4(NIFO*4); u4=0; // temp array
299  wavearray<float> U4(NIFO*4); U4=0; // temp array
300 
301  __m128* _Fp = (__m128*) Fp.data;
302  __m128* _Fx = (__m128*) Fx.data;
303  __m128* _am = (__m128*) am.data;
304  __m128* _AM = (__m128*) AM.data;
305  __m128* _xi = (__m128*) xi.data;
306  __m128* _XI = (__m128*) XI.data;
307  __m128* _fp = (__m128*) fp.data;
308  __m128* _fx = (__m128*) fx.data;
309  __m128* _nr = (__m128*) nr.data;
310  __m128* _ww = (__m128*) ww.data;
311  __m128* _WW = (__m128*) WW.data;
312  __m128* _bb = (__m128*) bb.data;
313  __m128* _BB = (__m128*) BB.data;
314 
315  for(i=0; i<NIFO; i++) {
316  vtd.push_back(tmp); // array of aligned energy vectors
317  vTD.push_back(tmp); // array of aligned energy vectors
318  eTD.push_back(tmp); // array of aligned energy vectors
319  }
320 
321  for(i=0; i<NIFO; i++) { // set up zero deley pointers
322  pa[i] = vtd[i].data + (tsize/2)*V4;
323  pA[i] = vTD[i].data + (tsize/2)*V4;
324  pe[i] = eTD[i].data + (tsize/2)*V4;
325  }
326 
327  net->a_00.resize(NIFO*V4); net->a_00=0.;
328  net->a_90.resize(NIFO*V4); net->a_90=0.;
329  net->rNRG.resize(V4); net->rNRG=0.;
330  net->pNRG.resize(V4); net->pNRG=0.;
331 
332  __m128* _aa = (__m128*) net->a_00.data; // set pointer to 00 array
333  __m128* _AA = (__m128*) net->a_90.data; // set pointer to 90 array
334 
335  net->pList.clear();
336  for(j=0; j<V; j++) { // loop over selected pixels
337  pix = pwc->getPixel(id,pI[j]); // get pixel pointer
338  net->pList.push_back(pix); // store pixel pointers for MRA
339 
340  double rms = 0.;
341  for(i=0; i<nIFO; i++) {
342  xx[i] = 1./pix->data[i].noiserms;
343  rms += xx[i]*xx[i]; // total inverse variance
344  }
345 
346  for(i=0; i<nIFO; i++) {
347  nr.data[j*NIFO+i]=(float)xx[i]/sqrt(rms); // normalized 1/rms
348  for(l=0; l<tsize; l++) {
349  aa = pix->tdAmp[i].data[l]; // copy TD 00 data
350  AA = pix->tdAmp[i].data[l+tsize]; // copy TD 90 data
351  vtd[i].data[l*V4+j] = aa; // copy 00 data
352  vTD[i].data[l*V4+j] = AA; // copy 90 data
353  eTD[i].data[l*V4+j] = aa*aa+AA*AA; // copy power
354  }
355  }
356  }
357 
358 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
359 // first sky loop
360 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
361 
362  int lb = 0;
363  int le = Lsky-1;
364  bool mra = false;
365  double suball=0;
366  double submra=0;
367 
368  stat=Lm=Em=Am=EE=0.; lm=Vm= -1;
369 
370  skyloop:
371 
372  for(l=lb; l<=le; l++) { // loop over sky locations
373  if(!mm[l] || l<0) continue; // skip delay configurations
374 
375  _sse_point_ps(_pe, pe, ml, int(l), (int)V4); // point _pe to energy vectors
376 
377  __m128 _msk;
378  __m128 _E_o = _mm_setzero_ps(); // total network energy
379  __m128 _E_n = _mm_setzero_ps(); // network energy above the threshold
380  __m128 _E_s = _mm_setzero_ps(); // subnet energy above the threshold
381  __m128 _M_m = _mm_setzero_ps(); // # of pixels above threshold
382  __m128* _rE = (__m128*) net->rNRG.data; // m128 pointer to energy array
383  __m128* _pE = (__m128*) net->pNRG.data; // m128 pointer to energy array
384 
385  for(j=0; j<V4; j+=4) { // loop over selected pixels
386  *_rE = _sse_sum_ps(_pe); // get pixel energy
387  _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_rE,_En)); // E>En 0/1 mask
388  _M_m = _mm_add_ps(_M_m,_msk); // count pixels above threshold
389  *_pE = _mm_mul_ps(*_rE,_msk); // zero sub-threshold pixels
390  _E_o = _mm_add_ps(_E_o,*_pE); // network energy
391  _sse_minSNE_ps(_rE,_pe,_pE); // subnetwork energy with _pe increment
392  _E_s = _mm_add_ps(_E_s,*_pE); // subnetwork energy
393  _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_pE++,_Es)); // subnet energy > Es 0/1 mask
394  _E_n = _mm_add_ps(_E_n,_mm_mul_ps(*_rE++,_msk)); // network energy
395  }
396 
397  _mm_storeu_ps(vvv,_E_n);
398  Ln = vvv[0]+vvv[1]+vvv[2]+vvv[3]; // network energy above subnet threshold
399  _mm_storeu_ps(vvv,_E_o);
400  Eo = vvv[0]+vvv[1]+vvv[2]+vvv[3]+0.01; // total network energy
401  _mm_storeu_ps(vvv,_E_s);
402  Ls = vvv[0]+vvv[1]+vvv[2]+vvv[3]; // subnetwork energy
403  _mm_storeu_ps(vvv,_M_m);
404  m = 2*(vvv[0]+vvv[1]+vvv[2]+vvv[3])+0.01; // pixels above threshold
405 
406  aa = Ls*Ln/(Eo-Ls);
407  if((aa-m)/(aa+m)<0.33) continue;
408 
409  net->pnt_(v00, pa, ml, (int)l, (int)V4); // pointers to first pixel 00 data
410  net->pnt_(v90, pA, ml, (int)l, (int)V4); // pointers to first pixel 90 data
411  float* pfp = fp.data; // set pointer to fp
412  float* pfx = fx.data; // set pointer tp fx
413  float* p00 = net->a_00.data; // set pointer for 00 array
414  float* p90 = net->a_90.data; // set pointer for 90 array
415 
416  m = 0;
417  for(j=0; j<V; j++) {
418  int jf = j*f_; // source sse pointer increment
419  net->cpp_(p00,v00); net->cpp_(p90,v90); // copy amplitudes with target increment
420  net->cpf_(pfp,FP,l); net->cpf_(pfx,FX,l); // copy antenna with target increment
421  _sse_zero_ps(_xi+jf); // zero MRA amplitudes
422  _sse_zero_ps(_XI+jf); // zero MRA amplitudes
423  _sse_cpf_ps(_am+jf,_aa+jf); // duplicate 00
424  _sse_cpf_ps(_AM+jf,_AA+jf); // duplicate 90
425  if(net->rNRG.data[j]>En) m++; // count superthreshold pixels
426  }
427 
428  __m128* _pp = (__m128*) am.data; // point to multi-res amplitudes
429  __m128* _PP = (__m128*) AM.data; // point to multi-res amplitudes
430 
431  if(mra) { // do MRA
432  _sse_MRA_ps(net,xi.data,XI.data,En,m); // get principal components
433  _pp = (__m128*) xi.data; // point to PC amplitudes
434  _PP = (__m128*) XI.data; // point to PC amplitudes
435  }
436 
437  m = 0; Ls=Ln=Eo=0;
438  for(j=0; j<V; j++) {
439  int jf = j*f_; // source sse pointer increment
440  int mf = m*f_; // target sse pointer increment
441  _sse_zero_ps(_bb+jf); // reset array for MRA amplitudes
442  _sse_zero_ps(_BB+jf); // reset array for MRA amplitudes
443  ee = _sse_abs_ps(_pp+jf,_PP+jf); // total pixel energy
444  if(ee<En) continue;
445  _sse_cpf_ps(_bb+mf,_pp+jf); // copy 00 amplitude/PC
446  _sse_cpf_ps(_BB+mf,_PP+jf); // copy 90 amplitude/PC
447  _sse_cpf_ps(_Fp+mf,_fp+jf); // copy F+
448  _sse_cpf_ps(_Fx+mf,_fx+jf); // copy Fx
449  _sse_mul_ps(_Fp+mf,_nr+jf); // normalize f+ by rms
450  _sse_mul_ps(_Fx+mf,_nr+jf); // normalize fx by rms
451  m++;
452  em = _sse_maxE_ps(_pp+jf,_PP+jf); // dominant pixel energy
453  Ls += ee-em; Eo += ee; // subnetwork energy, network energy
454  if(ee-em>Es) Ln += ee; // network energy above subnet threshold
455  }
456 
457  size_t m4 = m + (m%4 ? 4 - m%4 : 0);
458  _E_n = _mm_setzero_ps(); // + likelihood
459 
460  for(j=0; j<m4; j+=4) {
461  int jf = j*f_;
462  _sse_dpf4_ps(_Fp+jf,_Fx+jf,_fp+jf,_fx+jf); // go to DPF
463  _E_s = _sse_like4_ps(_fp+jf,_fx+jf,_bb+jf,_BB+jf); // std likelihood
464  _E_n = _mm_add_ps(_E_n,_E_s); // total likelihood
465  }
466  _mm_storeu_ps(vvv,_E_n);
467 
468  Lo = vvv[0]+vvv[1]+vvv[2]+vvv[3];
469  AA = aa/(fabs(aa)+fabs(Eo-Lo)+2*m*(Eo-Ln)/Eo); // subnet stat with threshold
470  ee = Ls*Eo/(Eo-Ls);
471  em = fabs(Eo-Lo)+2*m; // suball NULL
472  ee = ee/(ee+em); // subnet stat without threshold
473  aa = (aa-m)/(aa+m);
474 
475  if(AA>stat && !mra) {
476  stat=AA; Lm=Lo; Em=Eo; Am=aa; lm=l; Vm=m; suball=ee; EE=em;
477  }
478  }
479 
480  if(!mra && lm>=0) {mra=true; le=lb=lm; goto skyloop;} // get MRA principle components
481 
482  pwc->sCuts[id-1] = -1;
483  pwc->cData[id-1].likenet = Lm;
484  pwc->cData[id-1].energy = Em;
485  pwc->cData[id-1].theta = net->nLikelihood.getTheta(lm);
486  pwc->cData[id-1].phi = net->nLikelihood.getPhi(lm);
487  pwc->cData[id-1].skyIndex = lm;
488 
489  rHo = 0.;
490  if(mra) {
491  submra = Ls*Eo/(Eo-Ls); // MRA subnet statistic
492  submra/= fabs(submra)+fabs(Eo-Lo)+2*(m+6); // MRA subnet coefficient
493  To = 0;
494  pwc->p_Ind[id-1].push_back(lm);
495  for(j=0; j<vint->size(); j++) {
496  pix = pwc->getPixel(id,j);
497  pix->theta = net->nLikelihood.getTheta(lm);
498  pix->phi = net->nLikelihood.getPhi(lm);
499  To += pix->time/pix->rate/pix->layers;
500  if(j==0&&mra) pix->ellipticity = submra; // subnet MRA propagated to L-stage
501  if(j==0&&mra) pix->polarisation = fabs(Eo-Lo)+2*(m+6); // submra NULL propagated to L-stage
502  if(j==1&&mra) pix->ellipticity = suball; // subnet all-sky propagated to L-stage
503  if(j==1&&mra) pix->polarisation = EE; // suball NULL propagated to L-stage
504  }
505  To /= vint->size();
506  rHo = sqrt(Lo*Lo/(Eo+2*m)/nIFO); // estimator of coherent amplitude
507  }
508 
509  if(hist && rHo>net->netRHO)
510  for(j=0;j<vint->size();j++) hist->Fill(suball,submra);
511 
512  if(fmin(suball,submra)>TH && rHo>net->netRHO) {
513  count += vint->size();
514  if(hist) {
515  printf("lag|id %3d|%3d rho=%5.2f To=%5.1f stat: %5.3f|%5.3f|%5.3f ",
516  int(lag),int(id),rHo,To,suball,submra,stat);
517  printf("E: %6.1f|%6.1f L: %6.1f|%6.1f|%6.1f pix: %4d|%4d|%3d|%2d \n",
518  Em,Eo,Lm,Lo,Ls,int(vint->size()),int(V),Vm,int(m));
519  }
520  }
521  else pwc->sCuts[id-1]=1;
522 
523 // clean time delay data
524 
525  V = vint->size();
526  for(j=0; j<V; j++) { // loop over pixels
527  pix = pwc->getPixel(id,j);
528  pix->core = true;
529  if(pix->tdAmp.size()) pix->clean();
530  }
531  } // end of loop over clusters
532  return count;
533 }
534 
535 inline int _sse_MRA_ps(network* net, float* amp, float* AMP, float Eo, int K) {
536 // fast multi-resolution analysis inside sky loop
537 // select max E pixel and either scale or skip it based on the value of residual
538 // pointer to 00 phase amplitude of monster pixels
539 // pointer to 90 phase amplitude of monster pixels
540 // Eo - energy threshold
541 // K - number of principle components to extract
542 // returns number of MRA pixels
543  int j,n,mm;
544  int k = 0;
545  int m = 0;
546  int f = NIFO/4;
547  int V = (int)net->rNRG.size();
548  float* ee = net->rNRG.data; // residual energy
549  float* pp = net->pNRG.data; // residual energy
550  float EE = 0.; // extracted energy
551  float E;
552  float mam[NIFO];
553  float mAM[NIFO];
554  net->pNRG=-1;
555  for(j=0; j<V; ++j) if(ee[j]>Eo) pp[j]=0;
556 
557  __m128* _m00 = (__m128*) mam;
558  __m128* _m90 = (__m128*) mAM;
559  __m128* _amp = (__m128*) amp;
560  __m128* _AMP = (__m128*) AMP;
561  __m128* _a00 = (__m128*) net->a_00.data;
562  __m128* _a90 = (__m128*) net->a_90.data;
563 
564  while(k<K){
565 
566  for(j=0; j<V; ++j) if(ee[j]>ee[m]) m=j; // find max pixel
567  if(ee[m]<=Eo) break; mm = m*f;
568 
569  //cout<<" V= "<<V<<" m="<<m<<" ee[m]="<<ee[m];
570 
571  E = _sse_abs_ps(_a00+mm,_a90+mm); EE += E; // get PC energy
572  int J = net->wdmMRA.size()/7;
573  float* c = net->wdmMRA.getXTalk(m); // c1*c2+c3*c4=c1*c3+c2*c4=0
574 
575  if(E/EE < 0.01) break; // ignore small PC
576 
577  _sse_cpf_ps(mam,_a00+mm); // store a00 for max pixel
578  _sse_cpf_ps(mAM,_a90+mm); // store a90 for max pixel
579  _sse_add_ps(_amp+mm,_m00); // update 00 PC
580  _sse_add_ps(_AMP+mm,_m90); // update 90 PC
581 
582  for(j=0; j<J; j++) {
583  n = int(c[0]+0.1);
584  if(ee[n]>Eo) {
585  ee[n] = _sse_rotsub_ps(_m00,c[1],_m90,c[2],_a00+n*f); // subtract PC from a00
586  ee[n]+= _sse_rotsub_ps(_m00,c[3],_m90,c[4],_a90+n*f); // subtract PC from a90
587  }
588  c += 7;
589  }
590  //cout<<" "<<ee[m]<<" "<<k<<" "<<E<<" "<<EE<<" "<<endl;
591  pp[m] = _sse_abs_ps(_amp+mm,_AMP+mm); // store PC energy
592  k++;
593  }
594 /*
595  cout<<"EE="<<EE<<endl;
596  EE = 0;
597  for(j=0; j<V; ++j) {
598  if(pp[j]>=0) EE += ee[j];
599  if(pp[j]>=0.) cout<<j<<"|"<<pp[j]<<"|"<<ee[j]<<" "; // find max pixel
600  }
601  cout<<"EE="<<EE<<endl;
602 */
603  return k;
604 }
605 
monster wdmMRA
list of pixel pointers for MRA
Definition: network.hh:651
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
virtual size_t defragment(double T, double F, TH2F *=NULL)
T - maximum time gap in seconds F - maximum frequency gap in Hz.
Definition: netcluster.cc:1294
static float _sse_abs_ps(__m128 *_a)
Definition: watsse.hh:137
#define NIFO
Definition: wat.hh:74
size_t write(const char *file, int app=0)
Definition: netcluster.cc:3008
float phi
Definition: netpixel.hh:117
int job_elapsed_min
Definition: cwb_net.C:738
double M
Definition: DrawEBHH.C:13
std::vector< netcluster > wc_List
Definition: network.hh:610
static void cpp_(float *&, float **)
Definition: network.hh:1118
std::vector< wavearray< float > > tdAmp
Definition: netpixel.hh:123
int n
Definition: cwb_net.C:28
static void _sse_zero_ps(__m128 *_p)
Definition: watsse.hh:44
wavearray< float > a_90
buffer for cluster sky 00 amplitude
Definition: network.hh:653
TString("c")
wavearray< double > fx
Definition: detector.hh:364
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<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ 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< pixdata > data
Definition: netpixel.hh:122
wavearray< double > get(char *name, size_t index=0, char atype='R', int type=1, bool=true)
param: string with parameter name param: index in the amplitude array, which define detector param: c...
Definition: netcluster.cc:2207
netpixel pix(nifo)
std::vector< netpixel * > pList
Definition: network.hh:650
netcluster * pwc
Definition: cwb_job_obj.C:38
wavearray< short > index
Definition: detector.hh:368
static float _sse_rotsub_ps(__m128 *_u, float c, __m128 *_v, float s, __m128 *_a)
Definition: watsse.hh:399
double getTheta(size_t i)
Definition: skymap.hh:224
size_t setcore(bool core, int id=0)
Definition: netcluster.cc:243
static void _sse_cpf_ps(float *a, __m128 *_p)
Definition: watsse.hh:307
int nevt
virtual size_t supercluster(char atype, double S, bool core)
param: statistic: E - excess power, L - likelihood param: selection threshold T for likelihood cluste...
Definition: netcluster.cc:808
size_t layers
Definition: netpixel.hh:112
int m
Definition: cwb_net.C:28
std::vector< vector_int > cList
Definition: netcluster.hh:397
int j
Definition: cwb_net.C:28
i drho i
long subNetCut(int lag, float subnet=0.6, float subcut=0.33, TH2F *hist=NULL)
Definition: network.cc:1014
std::vector< detector * > ifoList
Definition: network.hh:608
long subNetCut(network *net, int lag, float snc, TH2F *hist)
SUPERCLUSTER.
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
size_t wdmListSize()
Definition: network.hh:446
bool core
Definition: netpixel.hh:120
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:431
skymap nLikelihood
Definition: network.hh:622
#define nIFO
wavearray< float > pNRG
buffers for cluster residual energy
Definition: network.hh:655
virtual size_t size() const
Definition: wavearray.hh:145
size_t esize(int k=2)
Definition: netcluster.hh:153
jfile
Definition: cwb_job_obj.C:43
wavearray< double > xx
Definition: TestFrame1.C:11
int _sse_MRA_ps(network *net, float *amp, float *AMP, float Eo, int K)
int simulation
Definition: config.hh:199
double Fgap
Definition: config.hh:136
wavearray< double > hot[2]
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
xtalk getXTalk(int nLay1, size_t indx1, int nLay2, size_t indx2)
param: numbers of layers identifying the resolution of the first pixel param: TF map index of the fir...
Definition: monster.cc:351
i() int(T_cor *100))
float polarisation
Definition: netpixel.hh:119
wavearray< double > * getHoT()
param: no parameters
Definition: detector.hh:175
void setDelayIndex(double rate)
param: MDC log file
Definition: network.cc:2896
int ifactor
const int NIFO_MAX
Definition: wat.hh:22
int BATCH
Definition: config.hh:245
double * tmp
Definition: testWDM_5.C:31
wavearray< float > a_00
wdm multi-resolution analysis
Definition: network.hh:652
wavearray< double > fp
Definition: detector.hh:363
printf("total live time: non-zero lags = %10.1f \, liveTot)
int l
std::vector< vector_int > p_Ind
Definition: netcluster.hh:403
static void cpf_(float *&a, double **p)
Definition: network.hh:1104
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
static void pnt_(float **, float **, short **, int, int)
Definition: network.hh:1091
int k
void PrintElapsedTime(int job_elapsed_time, double cpu_time, TString info)
size_t cpf(const netcluster &, bool=false, int=0)
Definition: netcluster.cc:117
wavearray< int > index
Definition: network.hh:640
double acor
Definition: network.hh:585
size_t time
Definition: netpixel.hh:110
int size()
Definition: monster.hh:91
size_t loadTDampSSE(network &net, char c, size_t BATCH=10000, size_t LOUD=0)
Definition: netcluster.cc:3317
wavearray< double > lagShift
Definition: detector.hh:369
double e2or
Definition: network.hh:584
double e
TFile * ifile
size_t rateANA
Definition: test_config1.C:21
size_t size()
Definition: netcluster.hh:147
WSeries< double > ww
Definition: Regression_H1.C:33
netpixel * getPixel(size_t n, size_t i)
Definition: netcluster.hh:413
double subnet
Definition: config.hh:247
size_t events()
Definition: network.hh:329
int l_low
Definition: config.hh:155
double getPhi(size_t i)
Definition: skymap.hh:164
int job_elapsed_time
Definition: cwb_net.C:736
float ellipticity
Definition: netpixel.hh:118
static void _sse_add_ps(__m128 *_a, __m128 *_b)
Definition: watsse.hh:248
std::vector< int > sCuts
Definition: netcluster.hh:392
int LOUD
Definition: config.hh:246
float theta
Definition: netpixel.hh:116
double fabs(const Complex &x)
Definition: numpy.cc:55
size_t csize()
Definition: netcluster.hh:151
int gIFACTOR
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:439
static __m128 _sse_sum_ps(__m128 **_p)
Definition: watsse.hh:515
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
std::vector< clusterdata > cData
Definition: netcluster.hh:391
static void _sse_point_ps(__m128 **_p, float **p, short **m, int l, int n)
Definition: watsse.hh:502
static void _sse_mul_ps(__m128 *_a, float b)
Definition: watsse.hh:56
DataType_t * data
Definition: wavearray.hh:319
double Tgap
Definition: config.hh:134
wavearray< float > rNRG
buffer for cluster sky 90 amplitudes
Definition: network.hh:654
netcluster wc
const int nRES
Definition: revMonster.cc:7
Long_t id
int job_elapsed_hour
Definition: cwb_net.C:737
wavearray< short > skyMask
Definition: network.hh:641
static float _sse_maxE_ps(__m128 *_a, __m128 *_A)
Definition: watsse.hh:554
float rate
Definition: netpixel.hh:113
static void _sse_minSNE_ps(__m128 *_pE, __m128 **_pe, __m128 *_es)
Definition: watsse.hh:540
size_t read(const char *)
Definition: netcluster.cc:3115
static __m128 _sse_like4_ps(__m128 *_f, __m128 *_a, __m128 *_A)
Definition: watsse.hh:998
int job_elapsed_sec
Definition: cwb_net.C:739
virtual void resize(unsigned int)
Definition: wavearray.cc:463
double TFgap
Definition: config.hh:138
size_t psize(int k=2)
Definition: netcluster.hh:163
double netRHO
Definition: network.hh:597
size_t inRate
Definition: config.hh:132
static void _sse_dpf4_ps(__m128 *_Fp, __m128 *_Fx, __m128 *_fp, __m128 *_fx)
Definition: watsse.hh:631
int levelR
Definition: config.hh:152
bool scPlugin
Definition: config.hh:368
exit(0)
void clean()
Definition: netpixel.hh:99
void clear()
Definition: netcluster.hh:427