21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 40 #define nPEAK 10 // number of peaks to be extracted from the reconstructed waveform 43 float PB[][nPEAK],
float PA[][nPEAK],
float PE[][nPEAK]);
54 cout <<
"-----> CWB_Plugin_WavePeaks.C" << endl;
55 cout <<
"ifo " << ifo.Data() << endl;
56 cout <<
"type " << type << endl;
76 cout <<
"CWB_Plugin_WavePeaks.C -> " 77 <<
"CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
83 cout <<
"-----> CWB_Plugin_WavePeaks.C -> " 84 <<
" gIFACTOR : " << gIFACTOR << endl;
87 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
98 TList *files = (TList*)gROOT->GetListOfFiles();
105 while ((file=(TSystemFile*)
next())) {
106 fname = file->GetName();
108 if(fname.Contains(
"wave_")) {
109 froot=(TFile*)file;froot->cd();
111 outDump.ReplaceAll(
".root.tmp",
".txt");
116 cout <<
"CWB_Plugin_WavePeaks.C : Error - output root file not found" << endl;
120 cout <<
"CWB_Plugin_WavePeaks.C : Error - output root file not found" << endl;
124 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
127 net_tree->SetBranchAddress(
"nP",&nP);
128 net_tree->SetBranchAddress(
"PF",PF);
129 net_tree->SetBranchAddress(
"PB",PB);
130 net_tree->SetBranchAddress(
"PA",PA);
131 net_tree->SetBranchAddress(
"PE",PE);
135 net_tree->Branch(
"nP",&nP,
"nP/I");
136 net_tree->Branch(
"PF",PF,TString::Format(
"PF[%i][%i]/F",cfg->
nIFO,
nPEAK));
137 net_tree->Branch(
"PB",PB,TString::Format(
"PB[%i][%i]/F",cfg->
nIFO,
nPEAK));
138 net_tree->Branch(
"PA",PA,TString::Format(
"PA[%i][%i]/F",cfg->
nIFO,
nPEAK));
139 net_tree->Branch(
"PE",PE,TString::Format(
"PE[%i][%i]/F",cfg->
nIFO,
nPEAK));
143 for(
int k=0;
k<
K;
k++) {
145 id = NET->
getwc(
k)->
get(const_cast<char*>(
"ID"), 0,
'L', rate);
149 int ID = size_t(
id.data[
j]+0.5);
162 int idSize = pd->
RWFID.size();
165 for (
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
166 if(wfIndex==-1)
continue;
173 pwfREC[
n] = pd->
RWFP[wfIndex];
196 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
197 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
211 float PB[][nPEAK],
float PA[][nPEAK],
float PE[][nPEAK]) {
214 double Fs=((double)wf->
rate()/(double)(2*size));
225 for(
int j=0;
j<
size;
j++) ET+=ener[
j];
228 for(
int j=0;j<size;j++) if(ener[j]>MA) MA=ener[
j];
236 for(
int j=0;j<size;j++) if(ener[j]>ME) {ME=ener[
j];jME=
j;}
239 float fmean=ME*Fs*jME;
240 float frms=ME*pow(Fs*jME,2);
245 for(
int j=jME-1;
j>=0;
j--) {
248 if(E<ge) {EP+=E;finf=
F;fmean+=E*
F;frms+=E*F*
F;ener[
j]=0;}
else break;
256 if(E<ge) {EP+=E;fsup=
F;fmean+=E*
F;frms+=E*F*
F;ener[
j]=0;}
else break;
261 frms = frms/EP-fmean*fmean;
262 frms = frms>0 ? sqrt(frms) : 0;
265 PA[
ifoID][
k] = sqrt(ME)/MA;
267 PE[
ifoID][
k] = ET>0 ? EP/ET : 0;
275 watplot PTS(const_cast<char*>(
"ptswrc"),200,20,800,500);
278 double tmin = wfREC->
start();
281 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0,
true, cfg->
fLow, cfg->
fHigh);
283 PTS.
plot(wfREC, const_cast<char*>(
"ALP"), 1, 0, 0);
285 PTS.
graph[0]->SetLineWidth(1);
289 if(fft)
sprintf(label,
"%s",
"fft");
290 else sprintf(label,
"%s",
"time");
291 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
292 else sprintf(label,
"%s_%s",label,
"white");
297 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)
void PlotWaveform(TString ifo, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)
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
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)
virtual size_t size() const
void GetGlitchParams(wavearray< double > *wf, int ifoID, float PF[][nPEAK], float PB[][nPEAK], float PA[][nPEAK], float PE[][nPEAK])
void output2G(TTree *, network *, size_t, int, double)
#define IMPORT(TYPE, VAR)
TIter next(twave->GetListOfBranches())
netevent EVT(itree, nifo)
netcluster * getwc(size_t n)
param: delay index
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double factors[FACTORS_MAX]
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.