43 #pragma GCC system_header
50 #include "TObjArray.h"
51 #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_CONFIG) {
94 gULAG = (cfg->lagSize) ?
true :
false;
97 if(type==CWB_PLUGIN_NETWORK) {
103 if(type==CWB_PLUGIN_INIT_JOB) {
105 if(!
gOPT.enabled)
return;
108 cout <<
"-----> CWB_Plugin_UniqueLags.C ";
109 cout <<
"type " << type << endl;
114 for(
int n=0;
n<cfg->nIFO;
n++) {
115 if(ifo==net->ifoName[
n]) {
id=
n;
break;}
119 if(cfg->simulation) {cout <<
"CWB_Plugin_UniqueLags.C : Error - works only for background" << endl; gSystem->Exit(1);}
120 if(cfg->nIFO<2 || cfg->nIFO>4) {cout <<
"CWB_Plugin_UniqueLags.C : Error - implemented only for 2/3/4 ifos network" << endl; gSystem->Exit(1);}
122 cwb2G* gCWB2G; IMPORT(cwb2G*,gCWB2G)
124 TArrayC* lagBuffer = &(gCWB2G->lagBuffer);
126 double segLen = gCWB2G->GetSegEnd()-gCWB2G->GetSegBegin();
143 cout << endl <<
"CWB_Plugin_UniqueLags.C : segLen -> " <<
segLen <<
" lagMax " <<
lagMax <<
" lagSize " <<
lagSize << endl << endl;
146 std::stringstream buffer;
147 std::streambuf * old = std::cout.rdbuf(buffer.rdbuf());
151 cout << 0 <<
"\t" << 0 <<
"\t" << 0 << endl;
152 std::vector<int> v[1];
156 cout << i <<
"\t" << lag0 <<
"\t" << lag1 << endl;
157 v[0].push_back(lag1-lag0);
159 for(
int k=0;k<1;k++) {
160 sort(v[k].begin(), v[k].end());
161 auto it = std::unique(v[k].begin(), v[k].end());
162 if(!(it == v[k].end())) {cout <<
"CWB_Plugin_UniqueLags.C : Error - Duplicate Lags" << endl; gSystem->Exit(1);}
166 cout << 0 <<
"\t" << 0 <<
"\t" << 0 <<
"\t" << 0 << endl;
167 std::vector<int> v[3];
172 cout << i <<
"\t" << lag0 <<
"\t" << lag1 <<
"\t" << lag2 << endl;
173 v[0].push_back(lag1-lag0);
174 v[1].push_back(lag2-lag0); v[2].push_back(lag2-lag1);
176 for(
int k=0;k<3;k++) {
177 sort(v[k].begin(), v[k].end());
178 auto it = std::unique(v[k].begin(), v[k].end());
179 if(!(it == v[k].end())) {cout <<
"CWB_Plugin_UniqueLags.C : Error - Duplicate Lags" << endl; gSystem->Exit(1);}
183 cout << 0 <<
"\t" << 0 <<
"\t" << 0 <<
"\t" << 0 <<
"\t" << 0 << endl;
184 std::vector<int> v[6];
190 cout << i <<
"\t" << lag0 <<
"\t" << lag1 <<
"\t" << lag2 <<
"\t" << lag3 << endl;
191 v[0].push_back(lag1-lag0);
192 v[1].push_back(lag2-lag0); v[2].push_back(lag2-lag1);
193 v[3].push_back(lag3-lag0); v[4].push_back(lag3-lag1); v[5].push_back(lag3-lag2);
195 for(
int k=0;k<6;k++) {
196 sort(v[k].begin(), v[k].end());
197 auto it = std::unique(v[k].begin(), v[k].end());
198 if(!(it == v[k].end())) {cout <<
"CWB_Plugin_UniqueLags.C : Error - Duplicate Lags" << endl; gSystem->Exit(1);}
203 std::cout.rdbuf(old);
206 lagBuffer->Set(buffer.str().size(),buffer.str().c_str());
208 lagBuffer->Set(lagBuffer->GetSize()+1);
209 (*lagBuffer)[lagBuffer->GetSize()-1]=0;
210 gCWB2G->lagMode[0]=
's';gCWB2G->lagMode[1]=0;
225 TObjArray*
token = TString(
options).Tokenize(TString(
' '));
226 for(
int j=0;j<
token->GetEntries();j++){
228 TObjString* tok = (TObjString*)
token->At(j);
229 TString stok = tok->GetString();
231 if(stok.Contains(
"ulags_enabled=")) {
232 TString ulags_enabled=stok;
233 ulags_enabled.Remove(0,ulags_enabled.Last(
'=')+1);
234 if(ulags_enabled==
"true")
gOPT.enabled=
true;
235 if(ulags_enabled==
"false")
gOPT.enabled=
false;
238 if(stok.Contains(
"ulags_lagSize=")) {
239 TString ulags_lagSize=stok;
240 ulags_lagSize.Remove(0,ulags_lagSize.Last(
'=')+1);
241 if(ulags_lagSize.IsDigit())
gOPT.lagSize=ulags_lagSize.Atoi();
242 if((
gOPT.lagSize%2)==0) {
243 cout <<
"ReadUserOptions Error : ulags_lagSize = " <<
gOPT.lagSize <<
" must be odd" << endl;
exit(1);
253 cout <<
"-----------------------------------------" << endl;
254 cout <<
"UniqueLags config options " << endl;
255 cout <<
"-----------------------------------------" << endl << endl;
256 if(
gOPT.enabled==
false) cout <<
"ULAGS_ENABLED = false" << endl;
257 if(
gOPT.enabled==
true) cout <<
"ULAGS_ENABLED = true " << endl;
258 cout <<
"ULAGS_LAG_SIZE = " <<
gOPT.lagSize << endl;
305 #pragma GCC system_header
310 #include "network.hh"
311 #include "wavearray.hh"
313 #include "TObjArray.h"
314 #include "TObjString.h"
316 #include "Toolbox.hh"
331 #define SETHR 1000000
348 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* net, WSeries<double>* x, TString ifo,
int type) {
358 if(type==CWB_PLUGIN_CONFIG) {
360 cout <<
"-----> CWB_Plugin_Gating.C" << endl;
364 if(type==CWB_PLUGIN_ICOHERENCE) {
367 cwb2G* gCWB2G; IMPORT(cwb2G*,gCWB2G)
368 double Tb = gCWB2G->GetSegBegin()-cfg->segEdge;
369 double Te = gCWB2G->GetSegEnd()+cfg->segEdge;
374 int nIFO = (gCWB2G->IsSingleDetector()) ? 1 : net->ifoListSize();
375 int size = net->getifo(0)->getHoT()->size();
376 double rate = net->getifo(0)->getHoT()->rate();
381 wavearray<double>* hot[NIFO_MAX];
382 for(
int n=0;
n<
nIFO;
n++) hot[
n] = net->getifo(
n)->getHoT();
390 int X = int(cfg->segEdge/dt+0.5);
391 int M = int(
TEDG/dt)+1;
392 int N = int(
TWIN/dt);
394 vector<waveSegment> glist;
395 wavearray<double> SE(
size);
396 wavearray<int> sVeto(
size);
403 for(
int j=0;j<N;j++) SE[N-1]+=pow(hot[
n]->
data[N-1-j],2);
404 for(
int i=N;i<
size;i++) {
406 SE[i] -= pow(hot[
n]->
data[i-N],2);
407 SE[i] += pow(hot[
n]->
data[i],2);
411 for(
int i=0;i<
size;i++) {
413 int is = i-
M>X ? i-
M : X;
415 for(
int k=is;k<es;k++) sVeto[k]=1;
419 sVeto[0]=0;sVeto[
size-1]=0;
420 for(
int i=0;i<
size-1;i++) sVeto[i]=sVeto[i+1]-sVeto[i];
425 for(
int i=0;i<
size;i++) {
426 if(sVeto[i]== 1) gseg.start = Tb+int(i*dt);
428 gseg.stop = Tb+int(i*dt+0.5);
430 glist.push_back(gseg);
437 for(
int j=gsize;j<glist.size();j++) {
438 cout << j <<
" -----> CWB_Plugin_Gating.C - " << net->getifo(
n)->Name <<
" gating time : start="
439 << glist[j].start <<
" stop=" << glist[j].stop <<
" len=" << glist[j].stop-glist[j].start << endl;
446 double gating_time = 0;
448 glist = CWB::Toolbox::unionSegments(glist);
449 gating_time = CWB::Toolbox::getTimeSegList(glist);
450 glist = CWB::Toolbox::invertSegments(glist);
451 net->segList = CWB::Toolbox::mergeSegLists(glist,net->segList);
454 cout<<
"-----> CWB_Plugin_Gating.C - gating time : " << gating_time << endl << endl;
458 sprintf(info,
"-GT:%g",gating_time);
459 gCWB2G->PrintAnalysisInfo(CWB_STAGE_COHERENCE,
"cwb2G::Coherence",info,
false);
502 #pragma GCC system_header
506 #include "network.hh"
507 #include "wavearray.hh"
509 #include "TObjArray.h"
510 #include "TObjString.h"
512 #include "TComplex.h"
515 #include "watplot.hh"
516 #include "gwavearray.hh"
530 double GetQfactor(wavearray<double>*
wf,
double frequency,
bool fixAmax);
532 void GetGaussFitPars(wavearray<double>*
wf,
double& mean,
double& sigma,
bool doenv=
true);
533 void GetGaussFitPars2(wavearray<double>*
wf,
double& mean,
double& sigma,
bool fixAmax);
535 void GetQveto(wavearray<double>*
wf,
float &Qveto,
float &Qfactor);
536 void GetLveto(netcluster* pwc,
int cid,
int nifo,
float* Lveto);
537 void PlotWaveform(TString ifo, wavearray<double>* wfREC,
538 CWB::config* cfg,
bool fft=
false,
bool strain=
false);
541 std::vector<netpixel>
DoPCA(
network* NET, CWB::config* cfg,
int lag,
int id);
542 void ResetPCA(
network* NET, CWB::config* cfg, netcluster* pwc, std::vector<netpixel>* vPIX,
int ID);
546 CWB_Plugin(TFile* jfile, CWB::config* cfg,
network* NET, WSeries<double>* x, TString ifo,
int type) {
559 if(type==CWB_PLUGIN_CONFIG) {
561 cout <<
"-----> CWB_Plugin_QLveto.C" << endl;
566 if(type==CWB_PLUGIN_ILIKELIHOOD) {
571 TList *files = (TList*)gROOT->GetListOfFiles();
574 int nIFO = NET->ifoListSize();
580 while ((file=(TSystemFile*)next())) {
581 fname = file->GetName();
583 if(
fname.Contains(
"wave_")) {
584 froot=(TFile*)file;froot->cd();
586 outDump.ReplaceAll(
".root.tmp",
".txt");
591 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
595 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
599 TTree* net_tree = (TTree *) froot->Get(
"waveburst");
601 EVT =
new netevent(
nIFO);
602 net_tree = EVT->setTree();
603 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
604 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
607 bool qveto_exists=
false;
608 bool lveto_exists=
false;
609 TIter next(net_tree->GetListOfBranches());
610 while ((branch=(TBranch*)next())) {
611 if(TString(
"Qveto").CompareTo(branch->GetName())==0) qveto_exists=
true;
612 if(TString(
"Lveto").CompareTo(branch->GetName())==0) lveto_exists=
true;
615 if(!qveto_exists) net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
616 if(!lveto_exists) net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
620 if(type==CWB_PLUGIN_OLIKELIHOOD) {
622 if(TString(cfg->analysis)!=
"2G") {
623 cout <<
"CWB_Plugin_QLveto.C -> "
624 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
629 int gIFACTOR=-1; IMPORT(
int,gIFACTOR)
634 float* gSLAGSHIFT=NULL; IMPORT(
float*,gSLAGSHIFT)
636 int nIFO = NET->ifoListSize();
639 wavearray<double>
id;
641 double factor = cfg->factors[gIFACTOR];
646 TList *files = (TList*)gROOT->GetListOfFiles();
653 while ((file=(TSystemFile*)next())) {
654 fname = file->GetName();
656 if(
fname.Contains(
"wave_")) {
657 froot=(TFile*)file;froot->cd();
659 outDump.ReplaceAll(
".root.tmp",
".txt");
664 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
668 cout <<
"CWB_Plugin_QLveto.C : Error - output root file not found" << endl;
672 TTree* net_tree = (TTree *) froot->Get(
"waveburst");
674 EVT =
new netevent(net_tree,
nIFO);
675 net_tree->SetBranchAddress(
"Qveto",Qveto);
676 net_tree->SetBranchAddress(
"Lveto",Lveto);
678 EVT =
new netevent(
nIFO);
679 net_tree = EVT->setTree();
680 net_tree->Branch(
"Qveto",Qveto,TString::Format(
"Qveto[%i]/F",4));
681 net_tree->Branch(
"Lveto",Lveto,TString::Format(
"Lveto[%i]/F",3));
683 EVT->setSLags(gSLAGSHIFT);
685 for(
int k=0; k<K; k++) {
687 id = NET->getwc(k)->get(
const_cast<char*
>(
"ID"), 0,
'L', rate);
689 for(
int j=0; j<(int)
id.
size(); j++) {
691 int ID = size_t(
id.
data[j]+0.5);
693 if(NET->getwc(k)->sCuts[ID-1]!=-1)
continue;
696 if(cfg->simulation==4) ofactor=-factor;
697 else if(cfg->simulation==3) ofactor=-gIFACTOR;
700 EVT->output2G(NULL,NET,ID,k,ofactor);
702 wavearray<double>** pwfREC =
new wavearray<double>*[
nIFO];
703 detector* pd = NET->getifo(0);
704 int idSize = pd->RWFID.size();
707 for (
int mm=0; mm<idSize; mm++)
if (pd->RWFID[mm]==ID) wfIndex=mm;
708 if(wfIndex==-1)
continue;
710 netcluster* pwc = NET->getwc(k);
711 cout << endl <<
"----------------------------------------------------------------" << endl;
714 Qveto[0]=Qveto[1]=1.e20;
715 double Qfactor1[NIFO_MAX];
716 double Qfactor2[NIFO_MAX];
721 pwfREC[
n] = pd->RWFP[wfIndex];
722 wavearray<double>* wfREC = pwfREC[
n];
724 #ifdef PLOT_WHITENED_WAVEFORMS
732 NET->getMRAwave(ID,k,
'S',0,
true);
733 GetQveto(&(pd->waveForm), qveto, qfactor);
734 if(qveto<Qveto[0]) Qveto[0]=qveto;
735 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
737 Qfactor1[
n] = qfactor;
739 Qfactor2[
n] =
GetQfactor(&(pd->waveForm), fpeak,
true);
741 cout <<
"Qfactor1/2 : " << pd->Name <<
" frequency[0] = " << EVT->frequency[0] <<
" fpeak = " << fpeak
742 <<
" -> " << Qfactor1[
n] <<
" / " << Qfactor2[
n] << endl;
746 NET->getMRAwave(ID,k,
'W',0,
true);
747 GetQveto(&(pd->waveBand), qveto, qfactor);
748 if(qveto<Qveto[0]) Qveto[0]=qveto;
749 if(qfactor<Qveto[1]) Qveto[1]=qfactor;
751 cout <<
"Qveto : " << pd->Name <<
" Qveto[0] = " << Qveto[0]
752 <<
" Qveto[1] = " << Qveto[1] << endl;
760 for(
int n=0;
n<
nIFO;
n++) Qveto[2]+=EVT->sSNR[
n]*Qfactor1[
n];
761 Qveto[2]/=EVT->likelihood;
764 for(
int n=0;
n<
nIFO;
n++) Qveto[3]+=EVT->sSNR[
n]*Qfactor2[
n];
765 Qveto[3]/=EVT->likelihood;
766 cout <<
"Qveto :" <<
" Qveto[2] = " << Qveto[2]
767 <<
" Qveto[3] = " << Qveto[3] << endl;
769 std::vector<netpixel> vPIX;
770 if(cfg->pattern>0) vPIX =
DoPCA(NET, cfg, k, ID);
772 if(cfg->pattern>0)
ResetPCA(NET, cfg, pwc, &vPIX, ID);
775 cout <<
"Lveto : " <<
"fmean : " << Lveto[0] <<
" frms : " << Lveto[1]
776 <<
" Energy Ratio : " << Lveto[2] << endl << endl;
777 cout <<
"----------------------------------------------------------------" << endl;
779 std::vector<int> sCuts = NET->getwc(k)->sCuts;
781 for(
int i=0; i<(int)sCuts.size(); i++)
if(i!=ID-1) NET->getwc(k)->sCuts[i]=1;
784 NET->getwc(k)->sCuts = sCuts;
786 if(cfg->dump) EVT->dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
787 EVT->output2G(net_tree,NET,ID,k,ofactor);
790 fprintf(EVT->fP,
"Qveto: ");
791 for(
int i=0; i<2*
nIFO; i++) fprintf(EVT->fP,
"%f ",Qveto[i]);
792 fprintf(EVT->fP,
"\n");
794 fprintf(EVT->fP,
"Lveto: ");
795 for(
int i=0; i<3; i++) fprintf(EVT->fP,
"%f ",Lveto[i]);
796 fprintf(EVT->fP,
"\n");
798 if(cfg->dump) EVT->dclose();
799 if(!cfg->cedDump) NET->getwc(k)->sCuts[ID-1]=1;
810 GetQveto(wavearray<double>*
wf,
float &Qveto,
float &Qfactor) {
812 wavearray<double> x = *
wf;;
817 x.resize(4*x.size());
819 for(
int j=xsize;j<x.size();j++) x[j]=0;
823 wavearray<double> a(x.size());
825 double dt = 1./x.rate();
828 for (
int i=1;i<x.size();i++) {
829 if(fabs(x[i])>xmax) xmax=fabs(x[i]);
841 for (
int i=1;i<
size;i++) {
842 if(a[i]>amax) {amax=a[i];imax=i;}
858 for (
int i=0;i<
size;i++) {
859 if(abs(imax-i)<=
NTHR) {
863 if(a[i]>amax/
ATHR) eout+=a[i]*a[i];
867 Qveto = ein>0 ? eout/ein : 0.;
871 float R = (a[imax-1]+a[imax+1])/a[imax]/2.;
872 Qfactor = sqrt(-pow(TMath::Pi(),2)/log(
R)/2.);
879 GetLveto(netcluster* pwc,
int cid,
int nifo,
float* Lveto) {
891 Lveto[0] = Lveto[1] = Lveto[2] = 0;
893 std::vector<int>* vint = &(pwc->cList[cid-1]);
894 int V = vint->size();
905 for(
int n=0;
n<V;
n++) {
906 netpixel* pix = pwc->getPixel(cid,
n);
907 if(pix->layers%2==0) {
908 cout <<
"CWB_Plugin_QLveto.C - Error : is enabled only for WDM (2G)" << endl;
911 if(!pix->core)
continue;
914 for(
int m=0;
m<nifo;
m++) {
915 likePix += pow(pix->getdata(
'S',
m),2);
916 likePix += pow(pix->getdata(
'P',
m),2);
919 double freq = pix->frequency*pix->rate/2.;
920 double df = pix->rate/2.;
923 if(likePix>likeMax) {likeMax=likePix;freqMax=freq;dfreqMax=df;}
935 for(
int n=0;
n<V;
n++) {
936 netpixel* pix = pwc->getPixel(cid,
n);
937 if(!pix->core)
continue;
940 for(
int m=0;
m<nifo;
m++) {
941 likePix += pow(pix->getdata(
'S',
m),2);
942 likePix += pow(pix->getdata(
'P',
m),2);
947 double freq = pix->frequency*pix->rate/2.;
948 if(fabs(freq-freqMax)<=dfreqMax) {
950 fmean += likePix*freq;
951 frms += likePix*freq*freq;
955 fmean = fmean/likeLin;
956 frms = frms/likeLin-fmean*fmean;
957 frms = frms>0 ? sqrt(frms) : 0.;
959 if(frms<dfreqMax/2.) frms=dfreqMax/2.;
967 Lveto[2] = likeTot>0. ? likeLin/likeTot : 0.;
973 #if defined PLOT_LIKELIHOOD
974 watplot WTS(
const_cast<char*
>(
"wts"));
975 WTS.plot(pwc, cid, nifo,
'L', 0,
const_cast<char*
>(
"COLZ"));
976 WTS.canvas->Print(
"l_tfmap_scalogram.png");
984 CWB::config* cfg,
bool fft,
bool strain) {
986 watplot PTS(
const_cast<char*
>(
"ptswrc"),200,20,800,500);
989 double tmin = wfREC->start();
990 wfREC->start(wfREC->start()-tmin);
992 PTS.plot(wfREC,
const_cast<char*
>(
"ALP"), 1, 0, 0,
true, cfg->fLow, cfg->fHigh);
994 PTS.plot(wfREC,
const_cast<char*
>(
"ALP"), 1, 0, 0);
996 PTS.graph[0]->SetLineWidth(1);
997 wfREC->start(wfREC->start()+tmin);
1008 PTS.canvas->Print(
fname);
1009 cout <<
"write : " <<
fname << endl;
1018 n = ifo->IWFP.size();
1019 for (
int i=0;i<
n;i++) {
1020 wavearray<double>*
wf = (wavearray<double>*)ifo->IWFP[i];
1026 n = ifo->RWFP.size();
1027 for (
int i=0;i<
n;i++) {
1028 wavearray<double>*
wf = (wavearray<double>*)ifo->RWFP[i];
1035 std::vector<netpixel>
DoPCA(
network* NET, CWB::config* cfg,
int lag,
int id) {
1039 size_t nIFO = NET->ifoList.size();
1041 float En = 2*NET->acor*NET->acor*
nIFO;
1043 int size = NET->a_00.size();
1047 netcluster* pwc = NET->getwc(lag);
1048 std::vector<netpixel> vPIX;
1050 std::vector<int> pI = NET->wdmMRA.getXTalk(pwc,
id,
false);
1052 if(V>cfg->BATCH)
return vPIX;
1054 wavearray<float> xi(
size); xi=0;
1055 wavearray<float> XI(
size); XI=0;
1057 __m128* _xi = (__m128*) xi.data;
1058 __m128* _XI = (__m128*) XI.data;
1060 __m128* _aa = (__m128*) NET->a_00.data;
1061 __m128* _AA = (__m128*) NET->a_90.data;
1064 for(
int j=0; j<V; j++) {
1066 _sse_zero_ps(_xi+jf);
1067 _sse_zero_ps(_XI+jf);
1068 ee = _sse_abs_ps(_aa+jf,_AA+jf);
1069 if(ee>En) nPC++;
else ee=0.;
1070 NET->rNRG.data[j] = ee;
1071 NET->pNRG.data[j] = NET->rNRG.data[j];
1074 nPC = NET->_sse_mra_ps(xi.data,XI.data,En,nPC);
1076 for(
int j=0; j<V; j++) {
1077 pix = pwc->getPixel(
id,pI[j]);
1078 vPIX.push_back(*pix);
1080 ee = NET->pNRG.data[j];
1083 for(
int i=0; i<
nIFO; i++) {
1084 pix->setdata(
double(xi.data[j*NIFO+i]),
'S',i);
1085 pix->setdata(
double(XI.data[j*NIFO+i]),
'P',i);
1092 void ResetPCA(
network* NET, CWB::config* cfg, netcluster* pwc, std::vector<netpixel>* vPIX,
int ID) {
1094 std::vector<int> pI = NET->wdmMRA.getXTalk(pwc, ID,
false);
1096 if(V>cfg->BATCH)
return;
1097 for(
int j=0; j<V; j++) {
1098 netpixel* pix = pwc->getPixel(ID,pI[j]);
1102 while(!vPIX->empty()) vPIX->pop_back();
1103 vPIX->clear(); std::vector<netpixel>().swap(*vPIX);
1107 GetQfactor(wavearray<double>*
wf,
double frequency,
bool fixAmax) {
1121 wavearray<double> x = *
wf;;
1127 x.resize(4*x.size());
1129 for(
int j=xsize;j<x.size();j++) x[j]=0;
1133 double gmean, gsigma;
1137 double xmin = gmean-3.0*gsigma;
1138 double xmax = gmean+3.0*gsigma;
1141 x = CWB::mdc::GetEnvelope(&x);
1144 double dt = 1./x.rate();
1148 for (
int i=1;i<x.size();i++) {
1149 if(x[i]>amax) {amax=x[i];imax=i;}
1153 for (
int i=1;i<x.size();i++) {
1155 if(
t>xmin &&
t<xmax) area+=x[i]*dt;
1158 double sigma = area/amax/sqrt(2*TMath::Pi());
1160 double qfactor = sigma*(TMath::TwoPi()*frequency);
1176 wavearray<double> x = *
wf;
1177 wavearray<double> ex = CWB::mdc::GetEnvelope(&x);
1179 for(
int i=0;i<N;i++) x[i]*=ex[i];
1184 double df=(x.rate()/(double)N)/2.;
1187 for(
int i=0;i<N;i+=2) {
1189 double amp=x[i]*x[i]+x[i+1]*x[i+1];
1190 if(amp>amax) {fmax=freq;amax=amp;}
1197 GetGaussFitPars(wavearray<double>*
wf,
double& mean,
double& sigma,
bool doenv) {
1208 wavearray<double> x = doenv ? CWB::mdc::GetEnvelope(
wf) : *
wf;
1212 double* time =
new double[N];
1213 double* amp =
new double[N];
1214 double dt = 1./x.rate();
1215 for(
int i=0;i<N;i++) {
1219 TGraph
gr(N,time,amp);
1222 gr.Fit(
"gaus",
"q0");
1223 TF1* gaus = (TF1*)
gr.GetFunction(
"gaus");
1225 mean = gaus->GetParameter(
"Mean");
1226 sigma = gaus->GetParameter(
"Sigma");
1252 wavearray<double> x = CWB::mdc::GetEnvelope(
wf);
1256 wavearray<double> x2 = x;
1257 for(
int i=0;i<x.size();i++) x2[i]=x[i]*x[i];
1259 double gmean, gsigma;
1263 double xmin = gmean-3.0*gsigma;
1264 double xmax = gmean+3.0*gsigma;
1269 double* time =
new double[N];
1270 double* amp =
new double[N];
1271 double dt = 1./x.rate();
1273 for(
int i=0;i<N;i++) {
1276 if(fabs(x[i])>amax) amax=fabs(x[i]);
1278 TGraph
gr(N,time,amp);
1282 TF1 *xgaus =
new TF1(
"xgaus",
"gaus",xmin,xmax);
1283 if(fixAmax) xgaus->SetParLimits(0,amax*0.999,amax*1.001);
1284 gr.Fit(
"xgaus",
"RQ");
1286 mean = xgaus->GetParameter(
"Mean");
1287 sigma = xgaus->GetParameter(
"Sigma");
1317 #pragma GCC system_header
1322 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)