21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 75 cout <<
"-----> CWB_Plugin_QLveto.C" << endl;
85 TList *files = (TList*)gROOT->GetListOfFiles();
94 while ((file=(TSystemFile*)
next())) {
95 fname = file->GetName();
97 if(fname.Contains(
"wave_")) {
98 froot=(TFile*)file;froot->cd();
100 outDump.ReplaceAll(
".root.tmp",
".txt");
105 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
109 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
113 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
117 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
118 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
121 bool qveto_exists=
false;
122 bool lveto_exists=
false;
123 TIter
next(net_tree->GetListOfBranches());
124 while ((branch=(TBranch*)
next())) {
125 if(
TString(
"Qveto").CompareTo(branch->GetName())==0) qveto_exists=
true;
126 if(
TString(
"Lveto").CompareTo(branch->GetName())==0) lveto_exists=
true;
129 if(!qveto_exists) net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
130 if(!lveto_exists) net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
137 cout <<
"CWB_Plugin_QLveto.C -> " 138 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
148 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
160 TList *files = (TList*)gROOT->GetListOfFiles();
167 while ((file=(TSystemFile*)
next())) {
168 fname = file->GetName();
170 if(fname.Contains(
"wave_")) {
171 froot=(TFile*)file;froot->cd();
173 outDump.ReplaceAll(
".root.tmp",
".txt");
178 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
182 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
186 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
189 net_tree->SetBranchAddress(
"Qveto",Qveto);
190 net_tree->SetBranchAddress(
"Lveto",Lveto);
194 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
195 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
199 for(
int k=0;
k<
K;
k++) {
201 id = NET->
getwc(
k)->
get(const_cast<char*>(
"ID"), 0,
'L', rate);
205 int ID = size_t(
id.data[
j]+0.5);
218 int idSize = pd->
RWFID.size();
221 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
222 if(wfIndex==-1)
continue;
225 cout << endl <<
"----------------------------------------------------------------" << endl;
228 Qveto[0]=Qveto[1]=1.e20;
235 pwfREC[
n] = pd->
RWFP[wfIndex];
238 #ifdef PLOT_WHITENED_WAVEFORMS 248 if(qveto<Qveto[0]) Qveto[0]=qveto;
249 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
251 Qfactor1[
n] = qfactor;
255 cout <<
"Qfactor1/2 : " << pd->
Name <<
" frequency[0] = " << EVT->
frequency[0] <<
" fpeak = " << fpeak
256 <<
" -> " << Qfactor1[
n] <<
" / " << Qfactor2[
n] << endl;
262 if(qveto<Qveto[0]) Qveto[0]=qveto;
263 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
265 cout <<
"Qveto : " << pd->
Name <<
" Qveto[0] = " << Qveto[0]
266 <<
" Qveto[1] = " << Qveto[1] << endl;
274 for(
int n=0;
n<
nIFO;
n++) Qveto[2]+=EVT->
sSNR[
n]*Qfactor1[
n];
278 for(
int n=0;
n<nIFO;
n++) Qveto[3]+=EVT->
sSNR[
n]*Qfactor2[
n];
280 cout <<
"Qveto :" <<
" Qveto[2] = " << Qveto[2]
281 <<
" Qveto[3] = " << Qveto[3] << endl;
283 std::vector<netpixel> vPIX;
289 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
290 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
291 cout <<
"----------------------------------------------------------------" << endl;
300 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
301 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
309 for(
int i=0; i<3; i++)
fprintf(EVT->
fP,
"%f ",Lveto[i]);
333 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
356 if(
a[
i]>amax) {amax=
a[
i];imax=
i;}
373 if(abs(imax-
i)<=
NTHR) {
381 Qveto = ein>0 ? eout/ein : 0.;
385 float R = (
a[imax-1]+
a[imax+1])/
a[imax]/2.;
405 Lveto[0] = Lveto[1] = Lveto[2] = 0;
407 std::vector<int>* vint = &(pwc->
cList[cid-1]);
408 int V = vint->size();
419 for(
int n=0;
n<V;
n++) {
422 cout <<
"CWB_Plugin_QLveto.C - Error : is enabled only for WDM (2G)" << endl;
425 if(!pix->
core)
continue;
429 likePix += pow(pix->
getdata(
'S',
m),2);
430 likePix += pow(pix->
getdata(
'P',
m),2);
437 if(likePix>likeMax) {likeMax=likePix;freqMax=
freq;dfreqMax=
df;}
449 for(
int n=0;
n<V;
n++) {
451 if(!pix->
core)
continue;
455 likePix += pow(pix->
getdata(
'S',
m),2);
456 likePix += pow(pix->
getdata(
'P',
m),2);
462 if(
fabs(freq-freqMax)<=dfreqMax) {
464 fmean += likePix*
freq;
465 frms += likePix*freq*
freq;
469 fmean = fmean/likeLin;
470 frms = frms/likeLin-fmean*fmean;
471 frms = frms>0 ? sqrt(frms) : 0.;
473 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
481 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
487 #if defined PLOT_LIKELIHOOD 489 WTS.
plot(pwc, cid, nifo,
'L', 0, const_cast<char*>(
"COLZ"));
490 WTS.
canvas->Print(
"l_tfmap_scalogram.png");
500 watplot PTS(const_cast<char*>(
"ptswrc"),200,20,800,500);
503 double tmin = wfREC->
start();
506 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0,
true, cfg->
fLow, cfg->
fHigh);
508 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0);
510 PTS.
graph[0]->SetLineWidth(1);
514 if(fft)
sprintf(label,
"%s",
"fft");
515 else sprintf(label,
"%s",
"time");
516 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
517 else sprintf(label,
"%s_%s",label,
"white");
523 cout <<
"write : " << fname << endl;
532 n = ifo->
IWFP.size();
533 for (
int i=0;
i<
n;
i++) {
540 n = ifo->
RWFP.size();
541 for (
int i=0;
i<
n;
i++) {
562 std::vector<netpixel> vPIX;
566 if(V>cfg->
BATCH)
return vPIX;
571 __m128* _xi = (__m128*) xi.
data;
572 __m128* _XI = (__m128*) XI.
data;
574 __m128* _aa = (__m128*) NET->
a_00.
data;
575 __m128* _AA = (__m128*) NET->
a_90.
data;
578 for(
int j=0;
j<V;
j++) {
583 if(ee>En) nPC++;
else ee=0.;
590 for(
int j=0;
j<V;
j++) {
592 vPIX.push_back(*pix);
610 if(V>cfg->
BATCH)
return;
611 for(
int j=0;
j<V;
j++) {
616 while(!vPIX->empty()) vPIX->pop_back();
617 vPIX->clear(); std::vector<netpixel>().swap(*vPIX);
643 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
647 double gmean, gsigma;
651 double xmin = gmean-3.0*gsigma;
652 double xmax = gmean+3.0*gsigma;
663 if(x[
i]>amax) {amax=x[
i];imax=
i;}
669 if(t>xmin && t<xmax) area+=x[
i]*
dt;
674 double qfactor = sigma*(TMath::TwoPi()*
frequency);
693 for(
int i=0;
i<
N;
i++) x[
i]*=ex[
i];
698 double df=(x.
rate()/(double)N)/2.;
701 for(
int i=0;
i<
N;
i+=2) {
703 double amp=x[
i]*x[
i]+x[
i+1]*x[
i+1];
704 if(amp>amax) {fmax=
freq;amax=amp;}
726 double* time =
new double[
N];
727 double* amp =
new double[
N];
729 for(
int i=0;
i<
N;
i++) {
733 TGraph
gr(N,time,amp);
737 TF1* gaus = (TF1*)gr.GetFunction(
"gaus");
739 mean = gaus->GetParameter(
"Mean");
740 sigma = gaus->GetParameter(
"Sigma");
773 double gmean, gsigma;
777 double xmin = gmean-3.0*gsigma;
778 double xmax = gmean+3.0*gsigma;
783 double* time =
new double[
N];
784 double* amp =
new double[
N];
787 for(
int i=0;
i<
N;
i++) {
792 TGraph
gr(N,time,amp);
796 TF1 *xgaus =
new TF1(
"xgaus",
"gaus",xmin,xmax);
797 if(fixAmax) xgaus->SetParLimits(0,amax*0.999,amax*1.001);
798 gr.Fit(
"xgaus",
"RQ");
800 mean = xgaus->GetParameter(
"Mean");
801 sigma = xgaus->GetParameter(
"Sigma");
wavearray< double > t(hp.size())
monster wdmMRA
list of pixel pointers for MRA
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
static float _sse_abs_ps(__m128 *_a)
void GetLveto(netcluster *pwc, int cid, int nifo, float *Lveto)
void setSLags(float *slag)
virtual void rate(double r)
wavearray< double > a(hp.size())
void ResetPCA(network *NET, CWB::config *cfg, netcluster *pwc, std::vector< netpixel > *vPIX, int ID)
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
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< wavearray< double > * > RWFP
int _sse_mra_ps(float *, float *, float, int)
std::vector< TGraph * > graph
WSeries< double > waveBand
std::vector< vector_int > cList
virtual void start(double s)
bool getMRAwave(size_t ID, size_t lag, char atype='S', int mode=0, bool tof=false)
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
std::vector< detector * > ifoList
std::vector< netpixel > DoPCA(network *NET, CWB::config *cfg, int lag, int id)
void dopen(const char *fname, char *mode, bool header=true)
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
double GetPeakFrequency(wavearray< double > *wf)
wavearray< float > pNRG
buffers for cluster residual energy
virtual size_t size() const
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
Float_t * frequency
GPS stop time of the cluster.
void output2G(TTree *, network *, size_t, int, double)
#define IMPORT(TYPE, VAR)
static wavearray< double > GetEnvelope(wavearray< double > *x)
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...
void ClearWaveforms(detector *ifo)
double GetQfactor(wavearray< double > *wf, double frequency, bool fixAmax)
wavearray< float > a_00
wdm multi-resolution analysis
TIter next(twave->GetListOfBranches())
std::vector< wavearray< double > * > IWFP
netpixel * getPixel(size_t n, size_t i)
FILE * fP
injected reconstructed xcor waveform
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)
netevent EVT(itree, nifo)
WSeries< double > waveForm
double fabs(const Complex &x)
Float_t * sSNR
data-signal correlation Xk*Sk
netcluster * getwc(size_t n)
param: delay index
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void GetQveto(wavearray< double > *wf, float &Qveto, float &Qfactor)
wavearray< float > rNRG
buffer for cluster sky 90 amplitudes
double factors[FACTORS_MAX]
void GetGaussFitPars2(wavearray< double > *wf, double &mean, double &sigma, bool fixAmax)
void GetGaussFitPars(wavearray< double > *wf, double &mean, double &sigma, bool doenv=true)
double getdata(char type='R', size_t n=0)
virtual void resize(unsigned int)
bool setdata(double a, char type='R', size_t n=0)