3 #pragma GCC system_header
10 #include "TObjArray.h"
11 #include "TObjString.h"
40 cout <<
"-----> CWB_Plugin_QLWveto.C" << endl;
41 cout <<
"ifo " << ifo.Data() << endl;
42 cout <<
"type " << type << endl;
58 TList *
files = (TList*)gROOT->GetListOfFiles();
67 while ((file=(TSystemFile*)
next())) {
68 fname = file->GetName();
70 if(fname.Contains(
"wave_")) {
71 froot=(TFile*)file;froot->cd();
73 outDump.ReplaceAll(
".root.tmp",
".txt");
78 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
82 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
86 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
90 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
91 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
92 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
99 cout <<
"CWB_Plugin_QLWveto.C -> "
100 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
106 cout <<
"-----> CWB_Plugin_QLWveto.C -> "
107 <<
" gIFACTOR : " << gIFACTOR << endl;
110 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
122 TList *
files = (TList*)gROOT->GetListOfFiles();
129 while ((file=(TSystemFile*)
next())) {
130 fname = file->GetName();
132 if(fname.Contains(
"wave_")) {
133 froot=(TFile*)file;froot->cd();
135 outDump.ReplaceAll(
".root.tmp",
".txt");
140 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
144 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
148 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
151 net_tree->SetBranchAddress(
"Qveto",Qveto);
152 net_tree->SetBranchAddress(
"Lveto",Lveto);
153 net_tree->SetBranchAddress(
"Wveto",Wveto);
157 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
158 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
159 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
163 for(
int k=0;
k<
K;
k++) {
169 int ID = size_t(
id.data[
j]+0.5);
182 int idSize = pd->
RWFID.size();
185 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
186 if(wfIndex==-1)
continue;
189 cout << endl <<
"----------------------------------------------------------------" << endl;
191 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
192 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
194 cout <<
"Wveto : " <<
" Slope : " << Wveto[0] <<
" Correlation : " << Wveto[1] << endl << endl;
201 pwfREC[
n] = pd->
RWFP[wfIndex];
204 #ifdef PLOT_WHITENED_WAVEFORMS
216 cout <<
"Qveto : " << pd->
Name <<
" Qveto[R] = " << Qveto[
n]
217 <<
" Qveto[W] = " << Qveto[
n+
nIFO] << endl;
221 cout <<
"----------------------------------------------------------------" << endl;
231 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
232 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
240 for(
int i=0; i<3; i++)
fprintf(EVT->
fP,
"%f ",Lveto[i]);
244 for(
int i=0; i<2; i++)
fprintf(EVT->
fP,
"%f ",Wveto[i]);
268 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
291 if(
a[
i]>amax) {amax=
a[
i];imax=
i;}
308 if(abs(imax-
i)<=
NTHR) {
316 float Qveto = ein>0 ? eout/ein : 0.;
335 Lveto[0] = Lveto[1] = Lveto[2] = 0;
337 std::vector<int>* vint = &(pwc->
cList[cid-1]);
338 int V = vint->size();
349 for(
int n=0;
n<V;
n++) {
352 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
355 if(!pix->
core)
continue;
359 likePix += pow(pix->
getdata(
'S',
m),2);
360 likePix += pow(pix->
getdata(
'P',
m),2);
367 if(likePix>likeMax) {likeMax=likePix;freqMax=freq;dfreqMax=
df;}
379 for(
int n=0;
n<V;
n++) {
381 if(!pix->
core)
continue;
385 likePix += pow(pix->
getdata(
'S',
m),2);
386 likePix += pow(pix->
getdata(
'P',
m),2);
392 if(
fabs(freq-freqMax)<=dfreqMax) {
394 fmean += likePix*freq;
395 frms += likePix*freq*freq;
399 fmean = fmean/likeLin;
400 frms = frms/likeLin-fmean*fmean;
401 frms = frms>0 ? sqrt(frms) : 0.;
403 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
411 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
417 #if defined PLOT_LIKELIHOOD
420 WTS.
canvas->Print(
"l_tfmap_scalogram.png");
438 Wveto[0] = Wveto[1] = 0;
440 std::vector<int>* vint = &(pwc->
cList[cid-1]);
441 int V = vint->size();
444 std::vector<double>
x;
445 std::vector<double>
y;
446 std::vector<double>
w;
449 for(
int j=0;
j<V;
j++) {
452 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
468 double xcm, ycm, qxx, qyy, qxy, ew;
469 xcm = ycm = qxx = qyy = qxy = ew = 0;
480 qxx += (x[
i] - xcm)*(x[
i] - xcm)*w[
i];
481 qyy += (y[
i] - ycm)*(y[
i] - ycm)*w[
i];
482 qxy += (x[
i] - xcm)*(y[
i] - ycm)*w[
i];
485 double beta = qxy/qxx;
486 double alpha = ycm-beta*xcm;
487 double corr = qxy/sqrt(qxx*qyy);
489 double bandwidth = sqrt(qyy/ew);
495 Wveto[1] =
fabs(corr);
507 double tmin = wfREC->
start();
514 PTS.
graph[0]->SetLineWidth(1);
518 if(fft)
sprintf(label,
"%s",
"fft");
519 else sprintf(label,
"%s",
"time");
520 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
521 else sprintf(label,
"%s_%s",label,
"white");
527 cout <<
"write : " << fname << endl;
536 n = ifo->
IWFP.size();
537 for (
int i=0;
i<
n;
i++) {
544 n = ifo->
RWFP.size();
545 for (
int i=0;
i<
n;
i++) {
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)
std::vector< wavearray< double > * > IWFP
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 ClearWaveforms(detector *ifo)
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)