21 #pragma GCC system_header 29 #include "TObjArray.h" 30 #include "TObjString.h" 40 #define USE_LOCAL_SUBNETCUT // comment to use the builtin implementation of subNetCut 48 cout <<
"-----> CWB_Plugin_supercluster_bench.C" << endl;
49 cout <<
"ifo " << ifo.Data() << endl;
50 cout <<
"type " << type << endl;
59 cout <<
"type==CWB_PLUGIN_ISUPERCLUSTER" << endl;
65 void* gIFILE=NULL;
IMPORT(
void*,gIFILE)
66 cout <<
"-----> CWB_Plugin_wavegraph.C -> " <<
" gIFILE : " << gIFILE << endl;
67 TFile*
ifile = (TFile*)gIFILE;
71 cout <<
"-----> CWB_Plugin_wavegraph.C -> " <<
" gIFACTOR : " << gIFACTOR << endl;
89 for(
int j=0;
j<(
int)lags;
j++) {
94 if(ifile!=NULL) wc.
read(ifile,
"coherence",
"clusters",0,cycle);
95 else wc.
read(jfile,
"coherence",
"clusters",0,cycle);
98 for(
int i=nRES-1;
i>=0;
i--)
99 wc.
read(ifile,
"coherence",
"clusters",-1,cycle,rateANA>>(
i+cfg->
l_low));
101 for(
int i=nRES-1;
i>=0;
i--)
102 wc.
read(jfile,
"coherence",
"clusters",-1,cycle,rateANA>>(
i+cfg->
l_low));
104 if(!cfg->
simulation) cout<<
"process lag " <<cycle<<
" ..."<<endl;
105 cout<<
"loaded clusters|pixels: "<<wc.
csize()<<
"|"<<wc.
size()<<endl;
109 cout<<
"super clusters|pixels: "<<wc.
esize(0)<<
"|"<<wc.
psize(0)<<endl;
123 #ifdef USE_LOCAL_SUBNETCUT 129 PrintElapsedTime(bench.RealTime(),bench.CpuTime(),
"subNetCut : Processing Time - ");
131 double pfrac = ptot>0 ? double(psel)/double(ptot) : 0.;
132 cout<<
"selected pixels: "<<psel<<
", fraction: "<<pfrac<< endl;
133 if(count<10000)
break;
139 nnn += pwc->
psize(-1);
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";
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();
186 if(!net->
wc_List[lag].size())
return 0;
191 cout<<
"network::subNetCut(): invalid network.\n";
196 float Es = 2*net->
e2or;
197 float TH =
fabs(snc);
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.);
209 float Lm,Em,Am,Lo,Eo,Co,Lr,Er,ee,em,To;
210 float cc,aa,AA,rHo,stat,Ls,Ln,EE;
227 for(i=0; i<
NIFO; i++) {
244 std::vector<int>* vint;
254 cid = pwc->
get((
char*)
"ID", 0,
'S',0);
258 id = size_t(cid.
data[k]+0.1);
259 if(pwc->
sCuts[
id-1] != -2)
continue;
260 vint = &(pwc->
cList[
id-1]);
270 tsize = pix->
tdAmp[0].size();
271 if(!tsize || tsize&1) {
272 cout<<
"network::subNetCut() error: wrong pixel TD data\n";
276 V4 = V + (V%4 ? 4 - V%4 : 0);
280 std::vector<wavearray<float> > vtd;
281 std::vector<wavearray<float> > vTD;
282 std::vector<wavearray<float> > eTD;
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;
315 for(i=0; i<NIFO; i++) {
321 for(i=0; i<
NIFO; i++) {
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;
332 __m128* _aa = (__m128*) net->
a_00.
data;
333 __m128* _AA = (__m128*) net->
a_90.
data;
338 net->
pList.push_back(pix);
341 for(i=0; i<
nIFO; i++) {
342 xx[
i] = 1./pix->
data[
i].noiserms;
346 for(i=0; i<
nIFO; i++) {
347 nr.
data[j*NIFO+
i]=(float)xx[i]/sqrt(rms);
348 for(l=0; l<tsize; l++) {
350 AA = pix->
tdAmp[
i].data[l+tsize];
351 vtd[
i].data[l*V4+
j] = aa;
352 vTD[
i].data[l*V4+
j] = AA;
353 eTD[
i].data[l*V4+
j] = aa*aa+AA*AA;
368 stat=Lm=Em=Am=EE=0.; lm=Vm= -1;
372 for(l=lb; l<=le; l++) {
373 if(!mm[l] || l<0)
continue;
378 __m128 _E_o = _mm_setzero_ps();
379 __m128 _E_n = _mm_setzero_ps();
380 __m128 _E_s = _mm_setzero_ps();
381 __m128 _M_m = _mm_setzero_ps();
382 __m128* _rE = (__m128*) net->
rNRG.
data;
383 __m128* _pE = (__m128*) net->
pNRG.
data;
385 for(j=0; j<V4; j+=4) {
387 _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_rE,_En));
388 _M_m = _mm_add_ps(_M_m,_msk);
389 *_pE = _mm_mul_ps(*_rE,_msk);
390 _E_o = _mm_add_ps(_E_o,*_pE);
392 _E_s = _mm_add_ps(_E_s,*_pE);
393 _msk = _mm_and_ps(_1,_mm_cmpge_ps(*_pE++,_Es));
394 _E_n = _mm_add_ps(_E_n,_mm_mul_ps(*_rE++,_msk));
397 _mm_storeu_ps(vvv,_E_n);
398 Ln = vvv[0]+vvv[1]+vvv[2]+vvv[3];
399 _mm_storeu_ps(vvv,_E_o);
400 Eo = vvv[0]+vvv[1]+vvv[2]+vvv[3]+0.01;
401 _mm_storeu_ps(vvv,_E_s);
402 Ls = vvv[0]+vvv[1]+vvv[2]+vvv[3];
403 _mm_storeu_ps(vvv,_M_m);
404 m = 2*(vvv[0]+vvv[1]+vvv[2]+vvv[3])+0.01;
407 if((aa-m)/(aa+
m)<0.33)
continue;
409 net->
pnt_(v00, pa, ml, (
int)l, (
int)V4);
410 net->
pnt_(v90, pA, ml, (
int)l, (
int)V4);
411 float* pfp = fp.
data;
412 float* pfx = fx.
data;
419 net->
cpp_(p00,v00); net->
cpp_(p90,v90);
420 net->
cpf_(pfp,FP,l); net->
cpf_(pfx,FX,l);
428 __m128* _pp = (__m128*) am.
data;
429 __m128* _PP = (__m128*) AM.
data;
433 _pp = (__m128*) xi.
data;
434 _PP = (__m128*) XI.
data;
453 Ls += ee-em; Eo += ee;
454 if(ee-em>Es) Ln += ee;
457 size_t m4 = m + (m%4 ? 4 - m%4 : 0);
458 _E_n = _mm_setzero_ps();
460 for(j=0; j<m4; j+=4) {
464 _E_n = _mm_add_ps(_E_n,_E_s);
466 _mm_storeu_ps(vvv,_E_n);
468 Lo = vvv[0]+vvv[1]+vvv[2]+vvv[3];
469 AA = aa/(
fabs(aa)+
fabs(Eo-Lo)+2*m*(Eo-Ln)/Eo);
471 em =
fabs(Eo-Lo)+2*
m;
475 if(AA>stat && !mra) {
476 stat=AA; Lm=Lo; Em=Eo; Am=aa; lm=
l; Vm=
m; suball=ee; EE=em;
480 if(!mra && lm>=0) {mra=
true; le=lb=lm;
goto skyloop;}
482 pwc->
sCuts[
id-1] = -1;
483 pwc->
cData[
id-1].likenet = Lm;
484 pwc->
cData[
id-1].energy = Em;
487 pwc->
cData[
id-1].skyIndex = lm;
491 submra = Ls*Eo/(Eo-Ls);
492 submra/=
fabs(submra)+
fabs(Eo-Lo)+2*(m+6);
494 pwc->
p_Ind[
id-1].push_back(lm);
495 for(j=0; j<vint->size(); j++) {
506 rHo = sqrt(Lo*Lo/(Eo+2*m)/nIFO);
509 if(hist && rHo>net->
netRHO)
510 for(j=0;j<vint->size();j++) hist->Fill(suball,submra);
512 if(fmin(suball,submra)>TH && rHo>net->
netRHO) {
513 count += vint->size();
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));
521 else pwc->
sCuts[
id-1]=1;
555 for(j=0; j<V; ++j) if(ee[j]>Eo) pp[j]=0;
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;
566 for(j=0; j<V; ++j) if(ee[j]>ee[
m]) m=j;
567 if(ee[m]<=Eo)
break; mm = m*
f;
575 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)
size_t write(const char *file, int app=0)
std::vector< netcluster > wc_List
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<< "\ 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
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.
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
network ** net
NOISE_MDC_SIMULATION.
wavearray< float > pNRG
buffers for cluster residual energy
virtual size_t size() const
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
printf("total live time: non-zero lags = %10.1f \, liveTot)
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)