3 #pragma GCC system_header
10 #include "TObjArray.h"
11 #include "TObjString.h"
39 cout <<
"-----> CWB_Plugin_QLWveto.C" << endl;
40 cout <<
"ifo " << ifo.Data() << endl;
41 cout <<
"type " << type << endl;
57 TList *
files = (TList*)gROOT->GetListOfFiles();
66 while ((file=(TSystemFile*)
next())) {
67 fname = file->GetName();
69 if(fname.Contains(
"wave_")) {
70 froot=(TFile*)file;froot->cd();
72 outDump.ReplaceAll(
".root.tmp",
".txt");
77 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
81 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
85 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
89 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
90 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
91 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
98 cout <<
"CWB_Plugin_QLWveto.C -> "
99 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
105 cout <<
"-----> CWB_Plugin_QLWveto.C -> "
106 <<
" gIFACTOR : " << gIFACTOR << endl;
109 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
121 TList *
files = (TList*)gROOT->GetListOfFiles();
128 while ((file=(TSystemFile*)
next())) {
129 fname = file->GetName();
131 if(fname.Contains(
"wave_")) {
132 froot=(TFile*)file;froot->cd();
134 outDump.ReplaceAll(
".root.tmp",
".txt");
139 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
143 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
147 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
150 net_tree->SetBranchAddress(
"Qveto",Qveto);
151 net_tree->SetBranchAddress(
"Lveto",Lveto);
152 net_tree->SetBranchAddress(
"Wveto",Wveto);
156 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
157 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
158 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
162 for(
int k=0;
k<
K;
k++) {
168 int ID = size_t(
id.data[
j]+0.5);
181 int idSize = pd->
RWFID.size();
184 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
185 if(wfIndex==-1)
continue;
188 cout << endl <<
"----------------------------------------------------------------" << endl;
190 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
191 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
193 cout <<
"Wveto : " <<
" Slope : " << Wveto[0] <<
" Correlation : " << Wveto[1] << endl << endl;
200 pwfREC[
n] = pd->
RWFP[wfIndex];
203 #ifdef PLOT_WHITENED_WAVEFORMS
215 cout <<
"Qveto : " << pd->
Name <<
" Qveto[R] = " << Qveto[
n]
216 <<
" Qveto[W] = " << Qveto[
n+
nIFO] << endl;
218 cout <<
"----------------------------------------------------------------" << endl;
228 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
229 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
237 for(
int i=0; i<3; i++)
fprintf(EVT->
fP,
"%f ",Lveto[i]);
241 for(
int i=0; i<3; i++)
fprintf(EVT->
fP,
"%f ",Wveto[i]);
265 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
288 if(
a[
i]>amax) {amax=
a[
i];imax=
i;}
305 if(abs(imax-
i)<=
NTHR) {
313 float Qveto = ein>0 ? eout/ein : 0.;
332 Lveto[0] = Lveto[1] = Lveto[2] = 0;
334 std::vector<int>* vint = &(pwc->
cList[cid-1]);
335 int V = vint->size();
346 for(
int n=0;
n<V;
n++) {
349 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
352 if(!pix->
core)
continue;
356 likePix += pow(pix->
getdata(
'S',
m),2);
357 likePix += pow(pix->
getdata(
'P',
m),2);
364 if(likePix>likeMax) {likeMax=likePix;freqMax=freq;dfreqMax=
df;}
376 for(
int n=0;
n<V;
n++) {
378 if(!pix->
core)
continue;
382 likePix += pow(pix->
getdata(
'S',
m),2);
383 likePix += pow(pix->
getdata(
'P',
m),2);
389 if(
fabs(freq-freqMax)<=dfreqMax) {
391 fmean += likePix*freq;
392 frms += likePix*freq*freq;
396 fmean = fmean/likeLin;
397 frms = frms/likeLin-fmean*fmean;
398 frms = frms>0 ? sqrt(frms) : 0.;
400 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
408 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
414 #if defined PLOT_LIKELIHOOD
417 WTS.
canvas->Print(
"l_tfmap_scalogram.png");
435 Wveto[0] = Wveto[1] = Wveto[2] = Wveto[3] = Wveto[4] = 0;
437 std::vector<int>* vint = &(pwc->
cList[cid-1]);
438 int V = vint->size();
441 std::vector<double>
x;
442 std::vector<double>
y;
443 std::vector<double>
w;
446 for(
int j=0;
j<V;
j++) {
449 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
465 double xcm, ycm, qxx, qyy, qxy, ew;
466 xcm = ycm = qxx = qyy = qxy = ew = 0;
477 qxx += (x[
i] - xcm)*(x[
i] - xcm)*w[
i];
478 qyy += (y[
i] - ycm)*(y[
i] - ycm)*w[
i];
479 qxy += (x[
i] - xcm)*(y[
i] - ycm)*w[
i];
482 double beta = qxy/qxx;
483 double alpha = ycm-beta*xcm;
484 double corr = qxy/sqrt(qxx*qyy);
486 double bandwidth = sqrt(qyy/ew);
492 Wveto[1] =
fabs(corr);
504 double tmin = wfREC->
start();
511 PTS.
graph[0]->SetLineWidth(1);
515 if(fft)
sprintf(label,
"%s",
"fft");
516 else sprintf(label,
"%s",
"time");
517 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
518 else sprintf(label,
"%s_%s",label,
"white");
524 cout <<
"write : " << fname << endl;
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
virtual size_t size() const
void setSLags(float *slag)
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
virtual void rate(double r)
float GetQveto(wavearray< double > *wf)
wavearray< double > a(hp.size())
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
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
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
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)
void dopen(const char *fname, char *mode, bool header=true)
void output2G(TTree *, network *, size_t, int, double)
void GetLveto(netcluster *pwc, int cid, int nifo, float *Lveto)
#define IMPORT(TYPE, VAR)
TIter next(twave->GetListOfBranches())
void GetWveto(netcluster *pwc, int cid, int nifo, float *Wveto)
netpixel * getPixel(size_t n, size_t i)
FILE * fP
injected reconstructed xcor waveform
netevent EVT(itree, nifo)
WSeries< double > waveForm
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
double fabs(const Complex &x)
netcluster * getwc(size_t n)
param: delay index
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double factors[FACTORS_MAX]
double getdata(char type='R', size_t n=0)
virtual void resize(unsigned int)
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)