Logo coherent WaveBurst  
Library Reference Guide
Logo
ced.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato, Sergey Klimenko
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #include "ced.hh"
20 #include "watplot.hh"
21 #include "wseries.hh"
22 
23 #include "THtml.h"
24 #include "TDocOutput.h"
25 #include "TH2.h"
26 #include "TStyle.h"
27 #include "TCanvas.h"
28 #include "TSystem.h"
29 #include "TMath.h"
30 #include "TMarker.h"
31 #include "TVector3.h"
32 #include "TRotation.h"
33 #include "TPolyLine.h"
34 #include "TMacro.h"
35 #include "Math/Rotation3D.h"
36 #include "Math/Vector3Dfwd.h"
37 #include "TLegend.h"
38 
39 #include "Meyer.hh"
40 #include "gskymap.hh"
41 #include "gnetwork.hh"
42 #include "STFT.hh"
43 #include <string.h>
44 
45 #define REPLACE(STRING,DIR,EXT) TString(STRING).ReplaceAll("/","").ReplaceAll(DIR,"").ReplaceAll("."+TString(EXT),"")
46 
47 using namespace ROOT::Math;
48 
49 ClassImp(CWB::ced) // used by THtml doc
50 
51 void
52 CWB::ced::Write(double factor, size_t iID, int LAG, char* dirCED) {
53 
54  if(!NET || !NET->nLag) exit(1);
55 
56  int i,j,k,ind;
57  int m,K,M,injID;
58  detector* pd;
59  netcluster* p;
60  int nIFO = (int)NET->ifoListSize(); // number of detectors
61  int bLag = LAG<0 ? 0 : LAG;
62  int eLag = LAG<0 ? NET->nLag : LAG+1;
63  wavecomplex Aa, gC;
64  factor = factor<=0 ? 1 : fabs(factor); // used to rescale injected events
65 
66  if(!nIFO) return;
67 
68  // check if it is one detector network
69  if(nIFO==2) if(strcmp(NET->ifoName[0],NET->ifoName[1])==0) nIFO=1;
70 
71  watplot WTS(const_cast<char*>("wtswrc"));
72  watplot PTS(const_cast<char*>("ptswrc"),200,20,800,500);
73  gskymap gSM;
74 
75 // injections
76 
77  injection INJ(nIFO);
78  size_t mdcID, ID;
79  double T, injTime;
80  skymap* psm;
81  std::vector<float>* vP;
82  std::vector<int>* vI;
83 
84  bool ellips = NET->tYPe=='i' || NET->tYPe=='I' ||
85  NET->tYPe=='g' || NET->tYPe=='G' ||
86  NET->tYPe=='s' || NET->tYPe=='S' ||
87  NET->tYPe=='l' || NET->tYPe=='L' ||
88  NET->tYPe=='c' || NET->tYPe=='C' ||
89  NET->tYPe=='e' || NET->tYPe=='E' ||
90  NET->tYPe=='p' || NET->tYPe=='P' ||
91  NET->tYPe=='r' || NET->tYPe=='R';
92 
93  bool burst = NET->tYPe=='b' || NET->tYPe=='B';
94 
95  wavearray<double> skSNR(nIFO);
96  wavearray<double> xkSNR(nIFO);
97 
98 // arrays for cluster parameters
99 
100  wavearray<double> clusterID_net;
101 
102  EVT->run = NET->nRun;
103  EVT->nevent = 0;
104 
105  for(int lag=bLag; lag<eLag; lag++){ // loop on time lags
106 
107  p = NET->getwc(lag); // pointer to netcluster
108  if(!p->size()) continue;
109 
110  if(NET->MRA) clusterID_net = p->get((char*)"ID",0,'S',0);
111  else clusterID_net = p->get((char*)"ID",0,'S',1);
112  K = clusterID_net.size();
113 
114  if(!K) continue;
115 
116 // read cluster parameters
117 
118  for(k=0; k<K; k++) // loop on events
119  {
120  ID = size_t(clusterID_net.data[k]+0.1);
121  if((iID)&&(ID!=iID)) continue;
122  if(ellips) {
123  if(NET->like()!='2') NET->SETNDM(ID,lag,true,NET->MRA ? 0 : 1);
124  }
125  else if(burst)
126  NET->setndm(ID,lag,true,1);
127  else
128  {cout<<"netevent::output(): incorrect search option"<<endl; exit(1);}
129 
130  psm = &(NET->getifo(0)->tau);
131  vI = &(NET->wc_List[lag].p_Ind[ID-1]);
132  ind = (*vI)[0]; // reconstructed sky index
133 
134 // set injections if there are any
135 
136  M = NET->mdc__IDSize();
137  if(!lag) { // only for zero lag
138  injTime = 1.e12;
139  injID = -1;
140  for(m=0; m<M; m++) {
141  mdcID = NET->getmdc__ID(m);
142  T = fabs(EVT->time[0] - NET->getmdcTime(mdcID));
143  if(T<injTime && INJ.fill_in(NET,mdcID)) {
144  injTime = T;
145  injID = mdcID;
146  }
147 // printf("%d %12.3f %12.3f\n",mdcID,NET->getmdcTime(mdcID),T);
148  }
149 
150  if(INJ.fill_in(NET,injID)) { // set injections
151 
152 // printf("injection type: %d %12.3f\n",INJ.type,INJ.time[0]);
153 
154  wavearray<double>** pwfINJ = new wavearray<double>*[nIFO];
155  wavearray<double>** pwfREC = new wavearray<double>*[nIFO];
156  pd = NET->getifo(0);
157  int idSize = pd->RWFID.size();
158  int wfIndex=-1;
159  for (int mm=0; mm<idSize; mm++) if (pd->RWFID[mm]==(int)ID) wfIndex=mm;
160 
161  for(j=0; j<int(nIFO); j++) {
162  pd = NET->getifo(j);
163  Aa = pd->antenna(EVT->theta[1],EVT->phi[1]); // inj antenna pattern
164  EVT->hrss[j+nIFO] = INJ.hrss[j]*factor;
165  EVT->bp[j+nIFO] = Aa.real();
166  EVT->bx[j+nIFO] = Aa.imag();
167  EVT->time[j+nIFO] = INJ.time[j];
168  EVT->Deff[j] = INJ.Deff[j]/factor;
169  TString xtitle = TString::Format("Time (sec) : GPS OFFSET = %.3f",EVT->gps[j]);
170 
171  pwfINJ[j] = INJ.pwf[j];
172  if (pwfINJ[j]==NULL) {
173  cout << "Error : Injected waveform not saved !!! : detector "
174  << NET->ifoName[j] << endl;
175  continue;
176  }
177  if (wfIndex<0) {
178  cout << "Error : Reconstructed waveform not saved !!! : ID -> "
179  << ID << " : detector " << NET->ifoName[j] << endl;
180  continue;
181  }
182  if (wfIndex>=0) pwfREC[j] = pd->RWFP[wfIndex];
183  double R = pd->TFmap.rate();
184  double rFactor = 1.;
185  rFactor *= factor;
186  wavearray<double>* wfINJ = pwfINJ[j];
187  *wfINJ*=rFactor;
188  wavearray<double>* wfREC = pwfREC[j];
189 
190  // rescale data when data are resampled (resample with wavelet change the amplitude)
191  double rescale = 1./pow(sqrt(2.),TMath::Log2(inRate/wfINJ->rate()));
192  *wfINJ*=rescale; *wfREC*=rescale; // rescale data
193 
194  double bINJ = wfINJ->start();
195  double eINJ = wfINJ->start()+wfINJ->size()/R;
196  double bREC = wfREC->start();
197  double eREC = wfREC->start()+wfREC->size()/R;
198  //cout.precision(14);
199  //cout << "bINJ : " << bINJ << " eINJ : " << eINJ << endl;
200  //cout << "bREC : " << bREC << " eREC : " << eREC << endl;
201 
202  int oINJ = bINJ>bREC ? 0 : int((bREC-bINJ)*R+0.5);
203  int oREC = bINJ<bREC ? 0 : int((bINJ-bREC)*R+0.5);
204  //cout << "oINJ : " << oINJ << " oREC : " << oREC << endl;
205 
206  double startXCOR = bINJ>bREC ? bINJ : bREC;
207  double endXCOR = eINJ<eREC ? eINJ : eREC;
208  int sizeXCOR = int((endXCOR-startXCOR)*R+0.5);
209  //cout << "startXCOR : " << startXCOR << " endXCOR : " << endXCOR << " sizeXCOR :" << sizeXCOR << endl;
210 
211  if (sizeXCOR<=0) continue;
212 
213  // the enINJ, enREC, xcorINJ_REC are computed in the INJ range
214 
215  double enINJ=0;
216  for (int i=0;i<(int)wfINJ->size();i++) enINJ+=wfINJ->data[i]*wfINJ->data[i];
217  //for (int i=0;i<sizeXCOR;i++) enINJ+=wfINJ->data[i+oINJ]*wfINJ->data[i+oINJ];
218 
219  double enREC=0;
220  //for (int i=0;i<wfREC->size();i++) enREC+=wfREC->data[i]*wfREC->data[i];
221  for (int i=0;i<sizeXCOR;i++) enREC+=wfREC->data[i+oREC]*wfREC->data[i+oREC];
222 
223  double xcorINJ_REC=0;
224  for (int i=0;i<sizeXCOR;i++) xcorINJ_REC+=wfINJ->data[i+oINJ]*wfREC->data[i+oREC];
225 
226  WSeries<double> wfREC_SUB_INJ;
227  wfREC_SUB_INJ.resize(sizeXCOR);
228  for (int i=0;i<sizeXCOR;i++) wfREC_SUB_INJ.data[i]=wfREC->data[i+oREC]-wfINJ->data[i+oINJ];
229  wfREC_SUB_INJ.start(startXCOR);
230  wfREC_SUB_INJ.rate(wfREC->rate());
231 
232 
233  EVT->iSNR[j] = enINJ;
234  EVT->oSNR[j] = enREC;
235  EVT->ioSNR[j] = xcorINJ_REC;
236 
237  //double erINJ_REC = enINJ+enREC-2*xcorINJ_REC;
238  //cout << "enINJ : " << enINJ << " enREC : " << enREC << " xcorINJ_REC : " << xcorINJ_REC << endl;
239  //cout << "erINJ_REC/enINJ : " << erINJ_REC/enINJ << endl;
240 
241  bool batch = gROOT->IsBatch();
242  gROOT->SetBatch(true);
243 
244  // find TF maps to optimal resolution level
245  double optRate = (p->cRate[ID-1])[0];
246  double optLayer = p->rate/optRate;
247  double optLevel = int(log10(optLayer)/log10(2));
248 
249  // DUMP WRC !!!
250  if (wfIndex>=0) {
251  double gmin,gmax;
252  char fname[1024];
253 
254  PTS.canvas->cd();
255 
256  sprintf(fname, "%s/%s_wf_white_inj.dat", dirCED, NET->ifoName[j]);
257  if(sbasedirCED!=NULL) wfINJ->wavearray<double>::Dump(const_cast<char*>(fname),2); // time, amp format
258 // if(sbasedirCED!=NULL) wfINJ->Dump(fname);
259  //cout << "Dump " << fname << endl;
260 
261  sprintf(fname, "%s/%s_wf_white_rec.dat", dirCED, NET->ifoName[j]);
262  if(sbasedirCED!=NULL) wfREC->wavearray<double>::Dump(const_cast<char*>(fname),2); // time, amp format
263 // if(sbasedirCED!=NULL) wfREC->Dump(fname);
264  //cout << "Dump " << fname << endl;
265 
266  sprintf(fname, "%s/%s_wf_white_inj_rec.png", dirCED, NET->ifoName[j]);
267  //cout << "Print " << fname << endl;
268  wfINJ->start(wfINJ->start()-EVT->gps[0]);
269  wfREC->start(wfREC->start()-EVT->gps[0]);
270  double bT,eT;
271  GetBoundaries((wavearray<double>&)*wfINJ, 0.995, bT, eT);
272  PTS.plot(wfINJ, const_cast<char*>("ALP"), 1, bT, eT);
273  // startXCOR-EVT->gps[0], endXCOR-EVT->gps[0]);
274  PTS.graph[0]->SetLineWidth(1);
275  PTS.graph[0]->GetXaxis()->SetTitle(xtitle);
276  if(bT<(startXCOR-EVT->gps[0])) bT=startXCOR-EVT->gps[0];
277  if(eT>(endXCOR-EVT->gps[0])) eT=endXCOR-EVT->gps[0];
278  PTS.plot(wfREC, const_cast<char*>("SAME"), 2, bT, eT);
279  // startXCOR-EVT->gps[0], endXCOR-EVT->gps[0]);
280  PTS.graph[1]->SetLineWidth(2);
281  gmin = TMath::Min(PTS.graph[0]->GetHistogram()->GetMinimum(),PTS.graph[1]->GetHistogram()->GetMinimum());
282  gmax = TMath::Max(PTS.graph[0]->GetHistogram()->GetMaximum(),PTS.graph[1]->GetHistogram()->GetMaximum());
283  PTS.graph[0]->GetYaxis()->SetRangeUser(0.9*gmin,1.1*gmax);
284  wfINJ->start(wfINJ->start()+EVT->gps[0]);
285  wfREC->start(wfREC->start()+EVT->gps[0]);
286  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
287  //sprintf(fname, "%s/%s_wf_white_inj_rec.root", dirCED, NET->ifoName[j]);
288  //PTS.canvas->Print(fname);
289  PTS.clear();
290 
291  if((pd->TFmap.gethigh()-pd->TFmap.getlow())>200) PTS.canvas->SetLogx(true);
292  PTS.canvas->SetLogy(true);
293  sprintf(fname, "%s/%s_wf_white_inj_rec_fft.png", dirCED, NET->ifoName[j]);
294  //cout << "Print " << fname << endl;
295  wfINJ->start(wfINJ->start()-EVT->gps[0]);
296  wfREC->start(wfREC->start()-EVT->gps[0]);
297  PTS.plot(wfINJ, const_cast<char*>("ALP"), 1,
298  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0],
299  true, pd->TFmap.getlow(), pd->TFmap.gethigh());
300  PTS.graph[0]->SetLineWidth(1);
301  PTS.plot(wfREC, const_cast<char*>("SAME"), 2,
302  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0],
303  true, pd->TFmap.getlow(), pd->TFmap.gethigh());
304  PTS.graph[1]->SetLineWidth(2);
305  gmin = TMath::Min(PTS.graph[0]->GetHistogram()->GetMinimum(),PTS.graph[1]->GetHistogram()->GetMinimum());
306  gmax = TMath::Max(PTS.graph[0]->GetHistogram()->GetMaximum(),PTS.graph[1]->GetHistogram()->GetMaximum());
307  PTS.graph[0]->GetYaxis()->SetRangeUser(0.9*gmin,1.1*gmax);
308  wfINJ->start(wfINJ->start()+EVT->gps[0]);
309  wfREC->start(wfREC->start()+EVT->gps[0]);
310  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
311  PTS.clear();
312  PTS.canvas->SetLogx(false);
313  PTS.canvas->SetLogy(false);
314  sprintf(fname, "%s/%s_wf_white_rec_sub_inj.png", dirCED, NET->ifoName[j]);
315  //cout << "Print " << fname << endl;
316  wfREC_SUB_INJ.start(wfREC_SUB_INJ.start()-EVT->gps[0]);
317  wfREC->start(wfREC->start()-EVT->gps[0]);
318  PTS.plot(wfREC, const_cast<char*>("ALP"), 2,
319  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0]);
320  PTS.graph[0]->SetLineWidth(1);
321  PTS.graph[0]->GetXaxis()->SetTitle(xtitle);
322  PTS.plot(wfREC_SUB_INJ, const_cast<char*>("SAME"), 1,
323  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0]);
324  PTS.graph[1]->SetLineWidth(2);
325  gmin = TMath::Min(PTS.graph[0]->GetHistogram()->GetMinimum(),PTS.graph[1]->GetHistogram()->GetMinimum());
326  gmax = TMath::Max(PTS.graph[0]->GetHistogram()->GetMaximum(),PTS.graph[1]->GetHistogram()->GetMaximum());
327  PTS.graph[0]->GetYaxis()->SetRangeUser(0.9*gmin,1.1*gmax);
328  wfREC_SUB_INJ.start(wfREC_SUB_INJ.start()+EVT->gps[0]);
329  wfREC->start(wfREC->start()+EVT->gps[0]);
330  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
331  //sprintf(fname, "%s/%s_wf_white_rec_sub_inj.root", dirCED, NET->ifoName[j]);
332  //PTS.canvas->Print(fname);
333  PTS.clear();
334 
335  if((pd->TFmap.gethigh()-pd->TFmap.getlow())>200) PTS.canvas->SetLogx(true);
336  PTS.canvas->SetLogy(true);
337  sprintf(fname, "%s/%s_wf_white_rec_sub_inj_fft.png", dirCED, NET->ifoName[j]);
338  //cout << "Print " << fname << endl;
339  wfREC_SUB_INJ.start(wfREC_SUB_INJ.start()-EVT->gps[0]);
340  wfREC->start(wfREC->start()-EVT->gps[0]);
341  PTS.plot(wfREC, const_cast<char*>("ALP"), 2,
342  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0],
343  true, pd->TFmap.getlow(), pd->TFmap.gethigh());
344  PTS.graph[0]->SetLineWidth(1);
345  PTS.plot(wfREC_SUB_INJ, const_cast<char*>("SAME"), 1,
346  startXCOR-EVT->gps[0], endXCOR-EVT->gps[0],
347  true, pd->TFmap.getlow(), pd->TFmap.gethigh());
348  PTS.graph[1]->SetLineWidth(2);
349  gmin = TMath::Min(PTS.graph[0]->GetHistogram()->GetMinimum(),PTS.graph[1]->GetHistogram()->GetMinimum());
350  gmax = TMath::Max(PTS.graph[0]->GetHistogram()->GetMaximum(),PTS.graph[1]->GetHistogram()->GetMaximum());
351  PTS.graph[0]->GetYaxis()->SetRangeUser(0.9*gmin,1.1*gmax);
352  wfREC_SUB_INJ.start(wfREC_SUB_INJ.start()+EVT->gps[0]);
353  wfREC->start(wfREC->start()+EVT->gps[0]);
354  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
355  PTS.clear();
356  PTS.canvas->SetLogx(false);
357  PTS.canvas->SetLogy(false);
358 
359  WTS.canvas->cd();
360  //if((pd->TFmap.gethigh()-pd->TFmap.getlow())>200) WTS.canvas->SetLogy(true);
361  // length of temporary buffer for tf plots
362  int xcor_length = sizeXCOR/wfINJ->rate();
363  int wts_size = xcor_length<8 ? 16 : 16*int(1+xcor_length/8.);
364  wts_size*=wfINJ->rate();
365 /*
366  // find optimal level
367  int oRate = int(wfINJ->rate()/EVT->rate[0]);
368  int oLevel=0;
369  while(oRate>1) {oRate/=2;oLevel++;}
370  //cout << "EVT->rate[0] : " << EVT->rate[0] << " oLevel : " << oLevel << endl;
371 */
372  Meyer<double> S(1024,2); // set wavelet for production
373 
374  wavearray<double> xINJ(wts_size);
375  xINJ.start(wfINJ->start()-EVT->gps[0]+double(oINJ+wts_size/2)/wfINJ->rate());
376  xINJ.rate(wfINJ->rate());
377  xINJ=0.;
378  for (int m=0;m<sizeXCOR;m++)
379  if(m<(int)xINJ.size()/2) xINJ.data[m+wts_size/2]=wfINJ->data[m+oINJ];
380  WSeries<double> wINJ(xINJ,S);
381  xINJ.resize(0);
382 
383  double wts_start,wts_stop;
384 
385  double rescale = 2.*pow(sqrt(2.),TMath::Log2(inRate/wINJ.rate()));
386  double wts_offset = wfINJ->start()-double(oINJ+wts_size/2)/wfINJ->rate();
387  TString xtitle = TString::Format("Time (sec) : GPS OFFSET = %.3f",wts_offset);
388 
389  //scalogram maps
390  sprintf(fname, "%s/%s_wf_white_inj_tf.png", dirCED, NET->ifoName[j]);
391  //cout << "Print " << fname << endl;
392 // wINJ.Forward(oLevel);
393  if(NET->wdm()) {if(NET->getwdm(optLayer+1)) wINJ.Forward(wINJ,*NET->getwdm(optLayer+1));}
394  else wINJ.Forward(optLevel);
395  wts_start = wINJ.start()+(double)(wts_size/2)/wINJ.rate();
396  wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/wINJ.rate() : wts_start+(wts_size/2)/wINJ.rate();
397  WTS.plot(&wINJ, 1, wts_start, wts_stop,const_cast<char*>("COLZ"));
398  WTS.hist2D->GetYaxis()->SetRangeUser(pd->TFmap.getlow(), pd->TFmap.gethigh());
399  WTS.hist2D->Scale(2*rescale);
400 // WTS.hist2D->GetZaxis()->SetRangeUser(0.1, WTS.hist2D->GetMaximum()); // set to white color low Z values
401  WTS.hist2D->GetXaxis()->SetTitle(xtitle);
402  WTS.hist2D->GetXaxis()->CenterTitle(false);
403  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
404  WTS.clear();
405 
406  wavearray<double> xREC(wts_size);
407  xREC.start(wfREC->start()-EVT->gps[0]+double(oREC+wts_size/2)/wfREC->rate());
408  xREC.rate(wfREC->rate());
409  xREC=0.;
410  for (int m=0;m<sizeXCOR;m++)
411  if(m<(int)xREC.size()/2) xREC.data[m+wts_size/2]=wfREC->data[m+oREC];
412  WSeries<double> wREC(xREC,S);
413  xREC.resize(0);
414 
415  //scalogram maps
416  sprintf(fname, "%s/%s_wf_white_rec_tf.png", dirCED, NET->ifoName[j]);
417  //cout << "Print " << fname << endl;
418 // wREC.Forward(oLevel);
419  if(NET->wdm()) {if(NET->getwdm(optLayer+1)) wREC.Forward(wREC,*NET->getwdm(optLayer+1));}
420  else wREC.Forward(optLevel);
421  wts_start = wREC.start()+(double)(wts_size/2)/wREC.rate();
422  wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/wREC.rate() : wts_start+(wts_size/2)/wREC.rate();
423  WTS.plot(&wREC, 1, wts_start, wts_stop,const_cast<char*>("COLZ"));
424  WTS.hist2D->GetYaxis()->SetRangeUser(pd->TFmap.getlow(), pd->TFmap.gethigh());
425  WTS.hist2D->Scale(2*rescale);
426 // WTS.hist2D->GetZaxis()->SetRangeUser(0.1, WTS.hist2D->GetMaximum()); // set to white color low Z values
427  WTS.hist2D->GetXaxis()->SetTitle(xtitle);
428  WTS.hist2D->GetXaxis()->CenterTitle(false);
429  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
430  WTS.clear();
431 
432  wavearray<double> xDIF(wts_size);
433  xDIF.start(wfREC->start()-EVT->gps[0]+double(oREC+wts_size/2)/wfREC->rate());
434  xDIF.rate(wfREC->rate());
435  xDIF=0.;
436  for (int m=0;m<sizeXCOR;m++)
437  if(m<(int)xDIF.size()/2) xDIF.data[m+wts_size/2]=wfREC->data[m+oREC]-wfINJ->data[m+oINJ];
438  WSeries<double> wDIF(xDIF,S);
439  xDIF.resize(0);
440 
441  //scalogram maps
442  sprintf(fname, "%s/%s_wf_white_dif_tf.png", dirCED, NET->ifoName[j]);
443  //cout << "Print " << fname << endl;
444 // wDIF.Forward(oLevel);
445  if(NET->wdm()) {if(NET->getwdm(optLayer+1)) wDIF.Forward(wDIF,*NET->getwdm(optLayer+1));}
446  else wDIF.Forward(optLevel);
447  wts_start = wDIF.start()+(double)(wts_size/2)/wDIF.rate();
448  wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/wDIF.rate() : wts_start+(wts_size/2)/wDIF.rate();
449  WTS.plot(&wDIF, 2, wts_start, wts_stop,const_cast<char*>("COLZ"));
450  WTS.hist2D->GetYaxis()->SetRangeUser(pd->TFmap.getlow(), pd->TFmap.gethigh());
451  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
452  WTS.clear();
453 
454  double t1 = wDIF.start();
455  double t2 = wDIF.start()+wDIF.size()/wDIF.rate();
456 
457  int ni = 1<<wDIF.pWavelet->m_Level;
458  int nb = int((t1-wDIF.start())*wDIF.rate()/ni);
459  int nj = int((t2-t1)*wDIF.rate())/ni;
460  int ne = nb+nj;
461 
462  int nsize=0;
463  double eeINJ=0;
464  double eeREC=0;
465  double eeDIF=0;
466  wavearray<double> wlINJ;
467  wavearray<double> wlREC;
468  wavearray<double> wlDIF;
469  for(int m=0;m<ni;m++) {
470  wINJ.getLayer(wlINJ,m);
471  wREC.getLayer(wlREC,m);
472  wDIF.getLayer(wlDIF,m);
473  for(int k=nb;k<ne;k++) {
474  if(fabs(wlREC.data[k])>0.1) {
475  eeINJ+=wlINJ.data[k]*wlINJ.data[k];
476  eeREC+=wlREC.data[k]*wlREC.data[k];
477  eeDIF+=wlDIF.data[k]*wlDIF.data[k];
478  nsize++;
479  }
480  }
481  }
482 
483  //cout << j << " tfNorm : " << eeINJ << " " << " " << eeREC << " " << eeDIF/eeINJ << " " << nsize << endl;
484 
485  wINJ.resize(0);
486  wREC.resize(0);
487  wDIF.resize(0);
488 
489  WTS.canvas->SetLogy(false);
490  gROOT->SetBatch(batch);
491  }
492  *wfINJ*=1./rFactor;
493  *wfINJ*=1./rescale; *wfREC*=1./rescale; // restore original rescaled data
494  }
495  }
496  }
497 /*
498  if(EVT->fP!=NULL) {
499  fprintf(EVT->fP,"\n# trigger %d in lag %d for \n",int(ID),int(n));
500  EVT->Dump();
501  vP = &(NET->wc_List[n].p_Map[ID-1]);
502  vI = &(NET->wc_List[n].p_Ind[ID-1]);
503  x = cos(psm->theta_1*PI/180.)-cos(psm->theta_2*PI/180.);
504  x*= (psm->phi_2-psm->phi_1)*180/PI/psm->size();
505  fprintf(EVT->fP,"sky_res: %f\n",sqrt(fabs(x)));
506  fprintf(EVT->fP,"map_lenght: %d\n",int(vP->size()));
507  fprintf(EVT->fP,"#skyID theta DEC step phi R.A step probability cumulative\n");
508  x = 0.;
509  for(j=0; j<int(vP->size()); j++) {
510  i = (*vI)[j];
511  x+= (*vP)[j];
512  fprintf(EVT->fP,"%6d %5.1f %5.1f %6.2f %5.1f %5.1f %6.2f %e %e\n",
513  int(i),psm->getTheta(i),psm->getDEC(i),psm->getThetaStep(i),
514  psm->getPhi(i),psm->getRA(i),psm->getPhiStep(i),(*vP)[j],x);
515  }
516  }
517 */
518  // dump to fits the probability skymap (only for healpix skymap)
519  if(nIFO>1) {
520  bool batch = gROOT->IsBatch();
521  gROOT->SetBatch(true);
522 
523  // Dump2fits probability skymap (healpix)
524  skymap skyprobcc = *psm;
525  skyprobcc=0.;
526  skymap skyprob = *psm;
527  skyprob=1.e-12;
528 
529  vP = &(NET->wc_List[lag].p_Map[ID-1]);
530  vI = &(NET->wc_List[lag].p_Ind[ID-1]);
531  double th,ph,ra;
532  int k;
533  for(j=0; j<int(vP->size()); j++) {
534  i = (*vI)[j];
535  th = skyprob.getTheta(i);
536  ph = skyprob.getPhi(i);
537 
538  k=skyprob.getSkyIndex(th, ph);
539  skyprob.set(k,(*vP)[j]);
540 
541  ra = skyprob.getRA(i);
542  k=skyprob.getSkyIndex(th, ra);
543  skyprobcc.set(k,(*vP)[j]);
544  }
545 
546  char fname[1024];
547 #ifdef _USE_HEALPIX
548  if(skyprobcc.getType()&&(sbasedirCED!=NULL)) { // healpix in celestial coordinates
549  sprintf(fname, "%s/skyprobcc.%s", dirCED, "fits");
550 
551  // build fits configur info
552  TString analysis = "1G";
553  if(NET->like()=='2') analysis="2G";
554  if(NET->MRA) analysis+=":MRA";
555  if(NET->pattern==0) analysis+=":Packet(0)";
556  if((NET->pattern!=0 && NET->pattern<0)) analysis+=TString::Format(":Packet(%d)",NET->pattern);
557  if((NET->pattern!=0 && NET->pattern>0)) analysis+=TString::Format(":Packet(+%d)",NET->pattern);
558 
559  char configur[64]="";
560  char search = NET->tYPe;
561  if (search=='r') sprintf(configur,"%s un-modeled",analysis.Data());
562  if(analysis=="1G") {
563  if((search=='i')||(search=='I')) sprintf(configur,"%s elliptical",analysis.Data());
564  if((search=='s')||(search=='S')) sprintf(configur,"%s linear",analysis.Data());
565  if((search=='g')||(search=='G')) sprintf(configur,"%s circular",analysis.Data());
566  } else {
567  if (search=='i') sprintf(configur,"%s iota-wave",analysis.Data());
568  if (search=='p') sprintf(configur,"%s psi-wave",analysis.Data());
569  if((search=='l')||(search=='s')) sprintf(configur,"%s linear",analysis.Data());
570  if((search=='c')||(search=='g')) sprintf(configur,"%s circular",analysis.Data());
571  if((search=='e')||(search=='b')) sprintf(configur,"%s elliptical",analysis.Data());
572  }
573  skyprobcc.Dump2fits(fname,EVT->time[0],configur,const_cast<char*>("PROB"),const_cast<char*>("pix-1"),'C');
574  }
575 #endif
576 
577  // dump skyprob plot in cc coordinates
578  gSM=skyprobcc;
579  gSM.SetOptions("hammer","Celestial",2);
580 
581  int L = gSM.size(); // number of pixels in the sphere
582  double pi = TMath::Pi();
583  double S = 4*pi*pow(180/pi,2); // solid angle of a sphere
584  double dS = S/L; // solid angle of a pixel
585 
586  for(int l=0;l<L;l++) { // loop over the sky grid
587  double prob = gSM.get(l); // get probability per pixel
588  prob/=dS; // normalize probability to prob per deg^2
589  if(prob==0) gSM.set(l,1e-40); // set !=0 to force dark blue background
590  }
591 
592  gSM.SetZaxisTitle("prob. per deg^{2}");
593  gSM.Draw(57);
594  TH2D* hsm = gSM.GetHistogram();
595  hsm->GetZaxis()->SetTitleOffset(0.85);
596  hsm->GetZaxis()->SetTitleSize(0.03);
597  sprintf(fname, "%s/skyprobcc.%s", dirCED, "png");
598  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
599 
600  gROOT->SetBatch(batch);
601  }
602  }
603  }
604 }
605 
606 int
607 CWB::ced::Write(double factor, bool fullCED) {
608 
609  int i,j,k,n,m,l;
610  int nIFO = NET->ifoListSize();
611  int K = NET->nLag;
612  int M = NET->mdc__ID.size();
613  if(M==0&&simulation) {
614  cout << "CWB::ced::Write : No injected events found -> force simulation=0" << endl;
615  simulation=0;
616  }
617  int ID;
618  char home_ced_path[1024]="~waveburst/WWW/LSC/waveburst/ced";
619  char home_ced_www[1024]="";
620  FILE* hP = NULL; // html file
621  char search = NET->tYPe;
622  TString analysis = "1G";
623  if(NET->like()=='2') analysis="2G";
624  if(NET->optim) analysis+=":SRA";
625  else analysis+=":MRA";
626  if(NET->pattern==0) analysis+=":Packet(0)";
627  if((NET->pattern!=0 && NET->pattern<0)) analysis+=TString::Format(":Packet(%d)",NET->pattern);
628  if((NET->pattern!=0 && NET->pattern>0)) analysis+=TString::Format(":Packet(+%d)",NET->pattern);
629  int wmod = NET->optim ? 1 : 0; // gwtMRAwave mode
630 
632  wavearray<double> tm;
633 
634  bool batch = gROOT->IsBatch();
635  gROOT->SetBatch(true);
636 
637  watplot PCH(const_cast<char*>("chirp"));
638  watplot WTS(const_cast<char*>("wts"));
639  watplot PTS(const_cast<char*>("pts"),200,20,800,500);
640  gskymap gSM; gSM.SetOptions("","Geographic",2);
641  gnetwork gNET(NET); // used to plot circles
642 
643  int optRate,optLayer,optLevel;
644 
645  TMarker inj; inj.SetMarkerStyle(29); // injected pos (white star)
646  TMarker INJ; INJ.SetMarkerStyle(30); // injected pos (empty black star)
647  TMarker rec; rec.SetMarkerStyle(29); // recostructed pos (black star)
648  TMarker REC; REC.SetMarkerStyle(30); // recostructed pos (emply white star)
649  TMarker det; det.SetMarkerStyle(20); // detected pos (black dot )
650  TMarker DET; DET.SetMarkerStyle(24); // detected pos (empty white dot )
651 
652  double r2d = 180./TMath::Pi();
653  double d2r = TMath::Pi()/180.;
654 
655  char dirCED[1024]="";
656  char command[1024];
657  char ifostr[20]="";
658  char fname[1024];
659 
660  int minTimeDet=nIFO;
661  double minTime=1e40;
662  double eventTime[NIFO];
663  double lagTime[NIFO];
664  double startSegTime,stopSegTime;
665  int ifoid[NIFO],sortid[NIFO];
667  detector *pD[NIFO];
668 
669  int rate = 1;
670  if(NET->like()=='2') rate = NET->MRA ? 0 : 1; // likelihood2G
671  else rate = int(2*NET->getifo(0)->TFmap.resolution(0)+0.5); // likelihoodI
672 
673  //Fill in all skymaps
674  double old_cc = NET->netCC;
675  double old_rho = NET->netRHO;
676  NET->netCC = -1;
677  NET->netRHO = 0;
678 
679  // check if it is one detector network
680  if(nIFO==2) if(strcmp(NET->ifoName[0],NET->ifoName[1])==0) nIFO=1;
681 
682  for(n=0; n<nIFO; n++) {
683  sprintf(ifostr,"%s%s",ifostr,NET->ifoName[n]);
684  pD[n] = NET->getifo(n);
685  ifoid[n]=n;
686  }
687  TMath::Sort(nIFO,ifoid,sortid,false);
688 
689  // create sbasedirCED if selected
690  if(sbasedirCED!=NULL) {
691  sprintf(command,"mkdir -p %s",sbasedirCED);
692  if(gSystem->Exec(command)) return 0;
693  } else {
694  rbasedirCED->cd();
695  }
696 
697  for(k=0; k<K; k++) { // loop over the lags
698 
699  id = NET->getwc(k)->get(const_cast<char*>("ID"), 0, 'L', rate);
700  tm = NET->getwc(k)->get(const_cast<char*>("TIME"), 0, 'L', 0);
701 
702 
703  for(j=0; j<(int)id.size(); j++) { // loop over cluster index
704 
705  ID = size_t(id.data[j]+0.5);
706 
707  if(NET->wdm() && NET->getwc(k)->sCuts[ID-1]!=-1) continue; // skip rejected/processed clusters
708 
709  if(NET->like()=='2') EVT->output2G(NULL,NET,ID,k,factor);
710  else EVT->output(NULL,NET,factor,ID,k);
711 
712  if(EVT->rho[analysis=="1G"?1:0] < rho) continue;
713 
714  int masterDet=0;
715  int lagMin=2147483647;
716  for(n=0; n<nIFO; n++) if(EVT->lag[n]<lagMin) {lagMin=int(EVT->lag[n]);masterDet=n;}
717 
718  // create ced directory & index.html link
719  strcpy(ifostr,"");
720  for(n=0; n<nIFO; n++) sprintf(ifostr,"%s%s",ifostr,NET->ifoName[n]);
721  if(sbasedirCED!=NULL) {
722  //if(nIFO==1&&strlen(chName)>1) sprintf(dirCED, "%s/%s_%s", sbasedirCED, ifostr,chName);
723  //else sprintf(dirCED, "%s/%s", sbasedirCED, ifostr);
724  sprintf(dirCED, "%s/%s", sbasedirCED, ifostr);
725  for(n=0; n<nIFO; n++) sprintf(dirCED, "%s_%.3f",dirCED,EVT->start[n]);
726  sprintf(command,"mkdir -p %s",dirCED);
727  if(gSystem->Exec(command)) return 0;
728 
729  if (getenv("HOME_CED_WWW")!=NULL) {
730  sprintf(home_ced_www,"%s",getenv("HOME_CED_WWW"));
731  }
732  if (getenv("HOME_CED_PATH")!=NULL) {
733  sprintf(home_ced_path,"%s",getenv("HOME_CED_PATH"));
734  }
735  strcpy(ifostr,"");
736  for(n=0; n<nIFO; n++) sprintf(ifostr,"%s%s",ifostr,NET->ifoName[sortid[n]]);
737  if(TString(home_ced_www).BeginsWith("/")) { // -> CED is not published by WWW but local
738  if(!simulation) sprintf(command,"cp %s/index/cedindex_%s.html %s/index.html",home_ced_path,ifostr,dirCED);
739  else sprintf(command,"cp %s/index/cedindex_sim_%s.html %s/index.html",home_ced_path,ifostr,dirCED);
740  } else {
741  if(!simulation) sprintf(command,"ln -s %s/index/cedindex_%s.html %s/index.html",home_ced_path,ifostr,dirCED);
742  else sprintf(command,"ln -s %s/index/cedindex_sim_%s.html %s/index.html",home_ced_path,ifostr,dirCED);
743  }
744  if(gSystem->Exec(command)) return 0;
745  } else {
746  //if(nIFO==1&&strlen(chName)>1) sprintf(dirCED, "%s_%s", ifostr,chName);
747  //else sprintf(dirCED, "%s", ifostr);
748  sprintf(dirCED, "%s", ifostr);
749  for(n=0; n<nIFO; n++) sprintf(dirCED, "%s_%.3f",dirCED,EVT->start[n]);
750  rbasedirCED->cd(); rbasedirCED->mkdir(dirCED)->cd();
751  }
752 
753  if(NET->like()=='2') EVT->output2G(NULL,NET,ID,k,factor);
754  else EVT->output(NULL,NET,factor,ID,k);
755 
756  //Write(factor,ID,k);
757  if(EVT->rho[analysis=="1G"?1:0] < rho) continue;
758 
759  double bPP =0.01;
760  double TH = 0.2;
761  TH2F* hist = NULL;
762  if(NET->like()=='2') ; // likelihood2G
763  else NET->likelihood(search, NET->acor, ID, k);
764 
765  // dump event file & get event parameters
766  if(sbasedirCED!=NULL) {
767  sprintf(fname, "%s/eventDump.txt", dirCED);
768  } else {
769  gRandom->SetSeed(0);
770  int rnID = int(gRandom->Rndm(13)*1.e9);
771  UserGroup_t* uinfo = gSystem->GetUserInfo();
772  TString uname = uinfo->fUser;
773  gSystem->Exec(TString("mkdir -p /dev/shm/")+uname);
774  sprintf(fname,"/dev/shm/%s/eventDump-%d.txt",uname.Data(),rnID);
775  }
776  EVT->dopen(fname,const_cast<char*>("w"));
777 
778  if(NET->like()=='2') EVT->output2G(NULL,NET,ID,k,factor);
779  else EVT->output(NULL,NET,factor,ID,k);
780 
781  Write(factor,ID,k,dirCED);
782  EVT->dclose();
783  if(sbasedirCED==NULL) {
784  TMacro macro(fname);
785  macro.Write("eventDump.txt");
786  gSystem->Exec(TString("rm ")+fname);
787  }
788 
789  // compute event time & lags time
790  for(n=0; n<nIFO; n++) eventTime[n]=(EVT->start[n]+EVT->stop[n])/2.;
791  for(n=0; n<nIFO; n++) minTime = ((eventTime[n]-EVT->gps[n])<minTime) ? eventTime[n]-EVT->gps[n] : minTime;
792  for(n=0; n<nIFO; n++) minTimeDet = ((eventTime[n]-EVT->gps[n])<=minTime) ? n : minTimeDet;
793  for(n=0; n<nIFO; n++) lagTime[n]=eventTime[n]-EVT->gps[minTimeDet]-minTime;
794  startSegTime= EVT->gps[minTimeDet];
795  // NOTE : we use EVT->duration[1] because it caintains the event stop-start
796  // while EVT->duration[0] contains the duration estimated with rms
797  stopSegTime = EVT->gps[minTimeDet]+EVT->left[minTimeDet]+EVT->right[minTimeDet]+EVT->duration[1];
798  for(n=0; n<nIFO; n++) xtitle[n] = TString::Format("Time (sec) : GPS OFFSET = %.3f",EVT->gps[n]);
799 
800  // create jobSummary.html & eventSummary.html
801  if(sbasedirCED!=NULL) sprintf(fname, "%s/jobSummary.html", dirCED);
802  else sprintf(fname, "/dev/null");
803  if((hP = fopen(fname, "w")) != NULL) {
804  fprintf(hP,"<table border=1 cellspacing=0 width=100%% height=100%%>\n");
805  fprintf(hP,"<tr align=\"center\">\n");
806  if(nIFO==1) {
807  fprintf(hP,"<th>DETECTOR</th>\n");
808  } else {
809  fprintf(hP,"<th>NETWORK</th>\n");
810  }
811  fprintf(hP,"<td>%s</td>\n",ifostr);
812  fprintf(hP,"</tr>\n");
813  fprintf(hP,"<tr align=\"center\">\n");
814  if(nIFO==1) {
815  fprintf(hP,"<th>CHANNEL</th>\n");
816  fprintf(hP,"<td>%s</td>\n",chName);
817  fprintf(hP,"</tr>\n");
818  fprintf(hP,"<tr align=\"center\">\n");
819  fprintf(hP,"<th>SEARCH</th>\n");
820  fprintf(hP,"<td>%s</td>\n",analysis.Data());
821  } else {
822  fprintf(hP,"<th>SEARCH</th>\n");
823  if(analysis=="1G") {
824  if(search=='E' || search=='E') fprintf(hP,"<td>%s un-modeled (%c)</td>\n",analysis.Data(),search);
825  if(search=='b' || search=='B') fprintf(hP,"<td>%s un-modeled (%c)</td>\n",analysis.Data(),search);
826  if(search=='r' || search=='R') fprintf(hP,"<td>%s un-modeled (%c)</td>\n",analysis.Data(),search);
827  if(search=='i' || search=='I') fprintf(hP,"<td>%s elliptical (%c)</td>\n",analysis.Data(),search);
828  if(search=='g' || search=='G') fprintf(hP,"<td>%s circular (%c)</td>\n",analysis.Data(),search);
829  if(search=='s' || search=='S') fprintf(hP,"<td>%s linear (%c)</td>\n",analysis.Data(),search);
830  } else {
831  char _search = std::tolower(search);
832  if(_search=='r') fprintf(hP,"<td>%s un-modeled(%c)</td>\n",analysis.Data(),search);
833  if(_search=='i') fprintf(hP,"<td>%s iota-wave(%c)</td>\n",analysis.Data(),search);
834  if(_search=='p') fprintf(hP,"<td>%s psi-wave(%c)</td>\n",analysis.Data(),search);
835  if(_search=='e'||_search=='b') fprintf(hP,"<td>%s elliptical(%c)</td>\n",analysis.Data(),search);
836  if(_search=='c'||_search=='g') fprintf(hP,"<td>%s circular(%c)</td>\n",analysis.Data(),search);
837  if(_search=='l'||_search=='s') fprintf(hP,"<td>%s linear(%c)</td>\n",analysis.Data(),search);
838  }
839  }
840  fprintf(hP,"</tr>\n");
841  fprintf(hP,"<tr align=\"center\">\n");
842  fprintf(hP,"<th>START SEGMENT</th>");
843  fprintf(hP,"<td>%9.3f</td>\n",startSegTime);
844  fprintf(hP,"</tr>\n");
845  fprintf(hP,"<tr align=\"center\">\n");
846  fprintf(hP,"<th>STOP SEGMENT</th>");
847  fprintf(hP,"<td>%9.3f</td>\n",stopSegTime);
848  fprintf(hP,"</tr>\n");
849  if(simulation) {
850  fprintf(hP,"<tr align=\"center\">\n");
851  fprintf(hP,"<th>MDC</th>\n");
852  fprintf(hP,"<td>%s</td>\n",NET->getmdcType(EVT->type[1]-1).c_str());
853  fprintf(hP,"</tr>\n");
854  }
855  if(!simulation&&nIFO>1) {
856  fprintf(hP,"<tr align=\"center\">\n");
857  fprintf(hP,"<th>LAG</th>\n");
858  fprintf(hP,"<td>");
859  for(n=0; n<nIFO-1; n++) fprintf(hP,"%3.3f / ",lagTime[n]);
860  fprintf(hP,"%3.3f",lagTime[nIFO-1]);
861  fprintf(hP,"</td>\n");
862  fprintf(hP,"</tr>\n");
863  }
864  fprintf(hP,"</table>\n");
865  fclose(hP);hP = NULL;
866  } else {
867  cout << "netevent::ced() error: cannot open file " << fname <<". \n";
868  }
869 
870  // convert user macro into html and copy to ced dir
871  if(sbasedirCED!=NULL) {
872  THtml html;
873  html.SetEtcDir(gSystem->ExpandPathName("$HOME_WAT/html/etc/html"));
874  html.SetProductName("CED");
875  TString html_input_dir=dirCED;
876  html.SetInputDir(html_input_dir.Data());
877 
878  char cmd[1024];
879  sprintf(cmd,"cp %s/html/etc/html/ROOT.css %s/",gSystem->ExpandPathName("$HOME_WAT"),dirCED);
880  gSystem->Exec(cmd);
881  sprintf(cmd,"cp %s/html/etc/html/ROOT.js %s/",gSystem->ExpandPathName("$HOME_WAT"),dirCED);
882  gSystem->Exec(cmd);
883 
885  if(gSystem->Getenv("CWB_PARAMETERS_FILE")==NULL) {
886  cout << "Error : environment CWB_PARAMETERS_FILE is not defined!!!" << endl;exit(1);
887  } else {
888  cwb_parameters_file=TString(gSystem->Getenv("CWB_PARAMETERS_FILE"));
889  }
891  if(gSystem->Getenv("CWB_UPARAMETERS_FILE")==NULL) {
892  cout << "Error : environment CWB_UPARAMETERS_FILE is not defined!!!" << endl;exit(1);
893  } else {
894  cwb_uparameters_file=TString(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
895  }
896 
897  // redirect stderr to /dev/null to getrid of messages produced by html.Convert
898  fpos_t poserr; fflush(stderr); fgetpos(stderr, &poserr);
899  int fderr = dup(fileno(stderr)); freopen("/dev/null", "w", stderr);
900  // redirect stdout to /dev/null to getrid of messages produced by html.Convert
901  fpos_t posout; fflush(stdout); fgetpos(stdout, &posout);
902  int fdout = dup(fileno(stdout)); freopen("/dev/null", "w", stdout);
903 
904  char title[1024];
905  sprintf(title,"<h2 class=\"convert\" align=\"center\"> %s </h2>",cwb_parameters_file.Data());
906  html.Convert(cwb_parameters_file.Data(),cwb_parameters_file.Data(),dirCED,"",0,title);
907  if(analysis=="1G") sprintf(cmd,"mv %s/cwb1G_parameters.C.html %s/cwb_parameters.C.html",dirCED,dirCED);
908  else sprintf(cmd,"mv %s/cwb2G_parameters.C.html %s/cwb_parameters.C.html",dirCED,dirCED);
909  gSystem->Exec(cmd);
910 
911  char work_dir[1024]; sprintf(work_dir,"%s",gSystem->WorkingDirectory()); // working dir
912  TString cwb_uparameters_path = TString(work_dir)+"/"+cwb_uparameters_file;
913  if(cwb_uparameters_file!="") {
914  sprintf(title,"<h2 class=\"convert\" align=\"center\"> %s </h2>",cwb_uparameters_path.Data());
915  html.Convert(cwb_uparameters_path.Data(),cwb_uparameters_file.Data(),dirCED,"",0,title);
916  // rename file to the standard user_parameters.C name
917  TString cwb_iparameters_path = TString(dirCED)+"/"+gSystem->BaseName(cwb_uparameters_path.Data())+".html";
918  TString cwb_oparameters_path = TString(dirCED)+"/user_parameters.C.html";
919  gSystem->Rename(cwb_iparameters_path.Data(),cwb_oparameters_path.Data());
920  }
921 
922  // restore the stderr output
923  fflush(stderr); dup2(fderr, fileno(stderr)); close(fderr);
924  clearerr(stderr); fsetpos(stderr, &poserr);
925  // restore the stdout output
926  fflush(stdout); dup2(fdout, fileno(stdout)); close(fdout);
927  clearerr(stdout); fsetpos(stdout, &posout);
928  }
929 
930  // create jobSummary.html & eventSummary.html
931  if(sbasedirCED!=NULL) sprintf(fname, "%s/eventSummary.html", dirCED);
932  else sprintf(fname, "/dev/null");
933  if((hP = fopen(fname, "w")) != NULL) {
934  fprintf(hP,"<table border=1 cellspacing=0 width=100%% height=100%%>\n");
935  fprintf(hP,"<tr align=\"center\">\n");
936  fprintf(hP,"<th>GPS TIME</th>\n");
937  fprintf(hP,"<th>SNR</th>\n");
938  if(nIFO==1) {
939  fprintf(hP,"<th>DURATION</th>\n");
940  fprintf(hP,"<th>FREQUENCY</th>\n");
941  fprintf(hP,"<th>BANDWIDTH</th>\n");
942  } else {
943  fprintf(hP,"<th>RHO[0/1]</th>\n");
944  fprintf(hP,"<th>CC[0/1/2/3]</th>\n");
945  fprintf(hP,"<th>ED</th>\n");
946  fprintf(hP,"<th>PHI</th>\n");
947  fprintf(hP,"<th>THETA</th>\n");
948  }
949  fprintf(hP,"</tr>\n");
950  fprintf(hP,"<tr align=\"center\">\n");
951  fprintf(hP,"<td>%9.3f</td>\n",EVT->time[minTimeDet]);
952  if(nIFO==1) {
953  fprintf(hP,"<td>%4.1f</td>\n",sqrt(EVT->likelihood/2.));
954  fprintf(hP,"<td>%3.3f</td>\n",EVT->duration[0]);
955  fprintf(hP,"<td>%3.1f</td>\n",EVT->frequency[0]);
956  fprintf(hP,"<td>%3.1f</td>\n",EVT->bandwidth[0]);
957  } else {
958  fprintf(hP,"<td>%4.1f</td>\n",sqrt(EVT->likelihood));
959  fprintf(hP,"<td>%3.1f / %3.1f</td>\n",EVT->rho[0],EVT->rho[1]);
960  fprintf(hP,"<td>%1.2f / %1.2f / %1.2f / %1.2f</td>\n",
961  EVT->netcc[0],EVT->netcc[1],EVT->netcc[2],EVT->netcc[3]);
962  fprintf(hP,"<td>%1.2f</td>\n",EVT->neted[0]/EVT->ecor);
963  fprintf(hP,"<td>%3.1f</td>\n",EVT->phi[0]);
964  fprintf(hP,"<td>%3.1f</td>\n",90.-EVT->theta[0]);
965  }
966  fprintf(hP,"</tr>\n");
967  fprintf(hP,"</table>\n");
968  fclose(hP);hP = NULL;
969  } else {
970  cout << "netevent::ced() error: cannot open file " << fname <<". \n";
971  }
972 
973  // plots nRMS
974  int nIFO_RMS=0;
975  std::vector<TGraph*> mgraph(nIFO);
976  Color_t psd_color[8] = {kBlue, kRed, kGreen, kBlack, 6, 3, 8, 43};
977  for(n=0; n<nIFO; n++) {
978 
979  if(pD[n]->nRMS.size()==0) continue; // it is zero when CED is produced starting from SUPERCLUSTER stage
980 
981  nIFO_RMS++;
982 
983  WSeries<double> nRMS = pD[n]->nRMS;
984 
985  double fLow = pD[n]->getTFmap()->getlow();
986  double fHigh = pD[n]->getTFmap()->gethigh();
987  double rate = pD[n]->getTFmap()->rate();
988  if(fLow<16) fLow=16;
989  if(fHigh>rate/2.) fHigh=rate/2.;
990 
991  WDM<double>* wdm = (WDM<double>*) pD[n]->nRMS.pWavelet;
992  int M = pD[n]->nRMS.getLevel();
993  double* map00 = wdm->pWWS;
994  double dF = rate/M/2./2.; // psd frequency resolution
995 
996  wavearray<double> psd(2*M); // PSD @ event time
997  psd.start(0);
998  psd.rate(1./dF);
999 
1000  wavearray<double> PSD=psd; // average PSD
1001  PSD=0;
1002 
1003  int nPSD = pD[n]->nRMS.size()/(M+1); // number of psd in the nRMS object
1004  double etime = eventTime[n]-EVT->gps[n]; // event time from the beginning of the buffer
1005 
1006  double segLen = stopSegTime-startSegTime;
1007  int I = (int)etime/(segLen/nPSD); // psd event index
1008 
1009  for(int i=0; i<nPSD; ++i){
1010  if(i==I) psd[0] = map00[0]; // first half-band
1011  PSD[0]+= pow(map00[0],2); // first half-band
1012  for(int j=1; j<M; j++){
1013  if(i==I) psd[2*j-1] = map00[j];
1014  if(i==I) psd[2*j] = map00[j];
1015  PSD[2*j-1]+= pow(map00[j],2);
1016  PSD[2*j] += pow(map00[j],2);
1017  }
1018  if(i==I) psd[2*M-1] = map00[M]; // last half-band
1019  PSD[2*M-1]+= pow(map00[M],2); // last half-band
1020  map00+=M+1;
1021  }
1022  // NOTE : check if the following normalization is correct when cfg->fResample>0
1023  psd*=sqrt(2.)/sqrt(inRate); // oneside psd normalization
1024  for(int j=0; j<PSD.size(); j++) PSD[j] = sqrt(PSD[j]/nPSD)*sqrt(2.)/sqrt(inRate); // oneside PSD normalization
1025 
1026  PTS.canvas->cd();
1027  gStyle->SetTitleFont(12,"D");
1028  sprintf(fname, "%s/%s_psd.%s", dirCED, NET->ifoName[n], gtype);
1029  PTS.plot((wavearray<double>&)psd, const_cast<char*>("ALP"), 1, fLow+2*dF, fHigh-2*dF);
1030  //PTS.plot((wavearray<double>&)PSD, const_cast<char*>("ALP"), 1, fLow+2*dF, fHigh-2*dF);
1031  PTS.graph[0]->SetTitle(TString::Format("Power Spectral Density after lines' removal @ Time (sec) = %.0f",EVT->time[minTimeDet]));
1032  PTS.graph[0]->GetXaxis()->SetTitle("Frequency (Hz) ");
1033  PTS.graph[0]->GetYaxis()->SetTitle("[strain / #sqrt{Hz}] ");
1034  PTS.graph[0]->SetMarkerStyle(1);
1035  PTS.graph[0]->SetMinimum(1.e-24);
1036  PTS.graph[0]->SetMaximum(1.e-20);
1037  PTS.graph[0]->SetLineWidth(2);
1038  PTS.graph[0]->SetLineColor(psd_color[n%8]);
1039  if(TString(NET->ifoName[n])=="L1") PTS.graph[0]->SetLineColor(TColor::GetColor("#66ccff"));
1040  if(TString(NET->ifoName[n])=="L1") PTS.graph[0]->SetMarkerColor(TColor::GetColor("#66ccff"));
1041  if(TString(NET->ifoName[n])=="H1") PTS.graph[0]->SetLineColor(kRed);
1042  if(TString(NET->ifoName[n])=="H1") PTS.graph[0]->SetMarkerColor(kRed);
1043  if(TString(NET->ifoName[n])=="V1") PTS.graph[0]->SetLineColor(TColor::GetColor("#9900cc"));
1044  if(TString(NET->ifoName[n])=="V1") PTS.graph[0]->SetMarkerColor(TColor::GetColor("#9900cc"));
1045  PTS.canvas->SetLogx(true);
1046  PTS.canvas->SetLogy(true);
1047  // draw the legend
1048  TLegend leg(0.753012,0.8-0.01,0.8885542,0.8793706,NULL,"brNDC");
1049  leg.SetTextAlign(22);
1050  leg.SetLineColor(kBlack);
1051  leg.AddEntry(PTS.graph[0],TString::Format("%s",NET->ifoName[n]),"lp");
1052  leg.Draw();
1053  //PTS.plot((wavearray<double>&)psd, const_cast<char*>("SAME"), 2, fLow+2*dF, fHigh-2*dF);
1054  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1055  mgraph[n] = PTS.graph[0];
1056  PTS.graph.clear();
1057  //PTS.clear();
1058 
1059  sprintf(fname, "%s/%s_psd.dat", dirCED, NET->ifoName[n]);
1060  if(sbasedirCED!=NULL) psd.wavearray<double>::Dump(const_cast<char*>(fname),2); // save freq, psd format into ascii file
1061  }
1062  if(nIFO_RMS==nIFO) { // nRMS is present for all detectors -> we can print the combined PSD
1063  PTS.graph=mgraph;;
1064  PTS.graph[0]->Draw("ALP"); for(n=1; n<nIFO; n++) PTS.graph[n]->Draw("SAME");
1065  // draw the legend
1066  TLegend leg(0.753012,0.8-nIFO*0.01,0.8885542,0.8793706,NULL,"brNDC");
1067  leg.SetTextAlign(22);
1068  leg.SetLineColor(kBlack);
1069  for(int n=0;n<nIFO;n++) leg.AddEntry(PTS.graph[n],TString::Format("%s",NET->ifoName[n]),"lp");
1070  leg.Draw();
1071  sprintf(fname, "%s/NET_psd.%s", dirCED, gtype);
1072  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1073  }
1074  PTS.canvas->SetLogx(false);
1075  PTS.canvas->SetLogy(false);
1076  PTS.clear();
1077  mgraph.clear();
1078 
1079  // get TF maps @ optimal resolution level
1080  optRate = (NET->getwc(k)->cRate[ID-1])[0];
1081  optLayer = NET->getwc(k)->rate/optRate;
1082  optLevel = int(log10(optLayer)/log10(2));
1084  for(int n=0; n<nIFO; n++) {
1085  pTF[n] = pD[n]->getTFmap();
1086  if(useSparse&&(analysis!="1G")) { // data not present in TF map (2G phase2), the sparse TF maps are used
1087  int optSparse = pD[n]->getSTFind(optRate); // get optimal sparse map index
1088  pD[n]->vSS[optSparse].Expand(true); // rebuild wseries from sparse table
1089  pTF[n] = new WSeries<double>(*(WSeries<double>*)&(pD[n]->vSS[optSparse]));
1090  pTF[n]->setlow(pD[n]->getTFmap()->getlow());
1091  pTF[n]->sethigh(pD[n]->getTFmap()->gethigh());
1092  }
1093  // rescale data when data are resampled (resample with wavelet change the amplitude)
1094  double rescale = 1./pow(sqrt(2.),TMath::Log2(inRate/pTF[n]->rate()));
1095  *pTF[n]*=rescale; // rescale TF map
1096  }
1097 
1098  // plot spectrograms
1099  for(int n=0; n<nIFO; n++) {
1100  if(pTF[n]->size()==0) continue;
1101  if(pTF[n]->getLevel()>0) pTF[n]->Inverse();
1102 
1103  int nfact=4;
1104  int nfft=nfact*512;
1105  int noverlap=nfft-10;
1106  double fparm=nfact*6;
1107  //int ystart = (EVT->start[n]-pTF[n]->start()-1)*pTF[n]->rate();
1108  //int ystop = (EVT->stop[n]-pTF[n]->start()+1)*pTF[n]->rate();
1109  int ystart = int((EVT->start[n]-EVT->gps[n]-1)*pTF[n]->rate());
1110  int ystop = int((EVT->stop[n]-EVT->gps[n]+1)*pTF[n]->rate());
1111  ystart-=nfft;
1112  ystop+=nfft;
1113  int ysize=ystop-ystart;
1114  wavearray<double> y;y.resize(ysize);y.rate(pTF[n]->rate());y.start(ystart/pTF[n]->rate());
1115 
1116  // stft use dt=y.rate() to normalize data but whitened data are already normalized by dt
1117  // so before stft data must be divided by 1./sqrt(dt)
1118  for(int i=0;i<(int)y.size();i++) y.data[i]=pTF[n]->data[i+ystart]/sqrt(y.rate());
1119 
1120  CWB::STFT stft(y,nfft,noverlap,"energy","gauss",fparm);
1121 
1122  TCanvas* canvas;
1123  double tstart = nfft/pTF[n]->rate()+ystart/pTF[n]->rate();
1124  double tstop = (ysize-nfft)/pTF[n]->rate()+ystart/pTF[n]->rate();
1125  stft.Draw(tstart,tstop,pTF[n]->getlow(),pTF[n]->gethigh(),0,spectrogram_zmax,1);
1126  stft.GetHistogram()->GetXaxis()->SetTitle(xtitle[n]);
1127  sprintf(fname, "%s/%s_spectrogram_1.%s", dirCED, NET->ifoName[n], gtype);
1128  canvas = stft.GetCanvas();
1129  if(sbasedirCED!=NULL) stft.Print(fname); else canvas->Write(REPLACE(fname,dirCED,gtype));
1130  canvas->SetLogy(true);
1131  stft.GetHistogram()->GetXaxis()->SetTitle(xtitle[n]);
1132  sprintf(fname, "%s/%s_spectrogram_logy_1.%s", dirCED, NET->ifoName[n], gtype);
1133  if(sbasedirCED!=NULL) stft.Print(fname); else canvas->Write(REPLACE(fname,dirCED,gtype));
1134 
1135  tstart+=0.9;tstop-=0.9;
1136  stft.Draw(tstart,tstop,pTF[n]->getlow(),pTF[n]->gethigh(),0,spectrogram_zmax,1);
1137  stft.GetHistogram()->GetXaxis()->SetTitle(xtitle[n]);
1138  sprintf(fname, "%s/%s_spectrogram_0.%s", dirCED, NET->ifoName[n], gtype);
1139  canvas = stft.GetCanvas();
1140  if(sbasedirCED!=NULL) stft.Print(fname); else canvas->Write(REPLACE(fname,dirCED,gtype));
1141  canvas->SetLogy(true);
1142  stft.GetHistogram()->GetXaxis()->SetTitle(xtitle[n]);
1143  sprintf(fname, "%s/%s_spectrogram_logy_0.%s", dirCED, NET->ifoName[n], gtype);
1144  if(sbasedirCED!=NULL) stft.Print(fname); else canvas->Write(REPLACE(fname,dirCED,gtype));
1145 
1146  y.resize(0);
1147  }
1148 
1149  // set TF maps to optimal resolution level
1150  for(int n=0; n<nIFO; n++) {
1151  float fLow = pTF[n]->getlow();
1152  float fHigh = pTF[n]->gethigh();
1153  if(useSparse&&(analysis!="1G")) { // data not present in TF map (2G phase2), use sparse TP map
1154  int optSparse = pD[n]->getSTFind(optRate); // get optimal sparse map index
1155  delete pTF[n];
1156  pTF[n] = new WSeries<double>(*(WSeries<double>*)&(pD[n]->vSS[optSparse]));
1157  } else {
1158  if(pTF[n]->size()==0) continue;
1159  if(NET->wdm()) {if(NET->getwdm(optLayer+1)) pTF[n]->Forward(*pTF[n],*NET->getwdm(optLayer+1));}
1160  else pTF[n]->Forward(optLevel);
1161  }
1162  pTF[n]->setlow(fLow);
1163  pTF[n]->sethigh(fHigh);
1164  }
1165 
1166  WTS.canvas->cd();
1167 
1168  // plot scalogram maps at optimal resolution level
1169  for(int n=0; n<nIFO; n++) {
1170  if(pTF[n]->size()==0) continue;
1171  sprintf(fname, "%s/%s_scalogram_1.%s", dirCED, NET->ifoName[n], gtype);
1172  WTS.plot(pTF[n], 2, EVT->start[n]-EVT->slag[n]-1,
1173  EVT->stop[n]-EVT->slag[n]+1,const_cast<char*>("COLZ"));
1174  WTS.hist2D->GetYaxis()->SetRangeUser(pTF[n]->getlow(),pTF[n]->gethigh());
1175  WTS.hist2D->GetXaxis()->SetTitle(xtitle[n]);
1176  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1177  WTS.clear();
1178  }
1179 
1180  // plot zoomed scalogram maps at optimal resolution level
1181  for(int n=0; n<nIFO; n++) {
1182  if(pTF[n]->size()==0) continue;
1183  WTS.plot(pTF[n], 2, EVT->start[n]-EVT->slag[n]-0.1,
1184  EVT->stop[n]-EVT->slag[n]+0.1, const_cast<char*>("COLZ"));
1185  WTS.hist2D->GetYaxis()->SetRangeUser(pTF[n]->getlow(),pTF[n]->gethigh());
1186  WTS.hist2D->GetXaxis()->SetTitle(xtitle[n]);
1187  sprintf(fname, "%s/%s_scalogram_0.%s", dirCED, NET->ifoName[n], gtype);
1188  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1189  //sprintf(fname, "%s/%s_scalogram_0.%s", dirCED, NET->ifoName[n], "root");
1190  //WTS.canvas->Print(fname);
1191  WTS.clear();
1192  }
1193 
1194  // resize to 0 sseries
1195  for(int n=0; n<nIFO; n++) {
1196  if(useSparse&&(analysis!="1G")) { // data not present in TF map (2G phase2), the sparse TF maps are used
1197  int optSparse = pD[n]->getSTFind(optRate); // get optimal sparse map index
1198  pD[n]->vSS[optSparse].Shrink(); // resize 0 wseries : leave only sparse table
1199  delete pTF[n];
1200  } else {
1201  // rescale data when data are resampled (resample with wavelet change the amplitude)
1202  double rescale = 1./pow(sqrt(2.),TMath::Log2(inRate/pTF[n]->rate()));
1203  *pTF[n]*=1./rescale; // restore original rescaled TF map
1204  }
1205  }
1206 
1207  // get reconstructed wave forms, signal
1208 
1209  int type = 1;
1210 
1211  PTS.canvas->cd();
1212 
1213  if(NET->like()=='2') {NET->getMRAwave(ID,k,'S',wmod,true);NET->getMRAwave(ID,k,'W',wmod,true);}
1214  else NET->getwave(ID, k, 'W');
1215 
1216  // rescale data when data are resampled (resample with wavelet change the amplitude)
1217  double rescale = 1./pow(sqrt(2.),TMath::Log2(inRate/pD[0]->waveForm.rate()));
1218  for(int n=0; n<nIFO; n++) {
1219  pD[n]->waveForm*=rescale; pD[n]->waveBand*=rescale; // rescale data
1220  double bT,eT;
1221  GetBoundaries((wavearray<double>&)pD[n]->waveForm, 0.999, bT, eT);
1222  sprintf(fname, "%s/%s_wf_signal.%s", dirCED, NET->ifoName[n], gtype);
1223  if(NET->wdm()) {
1224  PTS.plot((wavearray<double>&)pD[n]->waveBand, const_cast<char*>("ALP"), kGray, bT, eT);
1225  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("SAME"), kRed, bT, eT);
1226  } else {
1227  PTS.plot((wavearray<double>&)pD[n]->waveBand, const_cast<char*>("ALP"), kGray, bT, eT);
1228  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("SAME"), kRed, bT, eT);
1229  }
1230  PTS.graph[0]->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1231  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1232  PTS.clear();
1233 
1234  sprintf(fname, "%s/%s_wf_signal_fft.%s", dirCED, NET->ifoName[n], gtype);
1235  double flow = EVT->low[0];
1236  double fhigh = EVT->high[0];
1237  PTS.canvas->SetLogy(true);
1238  PTS.plot((wavearray<double>&)pD[n]->waveBand, const_cast<char*>("ALP"), kGray, 0., 0., true, flow, fhigh);
1239  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("SAME"), kRed, 0., 0., true, flow, fhigh);
1240  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1241  PTS.canvas->SetLogy(false);
1242  PTS.clear();
1243  }
1244 
1245  //save whitenet waveforms (SNR^2 = the sum of the squares of the samples)
1246 
1247  for(int n=0; n<nIFO; n++) {
1248  pD[n]->waveForm*=1./rescale; pD[n]->waveBand*=1./rescale; // restore original rescaled data
1249  //pD[n]->waveForm*=sqrt(pD[n]->waveForm.rate()); // normalize data to get snr=sqrt(sum(amp*amp*dt))
1250  sprintf(fname, "%s/%s_wf_signal.dat", dirCED, NET->ifoName[n]);
1251  double wstart = pD[n]->waveForm.wavearray<double>::start(); // save relative start time
1252  pD[n]->waveForm.wavearray<double>::start(EVT->gps[n]+pD[n]->waveForm.wavearray<double>::start()); // set absolute time
1253  if(sbasedirCED!=NULL) pD[n]->waveForm.wavearray<double>::Dump(const_cast<char*>(fname),2); // time, strain format
1254  //if(sbasedirCED!=NULL) pD[n]->waveForm.Dump(const_cast<char*>(fname));
1255  //pD[n]->waveForm*=1./sqrt(pD[n]->waveForm.rate()); // restore original rescaled data
1256  }
1257 
1258  // get reconstructed waveforms, signal + noise
1259 
1260  for(int n=0; n<nIFO; n++) pD[n]->waveBand.sethigh(0);
1261 
1262  if(NET->like()=='2') {NET->getMRAwave(ID,k,'s',wmod,true);NET->getMRAwave(ID,k,'w',wmod,true);}
1263  else NET->getwave(ID, k, 'S');
1264  for(int n=0; n<nIFO; n++) {
1265  pD[n]->waveForm*=rescale; pD[n]->waveBand*=rescale; // rescale data
1266  sprintf(fname, "%s/%s_wf_noise.%s", dirCED, NET->ifoName[n], gtype);
1267  if(NET->wdm()) {
1268  PTS.plot((wavearray<double>&)pD[n]->waveBand, const_cast<char*>("ALP"), kGray);
1269  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("SAME"), kRed);
1270  } else {
1271  PTS.plot((wavearray<double>&)pD[n]->waveBand, const_cast<char*>("ALP"), kGray);
1272  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("SAME"), kRed);
1273  }
1274  PTS.graph[0]->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1275  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1276  PTS.clear();
1277  }
1278 
1279  // get reconstructed waveforms, strain
1280  double bT,eT;
1281  for(int n=0; n<nIFO; n++) pD[n]->waveBand.sethigh(0);
1282  if(NET->like()=='2') NET->getMRAwave(ID,k,'s',wmod,true);
1283  else NET->getwave(ID, k, 'w');
1284  for(int n=0; n<nIFO; n++) {
1285  pD[n]->waveForm*=rescale; // rescale data
1286  GetBoundaries((wavearray<double>&)pD[n]->waveForm, 0.999, bT, eT);
1287  sprintf(fname, "%s/%s_wf_strain.%s", dirCED, NET->ifoName[n], gtype);
1288  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("ALP"), kRed, bT, eT);
1289  PTS.graph[0]->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1290  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1291  PTS.clear();
1292 
1293  GetBoundaries((wavearray<double>&)pD[n]->waveForm, 0.95, bT, eT);
1294  sprintf(fname, "%s/%s_wf_strain_zoom.%s", dirCED, NET->ifoName[n], gtype);
1295  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("ALP"), kRed, bT, eT);
1296  PTS.graph[0]->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1297  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1298  PTS.clear();
1299 
1300  double flow = EVT->low[0];
1301  double fhigh = EVT->high[0];
1302  sprintf(fname, "%s/%s_wf_strain_fft.%s", dirCED, NET->ifoName[n], gtype);
1303  PTS.plot((wavearray<double>&)pD[n]->waveForm, const_cast<char*>("ALP"), kRed, 0., 0., true, flow, fhigh);
1304  if(sbasedirCED!=NULL) PTS.canvas->Print(fname); else PTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1305  PTS.clear();
1306  }
1307 
1308  //save waveforms
1309 
1310  for(int n=0; n<nIFO; n++) {
1311  sprintf(fname, "%s/%s_wf_strain.dat", dirCED, NET->ifoName[n]);
1312  double wstart = pD[n]->waveForm.wavearray<double>::start(); // save relative start time
1313  pD[n]->waveForm.wavearray<double>::start(EVT->gps[n]+pD[n]->waveForm.wavearray<double>::start()); // set absolute time
1314  if(sbasedirCED!=NULL) pD[n]->waveForm.wavearray<double>::Dump(const_cast<char*>(fname),2); // time, strain format
1315  pD[n]->waveForm.wavearray<double>::start(wstart); // restore relative start time
1316  //if(sbasedirCED!=NULL) pD[n]->waveForm.Dump(const_cast<char*>(fname));
1317  }
1318 
1319  if(nIFO==1 || !fullCED) {
1320  if(NET->wdm()) NET->getwc(k)->sCuts[ID-1]=1; // mark clusters as processed (rejected)
1321  goto skip_skymap; // skip skymaps
1322  }
1323 
1324  // plot polargrams
1325 
1326  if(analysis.Contains("2G")) {
1327  for(m=0;m<2;m++) {
1328  gStyle->SetLineColor(kBlack);
1329  TCanvas* CPol = gNET.DrawPolargram(m,NET);
1330  if(CPol!=NULL) {
1331  sprintf(fname, "%s/polargram_%d.%s", dirCED, m+1, gtype);
1332  if(sbasedirCED!=NULL) CPol->Print(fname); else CPol->Write(REPLACE(fname,dirCED,gtype));
1333  }
1334  gStyle->SetLineColor(kWhite);
1335  }
1336  }
1337 
1338  //likelihood skymaps
1339 
1340  inj.SetX(EVT->phi[1]<180?EVT->phi[1]:EVT->phi[1]-360); inj.SetY(90.-EVT->theta[1]); // injected pos (white star)
1341  INJ.SetX(EVT->phi[1]<180?EVT->phi[1]:EVT->phi[1]-360); INJ.SetY(90.-EVT->theta[1]); // injected pos (ewhite star)
1342  rec.SetX(EVT->phi[0]<180?EVT->phi[0]:EVT->phi[0]-360); rec.SetY(90.-EVT->theta[0]); // recostr. pos (black star)
1343  REC.SetX(EVT->phi[0]<180?EVT->phi[0]:EVT->phi[0]-360); REC.SetY(90.-EVT->theta[0]); // recostr. pos (ewhite star)
1344  det.SetX(EVT->phi[3]<180?EVT->phi[3]:EVT->phi[3]-360); det.SetY(90.-EVT->theta[3]); // detected pos (black dot )
1345  DET.SetX(EVT->phi[3]<180?EVT->phi[3]:EVT->phi[3]-360); DET.SetY(90.-EVT->theta[3]); // detected pos (ewhite dot )
1346 
1347  inj.SetMarkerSize(2.5); inj.SetMarkerColor(kWhite);
1348  INJ.SetMarkerSize(2.5); INJ.SetMarkerColor(kBlack);
1349  rec.SetMarkerSize(2.5); rec.SetMarkerColor(kBlack);
1350  REC.SetMarkerSize(2.5); REC.SetMarkerColor(kWhite);
1351  det.SetMarkerSize(1.5); det.SetMarkerColor(kBlack);
1352  DET.SetMarkerSize(1.5); DET.SetMarkerColor(kWhite);
1353 
1354  gSM=NET->nSensitivity;
1355  sprintf(fname, "%s/sensitivity_plus.%s", dirCED, gtype);
1356  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1357  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1358  gSM=NET->nAlignment;
1359  sprintf(fname, "%s/sensitivity_cross.%s", dirCED, gtype);
1360  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1361  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1362  gSM=NET->nSkyStat;;
1363  sprintf(fname, "%s/skystat.%s", dirCED, gtype);
1364  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1365  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1366  gSM=NET->nLikelihood;;
1367  sprintf(fname, "%s/likelihood.%s", dirCED, gtype);
1368  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1369  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1370  gSM=NET->nNullEnergy;;
1371  sprintf(fname, "%s/null_energy.%s", dirCED, gtype);
1372  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1373  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1374  gSM=NET->nCorrEnergy;;
1375  sprintf(fname, "%s/corr_energy.%s", dirCED, gtype);
1376  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1377  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1378  gSM=NET->nPenalty;;
1379  sprintf(fname, "%s/penalty.%s", dirCED, gtype);
1380  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1381  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1382  gSM=NET->nDisbalance;;
1383  sprintf(fname, "%s/disbalance.%s", dirCED, gtype);
1384  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1385  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1386  gSM=NET->nCorrelation;;
1387  sprintf(fname, "%s/correlation.%s", dirCED, gtype);
1388  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1389  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1390  gSM=NET->nNetIndex;;
1391  gSM.GetHistogram()->GetZaxis()->SetRangeUser(1,nIFO);
1392  sprintf(fname, "%s/netindex.%s", dirCED, gtype);
1393  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1394  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1395  gSM.GetHistogram()->GetZaxis()->UnZoom();
1396  gSM=NET->nEllipticity;;
1397  sprintf(fname, "%s/ellipticity.%s", dirCED, gtype);
1398  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1399  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1400  gSM=NET->nPolarisation;;
1401  sprintf(fname, "%s/polarisation.%s", dirCED, gtype);
1402  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1403  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1404  gSM=NET->nProbability;;
1405  gSM.GetHistogram()->GetZaxis()->SetRangeUser(0,gSM.max());
1406  sprintf(fname, "%s/probability.%s", dirCED, gtype);
1407  gSM.Draw(); rec.Draw();REC.Draw(); det.Draw();DET.Draw(); if(simulation) {inj.Draw();INJ.Draw();}
1408  if(sbasedirCED!=NULL) gSM.Print(fname); else gSM.Write(REPLACE(fname,dirCED,gtype));
1409 
1410  // Dump probability skymap
1411  //int L = NET->nProbability.size();
1412  //wavearray<float> xprob(L);
1413  //for(int ll=0;ll<L;ll++) xprob.data[ll]=NET->nProbability.get(ll);
1414  sprintf(fname, "%s/probability.%s", dirCED, "root");
1415  if(sbasedirCED!=NULL) {
1417  gSM.SetOptions("","Geographic");
1418  gSM.DumpObject(fname);
1419  }
1420  //xprob.resize(0);
1421 
1422 #ifdef _USE_HEALPIX
1423  // Dump2fits probability skymap (healpix)
1424  if(sbasedirCED!=NULL) {
1425  sprintf(fname, "%s/probability.%s", dirCED, "fits");
1426  if(NET->nProbability.getType())
1427  NET->nProbability.Dump2fits(fname,EVT->time[0],const_cast<char*>(""),
1428  const_cast<char*>("PROB"),const_cast<char*>("pix-1"),'C');
1429  }
1430 #endif
1431 
1432  // add great circles (rec pos) to probability skymap
1433  sprintf(fname, "%s/probability_circles.%s", dirCED, gtype);
1434  gNET.SetGskymap(gSM);
1435  gNET.GetGskymap()->Draw();
1436  double phi,theta;
1437  CwbToGeographic(EVT->phi[0],EVT->theta[0],phi,theta);
1438  gNET.DrawCircles(phi,theta,(Color_t)kBlack,1,1,true);
1439  rec.Draw(); det.Draw();
1440  if(sbasedirCED!=NULL) gNET.GetGskymap()->Print(fname);
1441  else gNET.GetGskymap()->Write(REPLACE(fname,dirCED,gtype));
1442 
1443  skip_skymap:
1444 
1445  // get network time
1446  double gps_start = EVT->time[masterDet]-EVT->duration[1];
1447  double gps_stop = EVT->time[masterDet]+EVT->duration[1];
1448 
1449  // draw chirp : f^(-8/3) vs time
1450  if(NET->like()=='2') {
1451  PCH.canvas->cd();
1452  clusterdata* pcd = &(NET->getwc(k)->cData[ID-1]);
1453  sprintf(fname, "%s/mchirp.%s", dirCED, gtype);
1454  if(pcd->chirp.GetN()>0) { // number of points > 0
1455  PCH.plot(pcd, simulation ? EVT->chirp[0] : 0);
1456  if(sbasedirCED!=NULL) PCH.canvas->Print(fname);
1457  else PCH.canvas->Write(REPLACE(fname,dirCED,gtype));
1458  }
1459  PCH.clear();
1460  }
1461 
1462  // in likelihood2G pixeLHood,pixeLNull are not defined
1463  // use monster event display (multi resolution analysis)
1464  if(NET->like()=='2') {
1465  bool isPCs = !(NET->optim&&std::isupper(search)); // are Principal Components ?
1466  WTS.canvas->cd();
1467  netcluster* pwc = NET->getwc(k);
1468  sprintf(fname, "%s/l_tfmap_scalogram.%s", dirCED, gtype);
1469  WTS.plot(pwc, ID, nIFO, isPCs?'L':'l', 0, const_cast<char*>("COLZ"),256,NET->pattern>0);
1470  WTS.hist2D->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1471  if(sbasedirCED!=NULL) WTS.canvas->Print(fname);
1472  else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1473  WTS.clear();
1474  sprintf(fname, "%s/n_tfmap_scalogram.%s", dirCED, gtype);
1475  WTS.plot(pwc, ID, nIFO, isPCs?'N':'n', 0, const_cast<char*>("COLZ"),256,NET->pattern>0);
1476  WTS.hist2D->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1477  if(sbasedirCED!=NULL) WTS.canvas->Print(fname);
1478  else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1479  WTS.clear();
1480  } else {
1481  // plot likelihood map
1482  WTS.canvas->cd();
1483  sprintf(fname, "%s/l_tfmap_scalogram.%s", dirCED, gtype);
1484  WTS.plot(NET->pixeLHood, 0, gps_start-EVT->slag[masterDet],
1485  gps_stop-EVT->slag[masterDet], const_cast<char*>("COLZ"));
1486  WTS.hist2D->GetYaxis()->SetRangeUser(EVT->low[0],EVT->high[0]);
1487  WTS.hist2D->SetTitle("Scalogram");
1488  WTS.hist2D->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1489  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1490  WTS.clear();
1491 
1492  // plot null map
1493  sprintf(fname, "%s/n_tfmap_scalogram.%s", dirCED, gtype);
1494  WTS.plot(NET->pixeLNull, 0, gps_start-EVT->slag[masterDet],
1495  gps_stop-EVT->slag[masterDet], const_cast<char*>("COLZ"));
1496  WTS.hist2D->GetYaxis()->SetRangeUser(EVT->low[0],EVT->high[0]);
1497  WTS.hist2D->SetTitle("Scalogram");
1498  WTS.hist2D->GetXaxis()->SetTitle(xtitle[minTimeDet]);
1499  if(sbasedirCED!=NULL) WTS.canvas->Print(fname); else WTS.canvas->Write(REPLACE(fname,dirCED,gtype));
1500  WTS.clear();
1501  }
1502 
1503  // mark clusters as processed (rejected)
1504  if(NET->wdm()) NET->getwc(k)->sCuts[ID-1]=1;
1505 
1506  } // End loop on found events
1507  } // End loop on lags
1508 
1509  // restore NET thresholds
1510  NET->netCC = old_cc;
1511  NET->netRHO = old_rho;
1512 
1513  gROOT->SetBatch(batch); // restore batch status
1514 
1515  return 1;
1516 }
1517 
1518 double
1519 CWB::ced::GetBoundaries(wavearray<double> x, double P, double& bT, double& eT) {
1520 
1521  if(P<0) P=0;
1522  if(P>1) P=1;
1523 
1524  int N = x.size();
1525 
1526  double E = 0; // signal energy
1527  double avr = 0; // average
1528  for(int i=0;i<N;i++) {avr+=i*x[i]*x[i]; E+=x[i]*x[i];}
1529  int M=int(avr/E); // central index
1530 
1531  // search range which contains percentage P of the total energy E
1532  int jB=0;
1533  int jE=N-1;
1534  double a,b;
1535  double sum = ((M>=0)&&(M<N)) ? x[M]*x[M] : 0.;
1536  for(int j=1; j<N; j++) {
1537  a = ((M-j>=0)&&(M-j<N)) ? x[M-j] : 0.;
1538  b = ((M+j>=0)&&(M+j<N)) ? x[M+j] : 0.;
1539  if(a) jB=M-j;
1540  if(b) jE=M+j;
1541  sum += a*a+b*b;
1542  if(sum/E > P) break;
1543  }
1544 
1545  bT = x.start()+jB/x.rate();
1546  eT = x.start()+jE/x.rate();
1547 
1548  return eT-bT;
1549 }
1550 
1551 void
1553 
1554  if(TString(options)!="") {
1555 
1556  TObjArray* token = TString(options).Tokenize(TString(' '));
1557  for(int j=0;j<token->GetEntries();j++) {
1558 
1559  TObjString* tok = (TObjString*)token->At(j);
1560  TString stok = tok->GetString();
1561 
1562  // set max z value used for spectrograms
1563  if(stok.Contains("spectrogram_zmax=")) {
1564  TString _spectrogram_zmax=stok;
1565  _spectrogram_zmax.Remove(0,_spectrogram_zmax.Last('=')+1);
1566  if(_spectrogram_zmax.IsFloat()) spectrogram_zmax=_spectrogram_zmax.Atof();
1567  }
1568  }
1569  }
1570 }
1571 
std::vector< char * > ifoName
Definition: network.hh:609
void SetOptions(int simulation, double rho, double inRate, bool useSparse=false, char *gtype=const_cast< char *>("png"), int paletteId=0)
Definition: ced.hh:88
TCanvas * DrawPolargram(int ptype, network *net=NULL)
Definition: gnetwork.cc:1535
void sethigh(double f)
Definition: wseries.hh:132
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
TH2D * GetHistogram()
Definition: gskymap.hh:138
gskymap * gSM
tfmap Forward(ts, wdm)
double rho
double netCC
Definition: network.hh:596
virtual void resize(unsigned int)
Definition: wseries.cc:901
Double_t * time
beam pattern coefficients for hx
Definition: injection.hh:89
#define NIFO
Definition: wat.hh:74
int noverlap
Definition: TestDelta.C:20
size_t nLag
Definition: network.hh:573
std::vector< vector_int > cRate
Definition: netcluster.hh:398
double getlow() const
Definition: wseries.hh:129
Float_t * rho
biased null statistics
Definition: netevent.hh:112
char xtitle[1024]
Float_t * high
min frequency
Definition: netevent.hh:104
TH1 * t1
WSeries< double > pixeLHood
Definition: network.hh:634
double M
Definition: DrawEBHH.C:13
gnetwork * gNET
std::vector< wavearray< double > > wREC[MAX_TRIALS]
std::vector< netcluster > wc_List
Definition: network.hh:610
Float_t ecor
Definition: netevent.hh:120
Double_t * start
cluster duration = stopW-startW
Definition: netevent.hh:99
std::vector< double > * getmdcTime()
Definition: network.hh:422
double fHigh
virtual void rate(double r)
Definition: wavearray.hh:141
Float_t * duration
max cluster time relative to segment start
Definition: netevent.hh:98
Float_t * low
average center_of_snr frequency
Definition: netevent.hh:103
void Print(TString pname)
Definition: STFT.cc:315
float factor
bool getwave(size_t, size_t, char='W')
param: cluster ID param: delay index param: time series type return: true if time series are extracte...
Definition: network.cc:3576
void DrawCircles(double phi, double theta, double gps, Color_t lcolor=kBlack, Width_t lwidth=1, Style_t lstyle=1, bool labels=false)
Definition: gnetwork.cc:1308
wavearray< double > a(hp.size())
void SetGskymap(gskymap &gSM)
Definition: gnetwork.hh:45
int n
Definition: cwb_net.C:28
skymap nSkyStat
Definition: network.hh:628
double imag() const
Definition: wavecomplex.hh:70
TString("c")
void set(size_t i, double a)
Definition: gskymap.hh:128
size_t nRun
Definition: network.hh:572
double GetBoundaries(wavearray< double > x, double P, double &bT, double &eT)
Definition: ced.cc:1519
int ID
Definition: TestMDC.C:70
Float_t * right
segment start GPS time
Definition: netevent.hh:96
skymap nPenalty
Definition: network.hh:624
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...
Definition: netcluster.cc:2207
std::vector< wavearray< double > * > RWFP
Definition: detector.hh:382
float theta
int nfact
Definition: TestDelta.C:18
WDM< double > wdm(nLAYERS, nLAYERS, 6, 10)
wavearray< double > psd(33)
netcluster * pwc
Definition: cwb_job_obj.C:38
int nfft
Definition: TestDelta.C:19
TH2F * ph
string getmdcType(size_t n)
Definition: network.hh:420
std::vector< TGraph * > graph
Definition: watplot.hh:194
return wmap canvas
Float_t * left
min cluster time relative to segment start
Definition: netevent.hh:97
void setlow(double f)
Definition: wseries.hh:125
std::vector< SSeries< double > > vSS[NIFO_MAX]
string search
Definition: cWB_conf.py:110
char ifostr[64]
double getTheta(size_t i)
Definition: skymap.hh:224
Float_t * ioSNR
reconstructed snr waveform
Definition: netevent.hh:139
skymap nPolarisation
Definition: network.hh:630
void Draw(int dpaletteId=1, Option_t *option="colfz")
Definition: gskymap.cc:460
Long_t size
WSeries< double > waveBand
Definition: detector.hh:356
Int_t * type
event ID
Definition: netevent.hh:74
int m
Definition: cwb_net.C:28
DataType_t * pWWS
Definition: WaveDWT.hh:141
char command[1024]
Definition: cwb_compile.C:44
virtual void start(double s)
Definition: wavearray.hh:137
double max()
Definition: skymap.cc:438
std::vector< size_t > mdc__ID
Definition: network.hh:615
int j
Definition: cwb_net.C:28
double rate
Definition: detector.hh:341
bool getMRAwave(size_t ID, size_t lag, char atype='S', int mode=0, bool tof=false)
Definition: network.cc:3666
i drho i
double rate
Definition: netcluster.hh:378
double gethigh() const
Definition: wseries.hh:136
skymap tau
Definition: detector.hh:346
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
Definition: watplot.cc:150
#define N
double GetBoundaries(wavearray< double > x, double P, double &bT, double &eT)
double pi
Definition: TestChirp.C:18
skymap nCorrEnergy
Definition: network.hh:625
void dopen(const char *fname, char *mode, bool header=true)
Definition: netevent.hh:312
TH2F * hist2D
Definition: watplot.hh:193
void Draw(double t1=0.0, double t2=0.0, double f1=0.0, double f2=0.0, double z1=0.0, double z2=0.0, int dpaletteId=DUMMY_PALETTE_ID, Option_t *option="colfz")
Definition: STFT.cc:94
size_t ifoListSize()
Definition: network.hh:431
Int_t run
max size used by allocate() for the probability maps
Definition: netevent.hh:71
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
WDM< double > * getwdm(size_t M)
param: number of wdm layers
Definition: network.hh:448
skymap nLikelihood
Definition: network.hh:622
void clear()
Definition: watplot.hh:58
bool optim
Definition: network.hh:590
#define nIFO
size_t getSkyIndex(double th, double ph)
param: theta param: phi
Definition: skymap.cc:720
double tstart
virtual size_t size() const
Definition: wavearray.hh:145
TCanvas * canvas
Definition: watplot.hh:192
tlive_fix Write()
int getLevel()
Definition: wseries.hh:109
float phi
Float_t * frequency
GPS stop time of the cluster.
Definition: netevent.hh:102
TString chName[NIFO_MAX]
double ra
Definition: ConvertGWGC.C:46
wavecomplex antenna(double, double, double=0.)
param: source theta,phi, polarization angle psi in degrees
Definition: detector.cc:490
void output2G(TTree *, network *, size_t, int, double)
Definition: netevent.cc:711
Int_t nevent
run ID
Definition: netevent.hh:72
Double_t * hrss
estimated bandwidth
Definition: injection.hh:95
double real() const
Definition: wavecomplex.hh:69
WSeries< double > nRMS
Definition: detector.hh:358
watplot * WTS
Definition: ChirpMass.C:119
Float_t * Deff
eBBH array
Definition: netevent.hh:130
Double_t * gps
average center_of_gravity time
Definition: netevent.hh:95
double getRA(size_t i)
Definition: skymap.hh:215
watplot * PCH
Definition: ChirpMass.C:120
i() int(T_cor *100))
network NET
Definition: cwb_dump_inj.C:30
double Pi
const int NIFO_MAX
Definition: wat.hh:22
double fhigh
TH2D * GetHistogram()
Definition: STFT.hh:71
Double_t * stop
GPS start time of the cluster.
Definition: netevent.hh:100
WSeries< double > pTF[nRES]
Definition: revMonster.cc:8
int l
Float_t * lag
time between consecutive events
Definition: netevent.hh:84
char fname[1024]
segLen
Definition: cwb_eced.C:24
int nsize
std::vector< int > RWFID
Definition: detector.hh:381
int Write(double factor, bool fullCED=true)
Definition: ced.cc:607
size_t mdc__IDSize()
Definition: network.hh:414
int k
int pattern
Definition: network.hh:601
double tstop
UserGroup_t * uinfo
Definition: cwb_frdisplay.C:91
Float_t * netcc
effective correlated SNR
Definition: netevent.hh:113
TObjArray * token
double acor
Definition: network.hh:585
Float_t * slag
time lag [sec]
Definition: netevent.hh:85
void output(TTree *=NULL, network *=NULL, double=0., size_t=0, int=-1)
Definition: netevent.cc:1193
Definition: skymap.hh:63
double e
long likelihood(char='E', double=sqrt(2.), int=0, size_t=0, int=-1, bool=false)
Definition: network.cc:4446
size_t size()
Definition: netcluster.hh:147
Double_t * hrss
high-low
Definition: netevent.hh:106
char like()
Definition: network.hh:512
double flow
char options[256]
gskymap * GetGskymap()
Definition: gnetwork.hh:44
double getPhi(size_t i)
Definition: skymap.hh:164
WSeries< double > TFmap
Definition: detector.hh:354
TString cwb_parameters_file
char title[256]
Definition: SSeriesExample.C:1
Float_t * phi
sqrt(h+*h+ + hx*hx)
Definition: netevent.hh:87
WSeries< double > pixeLNull
Definition: network.hh:635
skymap nAlignment
Definition: network.hh:620
netevent EVT(itree, nifo)
Float_t * theta
[0]-reconstructed, [1]-injected phi angle, [2]-RA
Definition: netevent.hh:88
Double_t * time
beam pattern coefficients for hx
Definition: netevent.hh:94
double T
Definition: testWDM_4.C:11
TGraphErrors chirp
chirp fit parameters (don&#39;t remove ! fix crash when exit from CINT)
Definition: netcluster.hh:93
std::vector< int > sCuts
Definition: netcluster.hh:392
WSeries< double > waveForm
Definition: detector.hh:355
void dclose()
Definition: netevent.hh:321
double fLow
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:179
int getType()
Definition: skymap.hh:296
skymap nDisbalance
Definition: network.hh:627
Definition: Meyer.hh:36
double fabs(const Complex &x)
Definition: numpy.cc:55
double resolution(int=0)
Definition: wseries.hh:155
TCanvas * GetCanvas()
Definition: STFT.hh:70
char cmd[1024]
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
void CwbToGeographic(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:414
strcpy(RunLabel, RUN_LABEL)
void DumpObject(const char *file, const char *name="gskymap")
Definition: gskymap.cc:1231
Float_t likelihood
Definition: netevent.hh:124
Meyer< double > S(1024, 2)
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:439
Float_t * bx
beam pattern coefficients for hp
Definition: netevent.hh:92
skymap nNetIndex
Definition: network.hh:626
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
skymap nSensitivity
list of wdm tranformations
Definition: network.hh:619
std::vector< clusterdata > cData
Definition: netcluster.hh:391
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:122
TString cwb_uparameters_file
DataType_t * data
Definition: wavearray.hh:319
Long_t id
Definition: ced.hh:44
skymap nNullEnergy
Definition: network.hh:623
char work_dir[512]
Definition: test_config1.C:143
double get(size_t i)
param: sky index
Definition: skymap.cc:699
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:456
wavearray< double > wINJ[NIFO_MAX]
in close()
skymap nCorrelation
Definition: network.hh:621
#define REPLACE(STRING, DIR, EXT)
Definition: ced.cc:45
cout<< "live time after cat 2 : "<< detSegs_ctime<< endl;if(detSegs_ctime< segTHR) {cout<< "job segment live time after cat2 < "<< segTHR<< " sec, job terminated !!!"<< endl;exit(1);} double Tb=detSegs[0].start;double Te=detSegs[0].stop;double dT=Te-Tb;char file[512], tdf00[512], tdf90[512], buFFer[1024];int rnID=int(gRandom->Rndm(13) *1.e9);if(simulation) { i=NET.readMDClog(injectionList, double(long(Tb)) -mdcShift);printf("GPS: %16.6f saved, injections: %d\", double(long(Tb)), i);frTB[nIFO].shiftBurstMDCLog(NET.mdcList, ifos, mdcShift);for(int i=0;i< NET.mdcTime.size();i++) NET.mdcTime[i]+=mdcShift;vector< waveSegment > mdcSegs(NET.mdcTime.size());for(int k=0;k< NET.mdcTime.size();k++) {mdcSegs[k].start=NET.mdcTime[k]-gap;mdcSegs[k].stop=NET.mdcTime[k]+gap;} vector< waveSegment > mdcSegs_dq2=slagTB.mergeSegLists(detSegs_dq2, mdcSegs);double mdcSegs_ctime=slagTB.getTimeSegList(mdcSegs_dq2);cout<< "live time in zero lag after cat2+inj : "<< mdcSegs_ctime<< endl;if(mdcSegs_ctime==0) {cout<< "job segment with zero cat2+inj live time in zero lag, job terminated !!!"<< endl;exit(1);} } if(dump_infos_and_exit) exit(0);if(mask >0.) NET.setSkyMask(mask, skyMaskFile);for(i=0;i< nIFO;i++) { frTB[i].readFrames(FRF[i], channelNamesRaw[i], x);x.start(x.start()+dataShift[i]);x.start(x.start() -segLen *(segID[i]-segID[0]));if(singleDetector) TB.resampleToPowerOfTwo(x);sprintf(file,"%s/%s_%d_%s_%d_%d.dat", nodedir, ifo[i], int(Tb), data_label, runID, rnID);if(dump_sensitivity_and_exit) { sprintf(file,"%s/sensitivity_%s_%d_%s_job%d.txt", dump_dir, ifo[i], int(Tb), data_label, runID);cout<< endl<< "Dump Sensitivity : "<< file<< endl<< endl;TB.makeSpectrum(file, x);continue;} if(dcCal[i]>0.) x *=dcCal[i];if(fResample >0) { x.FFT(1);x.resize(fResample/x.rate() *x.size());x.FFT(-1);x.rate(fResample);} pTF[i]=pD[i]-> getTFmap()
Bool_t fill_in(network *, int, bool=true)
Definition: injection.cc:349
Float_t * neted
network correlation coefficients: 0-net,1-pc,2-cc,3-net2
Definition: netevent.hh:114
simulation
Definition: cwb_eced.C:26
fclose(ftrig)
std::vector< SSeries< double > > vSS
Definition: detector.hh:352
size_t size()
Definition: skymap.hh:136
size_t getmdc__ID(size_t n)
Definition: network.hh:426
for(int i=0;i< 101;++i) Cos2[2][i]=0
pointers to detectors
wavearray< double > ** pwf
[x1,y1,z1,x2,y2,z2] components of spin vector
Definition: injection.hh:101
virtual void resize(unsigned int)
Definition: wavearray.cc:463
void Print(TString pname)
Definition: gskymap.cc:1122
bool MRA
Definition: network.hh:599
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:291
wavearray< double > y
Definition: Test10.C:31
bool wdm()
Definition: network.hh:510
int getSTFind(double r)
Definition: detector.hh:182
char tYPe
Definition: network.hh:588
double netRHO
Definition: network.hh:597
bool setndm(size_t, size_t, bool=true, int=1)
param: cluster ID param: lag index param: statistic identificator param: resolution idenificator retu...
Definition: network.cc:6525
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:84
skymap nProbability
Definition: network.hh:631
bool SETNDM(size_t, size_t, bool=true, int=1)
Definition: network.cc:6824
double fparm
Definition: TestDelta.C:22
Float_t * chirp
range to source: [0/1]-rec/inj
Definition: netevent.hh:128
detector ** pD
Float_t * Deff
injected snr in the detectors
Definition: injection.hh:97
CWB::STFT * stft
Definition: ChirpMass.C:121
void SetZaxisTitle(TString zAxisTitle)
Definition: gskymap.hh:150
exit(0)
Float_t * bp
[0]-reconstructed iota angle, [1]-injected iota angle
Definition: netevent.hh:91
Float_t * iSNR
energy of reconstructed responses Sk*Sk
Definition: netevent.hh:137
double avr
Float_t * bandwidth
max frequency
Definition: netevent.hh:105
skymap nEllipticity
Definition: network.hh:629
Float_t * oSNR
injected snr waveform
Definition: netevent.hh:138