43 #pragma GCC system_header
48 #include "gwavearray.hh"
49 #include "regression.hh"
51 #include "TObjArray.h"
52 #include "TObjString.h"
89 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* net, WSeries<double>* x, TString ifo,
int type) {
93 if(type==CWB_PLUGIN_NETWORK) {
99 if(type==CWB_PLUGIN_IDATA_CONDITIONING) {
103 if(type==CWB_PLUGIN_ODATA_CONDITIONING) {
105 cout <<
"-----> CWB_Plugin_O3aDataConditioning.C ";
106 cout <<
"type " << type << endl;
109 if(TString(cfg->analysis)==
"1G") {
110 cout <<
"CWB_Plugin_O3aConditioning Error - this plugin works only with 2G" << endl;
116 for(
int n=0;
n<cfg->nIFO;
n++) {
117 if(ifo==net->ifoName[
n]) {
id=
n;
break;}
119 if(
id<0) {cout <<
"Plugin : Error - bad ifo id" << endl; gSystem->Exit(1);}
121 if(!
gOPT.ifo[
id])
return;
123 wavearray<double> u,v,
w,p,
q,
s,
c;
124 WSeries<double> ws, WS;
125 detector* pD = net->getifo(
id);
126 wavearray<double>* hot = pD->getHoT();
127 int M = int(hot->rate()/64+0.1);
128 WDM<double> wdm(
M,
M,6,10);
129 double edge = net->Edge;
131 ws.Forward(*hot,wdm);
135 for(
int i=0; i<u.size(); i++) {
136 u.data[i]=sqrt(
c.data[i]*
c.data[i]+
s.data[i]*
s.data[i]);
137 c.data[i]/=u.data[i]>0. ? u.data[i] : 1;
138 s.data[i]/=u.data[i]>0. ? u.data[i] : 1;
142 double T = v.stop()-v.start();
143 v.lprFilter(4.,0,0.,edge,1);
144 double um = u.median(edge*
R,(
T-edge)*
R);
145 double vm = v.median(edge*
R,(
T-edge)*
R);
149 for(
int i=0; i<u.size(); i++) {
150 if(v.data[i]<0.) v.data[i]=0.;
151 vr = u.data[i]-v.data[i];
152 aa = u.data[i]<2*um?(u.data[i]-um)/um:1.;
153 if(vr<0 || aa<0) aa = 0;
155 v.data[i] = u.data[i]-vr*aa;
156 w.data[i] = v.data[i]/u.data[i];
163 for(
int i=0; i<u.size(); i++) {
164 p.data[i] = 1-
w.data[i];
165 if(p.data[i]>0.9) p.data[i]=0.;
167 for(
int i=
n+
m; i<u.size()-
n-
m; i++) {
168 for(
int j=0; j<
m; j++) {
169 q.data[j] += p.data[i]*(p.data[i-j]+p.data[i+j]);
174 pD->nVAR.resize(u.size());
177 for(
int i=
m+1; i<u.size()-
m-1; i++) {
180 for(
int j=8; j<
m; j++) {
181 aa = p.data[i-j]; sm += aa*aa*
q.data[j];
182 aa = p.data[i+j]; sp += aa*aa*
q.data[j];
184 aa = sp<sm ? sm : sp;
188 if(
w.data[i]==0)
w.data[i]=1.e-16;
189 pD->nVAR.data[i] =
w.data[i];
192 c*=v; ws.putLayer(
c, 1);
193 s*=v; ws.putLayer(
s,-1);
195 ws.Inverse();
c = ws;
196 WS.Inverse(-2);
s = WS;
197 *hot =
c; *hot +=
s; *hot *= 0.5;
199 pD->nVAR.start(hot->start());
200 pD->nVAR.setlow(16.);
201 pD->nVAR.sethigh(48.);
223 TObjArray*
token = TString(
options).Tokenize(TString(
' '));
224 for(
int j=0;j<
token->GetEntries();j++){
226 TObjString* tok = (TObjString*)
token->At(j);
227 TString stok = tok->GetString();
229 if(stok.Contains(
"o3ac_ifo=")) {
230 TString o3ac_ifo=stok;
231 o3ac_ifo.Remove(0,o3ac_ifo.Last(
'=')+1);
232 if(o3ac_ifo==
"enable")
gOPT.ifo[n_ifo]=
true;
233 if(o3ac_ifo==
"disable")
gOPT.ifo[n_ifo]=
false;
234 if(n_ifo<(NIFO_MAX-1)) n_ifo++;
243 cout <<
"-----------------------------------------" << endl;
244 cout <<
"O3aConditioning config options " << endl;
245 cout <<
"-----------------------------------------" << endl << endl;
246 for(
int n=0;
n<cfg->nIFO;
n++) {
247 if(
gOPT.ifo[
n]==
true) cout <<
"O3aC_IFO " << cfg->ifo[
n] <<
" enabled" << endl;
248 if(
gOPT.ifo[
n]==
false) cout <<
"O3aC_IFO " << cfg->ifo[
n] <<
" disabled" << endl;
256 for(
int n=0;
n<cfg->nIFO;
n++) {
258 if(TString(net->ifoName[
n])==
"L1")
gOPT.ifo[
n]=
true;
259 if(TString(net->ifoName[
n])==
"H1")
gOPT.ifo[
n]=
true;
301 #pragma GCC system_header
306 #include "network.hh"
307 #include "wavearray.hh"
309 #include "TObjArray.h"
310 #include "TObjString.h"
312 #include "Toolbox.hh"
327 #define SETHR 1000000
344 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* net, WSeries<double>* x, TString ifo,
int type) {
354 if(type==CWB_PLUGIN_CONFIG) {
356 cout <<
"-----> CWB_Plugin_Gating.C" << endl;
360 if(type==CWB_PLUGIN_ICOHERENCE) {
363 cwb2G* gCWB2G; IMPORT(cwb2G*,gCWB2G)
364 double Tb = gCWB2G->GetSegBegin()-cfg->segEdge;
365 double Te = gCWB2G->GetSegEnd()+cfg->segEdge;
370 int nIFO = (gCWB2G->IsSingleDetector()) ? 1 : net->ifoListSize();
371 int size = net->getifo(0)->getHoT()->size();
372 double rate = net->getifo(0)->getHoT()->rate();
377 wavearray<double>* hot[NIFO_MAX];
378 for(
int n=0;
n<
nIFO;
n++) hot[
n] = net->getifo(
n)->getHoT();
386 int X = int(cfg->segEdge/dt+0.5);
387 int M = int(
TEDG/dt)+1;
388 int N = int(
TWIN/dt);
390 vector<waveSegment> glist;
391 wavearray<double> SE(
size);
392 wavearray<int> sVeto(
size);
399 for(
int j=0;j<N;j++) SE[N-1]+=pow(hot[
n]->
data[N-1-j],2);
400 for(
int i=N;i<
size;i++) {
402 SE[i] -= pow(hot[
n]->
data[i-N],2);
403 SE[i] += pow(hot[
n]->
data[i],2);
407 for(
int i=0;i<
size;i++) {
409 int is = i-
M>X ? i-
M : X;
411 for(
int k=is;k<es;k++) sVeto[k]=1;
415 sVeto[0]=0;sVeto[
size-1]=0;
416 for(
int i=0;i<
size-1;i++) sVeto[i]=sVeto[i+1]-sVeto[i];
421 for(
int i=0;i<
size;i++) {
422 if(sVeto[i]== 1) gseg.start = Tb+int(i*dt);
424 gseg.stop = Tb+int(i*dt+0.5);
426 glist.push_back(gseg);
433 for(
int j=gsize;j<glist.size();j++) {
434 cout << j <<
" -----> CWB_Plugin_Gating.C - " << net->getifo(
n)->Name <<
" gating time : start="
435 << glist[j].start <<
" stop=" << glist[j].stop <<
" len=" << glist[j].stop-glist[j].start << endl;
442 double gating_time = 0;
444 glist = CWB::Toolbox::unionSegments(glist);
445 gating_time = CWB::Toolbox::getTimeSegList(glist);
446 glist = CWB::Toolbox::invertSegments(glist);
447 net->segList = CWB::Toolbox::mergeSegLists(glist,net->segList);
450 cout<<
"-----> CWB_Plugin_Gating.C - gating time : " << gating_time << endl << endl;
454 sprintf(info,
"-GT:%g",gating_time);
455 gCWB2G->PrintAnalysisInfo(CWB_STAGE_COHERENCE,
"cwb2G::Coherence",info,
false);
498 #pragma GCC system_header
502 #include "network.hh"
503 #include "wavearray.hh"
505 #include "TObjArray.h"
506 #include "TObjString.h"
508 #include "TComplex.h"
511 #include "watplot.hh"
512 #include "gwavearray.hh"
526 double GetQfactor(wavearray<double>*
wf,
double frequency,
bool fixAmax);
528 void GetGaussFitPars(wavearray<double>*
wf,
double& mean,
double& sigma,
bool doenv=
true);
529 void GetGaussFitPars2(wavearray<double>*
wf,
double& mean,
double& sigma,
bool fixAmax);
531 void GetQveto(wavearray<double>*
wf,
float &Qveto,
float &Qfactor);
532 void GetLveto(netcluster* pwc,
int cid,
int nifo,
float* Lveto);
533 void PlotWaveform(TString ifo, wavearray<double>* wfREC,
534 CWB::config* cfg,
bool fft=
false,
bool strain=
false);
537 std::vector<netpixel>
DoPCA(
network* NET, CWB::config* cfg,
int lag,
int id);
538 void ResetPCA(
network* NET, CWB::config* cfg, netcluster* pwc, std::vector<netpixel>* vPIX,
int ID);
542 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* NET, WSeries<double>* x, TString ifo,
int type) {
555 if(type==CWB_PLUGIN_CONFIG) {
557 cout <<
"-----> CWB_Plugin_QLveto.C" << endl;
562 if(type==CWB_PLUGIN_ILIKELIHOOD) {
567 TList *files = (TList*)gROOT->GetListOfFiles();
570 int nIFO = NET->ifoListSize();
576 while ((file=(TSystemFile*)next())) {
577 fname = file->GetName();
579 if(
fname.Contains(
"wave_")) {
580 froot=(TFile*)file;froot->cd();
582 outDump.ReplaceAll(
".root.tmp",
".txt");
587 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
591 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
595 TTree* net_tree = (TTree *) froot->Get(
"waveburst");
597 EVT =
new netevent(
nIFO);
598 net_tree = EVT->setTree();
599 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
600 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
603 bool qveto_exists=
false;
604 bool lveto_exists=
false;
605 TIter next(net_tree->GetListOfBranches());
606 while ((branch=(TBranch*)next())) {
607 if(TString(
"Qveto").CompareTo(branch->GetName())==0) qveto_exists=
true;
608 if(TString(
"Lveto").CompareTo(branch->GetName())==0) lveto_exists=
true;
611 if(!qveto_exists) net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
612 if(!lveto_exists) net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
616 if(type==CWB_PLUGIN_OLIKELIHOOD) {
618 if(TString(cfg->analysis)!=
"2G") {
619 cout <<
"CWB_Plugin_QLveto.C -> "
620 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
625 int gIFACTOR=-1; IMPORT(
int,gIFACTOR)
630 float* gSLAGSHIFT=NULL; IMPORT(
float*,gSLAGSHIFT)
632 int nIFO = NET->ifoListSize();
635 wavearray<double>
id;
637 double factor = cfg->factors[gIFACTOR];
642 TList *files = (TList*)gROOT->GetListOfFiles();
649 while ((file=(TSystemFile*)next())) {
650 fname = file->GetName();
652 if(
fname.Contains(
"wave_")) {
653 froot=(TFile*)file;froot->cd();
655 outDump.ReplaceAll(
".root.tmp",
".txt");
660 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
664 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
668 TTree* net_tree = (TTree *) froot->Get(
"waveburst");
670 EVT =
new netevent(net_tree,
nIFO);
671 net_tree->SetBranchAddress(
"Qveto",Qveto);
672 net_tree->SetBranchAddress(
"Lveto",Lveto);
674 EVT =
new netevent(
nIFO);
675 net_tree = EVT->setTree();
676 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
677 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
679 EVT->setSLags(gSLAGSHIFT);
681 for(
int k=0; k<K; k++) {
683 id = NET->getwc(k)->get(
const_cast<char*
>(
"ID"), 0,
'L', rate);
685 for(
int j=0; j<(int)
id.
size(); j++) {
687 int ID = size_t(
id.
data[j]+0.5);
689 if(NET->getwc(k)->sCuts[ID-1]!=-1)
continue;
692 if(cfg->simulation==4) ofactor=-factor;
693 else if(cfg->simulation==3) ofactor=-gIFACTOR;
696 EVT->output2G(NULL,NET,ID,k,ofactor);
698 wavearray<double>** pwfREC =
new wavearray<double>*[
nIFO];
699 detector* pd = NET->getifo(0);
700 int idSize = pd->RWFID.size();
703 for (
int mm=0; mm<idSize; mm++)
if (pd->RWFID[mm]==ID) wfIndex=mm;
704 if(wfIndex==-1)
continue;
706 netcluster* pwc = NET->getwc(k);
707 cout << endl <<
"----------------------------------------------------------------" << endl;
710 Qveto[0]=Qveto[1]=1.e20;
711 double Qfactor1[NIFO_MAX];
712 double Qfactor2[NIFO_MAX];
717 pwfREC[
n] = pd->RWFP[wfIndex];
718 wavearray<double>* wfREC = pwfREC[
n];
720 #ifdef PLOT_WHITENED_WAVEFORMS
728 NET->getMRAwave(ID,k,
'S',0,
true);
729 GetQveto(&(pd->waveForm), qveto, qfactor);
730 if(qveto<Qveto[0]) Qveto[0]=qveto;
731 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
733 Qfactor1[
n] = qfactor;
735 Qfactor2[
n] =
GetQfactor(&(pd->waveForm), fpeak,
true);
737 cout <<
"Qfactor1/2 : " << pd->Name <<
" frequency[0] = " << EVT->frequency[0] <<
" fpeak = " << fpeak
738 <<
" -> " << Qfactor1[
n] <<
" / " << Qfactor2[
n] << endl;
742 NET->getMRAwave(ID,k,
'W',0,
true);
743 GetQveto(&(pd->waveBand), qveto, qfactor);
744 if(qveto<Qveto[0]) Qveto[0]=qveto;
745 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
747 cout <<
"Qveto : " << pd->Name <<
" Qveto[0] = " << Qveto[0]
748 <<
" Qveto[1] = " << Qveto[1] << endl;
756 for(
int n=0;
n<
nIFO;
n++) Qveto[2]+=EVT->sSNR[
n]*Qfactor1[
n];
757 Qveto[2]/=EVT->likelihood;
760 for(
int n=0;
n<
nIFO;
n++) Qveto[3]+=EVT->sSNR[
n]*Qfactor2[
n];
761 Qveto[3]/=EVT->likelihood;
762 cout <<
"Qveto :" <<
" Qveto[2] = " << Qveto[2]
763 <<
" Qveto[3] = " << Qveto[3] << endl;
765 std::vector<netpixel> vPIX;
766 if(cfg->pattern>0) vPIX =
DoPCA(NET, cfg, k, ID);
768 if(cfg->pattern>0)
ResetPCA(NET, cfg, pwc, &vPIX, ID);
771 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
772 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
773 cout <<
"----------------------------------------------------------------" << endl;
775 std::vector<int> sCuts = NET->getwc(k)->sCuts;
777 for(
int i=0; i<(int)sCuts.size(); i++)
if(i!=ID-1) NET->getwc(k)->sCuts[i]=1;
780 NET->getwc(k)->sCuts = sCuts;
782 if(cfg->dump) EVT->dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
783 EVT->output2G(net_tree,NET,ID,k,ofactor);
786 fprintf(EVT->fP,
"Qveto: ");
787 for(
int i=0; i<2*
nIFO; i++) fprintf(EVT->fP,
"%f ",Qveto[i]);
788 fprintf(EVT->fP,
"\n");
790 fprintf(EVT->fP,
"Lveto: ");
791 for(
int i=0; i<3; i++) fprintf(EVT->fP,
"%f ",Lveto[i]);
792 fprintf(EVT->fP,
"\n");
794 if(cfg->dump) EVT->dclose();
795 if(!cfg->cedDump) NET->getwc(k)->sCuts[ID-1]=1;
806 GetQveto(wavearray<double>*
wf,
float &Qveto,
float &Qfactor) {
808 wavearray<double> x = *
wf;;
813 x.resize(4*x.size());
815 for(
int j=xsize;j<x.size();j++) x[j]=0;
819 wavearray<double> a(x.size());
821 double dt = 1./x.rate();
824 for (
int i=1;i<x.size();i++) {
825 if(fabs(x[i])>xmax) xmax=fabs(x[i]);
837 for (
int i=1;i<
size;i++) {
838 if(a[i]>amax) {amax=a[i];imax=i;}
854 for (
int i=0;i<
size;i++) {
855 if(abs(imax-i)<=
NTHR) {
859 if(a[i]>amax/
ATHR) eout+=a[i]*a[i];
863 Qveto = ein>0 ? eout/ein : 0.;
867 float R = (a[imax-1]+a[imax+1])/a[imax]/2.;
868 Qfactor = sqrt(-pow(TMath::Pi(),2)/log(
R)/2.);
875 GetLveto(netcluster* pwc,
int cid,
int nifo,
float* Lveto) {
887 Lveto[0] = Lveto[1] = Lveto[2] = 0;
889 std::vector<int>* vint = &(pwc->cList[cid-1]);
890 int V = vint->size();
901 for(
int n=0;
n<V;
n++) {
902 netpixel* pix = pwc->getPixel(cid,
n);
903 if(pix->layers%2==0) {
904 cout <<
"CWB_Plugin_QLveto.C - Error : is enabled only for WDM (2G)" << endl;
907 if(!pix->core)
continue;
910 for(
int m=0;
m<nifo;
m++) {
911 likePix += pow(pix->getdata(
'S',
m),2);
912 likePix += pow(pix->getdata(
'P',
m),2);
915 double freq = pix->frequency*pix->rate/2.;
916 double df = pix->rate/2.;
919 if(likePix>likeMax) {likeMax=likePix;freqMax=freq;dfreqMax=df;}
931 for(
int n=0;
n<V;
n++) {
932 netpixel* pix = pwc->getPixel(cid,
n);
933 if(!pix->core)
continue;
936 for(
int m=0;
m<nifo;
m++) {
937 likePix += pow(pix->getdata(
'S',
m),2);
938 likePix += pow(pix->getdata(
'P',
m),2);
943 double freq = pix->frequency*pix->rate/2.;
944 if(fabs(freq-freqMax)<=dfreqMax) {
946 fmean += likePix*freq;
947 frms += likePix*freq*freq;
951 fmean = fmean/likeLin;
952 frms = frms/likeLin-fmean*fmean;
953 frms = frms>0 ? sqrt(frms) : 0.;
955 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
963 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
969 #if defined PLOT_LIKELIHOOD
970 watplot WTS(
const_cast<char*
>(
"wts"));
971 WTS.plot(pwc, cid, nifo,
'L', 0,
const_cast<char*
>(
"COLZ"));
972 WTS.canvas->Print(
"l_tfmap_scalogram.png");
980 CWB::config* cfg,
bool fft,
bool strain) {
982 watplot PTS(
const_cast<char*
>(
"ptswrc"),200,20,800,500);
985 double tmin = wfREC->start();
986 wfREC->start(wfREC->start()-tmin);
988 PTS.plot(wfREC,
const_cast<char*
>(
"ALP"), 1, 0, 0,
true, cfg->fLow, cfg->fHigh);
990 PTS.plot(wfREC,
const_cast<char*
>(
"ALP"), 1, 0, 0);
992 PTS.graph[0]->SetLineWidth(1);
993 wfREC->start(wfREC->start()+tmin);
1004 PTS.canvas->Print(
fname);
1005 cout <<
"write : " <<
fname << endl;
1014 n = ifo->IWFP.size();
1015 for (
int i=0;i<
n;i++) {
1016 wavearray<double>*
wf = (wavearray<double>*)ifo->IWFP[i];
1022 n = ifo->RWFP.size();
1023 for (
int i=0;i<
n;i++) {
1024 wavearray<double>*
wf = (wavearray<double>*)ifo->RWFP[i];
1031 std::vector<netpixel>
DoPCA(
network* NET, CWB::config* cfg,
int lag,
int id) {
1035 size_t nIFO = NET->ifoList.size();
1037 float En = 2*NET->acor*NET->acor*
nIFO;
1039 int size = NET->a_00.size();
1043 netcluster* pwc = NET->getwc(lag);
1044 std::vector<netpixel> vPIX;
1046 std::vector<int> pI = NET->wdmMRA.getXTalk(pwc,
id,
false);
1048 if(V>cfg->BATCH)
return vPIX;
1050 wavearray<float> xi(
size); xi=0;
1051 wavearray<float> XI(
size); XI=0;
1053 __m128* _xi = (__m128*) xi.data;
1054 __m128* _XI = (__m128*) XI.data;
1056 __m128* _aa = (__m128*) NET->a_00.data;
1057 __m128* _AA = (__m128*) NET->a_90.data;
1060 for(
int j=0; j<V; j++) {
1062 _sse_zero_ps(_xi+jf);
1063 _sse_zero_ps(_XI+jf);
1064 ee = _sse_abs_ps(_aa+jf,_AA+jf);
1065 if(ee>En) nPC++;
else ee=0.;
1066 NET->rNRG.data[j] = ee;
1067 NET->pNRG.data[j] = NET->rNRG.data[j];
1070 nPC = NET->_sse_mra_ps(xi.data,XI.data,En,nPC);
1072 for(
int j=0; j<V; j++) {
1073 pix = pwc->getPixel(
id,pI[j]);
1074 vPIX.push_back(*pix);
1076 ee = NET->pNRG.data[j];
1079 for(
int i=0; i<
nIFO; i++) {
1080 pix->setdata(
double(xi.data[j*NIFO+i]),
'S',i);
1081 pix->setdata(
double(XI.data[j*NIFO+i]),
'P',i);
1088 void ResetPCA(
network* NET, CWB::config* cfg, netcluster* pwc, std::vector<netpixel>* vPIX,
int ID) {
1090 std::vector<int> pI = NET->wdmMRA.getXTalk(pwc, ID,
false);
1092 if(V>cfg->BATCH)
return;
1093 for(
int j=0; j<V; j++) {
1094 netpixel* pix = pwc->getPixel(ID,pI[j]);
1098 while(!vPIX->empty()) vPIX->pop_back();
1099 vPIX->clear(); std::vector<netpixel>().swap(*vPIX);
1103 GetQfactor(wavearray<double>*
wf,
double frequency,
bool fixAmax) {
1117 wavearray<double> x = *
wf;;
1123 x.resize(4*x.size());
1125 for(
int j=xsize;j<x.size();j++) x[j]=0;
1129 double gmean, gsigma;
1133 double xmin = gmean-3.0*gsigma;
1134 double xmax = gmean+3.0*gsigma;
1137 x = CWB::mdc::GetEnvelope(&x);
1140 double dt = 1./x.rate();
1144 for (
int i=1;i<x.size();i++) {
1145 if(x[i]>amax) {amax=x[i];imax=i;}
1149 for (
int i=1;i<x.size();i++) {
1151 if(
t>xmin &&
t<xmax) area+=x[i]*dt;
1154 double sigma = area/amax/sqrt(2*TMath::Pi());
1156 double qfactor = sigma*(TMath::TwoPi()*frequency);
1172 wavearray<double> x = *
wf;
1173 wavearray<double> ex = CWB::mdc::GetEnvelope(&x);
1175 for(
int i=0;i<N;i++) x[i]*=ex[i];
1180 double df=(x.rate()/(double)N)/2.;
1183 for(
int i=0;i<N;i+=2) {
1185 double amp=x[i]*x[i]+x[i+1]*x[i+1];
1186 if(amp>amax) {fmax=freq;amax=amp;}
1193 GetGaussFitPars(wavearray<double>*
wf,
double& mean,
double& sigma,
bool doenv) {
1204 wavearray<double> x = doenv ? CWB::mdc::GetEnvelope(
wf) : *
wf;
1208 double* time =
new double[N];
1209 double* amp =
new double[N];
1210 double dt = 1./x.rate();
1211 for(
int i=0;i<N;i++) {
1215 TGraph
gr(N,time,amp);
1218 gr.Fit(
"gaus",
"q0");
1219 TF1* gaus = (TF1*)
gr.GetFunction(
"gaus");
1221 mean = gaus->GetParameter(
"Mean");
1222 sigma = gaus->GetParameter(
"Sigma");
1248 wavearray<double> x = CWB::mdc::GetEnvelope(
wf);
1252 wavearray<double> x2 = x;
1253 for(
int i=0;i<x.size();i++) x2[i]=x[i]*x[i];
1255 double gmean, gsigma;
1259 double xmin = gmean-3.0*gsigma;
1260 double xmax = gmean+3.0*gsigma;
1265 double* time =
new double[N];
1266 double* amp =
new double[N];
1267 double dt = 1./x.rate();
1269 for(
int i=0;i<N;i++) {
1272 if(fabs(x[i])>amax) amax=fabs(x[i]);
1274 TGraph
gr(N,time,amp);
1278 TF1 *xgaus =
new TF1(
"xgaus",
"gaus",xmin,xmax);
1279 if(fixAmax) xgaus->SetParLimits(0,amax*0.999,amax*1.001);
1280 gr.Fit(
"xgaus",
"RQ");
1282 mean = xgaus->GetParameter(
"Mean");
1283 sigma = xgaus->GetParameter(
"Sigma");
1313 #pragma GCC system_header
1318 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* net, WSeries<double>* x, TString ifo,
int type) {
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
sprintf(tag,"wave_%s", data_label)
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
void ReadUserOptions(TString options)
void PrintUserOptions(CWB::config *cfg)
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
std::vector< netpixel > DoPCA(network *NET, CWB::config *cfg, int lag, int id)
void ClearWaveforms(detector *ifo)
void GetLveto(netcluster *pwc, int cid, int nifo, float *Lveto)
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
void GetGaussFitPars2(wavearray< double > *wf, double &mean, double &sigma, bool fixAmax)
double GetQfactor(wavearray< double > *wf, double frequency, bool fixAmax)
void GetGaussFitPars(wavearray< double > *wf, double &mean, double &sigma, bool doenv=true)
void ResetPCA(network *NET, CWB::config *cfg, netcluster *pwc, std::vector< netpixel > *vPIX, int ID)
double GetPeakFrequency(wavearray< double > *wf)
void GetQveto(wavearray< double > *wf, float &Qveto, float &Qfactor)
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)