3 #pragma GCC system_header
11 #include "TObjArray.h"
12 #include "TObjString.h"
22 #define USE_LOCAL_SUBNETCUT // comment to use the builtin implementation of subNetCut
30 cout <<
"-----> CWB_Plugin_supercluster_bench.C" << endl;
31 cout <<
"ifo " << ifo.Data() << endl;
32 cout <<
"type " << type << endl;
41 cout <<
"type==CWB_PLUGIN_ISUPERCLUSTER" << endl;
47 void* gIFILE=NULL;
IMPORT(
void*,gIFILE)
48 cout <<
"-----> CWB_Plugin_wavegraph.C -> " <<
" gIFILE : " << gIFILE << endl;
49 TFile*
ifile = (TFile*)gIFILE;
53 cout <<
"-----> CWB_Plugin_wavegraph.C -> " <<
" gIFACTOR : " << gIFACTOR << endl;
71 for(
int j=0;
j<(
int)lags;
j++) {
76 if(ifile!=NULL) wc.
read(ifile,
"coherence",
"clusters",0,cycle);
77 else wc.
read(jfile,
"coherence",
"clusters",0,cycle);
80 for(
int i=nRES-1;
i>=0;
i--)
81 wc.
read(ifile,
"coherence",
"clusters",-1,cycle,rateANA>>(
i+cfg->
l_low));
83 for(
int i=nRES-1;
i>=0;
i--)
84 wc.
read(jfile,
"coherence",
"clusters",-1,cycle,rateANA>>(
i+cfg->
l_low));
86 if(!cfg->
simulation) cout<<
"process lag " <<cycle<<
" ..."<<endl;
87 cout<<
"loaded clusters|pixels: "<<wc.
csize()<<
"|"<<wc.
size()<<endl;
91 cout<<
"super clusters|pixels: "<<wc.
esize(0)<<
"|"<<wc.
psize(0)<<endl;
105 #ifdef USE_LOCAL_SUBNETCUT
111 PrintElapsedTime(bench.RealTime(),bench.CpuTime(),
"subNetCut : Processing Time - ");
113 double pfrac = ptot>0 ? double(psel)/double(ptot) : 0.;
114 cout<<
"selected pixels: "<<psel<<
", fraction: "<<pfrac<< endl;
115 if(count<10000)
break;
121 nnn += pwc->
psize(-1);
124 if(mmm) cout<<
"events in the buffer: "<<net->
events()<<
"|"<<nnn<<
"|"<<nnn/double(mmm)<<
"\n";
125 else cout<<
"events in the buffer: "<<net->
events()<<
"\n";
128 pwc->
write(jfile,
"supercluster",
"clusters",0,cycle);
129 pwc->
write(jfile,
"supercluster",
"clusters",-1,cycle);
130 cout<<cycle<<
"|"<<pwc->
csize()<<
"|"<<pwc->
size()<<
" ";cout.flush();
168 if(!net->
wc_List[lag].size())
return 0;
173 cout<<
"network::subNetCut(): invalid network.\n";
178 float Es = 2*net->
e2or;
179 float TH =
fabs(snc);
181 __m128 _En = _mm_set1_ps(En);
182 __m128 _Es = _mm_set1_ps(Es);
183 __m128 _oo = _mm_set1_ps(1.
e-12);
184 __m128 _0 = _mm_set1_ps(0.);
185 __m128 _05 = _mm_set1_ps(0.5);
186 __m128 _1 = _mm_set1_ps(1.);
191 float Lm,Em,Am,Lo,Eo,Co,Lr,Er,ee,em,To;
192 float cc,aa,AA,rHo,stat,Ls,Ln,EE;
209 for(i=0; i<
NIFO; i++) {
226 std::vector<int>* vint;
236 cid = pwc->
get((
char*)
"ID", 0,
'S',0);
240 id = size_t(cid.
data[k]+0.1);
241 if(pwc->
sCuts[
id-1] != -2)
continue;
242 vint = &(pwc->
cList[
id-1]);
252 tsize = pix->
tdAmp[0].size();
253 if(!tsize || tsize&1) {
254 cout<<
"network::subNetCut() error: wrong pixel TD data\n";
258 V4 = V + (V%4 ? 4 - V%4 : 0);
262 std::vector<wavearray<float> > vtd;
263 std::vector<wavearray<float> > vTD;
264 std::vector<wavearray<float> > eTD;
283 __m128* _Fp = (__m128*) Fp.
data;
284 __m128* _Fx = (__m128*) Fx.
data;
285 __m128* _am = (__m128*) am.
data;
286 __m128* _AM = (__m128*) AM.
data;
287 __m128* _xi = (__m128*) xi.
data;
288 __m128* _XI = (__m128*) XI.
data;
289 __m128* _fp = (__m128*) fp.
data;
290 __m128* _fx = (__m128*) fx.
data;
291 __m128* _nr = (__m128*) nr.
data;
292 __m128* _ww = (__m128*) ww.
data;
293 __m128* _WW = (__m128*) WW.
data;
294 __m128* _bb = (__m128*) bb.
data;
295 __m128* _BB = (__m128*) BB.
data;
297 for(i=0; i<NIFO; i++) {
303 for(i=0; i<
NIFO; i++) {
304 pa[
i] = vtd[
i].data + (tsize/2)*V4;
305 pA[
i] = vTD[
i].data + (tsize/2)*V4;
306 pe[
i] = eTD[
i].data + (tsize/2)*V4;
314 __m128* _aa = (__m128*) net->
a_00.
data;
315 __m128* _AA = (__m128*) net->
a_90.
data;
320 net->
pList.push_back(pix);
323 for(i=0; i<
nIFO; i++) {
324 xx[
i] = 1./pix->
data[
i].noiserms;
328 for(i=0; i<
nIFO; i++) {
329 nr.
data[j*NIFO+
i]=(float)xx[i]/sqrt(rms);
330 for(l=0; l<tsize; l++) {
332 AA = pix->
tdAmp[
i].data[l+tsize];
333 vtd[
i].data[l*V4+
j] = aa;
334 vTD[
i].data[l*V4+
j] = AA;
335 eTD[
i].data[l*V4+
j] = aa*aa+AA*AA;
350 stat=Lm=Em=Am=EE=0.; lm=Vm= -1;
354 for(l=lb; l<=le; l++) {
355 if(!mm[l] || l<0)
continue;
360 __m128 _E_o = _mm_setzero_ps();
361 __m128 _E_n = _mm_setzero_ps();
362 __m128 _E_s = _mm_setzero_ps();
363 __m128 _M_m = _mm_setzero_ps();
364 __m128* _rE = (__m128*) net->
rNRG.
data;
365 __m128* _pE = (__m128*) net->
pNRG.
data;
367 for(j=0; j<V4; j+=4) {
369 _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_rE,_En));
370 _M_m = _mm_add_ps(_M_m,_msk);
371 *_pE = _mm_mul_ps(*_rE,_msk);
372 _E_o = _mm_add_ps(_E_o,*_pE);
374 _E_s = _mm_add_ps(_E_s,*_pE);
375 _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_pE++,_Es));
376 _E_n = _mm_add_ps(_E_n,_mm_mul_ps(*_rE++,_msk));
379 _mm_storeu_ps(vvv,_E_n);
380 Ln = vvv[0]+vvv[1]+vvv[2]+vvv[3];
381 _mm_storeu_ps(vvv,_E_o);
382 Eo = vvv[0]+vvv[1]+vvv[2]+vvv[3]+0.01;
383 _mm_storeu_ps(vvv,_E_s);
384 Ls = vvv[0]+vvv[1]+vvv[2]+vvv[3];
385 _mm_storeu_ps(vvv,_M_m);
386 m = 2*(vvv[0]+vvv[1]+vvv[2]+vvv[3])+0.01;
389 if((aa-m)/(aa+
m)<0.33)
continue;
391 net->
pnt_(v00, pa, ml, (
int)l, (
int)V4);
392 net->
pnt_(v90, pA, ml, (
int)l, (
int)V4);
393 float* pfp = fp.
data;
394 float* pfx = fx.
data;
401 net->
cpp_(p00,v00); net->
cpp_(p90,v90);
402 net->
cpf_(pfp,FP,l); net->
cpf_(pfx,FX,l);
410 __m128* _pp = (__m128*) am.
data;
411 __m128* _PP = (__m128*) AM.
data;
415 _pp = (__m128*) xi.
data;
416 _PP = (__m128*) XI.
data;
435 Ls += ee-em; Eo += ee;
436 if(ee-em>Es) Ln += ee;
439 size_t m4 = m + (m%4 ? 4 - m%4 : 0);
440 _E_n = _mm_setzero_ps();
442 for(j=0; j<m4; j+=4) {
446 _E_n = _mm_add_ps(_E_n,_E_s);
448 _mm_storeu_ps(vvv,_E_n);
450 Lo = vvv[0]+vvv[1]+vvv[2]+vvv[3];
451 AA = aa/(
fabs(aa)+
fabs(Eo-Lo)+2*m*(Eo-Ln)/Eo);
453 em =
fabs(Eo-Lo)+2*
m;
457 if(AA>stat && !mra) {
458 stat=AA; Lm=Lo; Em=Eo; Am=aa; lm=
l; Vm=
m; suball=ee; EE=em;
462 if(!mra && lm>=0) {mra=
true; le=lb=lm;
goto skyloop;}
464 pwc->
sCuts[
id-1] = -1;
465 pwc->
cData[
id-1].likenet = Lm;
466 pwc->
cData[
id-1].energy = Em;
469 pwc->
cData[
id-1].skyIndex = lm;
473 submra = Ls*Eo/(Eo-Ls);
474 submra/=
fabs(submra)+
fabs(Eo-Lo)+2*(m+6);
476 pwc->
p_Ind[
id-1].push_back(lm);
477 for(j=0; j<vint->size(); j++) {
488 rHo = sqrt(Lo*Lo/(Eo+2*m)/nIFO);
491 if(hist && rHo>net->
netRHO)
492 for(j=0;j<vint->size();j++) hist->Fill(suball,submra);
494 if(fmin(suball,submra)>TH && rHo>net->
netRHO) {
495 count += vint->size();
497 printf(
"lag|id %3d|%3d rho=%5.2f To=%5.1f stat: %5.3f|%5.3f|%5.3f ",
498 int(lag),
int(
id),rHo,To,suball,submra,stat);
499 printf(
"E: %6.1f|%6.1f L: %6.1f|%6.1f|%6.1f pix: %4d|%4d|%3d|%2d \n",
500 Em,Eo,Lm,Lo,Ls,
int(vint->size()),
int(V),Vm,
int(m));
503 else pwc->
sCuts[
id-1]=1;
537 for(j=0; j<V; ++j) if(ee[j]>Eo) pp[j]=0;
539 __m128* _m00 = (__m128*) mam;
540 __m128* _m90 = (__m128*) mAM;
541 __m128* _amp = (__m128*) amp;
542 __m128* _AMP = (__m128*) AMP;
543 __m128* _a00 = (__m128*) net->
a_00.
data;
544 __m128* _a90 = (__m128*) net->
a_90.
data;
548 for(j=0; j<V; ++j) if(ee[j]>ee[
m]) m=j;
549 if(ee[m]<=Eo)
break; mm = m*
f;
557 if(E/EE < 0.01)
break;
monster wdmMRA
list of pixel pointers for MRA
detector * getifo(size_t n)
param: detector index
virtual size_t defragment(double T, double F, TH2F *=NULL)
T - maximum time gap in seconds F - maximum frequency gap in Hz.
static float _sse_abs_ps(__m128 *_a)
virtual size_t size() const
size_t write(const char *file, int app=0)
std::vector< netcluster > wc_List
printf("total live time: non-zero lags = %10.1f \n", liveTot)
static void cpp_(float *&, float **)
std::vector< wavearray< float > > tdAmp
static void _sse_zero_ps(__m128 *_p)
wavearray< float > a_90
buffer for cluster sky 00 amplitude
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< pixdata > data
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...
std::vector< netpixel * > pList
static float _sse_rotsub_ps(__m128 *_u, float c, __m128 *_v, float s, __m128 *_a)
double getTheta(size_t i)
size_t setcore(bool core, int id=0)
static void _sse_cpf_ps(float *a, __m128 *_p)
virtual size_t supercluster(char atype, double S, bool core)
param: statistic: E - excess power, L - likelihood param: selection threshold T for likelihood cluste...
std::vector< vector_int > cList
long subNetCut(int lag, float subnet=0.6, float subcut=0.33, TH2F *hist=NULL)
std::vector< detector * > ifoList
long subNetCut(network *net, int lag, float snc, TH2F *hist)
SUPERCLUSTER.
network ** net
NOISE_MDC_SIMULATION.
wavearray< float > pNRG
buffers for cluster residual energy
int _sse_MRA_ps(network *net, float *amp, float *AMP, float Eo, int K)
wavearray< double > hot[2]
#define IMPORT(TYPE, VAR)
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...
wavearray< double > * getHoT()
param: no parameters
void setDelayIndex(double rate)
param: MDC log file
wavearray< float > a_00
wdm multi-resolution analysis
std::vector< vector_int > p_Ind
static void cpf_(float *&a, double **p)
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)
void PrintElapsedTime(int job_elapsed_time, double cpu_time, TString info)
size_t cpf(const netcluster &, bool=false, int=0)
size_t loadTDampSSE(network &net, char c, size_t BATCH=10000, size_t LOUD=0)
wavearray< double > lagShift
netpixel * getPixel(size_t n, size_t i)
static void _sse_add_ps(__m128 *_a, __m128 *_b)
double fabs(const Complex &x)
netcluster * getwc(size_t n)
param: delay index
static __m128 _sse_sum_ps(__m128 **_p)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
std::vector< clusterdata > cData
static void _sse_point_ps(__m128 **_p, float **p, short **m, int l, int n)
static void _sse_mul_ps(__m128 *_a, float b)
wavearray< float > rNRG
buffer for cluster sky 90 amplitudes
wavearray< short > skyMask
static float _sse_maxE_ps(__m128 *_a, __m128 *_A)
static void _sse_minSNE_ps(__m128 *_pE, __m128 **_pe, __m128 *_es)
size_t read(const char *)
static __m128 _sse_like4_ps(__m128 *_f, __m128 *_a, __m128 *_A)
virtual void resize(unsigned int)
static void _sse_dpf4_ps(__m128 *_Fp, __m128 *_Fx, __m128 *_fp, __m128 *_fx)