21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 55 cout <<
"-----> CWB_Plugin_Qveto.C" << endl;
56 cout <<
"ifo " << ifo.Data() << endl;
57 cout <<
"type " << type << endl;
72 TList *files = (TList*)gROOT->GetListOfFiles();
81 while ((file=(TSystemFile*)
next())) {
82 fname = file->GetName();
84 if(fname.Contains(
"wave_")) {
85 froot=(TFile*)file;froot->cd();
87 outDump.ReplaceAll(
".root.tmp",
".txt");
92 cout <<
"CWB_Plugin_Qveto.C : Error - output root file not found" << endl;
96 cout <<
"CWB_Plugin_Qveto.C : Error - output root file not found" << endl;
100 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
104 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",cfg->
nIFO));
105 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
112 cout <<
"CWB_Plugin_Qveto.C -> " 113 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
119 cout <<
"-----> CWB_Plugin_Qveto.C -> " 120 <<
" gIFACTOR : " << gIFACTOR << endl;
123 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
135 TList *files = (TList*)gROOT->GetListOfFiles();
142 while ((file=(TSystemFile*)
next())) {
143 fname = file->GetName();
145 if(fname.Contains(
"wave_")) {
146 froot=(TFile*)file;froot->cd();
148 outDump.ReplaceAll(
".root.tmp",
".txt");
153 cout <<
"CWB_Plugin_Qveto.C : Error - output root file not found" << endl;
157 cout <<
"CWB_Plugin_Qveto.C : Error - output root file not found" << endl;
161 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
164 net_tree->SetBranchAddress(
"Qveto",Qveto);
165 net_tree->SetBranchAddress(
"Lveto",Lveto);
169 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",cfg->
nIFO));
170 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
174 for(
int k=0;
k<
K;
k++) {
176 id = NET->
getwc(
k)->
get(const_cast<char*>(
"ID"), 0,
'L', rate);
180 int ID = size_t(
id.data[
j]+0.5);
193 int idSize = pd->
RWFID.size();
196 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
197 if(wfIndex==-1)
continue;
200 cout << endl <<
"----------------------------------------------------------------" << endl;
202 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
203 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
210 pwfREC[
n] = pd->
RWFP[wfIndex];
213 #ifdef PLOT_WHITENED_WAVEFORMS 219 cout <<
"Qveto : " << pd->
Name <<
" Qveto = " << Qveto[
n] << 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]);
264 for(
int j=xsize;
j<x.
size();
j++) x[
j]=0;
287 if(
a[
i]>amax) {amax=
a[
i];imax=
i;}
304 if(abs(imax-
i)<=
NTHR) {
312 float Qveto = ein>0 ? eout/ein : 0.;
331 Lveto[0] = Lveto[1] = Lveto[2] = 0;
333 std::vector<int>* vint = &(pwc->
cList[cid-1]);
334 int V = vint->size();
345 for(
int n=0;
n<V;
n++) {
348 cout <<
"CWB_Plugin_Qveto.C - Error : is enabled only for WDM (2G)" << endl;
351 if(!pix->
core)
continue;
355 likePix += pow(pix->
getdata(
'S',
m),2);
356 likePix += pow(pix->
getdata(
'P',
m),2);
363 if(likePix>likeMax) {likeMax=likePix;freqMax=
freq;dfreqMax=
df;}
375 for(
int n=0;
n<V;
n++) {
377 if(!pix->
core)
continue;
381 likePix += pow(pix->
getdata(
'S',
m),2);
382 likePix += pow(pix->
getdata(
'P',
m),2);
388 if(
fabs(freq-freqMax)<=dfreqMax) {
390 fmean += likePix*
freq;
391 frms += likePix*freq*
freq;
395 fmean = fmean/likeLin;
396 frms = frms/likeLin-fmean*fmean;
397 frms = frms>0 ? sqrt(frms) : 0.;
399 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
407 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
413 #if defined PLOT_LIKELIHOOD 415 WTS.
plot(pwc, cid, nifo,
'L', 0, const_cast<char*>(
"COLZ"));
416 WTS.
canvas->Print(
"l_tfmap_scalogram.png");
426 watplot PTS(const_cast<char*>(
"ptswrc"),200,20,800,500);
429 double tmin = wfREC->
start();
432 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0,
true, cfg->
fLow, cfg->
fHigh);
434 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0);
436 PTS.
graph[0]->SetLineWidth(1);
440 if(fft)
sprintf(label,
"%s",
"fft");
441 else sprintf(label,
"%s",
"time");
442 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
443 else sprintf(label,
"%s_%s",label,
"white");
449 cout <<
"write : " << fname << endl;
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
void setSLags(float *slag)
virtual void rate(double r)
wavearray< double > a(hp.size())
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...
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)
std::vector< wavearray< double > * > RWFP
std::vector< TGraph * > graph
std::vector< vector_int > cList
virtual void start(double s)
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())
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
virtual size_t size() const
void output2G(TTree *, network *, size_t, int, double)
#define IMPORT(TYPE, VAR)
TIter next(twave->GetListOfBranches())
netpixel * getPixel(size_t n, size_t i)
FILE * fP
injected reconstructed xcor waveform
netevent EVT(itree, nifo)
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)
float GetQveto(wavearray< double > *wf)
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)