Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_Skymap.C
Go to the documentation of this file.
1 #define XIFO 4
2 
3 #pragma GCC system_header
4 
5 #include "cwb.hh"
6 #include "config.hh"
7 #include "network.hh"
8 #include "wavearray.hh"
9 #include "TString.h"
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TRandom.h"
13 #include "TComplex.h"
14 #include "TMath.h"
15 #include "mdc.hh"
16 #include <vector>
17 
18 
19 void
21 //!EVENT_REPORT
22 // This plugin save skymap to output root file
23 
24  cout << endl;
25  cout << "-----> CWB_Plugin_Skymap.C" << endl;
26  cout << "ifo " << ifo.Data() << endl;
27  cout << "type " << type << endl;
28  cout << endl;
29 
30  if(type==CWB_PLUGIN_OLIKELIHOOD) {
31 
32  int i,j,k,n,m,l;
33  int nIFO = net->ifoListSize();
34  int K = net->nLag;
35  int M = net->mdc__ID.size();
36  int ID;
37  char search = net->tYPe;
38 
40 
41  bool batch = gROOT->IsBatch();
42  gROOT->SetBatch(true);
43 
44  watplot SMS(const_cast<char*>("sms"),200,20,800,400);
45 
46  char ifostr[20] = "";
47  char strtime[1024] = "";
48  char fname[1024];
49 
50  int minTimeDet=nIFO;
51  double minTime=1e40;
52  double eventTime[NIFO];
53  double lagTime[NIFO];
54  int ifoid[NIFO],sortid[NIFO];
55  double factor = 1;
56 
57 
58  //Fill in all skymaps
59  double old_cc = net->netCC;
60  double old_rho = net->netRHO;
61  net->netCC = -1;
62  net->netRHO = 0;
63 
64  // search output root file in the system list
65  TFile* froot = NULL;
66  TList *files = (TList*)gROOT->GetListOfFiles();
67  if (files) {
68  TIter next(files);
69  TSystemFile *file;
70  TString fname;
71  bool check=false;
72  while ((file=(TSystemFile*)next())) {
73  fname = file->GetName();
74  // set output root file as the current file
75  if(fname.Contains("wave_")) {froot=(TFile*)file;froot->cd();}
76  }
77  if(!froot) {
78  cout << "CWB_Plugin_skymap.C : Error - output root file not found" << endl;
79  exit(1);
80  }
81  } else {
82  cout << "CWB_Plugin_skymap.C : Error - output root file not found" << endl;
83  exit(1);
84  }
85 
86  TDirectory* cdskymap = (TDirectory*)froot->Get("skymap");
87  if(cdskymap==NULL) cdskymap = froot->mkdir("skymap");
88 
89  netevent* EVT = new netevent(nIFO);
90 
91  int rate = int(2*net->getifo(0)->TFmap.resolution(0)+0.5);
92 
93  for(k=0; k<K; k++) { // loop over the lags
94 
95  id = net->getwc(k)->get(const_cast<char*>("ID"), 0, 'L', rate);
96 
97  for(j=0; j<(int)id.size(); j++) { // loop over cluster index
98 
99  ID = size_t(id.data[j]+0.5); // cluster id
100 
101  EVT->output(NULL,net,factor,ID,k); // get reconstructed parameters
102  if(EVT->rho[1] < cfg->cedRHO) continue; // skip events under rho threshold
103 
104  int masterDet=0;
105  int lagMin=2147483647;
106  for(n=0; n<nIFO; n++) if(EVT->lag[n]<lagMin) {lagMin=int(EVT->lag[n]);masterDet=n;}
107 
108  net->likelihood(search, net->acor, ID, k); // exec likelihood search
109 
110  // get event network time
111  double gps_start = EVT->time[masterDet]-EVT->duration[masterDet];
112  double gps_stop = EVT->time[masterDet]+EVT->duration[masterDet];
113 
114  // create a unique label
115  for(n=0; n<nIFO; n++) sprintf(strtime, "%s_%.3f",strtime,EVT->start[n]);
116 
117  //likelihood skymaps
118  TMarker inj(EVT->phi[1],90.-EVT->theta[1], 29); // injected pos (white star)
119  TMarker rec(EVT->phi[0],90.-EVT->theta[0], 29); // recostructed pos (black star)
120  TMarker det(EVT->phi[3],90.-EVT->theta[3], 20); // detected pos (black dot )
121  inj.SetMarkerSize(2.0); inj.SetMarkerColor(kWhite);
122  rec.SetMarkerSize(2.0); rec.SetMarkerColor(kBlack);
123  det.SetMarkerSize(1.0); det.SetMarkerColor(kBlack);
124 
125  char evtdir[64];
126  sprintf(evtdir, "run_%d_id_%d",net->nRun,ID);
127  TDirectory* cdevtdir = (TDirectory*)cdskymap->Get(evtdir);
128  if(cdevtdir==NULL) cdevtdir = cdskymap->mkdir(evtdir);
129  cdevtdir->cd();
130 
131  SMS.canvas->cd();
132  sprintf(fname, "sensitivity_plus");
133  SMS.plot(net->nSensitivity, 0);
134  rec.Draw(); det.Draw(); if(M) inj.Draw();
135  SMS.canvas->Write(fname);
136  SMS.clear();
137  sprintf(fname, "sensitivity_cross");
138  SMS.plot(net->nAlignment, 0);
139  rec.Draw(); det.Draw(); if(M) inj.Draw();
140  SMS.canvas->Write(fname);
141  SMS.clear();
142  sprintf(fname, "skystat");
143  SMS.plot(net->nSkyStat, 0);
144  rec.Draw(); det.Draw(); if(M) inj.Draw();
145  SMS.canvas->Write(fname);
146  SMS.clear();
147  sprintf(fname, "likelihood");
148  SMS.plot(net->nLikelihood, 0);
149  rec.Draw(); det.Draw(); if(M) inj.Draw();
150  SMS.canvas->Write(fname);
151  SMS.clear();
152  sprintf(fname, "null_energy");
153  SMS.plot(net->nNullEnergy, 0);
154  rec.Draw(); det.Draw(); if(M) inj.Draw();
155  SMS.canvas->Write(fname);
156  SMS.clear();
157  sprintf(fname, "corr_energy");
158  SMS.plot(net->nCorrEnergy, 0);
159  rec.Draw(); det.Draw(); if(M) inj.Draw();
160  SMS.canvas->Write(fname);
161  SMS.clear();
162  sprintf(fname, "penalty");
163  SMS.plot(net->nPenalty, 0);
164  rec.Draw(); det.Draw(); if(M) inj.Draw();
165  SMS.canvas->Write(fname);
166  SMS.clear();
167  sprintf(fname, "disbalance");
168  SMS.plot(net->nDisbalance, 0);
169  rec.Draw(); det.Draw(); if(M) inj.Draw();
170  SMS.canvas->Write(fname);
171  SMS.clear();
172  sprintf(fname, "correlation");
173  SMS.plot(net->nCorrelation, 0);
174  rec.Draw(); det.Draw(); if(M) inj.Draw();
175  SMS.canvas->Write(fname);
176  SMS.clear();
177  sprintf(fname, "netindex");
178  SMS.plot(net->nNetIndex, 0);
179  rec.Draw(); det.Draw(); if(M) inj.Draw();
180  SMS.canvas->Write(fname);
181  SMS.clear();
182  sprintf(fname, "ellipticity");
183  SMS.plot(net->nEllipticity, 0);
184  rec.Draw(); det.Draw(); if(M) inj.Draw();
185  SMS.canvas->Write(fname);
186  SMS.clear();
187  sprintf(fname, "polarisation");
188  SMS.plot(net->nPolarisation, 0);
189  rec.Draw(); det.Draw(); if(M) inj.Draw();
190  SMS.canvas->Write(fname);
191  SMS.clear();
192  sprintf(fname, "probability");
193  SMS.plot(net->nProbability, 0);
194  rec.Draw(); det.Draw(); if(M) inj.Draw();
195  SMS.canvas->Write(fname);
196  SMS.clear();
197 
198  } // End loop on found events
199  } // End loop on lags
200 
201  // restore NET thresholds
202  net->netCC = old_cc;
203  net->netRHO = old_rho;
204  }
205 
206  return;
207 }
208 
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
double netCC
Definition: network.hh:578
#define NIFO
Definition: wat.hh:56
size_t nLag
Definition: network.hh:555
Float_t * rho
biased null statistics
Definition: netevent.hh:93
Double_t * start
cluster duration = stopW-startW
Definition: netevent.hh:80
Float_t * duration
max cluster time relative to segment start
Definition: netevent.hh:79
double cedRHO
Definition: config.hh:280
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
int n
Definition: cwb_net.C:10
skymap nSkyStat
Definition: network.hh:610
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TString("c")
size_t nRun
Definition: network.hh:554
int ID
Definition: TestMDC.C:70
skymap nPenalty
Definition: network.hh:606
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<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t 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:2188
char ifostr[64]
#define SMS
Definition: FrDisplay.cc:108
skymap nPolarisation
Definition: network.hh:612
Long_t size
#define M
Definition: UniqSLagsList.C:3
int m
Definition: cwb_net.C:10
std::vector< size_t > mdc__ID
Definition: network.hh:597
int j
Definition: cwb_net.C:10
i drho i
search
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:132
skymap nCorrEnergy
Definition: network.hh:607
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:413
skymap nLikelihood
Definition: network.hh:604
void clear()
Definition: watplot.hh:40
#define nIFO
TCanvas * canvas
Definition: watplot.hh:174
double factor
jfile
Definition: cwb_job_obj.C:25
i() int(T_cor *100))
TIter next(twave->GetListOfBranches())
Float_t * lag
time between consecutive events
Definition: netevent.hh:65
char fname[1024]
int k
double acor
Definition: network.hh:567
void output(TTree *=NULL, network *=NULL, double=0., size_t=0, int=-1)
Definition: netevent.cc:1166
long likelihood(char='E', double=sqrt(2.), int=0, size_t=0, int=-1, bool=false)
Definition: network.cc:4415
TFile * froot
WSeries< double > TFmap
Definition: detector.hh:336
Float_t * phi
sqrt(h+*h+ + hx*hx)
Definition: netevent.hh:68
skymap nAlignment
Definition: network.hh:602
netevent EVT(itree, nifo)
Float_t * theta
[0]-reconstructed, [1]-injected phi angle, [2]-RA
Definition: netevent.hh:69
Double_t * time
beam pattern coefficients for hx
Definition: netevent.hh:75
skymap nDisbalance
Definition: network.hh:609
string file
Definition: cwb_online.py:385
double resolution(int=0)
Definition: wseries.hh:137
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:421
int l
Definition: cbc_plots.C:434
skymap nNetIndex
Definition: network.hh:608
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
skymap nSensitivity
list of wdm tranformations
Definition: network.hh:601
Long_t id
skymap nNullEnergy
Definition: network.hh:605
skymap nCorrelation
Definition: network.hh:603
list files
Definition: cwb_online.py:529
int check
char tYPe
Definition: network.hh:570
double netRHO
Definition: network.hh:579
skymap nProbability
Definition: network.hh:613
exit(0)
skymap nEllipticity
Definition: network.hh:611