11 #pragma GCC system_header
19 #include "TObjArray.h"
20 #include "TObjString.h"
42 #define DISPLAY_WORLD_MAP
50 #define TREE_NAME "waveburst"
55 #define SNR_THRESHOLD 100000000.
61 #define MIN_TRIGGERS_PER_PIXEL 2
66 #define MAX_ENTRIES_PER_PIXEL 300
81 #define ANGULAR_RESOLUTION (1./3.)
82 #define NPIX_SMOOTH 13
99 printf(
"Please run this script in compiled mode by running \".x DrawSkyMapPRC.C+\"\n");
104 if((pType!=
"MEDIAN50")&&(pType!=
"MEDIAN90")&&(pType!=
"WRC50")&&(pType!=
"EFFICIENCY")) {
105 cout <<
"Plot Type not available !!!" << endl;
106 cout <<
"Select Plot Type : MEDIAN50/MEDIAN90/WRC50/EFFICIENCY" << endl;
111 TFile *file0 = TFile::Open(ifName);
112 cout << ifName.Data() << endl;
113 if (file0==NULL) {cout <<
"Error Opening file" << endl;
exit(1);}
115 if (itree==NULL) {cout <<
"Error Opening tree" << endl;
exit(1);}
118 TList*
list = itree->GetUserInfo();
119 int nIFO=list->GetSize();
120 if (nIFO==0) {cout <<
"Error : no ifo present in the tree" << endl;
exit(1);}
122 for (
int n=0;
n<list->GetSize();
n++) {
138 sprintf(cut,
"%s && neted[0]/ecor<%f",cut,ED_THR);
140 sprintf(cut,
"%s && abs(time[0]-time[%d])<0.1",cut,nIFO);
142 if(type>0)
sprintf(cut,
"%s && type[1]==%d",cut,type);
150 if (pType==
"WRC50") {
151 char selection[256]=
"theta[1]:phi[1]";
153 char selection_wrc_num[256]=
"iSNR[0]+oSNR[0]-2*ioSNR[0]";
154 for(
int i=1;
i<
nIFO;
i++)
sprintf(selection_wrc_num,
"%s+iSNR[%d]+oSNR[%d]-2*ioSNR[%d]",selection_wrc_num,
i,
i,
i);
156 char selection_wrc_den[256]=
"oSNR[0]";
157 for(
int i=1;
i<
nIFO;
i++)
sprintf(selection_wrc_den,
"%s+oSNR[%d]",selection_wrc_den,
i);
159 sprintf(selection,
"%s:(%s)/(%s):sqrt(likelihood)",selection,selection_wrc_num,selection_wrc_den);
160 cout <<
"selection : " << selection << endl;
161 itree->Draw(selection,cut,
"goff");
163 itree->Draw(
"theta[1]:phi[1]:erA[0]:sqrt(likelihood)",cut,
"goff");
166 int inj_size = itree->GetSelectedRows();
167 double* iinj_theta = itree->GetV1();
168 double* iinj_phi = itree->GetV2();
169 double* iierA0 = itree->GetV3();
170 double* insnr = itree->GetV4();
171 double*
inj_theta =
new double[inj_size];
172 double*
inj_phi =
new double[inj_size];
173 double* erA0 =
new double[inj_size];
174 double* nsnr =
new double[inj_size];
175 for (
int i=0;
i<inj_size;
i++) {
176 inj_theta[
i]=iinj_theta[
i];
177 inj_phi[
i]=iinj_phi[
i];
182 if (pType==
"WRC50") {
183 char selection[256]=
"";
185 char selection_wrc_num[256]=
"iSNR[0]+oSNR[0]-2*ioSNR[0]";
186 for(
int i=1;
i<
nIFO;
i++)
sprintf(selection_wrc_num,
"%s+iSNR[%d]+oSNR[%d]-2*ioSNR[%d]",selection_wrc_num,
i,
i,
i);
188 char selection_wrc_den[256]=
"oSNR[0]";
189 for(
int i=1;
i<
nIFO;
i++)
sprintf(selection_wrc_den,
"%s+oSNR[%d]",selection_wrc_den,
i);
191 sprintf(selection,
"(%s)/(%s):erA[1]:erA[5]:erA[9]",selection_wrc_num,selection_wrc_den);
192 cout <<
"selection : " << selection << endl;
193 itree->Draw(selection,cut,
"goff");
195 itree->Draw(
"erA[0]:erA[1]:erA[5]:erA[9]",cut,
"goff");
198 double* ierA0 = itree->GetV1();
199 double* ierA1 = itree->GetV2();
200 double* ierA5 = itree->GetV3();
201 double* ierA9 = itree->GetV3();
203 for(
int i=0;
i<10;
i++) erA[
i] =
new double[inj_size];
204 for (
int i=0;
i<inj_size;
i++) {
211 itree->Draw(
"theta[0]:phi[0]:inet:type[1]",cut,
"goff");
215 int size = itree->GetSelectedRows();
217 double*
rec_phi = itree->GetV2();
218 double* inet = itree->GetV3();
219 double* itype = itree->GetV4();
221 cout <<
"Selected entries : " << size << endl;
226 double* coverage =
new double[
L];
for (
int l=0;
l<
L;
l++) coverage[
l]=0;
227 double* mean =
new double[
L];
for (
int l=0;
l<
L;
l++) mean[
l]=0;
228 double* nri =
new double[
L];
for (
int l=0;
l<
L;
l++) nri[
l]=0.;
229 double*
snr =
new double[
L];
for (
int l=0;
l<
L;
l++) snr[
l]=0.;
231 int* nEA0 =
new int[
L];
232 for (
int l=0;
l<
L;
l++) nEA0[
l]=0;
233 float** EA0 =
new float*[
L];
235 for (
int l=0;
l<
L;
l++) {
243 double inj_ph=inj_phi[
i];
244 double inj_th=inj_theta[
i];
248 if (erA[0][
i]<erA[5][
i]) coverage[inj_ind]++;
249 nri[inj_ind]+=inet[
i];
250 snr[inj_ind]+=nsnr[
i];
251 mean[inj_ind]+=erA0[
i];
252 EA0[inj_ind][nEA0[inj_ind]++]=erA0[
i];
259 if(pType==
"EFFICIENCY") {
261 mdcFileName.ReplaceAll(
"wave_",
"mdc_");
262 cout <<
"opening file " << mdcFileName.Data();
263 TFile *fileMDC = TFile::Open(mdcFileName.Data());
264 if (fileMDC==NULL) {cout <<
"Error Opening mdc file" << endl;
exit(1);}
265 TTree* itreeMDC = (TTree *) gROOT->FindObject(
"mdc");
266 if (itreeMDC==NULL) {cout <<
"Error Opening mdc tree" << endl;
exit(1);}
267 char mdc_cut[256]=
"run>0";
268 if(type>0)
sprintf(mdc_cut,
"%s && type[0]==%d",mdc_cut,type);
269 cout <<
"mdc_cut : " << mdc_cut << endl;
270 itreeMDC->Draw(
"theta[0]:phi[0]",mdc_cut,
"goff");
271 int mdc_size = itreeMDC->GetSelectedRows();
272 double* mdc_theta = itreeMDC->GetV1();
273 double* mdc_phi = itreeMDC->GetV2();
278 for (
int l=0;
l<
L;
l++) nMDC0[
l]=0;
279 for (
int l=0;
l<
L;
l++) nMDC[
l]=0;
280 for (
int i=0;
i<mdc_size;
i++) {
286 int* nEA =
new int[
L];
287 for (
int l=0;
l<
L;
l++) nEA[
l]=0;
288 double** EA =
new double*[
L];
290 for (
int l=0;
l<
L;
l++) {
296 double* snr_smooth =
new double[
L];
297 for (
int l=0;
l<
L;
l++) snr_smooth[
l]=0.;
301 for(
int l=0;
l<
L;
l++){
307 double ith = th+
in*st;
if(ith<0) ith+=180;
if(ith>180) ith-=180;
311 double iph = ph+im*sp;
if(iph<0) iph+=360;
if(iph>360) iph-=360;
315 for (
int n=0;
n<nEA0[
i];
n++) EA[
l][nEA[
l]++]=EA0[i][
n];
316 snr_smooth[
l]+=snr[
i];
317 if(pType==
"EFFICIENCY") nMDC[
l]+=nMDC0[
i];
323 for (
int l=0;l<L;l++) if(nEA[l]>nEA_max) nEA_max=nEA[
l];
324 for (
int l=0;l<L;l++) if(nEA[l]>0) coverage[
l]/=(
double)nEA[
l];
325 for (
int l=0;l<L;l++) if(nEA[l]>0) nri[
l]/=(
double)nEA[
l];
326 for (
int l=0;l<L;l++) if(nEA[l]>0) mean[
l]/=(
double)nEA[
l];
327 for (
int l=0;l<L;l++) if(nEA[l]>0) snr_smooth[
l]/=(
double)nEA[
l];
329 double*
tmp =
new double[nEA_max];
330 int*
index =
new int[nEA_max];
331 for (
int l=0;l<L;l++) if(nEA[l]>0) {
332 for (
int n=0;
n<nEA[
l];
n++) tmp[
n]=EA[
l][
n];
333 TMath::Sort(nEA[
l],tmp,index,
false);
334 for (
int n=0;
n<nEA[
l];
n++) EA[l][
n]=tmp[index[
n]];
339 double* EA50 =
new double[
L];
340 double* EA90 =
new double[
L];
342 EA50[
l]=EA[
l][nEA[
l]/2];
343 EA90[
l]=EA[
l][(nEA[
l]*9)/10];
344 }
else {EA50[
l]=0.; EA90[
l]=0.;}
348 TObjString* otoken = (TObjString*)token->At(token->GetEntries()-1);
349 TString ifile_label = otoken->GetString();
350 ifile_label.ReplaceAll(
".root",
"");
351 cout <<
"ifile_label " << ifile_label.Data() << endl;
353 char title_label[256]=
"";
354 sprintf(title_label,
"%s : ",pType.Data());
355 char cut_label[256]=
"";
364 sprintf(cut_label,
"%s_ed_%.2f",cut_label,ED_THR);
368 cout <<
"cut_label : " << cut_label << endl;
371 for (
int n=0;
n<list->GetSize();
n++) gNET->
add(pDetector[
n]);
381 #ifdef DISPLAY_WORLD_MAP
385 if (pType==
"MEDIAN50")
for (
int l=0;
l<
L;
l++) gSM->
set(
l,EA50[
l]);
386 if (pType==
"MEDIAN90")
for (
int l=0;l<
L;l++) gSM->
set(l,EA90[l]);
387 if (pType==
"WRC50")
for (
int l=0;l<
L;l++) gSM->
set(l,EA50[l]);
389 if (pType==(
"EFFICIENCY")) {
390 for (
int l=0;l<L;l++) if (nMDC[l]>0) gSM->
set(l,
double(nEA[l])/nMDC[l]);
else gSM->
set(l,0.0);
394 if (pType==
"MEDIAN50") h2->GetZaxis()->SetRangeUser(0.5,50);
395 if (pType==
"MEDIAN90") h2->GetZaxis()->SetRangeUser(0.5,50);
396 if (pType==
"EFFICIENCY") h2->GetZaxis()->SetRangeUser(0.,1);
397 if (pType==
"WRC50") h2->GetZaxis()->SetRangeUser(0.05,0.5);
402 if (pType==
"MEDIAN50") sTITLE =
"Median Error Region 50%";
403 if (pType==
"MEDIAN90") sTITLE =
"Median Error Region 90%";
404 if (pType==
"EFFICIENCY") sTITLE =
"Efficiency";
405 if (pType==
"WRC50") sTITLE =
"Median Normalized Residual Energy 50%";
407 if(Tag!=
"") sTITLE=sTITLE+
" "+Tag;
410 if (pType==
"MEDIAN50") gSM->
SetLogz(
true);
411 if (pType==
"MEDIAN90") gSM->
SetLogz(
true);
412 if (pType==
"WRC50") gSM->
SetLogz(
true);
417 for(
int n=0; n<
nIFO; n++) {
418 sprintf(ifostr,
"%s %s",ifostr,pDetector[n]->Name);
420 cout <<
"oNetwork : " << ifostr << endl;
431 for (
int l=0;l<L;l++) if(nEA[l]>0) {MeanEA50+=EA50[
l];nMeanEA50++;}
433 cout <<
"MeanEA50 : " << MeanEA50 << endl;
435 char skymap_file_name[256]=
"";
438 sprintf(skymap_file_name,
"SKYMAP_%s_%s_RES%d%s_%d.root",
441 sprintf(skymap_file_name,
"SKYMAP_%s_%s_RES%d%s.root",
444 cout << skymap_file_name << endl;
455 sprintf(skymap_file_name,
"%s_%s_RES%d%s.png",
457 cout << skymap_file_name << endl;
458 gSM->
Print(skymap_file_name);
detectorParams getDetectorParams()
size_t add(detector *)
param: detector structure return number of detectors in the network
void DrawSitesArms(double mlength=600000., Color_t lcolor=kBlack, Size_t lwidth=1.0, Style_t lstyle=1)
printf("total live time: non-zero lags = %10.1f \n", liveTot)
void setAntenna(detector *)
param: detector (use theta, phi index array)
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
void set(size_t i, double a)
double getTheta(size_t i)
double getThetaStep(size_t i)
void DumpObject(char *file)
double getPhiStep(size_t i)
void Draw(int dpaletteId=0, Option_t *option="colfz")
#define MIN_TRIGGERS_PER_PIXEL
size_t getSkyIndex(double th, double ph)
param: theta param: phi
void DrawSitesShortLabel(Color_t tcolor=kBlack, Size_t tsize=0.052, Font_t tfont=32)
void setSkyMaps(double sms, double t1, double t2, double p1, double p2)
#define MAX_ENTRIES_PER_PIXEL
void DrawSites(Color_t mcolor=kBlack, Size_t msize=2.0, Style_t mstyle=20)
void DrawSkyMapPRC(TString ifName, TString pType="MEDIAN50", int type=0, TString Title="", TString Tag="")
void setDelay(const char *="L1")
void SetTitle(TString title)
void SetWorldMap(bool drawWorldMap=true)
void SetLogz(bool isLogz=true)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
#define ANGULAR_RESOLUTION
void Print(TString pname)
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)