21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 58 cout <<
"-----> CWB_Plugin_QLWveto.C" << endl;
59 cout <<
"ifo " << ifo.Data() << endl;
60 cout <<
"type " << type << endl;
76 TList *files = (TList*)gROOT->GetListOfFiles();
85 while ((file=(TSystemFile*)
next())) {
86 fname = file->GetName();
88 if(fname.Contains(
"wave_")) {
89 froot=(TFile*)file;froot->cd();
91 outDump.ReplaceAll(
".root.tmp",
".txt");
96 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
100 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
104 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
108 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
109 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
110 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
117 cout <<
"CWB_Plugin_QLWveto.C -> " 118 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
124 cout <<
"-----> CWB_Plugin_QLWveto.C -> " 125 <<
" gIFACTOR : " << gIFACTOR << endl;
128 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
140 TList *files = (TList*)gROOT->GetListOfFiles();
147 while ((file=(TSystemFile*)
next())) {
148 fname = file->GetName();
150 if(fname.Contains(
"wave_")) {
151 froot=(TFile*)file;froot->cd();
153 outDump.ReplaceAll(
".root.tmp",
".txt");
158 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
162 cout <<
"CWB_Plugin_QLWveto.C : Error - output root file not found" << endl;
166 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
169 net_tree->SetBranchAddress(
"Qveto",Qveto);
170 net_tree->SetBranchAddress(
"Lveto",Lveto);
171 net_tree->SetBranchAddress(
"Wveto",Wveto);
175 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",2*cfg->
nIFO));
176 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
177 net_tree->Branch(
"Wveto",Wveto,TString::Format(
"Wveto[%i]/F",2));
181 for(
int k=0;
k<
K;
k++) {
183 id = NET->
getwc(
k)->
get(const_cast<char*>(
"ID"), 0,
'L', rate);
187 int ID = size_t(
id.data[
j]+0.5);
200 int idSize = pd->
RWFID.size();
203 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
204 if(wfIndex==-1)
continue;
207 cout << endl <<
"----------------------------------------------------------------" << endl;
209 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
210 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
212 cout <<
"Wveto : " <<
" Slope : " << Wveto[0] <<
" Correlation : " << Wveto[1] << endl << endl;
219 pwfREC[
n] = pd->
RWFP[wfIndex];
222 #ifdef PLOT_WHITENED_WAVEFORMS 234 cout <<
"Qveto : " << pd->
Name <<
" Qveto[R] = " << Qveto[
n]
235 <<
" Qveto[W] = " << Qveto[
n+
nIFO] << endl;
239 cout <<
"----------------------------------------------------------------" << endl;
249 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
250 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
258 for(
int i=0; i<3; i++)
fprintf(EVT->
fP,
"%f ",Lveto[i]);
262 for(
int i=0; i<2; i++)
fprintf(EVT->
fP,
"%f ",Wveto[i]);
286 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
309 if(
a[
i]>amax) {amax=
a[
i];imax=
i;}
326 if(abs(imax-
i)<=
NTHR) {
334 float Qveto = ein>0 ? eout/ein : 0.;
353 Lveto[0] = Lveto[1] = Lveto[2] = 0;
355 std::vector<int>* vint = &(pwc->
cList[cid-1]);
356 int V = vint->size();
367 for(
int n=0;
n<V;
n++) {
370 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
373 if(!pix->
core)
continue;
377 likePix += pow(pix->
getdata(
'S',
m),2);
378 likePix += pow(pix->
getdata(
'P',
m),2);
385 if(likePix>likeMax) {likeMax=likePix;freqMax=
freq;dfreqMax=
df;}
397 for(
int n=0;
n<V;
n++) {
399 if(!pix->
core)
continue;
403 likePix += pow(pix->
getdata(
'S',
m),2);
404 likePix += pow(pix->
getdata(
'P',
m),2);
410 if(
fabs(freq-freqMax)<=dfreqMax) {
412 fmean += likePix*
freq;
413 frms += likePix*freq*
freq;
417 fmean = fmean/likeLin;
418 frms = frms/likeLin-fmean*fmean;
419 frms = frms>0 ? sqrt(frms) : 0.;
421 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
429 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
435 #if defined PLOT_LIKELIHOOD 437 WTS.
plot(pwc, cid, nifo,
'L', 0, const_cast<char*>(
"COLZ"));
438 WTS.
canvas->Print(
"l_tfmap_scalogram.png");
456 Wveto[0] = Wveto[1] = 0;
458 std::vector<int>* vint = &(pwc->
cList[cid-1]);
459 int V = vint->size();
462 std::vector<double>
x;
463 std::vector<double>
y;
464 std::vector<double>
w;
467 for(
int j=0;
j<V;
j++) {
470 cout <<
"CWB_Plugin_QLWveto.C - Error : is enabled only for WDM (2G)" << endl;
486 double xcm, ycm, qxx, qyy, qxy, ew;
487 xcm = ycm = qxx = qyy = qxy = ew = 0;
498 qxx += (x[
i] - xcm)*(x[
i] - xcm)*w[
i];
499 qyy += (y[
i] - ycm)*(y[
i] - ycm)*w[
i];
500 qxy += (x[
i] - xcm)*(y[
i] - ycm)*w[
i];
503 double beta = qxy/qxx;
504 double alpha = ycm-beta*xcm;
505 double corr = qxy/sqrt(qxx*qyy);
507 double bandwidth = sqrt(qyy/ew);
513 Wveto[1] =
fabs(corr);
522 watplot PTS(const_cast<char*>(
"ptswrc"),200,20,800,500);
525 double tmin = wfREC->
start();
528 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0,
true, cfg->
fLow, cfg->
fHigh);
530 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0);
532 PTS.
graph[0]->SetLineWidth(1);
536 if(fft)
sprintf(label,
"%s",
"fft");
537 else sprintf(label,
"%s",
"time");
538 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
539 else sprintf(label,
"%s_%s",label,
"white");
545 cout <<
"write : " << fname << endl;
554 n = ifo->
IWFP.size();
555 for (
int i=0;
i<
n;
i++) {
562 n = ifo->
RWFP.size();
563 for (
int i=0;
i<
n;
i++) {
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
void setSLags(float *slag)
virtual void rate(double r)
wavearray< double > a(hp.size())
float GetQveto(wavearray< double > *wf)
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
std::vector< TGraph * > graph
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)
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)
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
virtual size_t size() const
void GetWveto(netcluster *pwc, int cid, int nifo, float *Wveto)
void output2G(TTree *, network *, size_t, int, double)
#define IMPORT(TYPE, VAR)
TIter next(twave->GetListOfBranches())
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
double fabs(const Complex &x)
netcluster * getwc(size_t n)
param: delay index
void ClearWaveforms(detector *ifo)
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)
void GetLveto(netcluster *pwc, int cid, int nifo, float *Lveto)
virtual void resize(unsigned int)