Logo coherent WaveBurst  
Library Reference Guide
Logo
gskymap.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
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 
20 #include "gskymap.hh"
21 #include "TPaletteAxis.h"
22 
23 
24 ClassImp(gskymap)
25 
26 //______________________________________________________________________________
27 /* Begin_Html
28 <center><h2>gskymap class</h2></center>
29 This class gskymap is derived from the skymap class
30  It is used to produce the skymap plots.
31 
32 <p>
33 
34 <h3><a name="usage">Usage</a></h3>
35 
36 create gskymap with HEALPix order=7
37 <pre>
38  <a class="funcname" href="#gskymap:gskymap">gskymap</a> gSM((int)7);
39 </pre>
40 set gskymap options
41 <pre>
42  gSM.<a class="funcname" href="#gskymap:SetOptions">SetOptions</a>("cartesian","geographic",1);
43 </pre>
44 set title
45 <pre>
46  gSM.<a class="funcname" href="#gskymap:SetTitle">SetTitle</a>("Projection : cartesian - Coordinates : geographic");
47 </pre>
48 set world map
49 <pre>
50  gSM.<a class="funcname" href="#gskymap:SetWorldMap">SetWorldMap</a>();
51 </pre>
52 draw skymap
53 <pre>
54  gSM.<a class="funcname" href="#gskymap:Draw">Draw</a>(0,"col");
55 </pre>
56 
57 <p>
58 <h3><a name="example">Example</a></h3>
59 <p>
60 The macro <a href="./tutorials/gwat/DrawGskymap.C.html">DrawGskymap.C</a> is an example which shown how to use the gskymap class.<br>
61 The pictures below gives the macro output plots.<br>
62 <p>
63 
64 End_Html
65 
66 Begin_Macro
67 DrawGskymap.C("cartesian")
68 End_Macro
69 Begin_Macro
70 DrawGskymap.C("hammer")
71 End_Macro
72 Begin_Macro
73 DrawGskymap.C("parabolic")
74 End_Macro
75 Begin_Macro
76 DrawGskymap.C("sinusoidal")
77 End_Macro */
78 
79 
80 using namespace std;
81 
82 //______________________________________________________________________________
83 void
84 gskymap::SetOptions(TString projection, TString coordinate, double resolution, bool goff) {
85 //
86 // Set graphical options
87 //
88 // Input: projection - set projection type
89 // - "hammer" (default)
90 // - "sinusoidal"
91 // - "parabolic"
92 // - "cartesian" or ""
93 //
94 // coordinate - set the coordinate type
95 // - "geographic" (default)
96 // - "celestial"
97 // - "cwb"
98 //
99 // resolution - factor used to increase the resolution of the skymap (default=1)
100 // phi = 2*360*resolution points, theta = 2*180*resolution
101 //
102 // goff - true -> turn off the graphical output (default = false)
103 //
104 
105  coordinate.ToUpper();
106 
107  if (resolution<=0) {cout << "gskymap::gskymap: Error sky resolution must be >0" << endl;exit(1);}
108 
109  if(gSystem->Getenv("CWB_GWAT")!=NULL) {
110  worldMapPath=TString(gSystem->Getenv("CWB_GWAT"))+"/data";
111  } else {
112  worldMapPath=".";
113  }
114 
115  // generate a unique base name for canvas and hist2d
116  gRandom->SetSeed(0);
117  char sname[64];sprintf(sname,"gskymap_%d",int(gRandom->Rndm(13)*1.e9));
118  name = sname;
119  this->projection = projection;
120  this->coordinate = coordinate;
121  this->resolution = resolution;
122  this->goff = goff;
123 
124  wtopx=35; wtopy=46; ww=817; wh=472;
125 
126  double phMin = -180;
127  double phMax = 180;
128  double thMin = -90;
129  double thMax = 90;
130  if (coordinate.CompareTo("CWB")==0) {phMin=0;phMax=360;thMin=0;thMax=180;}
131  if (coordinate.CompareTo("CELESTIAL")==0) {phMin=0;phMax=360;thMin=-90;thMax=90;}
132 
133  if(h2!=NULL) delete h2;
134  char nameh[64];sprintf(nameh,"h_%s",name.Data());
135  h2 = new TH2D(nameh,"gskymap", int(360*resolution), phMin, phMax, int(180*resolution), thMin, thMax);
136  h2->SetStats(kFALSE);
137  h2->SetTitleFont(12);
138  h2->SetTitle(title);
139  h2->SetFillColor(kWhite);
140 
141  h2->GetXaxis()->SetNdivisions(-604);
142  h2->GetXaxis()->SetLabelFont(42);
143  h2->GetXaxis()->SetLabelOffset(0.014);
144  h2->GetXaxis()->SetTitleOffset(1.2);
145  h2->GetYaxis()->SetTitleOffset(0.8);
146  h2->GetYaxis()->SetNdivisions(-602);
147  h2->GetYaxis()->SetLabelFont(42);
148  h2->GetYaxis()->SetLabelOffset(0.01);
149  h2->GetZaxis()->SetLabelFont(42);
150  h2->GetZaxis()->SetNoExponent(false);
151 
152  h2->GetXaxis()->SetTitleFont(42);
153  if ((coordinate.CompareTo("CWB")==0)||(coordinate.CompareTo("GEOGRAPHIC")==0)) {
154  h2->GetXaxis()->SetTitle("#phi (deg)");
155  } else if (coordinate.CompareTo("CELESTIAL")==0) {
156  h2->GetXaxis()->SetTitle("RA (deg)");
157  } else {
158  {cout << "gskymap::gskymap: Error : coordinate system not declared" << endl;exit(1);}
159  }
160  h2->GetXaxis()->CenterTitle(true);
161 
162  h2->GetYaxis()->SetTitleFont(42);
163  if ((coordinate.CompareTo("CWB")==0)||(coordinate.CompareTo("GEOGRAPHIC")==0)) {
164  h2->GetYaxis()->SetTitle("#theta (deg)");
165  } else if (coordinate.CompareTo("CELESTIAL")==0) {
166  h2->GetYaxis()->SetTitle("DEC (deg)");
167  } else {
168  {cout << "gskymap::gskymap: Error : coordinate system not declared" << endl;exit(1);}
169  }
170  h2->GetYaxis()->CenterTitle(true);
171 
172  h2->GetZaxis()->SetTitleOffset(0.6);
173  h2->GetZaxis()->SetTitleFont(42);
174  h2->GetZaxis()->SetTitle(zAxisTitle);
175  h2->GetZaxis()->CenterTitle(true);
176 
177  if(this->size()) FillData();
178 }
179 
180 //______________________________________________________________________________
181 void
183 //
184 // create canvas object used for skymap plot
185 //
186 
187 // TCanvas* tcanvas = (TCanvas*) gROOT->FindObject(name);
188 // if (tcanvas!=NULL) {cout << "gskymap::gskymap: Error Canvas Name already exist" << endl;exit(1);}
189  if(canvas!=NULL) delete canvas;
190  if(!goff) {
191  char namec[64];sprintf(namec,"c_%s",name.Data());
192  canvas = new TCanvas(namec, "gskymap", wtopx, wtopy, ww, wh);
193  canvas->Clear();
194  canvas->ToggleEventStatus();
195  canvas->SetGridx(false);
196  canvas->SetGridy(false);
197  canvas->SetLogz(isLogz);
198  canvas->SetFillColor(kWhite);
199  canvas->SetLeftMargin(0.08);
200  canvas->SetBottomMargin(0.13);
201  canvas->SetBorderMode(0);
202  //canvas->SetWindowSize(1200,600);
203  //canvas->SetGrayscale();
204  } else {
205  canvas=NULL;
206  }
207 
208  // remove the red box around canvas
209  gStyle->SetFrameBorderMode(0);
210  gROOT->ForceStyle();
211 
212  gStyle->SetTitleH(0.050);
213  gStyle->SetTitleW(0.95);
214  gStyle->SetTitleY(0.98);
215  gStyle->SetTitleFont(12,"D");
216  gStyle->SetTitleColor(kBlue,"D");
217  gStyle->SetTextFont(12);
218  gStyle->SetTitleFillColor(kWhite);
219  gStyle->SetLineColor(kWhite);
220  gStyle->SetNumberContours(256);
221  gStyle->SetMarkerStyle(7);
222  gStyle->SetMarkerSize(2);
223  gStyle->SetCanvasColor(kWhite);
224  gStyle->SetStatBorderSize(1);
225 }
226 
227 //______________________________________________________________________________
228 gskymap::~gskymap() {
229 //
230 // destructor
231 //
232 
233  if(h2!=NULL) delete h2;
234  if(canvas!=NULL) delete canvas;
235 
236  if (wm_size) delete [] wm_lon;
237  if (wm_size) delete [] wm_lat;
238 
239  ClearGalacticDisk();
240  ClearWorldMap();
241  ClearGridx();
242  ClearGridy();
243  ClearAxisLabel();
244 }
245 
246 //______________________________________________________________________________
247 void
249 //
250 // fill the internal skymap reading from ascii file
251 //
252 // Input: fname - input file name
253 //
254 // format :
255 //
256 // header : sky_res -> area of a pixel (degrees)
257 // theta_1 -> theta min
258 // theta_2 -> theta max
259 // phi_1 -> phi min
260 // phi_2 -> phi max
261 // lenght -> number of entries
262 //
263 // list of data: sky_index value
264 //
265 
266  char iline[1024];
267  TObjArray* tok;
268 
269  ifstream in;
270  in.open(fname,ios::in);
271  if (!in.good()) {cout << "gskymap::FillData: Error Opening File : " << fname << endl;exit(1);}
272 
273  in.getline(iline,1024);
274  in.getline(iline,1024);
275  if(TString(iline).Contains("skymap")==0)
276  {cout << "gskymap::FillData: " << fname << " is not a skymap file" << endl;exit(1);}
277  in.getline(iline,1024);
278  tok = TString(iline).Tokenize(TString(' '));
279  TObjString* tsms = (TObjString*)tok->At(1);
280  if(tsms->GetString().IsAlpha()==1)
281  {cout << "gskymap::FillData: resolution is not well defined " << endl;exit(1);}
282  double sms = tsms->GetString().Atof();
283  in.getline(iline,1024);
284  tok = TString(iline).Tokenize(TString(' '));
285  TObjString* ttheta_1 = (TObjString*)tok->At(1);
286  if(ttheta_1->GetString().IsAlpha()==1)
287  {cout << "gskymap::FillData: theta_1 is not well defined " << endl;exit(1);}
288  double theta_1 = ttheta_1->GetString().Atof();
289  in.getline(iline,1024);
290  tok = TString(iline).Tokenize(TString(' '));
291  TObjString* ttheta_2 = (TObjString*)tok->At(1);
292  if(ttheta_2->GetString().IsAlpha()==1)
293  {cout << "gskymap::FillData: theta_2 is not well defined " << endl;exit(1);}
294  double theta_2 = ttheta_2->GetString().Atof();
295  in.getline(iline,1024);
296  tok = TString(iline).Tokenize(TString(' '));
297  TObjString* tphi_1 = (TObjString*)tok->At(1);
298  if(tphi_1->GetString().IsAlpha()==1)
299  {cout << "gskymap::FillData: phi_1 is not well defined " << endl;exit(1);}
300  double phi_1 = tphi_1->GetString().Atof();
301  in.getline(iline,1024);
302  tok = TString(iline).Tokenize(TString(' '));
303  TObjString* tphi_2 = (TObjString*)tok->At(1);
304  if(tphi_2->GetString().IsAlpha()==1)
305  {cout << "gskymap::FillData: phi_2 is not well defined " << endl;exit(1);}
306  double phi_2 = tphi_2->GetString().Atof();
307  in.getline(iline,1024);
308  tok = TString(iline).Tokenize(TString(' '));
309  TObjString* tlenght = (TObjString*)tok->At(1);
310  if(tlenght->GetString().IsAlpha()==1)
311  {cout << "gskymap::FillData: lenght is not well defined " << endl;exit(1);}
312  int lenght = tlenght->GetString().Atoi();
313 
314  //sms = double(int(1000*sms))/1000.;
315 
316  //cout << sms << " " << theta_1 << " " << theta_2 << " " << phi_1 << " " << phi_2 << endl;
317 
318  int L = skymap::size();
319  if(L!=lenght)
320  {cout << "gskymap::FillData: lenght is not consistent" << endl;exit(1);}
321 
322  while (1) {
323 
324  in.getline(iline,1024);
325  if (!in.good()) break;
326  //cout << ++cnt << " " << iline << endl;
327  tok = TString(iline).Tokenize(TString(' '));
328 
329  if (tok->GetEntries()==1) continue;
330 
331  TObjString* tindex = (TObjString*)tok->At(0);
332  TObjString* tvalue = (TObjString*)tok->At(1);
333 
334  if (tindex->GetString().IsAlpha()==1)
335  {cout << "gskymap::FillData: index " << tindex->GetString().Data() << " is not well defined " << endl;exit(1);}
336  //if (tvalue->GetString().IsAlpha()==1) continue;
337  // {cout << "gskymap::FillData: value " << tvalue->GetString().Data() << " is not well defined " << endl;exit(1);}
338 
339  int index = tindex->GetString().Atoi();
340  double value = tvalue->GetString().Atof();
341 
342  if(index>=0&&index<L)
343  skymap::set(index,value);
344  else
345  {cout << "gskymap::FillData: index " << index << " not allowed - max " << L-1 << endl;}
346 
347  }
348  in.close();
349 
350  FillData();
351 
352  return;
353 }
354 
355 //______________________________________________________________________________
356 void
358 //
359 // Fill 2D histo with the internal skymap data
360 //
361 
362  int size=int(2*180*resolution*2*360*resolution);
363 
364  double* phi = new double[size];
365  double* theta = new double[size];
366  double* binc = new double[size];
367 
368  int k=0;
369  for(int i=0;i<2*180*resolution;i++) {
370  for(int j=0;j<2*360*resolution;j++) {
371  phi[k]=(double)j/(2*resolution);
372  theta[k]=(double)i/(2*resolution);
373  binc[k]=skymap::get(theta[k],phi[k]);
374  k++;
375  }
376  }
377 
378  if (coordinate.CompareTo("GEOGRAPHIC")==0) {
379  for (int i=0;i<k;i++) CwbToGeographic(phi[i],theta[i],phi[i],theta[i]);
380  }
381  if (coordinate.CompareTo("CELESTIAL")==0) {
382  for (int i=0;i<k;i++) CwbToCelestial(phi[i],theta[i],phi[i],theta[i]);
383  }
384 
385  FillData(k, phi, theta, binc);
386 
387  delete [] phi;
388  delete [] theta;
389  delete [] binc;
390 }
391 
392 //______________________________________________________________________________
393 void
394 gskymap::FillData(int size, double* phi, double* theta, double* binc) {
395 //
396 // Fill 2D histo using input arrays
397 //
398 // Input: size - size of the input arrays
399 // phi - arrays of phi values
400 // theta - arrays of theta values
401 // binc - arrays of amplitudes
402 //
403 
404  for (int i=0;i<size;i++) {
405  double x,y;
406  if (coordinate.CompareTo("CWB")==0) {
407  if(phi[i]<0) phi[i]+=360.;
408  if(phi[i]>360) phi[i]-=360.;
409  if(theta[i]<0) theta[i]+=180.;
410  if(theta[i]>180) theta[i]-=180.;
411  }
412  if (coordinate.CompareTo("GEOGRAPHIC")==0) {
413  if(phi[i]<-180) phi[i]+=360.;
414  if(phi[i]>180) phi[i]-=360.;
415  if(theta[i]<-90) theta[i]+=180.;
416  if(theta[i]>90) theta[i]-=180.;
417  phi[i]+=180.;
418  theta[i]+=90.;
419  }
420  if (coordinate.CompareTo("CELESTIAL")==0) {
421  if(phi[i]<0) phi[i]+=360.;
422  if(phi[i]>360) phi[i]-=360.;
423  if(theta[i]<-90) theta[i]+=180.;
424  if(theta[i]>90) theta[i]-=180.;
425  theta[i]+=90.;
426  }
427  if (projection.CompareTo("hammer")==0) {
428  ProjectHammer((phi[i]-180), (theta[i]-90), x, y);
429  x+=180+1;
430  y+=90+1;
431  } else
432  if (projection.CompareTo("sinusoidal")==0) {
433  ProjectSinusoidal((phi[i]-180), (theta[i]-90), x, y);
434  x+=180+1;
435  y+=90+1;
436  } else
437  if (projection.CompareTo("parabolic")==0) {
438  ProjectParabolic((phi[i]-180), (theta[i]-90), x, y);
439  x+=180+1;
440  y+=90+1;
441  } else {
442  x=phi[i];
443  y=theta[i];
444  }
445  h2->SetBinContent(int(x*resolution)+1,int(y*resolution)+1,binc[i]);
446 
447  if (coordinate.CompareTo("GEOGRAPHIC")==0) {
448  CwbToGeographic(phi[i],theta[i],phi[i],theta[i]);
449  //phi[i]-=180.;
450  //theta[i]+=90.;
451  }
452  if (coordinate.CompareTo("CELESTIAL")==0) {
453  CwbToCelestial(phi[i],theta[i],phi[i],theta[i]);
454  }
455  }
456 }
457 
458 //______________________________________________________________________________
459 void
460 gskymap::Draw(int dpaletteId, Option_t* goption) {
461 //
462 // draw skymap
463 //
464 // Input: dpaletteId - color palette used for the skymap
465 // goption - graphical options
466 //
467 
468  if(goff) return;
469 
470  CreateCanvas();
471 
472  TGaxis::SetMaxDigits(3);
473 
474  if(changed) {FillData();changed=false;}
475 
476  if (dpaletteId==DUMMY_PALETTE_ID) {
477  if (paletteId!=0) {
478  SetPlotStyle(paletteId);
479  } else {
480  gStyle->SetPalette(kBird,0);
481  }
482  } else {
483  if (dpaletteId!=0) {
484  SetPlotStyle(dpaletteId);
485  } else {
486  gStyle->SetPalette(kBird,0);
487  }
488  }
489 
490  canvas->cd();
491  canvas->SetLogz(isLogz);
492  h2->Draw(goption);
493  // change palette's width
494  canvas->Update();
495  TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
496  if(palette) {
497  palette->SetX1NDC(0.91);
498  palette->SetX2NDC(0.933);
499  palette->SetTitleOffset(0.92);
500  palette->GetAxis()->SetTickSize(0.01);
501  canvas->Modified();
502  }
503 
504  Double_t rlonait[360*4],rlatait[360*4];
505  Double_t kfix;
506  Int_t kk,k;
507  double mdistance=8.; // min distance (degrees) between polyline segments (avoid solid line when saved)
508 
509 // draw lines of constant longitude
510  if (isGridy) {
511  ClearGridy();
512  for (kk=0;kk<=360;kk+=15){
513  kfix=kk;
514  int klen=0;
515  for (k=0;k<180*4;k++){
516  double x,y;
517  double phi = kfix;
518  double theta = k/4.;
519  if (projection.CompareTo("hammer")==0) {
520  ProjectHammer((phi-180), (theta-90), x, y);
521  } else
522  if (projection.CompareTo("sinusoidal")==0) {
523  ProjectSinusoidal((phi-180), (theta-90), x, y);
524  } else
525  if (projection.CompareTo("parabolic")==0) {
526  ProjectParabolic((phi-180), (theta-90), x, y);
527  } else {
528  x=phi-180;
529  y=theta-90;
530  }
531  if (coordinate.CompareTo("CWB")==0) {x+=180;y+=90;}
532  //if (coordinate.CompareTo("CELESTIAL")==0) {x+=180;}
533  if (coordinate.CompareTo("CELESTIAL")==0) {x+=180;x=360-x;} //TO BE CHECKED
534  rlonait[klen] = x;
535  rlatait[klen] = y;
536  double distance = klen>0 ? sqrt(pow(x-rlonait[klen-1],2)+pow(y-rlatait[klen-1],2)) : mdistance;
537  if(distance>=mdistance || k==(180*4-1)) klen++;
538  }
539  TPolyLine *pL = new TPolyLine(klen,rlonait,rlatait);
540  pL->SetLineColor(colorGridx);
541  if(kk==0 || kk==360) pL->SetLineStyle(1); else pL->SetLineStyle(3);
542  pL->Draw();
543  gridyL.push_back(pL);
544  }
545  }
546 
547 /// draw lines of constant latitude
548  if (isGridx) {
549  ClearGridx();
550  //for (kk=10;kk<180;kk+=10){
551  for (kk=15;kk<180;kk+=15){
552  kfix=kk;
553  int klen=0;
554  for (k=0;k<360*4;k++){
555  double x,y;
556  double phi = k/4.;
557  double theta = kfix;
558  if (projection.CompareTo("hammer")==0) {
559  ProjectHammer((phi-180), (theta-90), x, y);
560  } else
561  if (projection.CompareTo("sinusoidal")==0) {
562  ProjectSinusoidal((phi-180), (theta-90), x, y);
563  } else
564  if (projection.CompareTo("parabolic")==0) {
565  ProjectParabolic((phi-180), (theta-90), x, y);
566  } else {
567  x=phi-180;
568  y=theta-90;
569  }
570  if (coordinate.CompareTo("CWB")==0) {x+=180;y+=90;}
571  //if (coordinate.CompareTo("CELESTIAL")==0) {x+=180;}
572  if (coordinate.CompareTo("CELESTIAL")==0) {x+=180;x=360-x;} // TO BE CHECKED
573  rlonait[klen] = x;
574  rlatait[klen] = y;
575  double distance = klen>0 ? sqrt(pow(x-rlonait[klen-1],2)+pow(y-rlatait[klen-1],2)) : mdistance;
576  if(distance>=mdistance || k==(360*4-1)) klen++;
577  }
578  TPolyLine *pL = new TPolyLine(klen,rlonait,rlatait);
579  pL->SetLineColor(colorGridy);
580  if(kk==0 || kk==180) pL->SetLineStyle(1); else pL->SetLineStyle(3);
581  pL->Draw();
582  gridxL.push_back(pL);
583  }
584  }
585 
586 /// draw labels of constant latitude
587 /*
588  if ((projection.CompareTo("")!=0)&&(coordinate.CompareTo("GEOGRAPHIC")==0)) {
589  ClearAxisLabel();
590  double phi[100],theta[100];
591  int k=0;
592  //for (kk=0;kk<=360;kk+=40) {phi[k]=kk-180;theta[k]=0;k++;}
593  //for (kk=0;kk<=180;kk+=10) {phi[k]=-180;theta[k]=kk-90;k++;}
594  for (kk=0;kk<=360;kk+=15) {phi[k]=kk-180;theta[k]=0;k++;}
595  for (kk=0;kk<=180;kk+=15) {phi[k]=-180;theta[k]=kk-90;k++;}
596  char label[16];
597  for(kk=0;kk<k;kk++) {
598  if(theta[kk]!=0)
599  sprintf(label,"%d",(int)theta[kk]);
600  else
601  sprintf(label,"%d",(int)phi[kk]+180);
602  double x,y;
603  if (projection.CompareTo("hammer")==0) {
604  ProjectHammer(phi[kk], theta[kk], x, y);
605  } else
606  if (projection.CompareTo("sinusoidal")==0) {
607  ProjectSinusoidal(phi[kk], theta[kk], x, y);
608  } else
609  if (projection.CompareTo("parabolic")==0) {
610  ProjectParabolic(phi[kk], theta[kk], x, y);
611  } else {
612  x=phi[kk];y=theta[kk];
613  }
614  TText *tP = new TText(x,y,label);
615  tP->SetTextSize(0.04);
616  tP->SetTextColor(kBlack);
617  tP->SetTextFont(42);
618  if(theta[kk]>0) tP->SetTextAlign(31);
619  if(theta[kk]==0) tP->SetTextAlign(32);
620  if(theta[kk]<0) tP->SetTextAlign(33);
621  tP->Draw();
622  axisT.push_back(tP);
623  }
624  }
625 */
626 
627 /// draw line of galactic disk
628  if (gpsGalacticDisk>=0.) {
629  ClearGalacticDisk();
630 
631  double gphi = gpsGalacticDisk>0. ? skymap::RA2phi(0., gpsGalacticDisk) : 0.;
632 
633  int L=4*360;
634  wavearray<float> th(L);
635  wavearray<float> ph(L);
636  for (int l=0;l<L;l++) {
637  double phi,theta;
638  GalacticToEquatorial(l/4.,0.,phi,theta);
639  ph.data[l]=phi+gphi;
640  th.data[l]=theta;
641  ph.data[l]=fmod(ph.data[l],360);
642  }
643 
644  wavearray<double> x(L);
645  wavearray<double> y(L);
646  int P=0;
647  for (int l=0;l<L;l++) {
648  if((fabs(ph.data[l]-ph.data[l==0?L-1:l-1])<180)&&(l<L-1)) {
649  x.data[P]=ph.data[l]; y.data[P]=th.data[l];
650 
651  if (projection.CompareTo("hammer")==0) {
652  ProjectHammer((x.data[P]-180), (-y.data[P]), x.data[P], y.data[P]);
653  x.data[P]=x.data[P]+180; y.data[P]=-y.data[P];
654  } else if (projection.CompareTo("sinusoidal")==0) {
655  ProjectSinusoidal((x.data[P]-180), (-y.data[P]), x.data[P], y.data[P]);
656  x.data[P]=x.data[P]+180; y.data[P]=-y.data[P];
657  } else if (projection.CompareTo("parabolic")==0) {
658  ProjectParabolic((x.data[P]-180), (-y.data[P]), x.data[P], y.data[P]);
659  x.data[P]=x.data[P]+180; y.data[P]=-y.data[P];
660  } else {
661  }
662  if (coordinate.CompareTo("GEOGRAPHIC")==0)
663  {x.data[P]=x.data[P]-180;}
664  if (coordinate.CompareTo("CWB")==0)
665  {y.data[P]=90+y.data[P];}
666  if (coordinate.CompareTo("CELESTIAL")==0)
667  {x.data[P]=360-x.data[P];y.data[P]=90+y.data[P];}
668  P++;
669  } else {
670  TPolyLine *pL = new TPolyLine(P,x.data,y.data);
671  pL->SetLineColor(colorGalacticDisk);
672  pL->Draw();
673  gdL.push_back(pL);
674  P=0;
675  }
676  }
677  }
678 
679  if (drawWorldMap && (coordinate.CompareTo("CELESTIAL")!=0)) {
680  ClearWorldMap();
681  if (wm_size==0) {
682  // geographic coordinates
683  wm_size = ReadWorlMapCoastLine(wm_lon, wm_lat);
684  }
685  for (int n=0;n<wm_size;n++) {
686  double x,y;
687  double phi = wm_lon[n];
688  double theta = wm_lat[n];
689  if (coordinate.CompareTo("CWB")==0) {phi+=180;if(phi>180) phi=phi-360;}
690  if (coordinate.CompareTo("CELESTIAL")==0) {phi+=180;if(phi>180) phi=phi-360;phi=360-phi;} //TOBE CHECK
691  if (projection.CompareTo("hammer")==0) {
692  ProjectHammer(phi, theta, x, y);
693  } else
694  if (projection.CompareTo("sinusoidal")==0) {
695  ProjectSinusoidal(phi, theta, x, y);
696  } else
697  if (projection.CompareTo("parabolic")==0) {
698  ProjectParabolic(phi, theta, x, y);
699  } else {
700  x=phi;
701  y=theta;
702  }
703  if (coordinate.CompareTo("CWB")==0) {GeographicToCwb(x+180,y,x,y);}
704  if (coordinate.CompareTo("CELESTIAL")==0) {CelestialToCwb(x+180,y,x,y);} // TO BE CHECKED
705  TMarker *mP = new TMarker(x,y, 1); // WARNING : style=20,size=0.1 has issue when printed
706  mP->SetMarkerColor(kGray+1);
707  mP->Draw();
708  wmM.push_back(mP);
709  }
710  }
711 
712  if (coordinate.CompareTo("CELESTIAL")==0) {
713  ReverseXAxis(h2);
714  }
715 
716  TGaxis::SetMaxDigits();
717 }
718 
719 //______________________________________________________________________________
720 void
721 gskymap::DrawMarker(double ra, double dec, double gps, int marker, Size_t msize, Color_t mcolor) {
722 //
723 // Draw a marker in the ra,dec coordinates (see ROOT TMarker input parameters)
724 //
725 // Input: ra,dec - celestial coordinates
726 // gps - gps time
727 // mcolor - color of marker
728 // msize - size of marker
729 // mstyle - style of marker
730 //
731 
732  double phi,theta;
733  GeographicToCwb(ra,dec,phi,theta);
734  phi = gps>0 ? skymap::RA2phi(phi, gps) : phi;
735  if(coordinate.CompareTo("GEOGRAPHIC")==0) CwbToGeographic(phi,theta,phi,theta);
736  if(coordinate.CompareTo("CELESTIAL")==0) CwbToCelestial(phi,theta,phi,theta);
737  DrawMarker(phi, theta, marker, msize, mcolor);
738 }
739 
740 //______________________________________________________________________________
741 void
742 gskymap::DrawMarker(double phi, double theta, int marker, Size_t msize, Color_t mcolor) {
743 //
744 // Draw a marker in the phi,theta coordinates (see ROOT TMarker input parameters)
745 //
746 // Input: phi,theta - skymap coordinates
747 // mcolor - color of marker
748 // msize - size of marker
749 // mstyle - style of marker
750 //
751 
752  if(goff) return;
753 
754  double x,y;
755  if (projection.CompareTo("hammer")==0) {
756  //ProjectHammer((phi-180), -(theta-90), x, y);
757  ProjectHammer(phi, theta, x, y);
758  } else
759  if (projection.CompareTo("sinusoidal")==0) {
760  //ProjectSinusoidal((phi-180), -(theta-90), x, y);
761  ProjectSinusoidal(phi, theta, x, y);
762  } else
763  if (projection.CompareTo("parabolic")==0) {
764  //ProjectParabolic((phi-180), -(theta-90), x, y);
765  ProjectParabolic(phi, theta, x, y);
766  } else {
767  x=phi;
768  y=theta;
769  }
770 
771  TMarker *mP = new TMarker(x,y, marker);
772  mP->SetMarkerSize(msize);
773  mP->SetMarkerColor(mcolor);
774  mP->Draw();
775 }
776 
777 //______________________________________________________________________________
778 void
779 gskymap::DrawText(double ra, double dec, double gps, TString text, double tsize, Color_t tcolor) {
780 //
781 // Draw a text to ra,dec coordinates
782 //
783 // Input: ra,dec - celestial coordinates
784 // text - text
785 // tsize - size of text
786 // tcolor - color of text
787 //
788 
789  double phi,theta;
790  GeographicToCwb(ra,dec,phi,theta);
791  phi = gps>0 ? skymap::RA2phi(phi, gps) : phi;
792  if(coordinate.CompareTo("GEOGRAPHIC")==0) CwbToGeographic(phi,theta,phi,theta);
793  if(coordinate.CompareTo("CELESTIAL")==0) CwbToCelestial(phi,theta,phi,theta);
794  DrawText(phi, theta, text, tsize, tcolor);
795 }
796 
797 //______________________________________________________________________________
798 void
799 gskymap::DrawText(double phi, double theta, TString text, double tsize, Color_t tcolor) {
800 //
801 // Draw a text to phi,theta coordinates
802 //
803 // Input: phi,theta - skymap coordinates
804 // text - text
805 // tsize - size of text
806 // tcolor - color of text
807 //
808 
809  if(goff) return;
810 
811  double x,y;
812  if (projection.CompareTo("hammer")==0) {
813  //ProjectHammer((phi-180), -(theta-90), x, y);
814  ProjectHammer(phi, theta, x, y);
815  } else
816  if (projection.CompareTo("sinusoidal")==0) {
817  //ProjectSinusoidal((phi-180), -(theta-90), x, y);
818  ProjectSinusoidal(phi, theta, x, y);
819  } else
820  if (projection.CompareTo("parabolic")==0) {
821  //ProjectParabolic((phi-180), -(theta-90), x, y);
822  ProjectParabolic(phi, theta, x, y);
823  } else {
824  x=phi;
825  y=theta;
826  }
827 
828  TText *tP = new TText(x,y,text);
829  tP->SetTextSize(tsize);
830  tP->SetTextColor(tcolor);
831  tP->Draw();
832 }
833 
834 //______________________________________________________________________________
835 void
836 gskymap::ProjectHammer(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
837 {
838 //
839 // Static function
840 // Convert Right Ascension, Declination to X,Y using an AITOFF projection.
841 // This procedure can be used to create an all-sky map in Galactic
842 // coordinates with an equal-area Aitoff projection. Output map
843 // coordinates are zero longitude centered.
844 // Also called Hammer-Aitoff projection (first presented by Ernst von Hammer in 1892)
845 // source: GMT
846 // code from Ernst-Jan Buis
847 // http://en.wikipedia.org/wiki/Hammer_projection
848 //
849 // INPUT : Geographic Coordinates
850 // LONGITUDE (W:-Pi,E:+Pi)
851 // LATITUDE (N:+Pi/2,S:-Pi/2)
852 //
853 
854  Double_t x, y;
855 
856  Double_t alpha2 = (l/2)*TMath::DegToRad();
857  Double_t delta = b*TMath::DegToRad();
858  Double_t r2 = TMath::Sqrt(2.);
859  Double_t f = 2*r2/TMath::Pi();
860  Double_t cdec = TMath::Cos(delta);
861  Double_t denom = TMath::Sqrt(1. + cdec*TMath::Cos(alpha2));
862  x = cdec*TMath::Sin(alpha2)*2.*r2/denom;
863  y = TMath::Sin(delta)*r2/denom;
864  x *= TMath::RadToDeg()/f;
865  y *= TMath::RadToDeg()/f;
866  // x *= -1.; // for a skymap swap left<->right
867  Al = x;
868  Ab = y;
869 
870  return;
871 }
872 
873 //______________________________________________________________________________
874 void
875 gskymap::ProjectSinusoidal(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
876 {
877 //
878 // Static function
879 // code from Ernst-Jan Buis
880 //
881 // INPUT : Geographic Coordinates
882 // LONGITUDE (W:-Pi,E:+Pi)
883 // LATITUDE (N:+Pi/2,S:-Pi/2)
884 //
885 
886  Al = l*cos(b*TMath::DegToRad());
887  Ab = b;
888  return;
889 }
890 
891 //______________________________________________________________________________
892 void
893 gskymap::ProjectParabolic(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
894 {
895 //
896 // Static function
897 // code from Ernst-Jan Buis
898 //
899 // INPUT : Geographic Coordinates
900 // LONGITUDE (W:-Pi,E:+Pi)
901 // LATITUDE (N:+Pi/2,S:-Pi/2)
902 //
903 
904  Al = l*(2.*TMath::Cos(2*b*TMath::DegToRad()/3) - 1);
905  Ab = 180*TMath::Sin(b*TMath::DegToRad()/3);
906  return;
907 }
908 
909 //______________________________________________________________________________
910 void
911 gskymap::SetPlotStyle(int paletteId) {
912 //
913 // set the color palette used for the skymap plot
914 //
915 // Input: paletteId - palette number (1,2,3,4,5)
916 //
917 // -----------------------------------------------------------------
918 // http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/
919 // -----------------------------------------------------------------
920 //
921 
922  const Int_t NRGBs = 5;
923  const Int_t NCont = 255;
924 
925  if (fabs(paletteId)==1) {
926  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
927  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
928  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
929  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
930  if (paletteId<0) {
931  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
932  } else {
933  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
934  }
935  } else
936  if (fabs(paletteId)==2) {
937  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
938  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
939  //Double_t red[NRGBs] = { 0.00, 0.00, 0.00, 1.00, 1.00 };
940  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
941  //Double_t green[NRGBs] = { 0.00, 1.00, 1.00, 1.00, 0.00 };
942  Double_t blue[NRGBs] = { 1.00, 1.00, 0.00, 0.00, 0.00 };
943  if (paletteId<0) {
944  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
945  } else {
946  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
947  }
948  } else
949  if (fabs(paletteId)==3) {
950  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
951  Double_t red[NRGBs] = { 0.00, 0.09, 0.18, 0.09, 0.00 };
952  Double_t green[NRGBs] = { 0.01, 0.02, 0.39, 0.68, 0.97 };
953  Double_t blue[NRGBs] = { 0.17, 0.39, 0.62, 0.79, 0.97 };
954  if (paletteId<0) {
955  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
956  } else {
957  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
958  }
959  } else
960  if (fabs(paletteId)==4) {
961  Double_t stops[NRGBs] = { 0.00, 0.50, 0.75, 0.875, 1.00 };
962  Double_t red[NRGBs] = { 1.00, 1.00, 1.00, 1.00, 1.00 };
963  Double_t green[NRGBs] = { 1.00, 0.75, 0.50, 0.25, 0.00 };
964  Double_t blue[NRGBs] = { 0.00, 0.00, 0.00, 0.00, 0.00 };
965  if (paletteId<0) {
966  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
967  } else {
968  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
969  }
970  } else
971  if (fabs(paletteId)==5) { // Greyscale palette
972  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
973  Double_t red[NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
974  Double_t green[NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
975  Double_t blue[NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
976  if (paletteId<0) {
977  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
978  } else {
979  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
980  }
981  } else
982  if (fabs(paletteId)==57) { // kBird palette (is defined only in ROOT6)
983  Double_t stops[9] = { 0., 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0};
984  Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
985  Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
986  Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
987  if (paletteId<0) {
988  TColor::CreateGradientColorTable(9, stops, blue, green, red, NCont);
989  } else {
990  TColor::CreateGradientColorTable(9, stops, red, green, blue, NCont);
991  }
992  }
993 
994  gStyle->SetNumberContours(NCont);
995 
996  return;
997 }
998 
999 //______________________________________________________________________________
1000 int
1001 gskymap::ReadWorlMapCoastLine(double*& wm_lon, double*& wm_lat) {
1002 //
1003 // Read the World Coastline map
1004 //
1005 // return in longitudes/latitudes arrays the world cordinates
1006 //
1007 // -----------------------------------------------------------------
1008 // Coastline map (shapefile) download from :
1009 // http://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-coastline/
1010 // hape2Text transforms ESRI shapefiles into Ascii files
1011 // http://www.zonums.com/shp2text.html
1012 // -----------------------------------------------------------------
1013 //
1014 
1015  char ifileName[256];
1016  sprintf(ifileName,"%s/%s",worldMapPath.Data(),WorlMapCoastLine);
1017 
1018  ifstream in;
1019  in.open(ifileName,ios::in);
1020  if (!in.good()) {cout << "gskymap::ReadWorlMapCoastLine: Error Opening File : " << ifileName << endl;exit(1);}
1021 
1022  int cnt=0;
1023  char iline[1024];
1024  int size = WM_ENTRIES;
1025  wm_lon = new double[size];
1026  wm_lat = new double[size];
1027  while (1) {
1028 
1029  in.getline(iline,1024);
1030  if (!in.good()) break;
1031  //cout << ++cnt << " " << iline << endl;
1032  TObjArray* tok = TString(iline).Tokenize(TString(' '));
1033 
1034  if (tok->GetEntries()==1) continue;
1035 
1036  TObjString* tra = (TObjString*)tok->At(0);
1037  TObjString* tdec = (TObjString*)tok->At(1);
1038 
1039  if (tdec->GetString().IsAlpha()==1) continue;
1040  //cout << tra->GetString().Data() << " " << tdec->GetString().Data() << endl;
1041 
1042  double ra = tra->GetString().Atof();
1043  double dec = tdec->GetString().Atof();
1044 
1045  if (fabs(dec)<0.001) continue;
1046 
1047  wm_lon[cnt] = ra;
1048  wm_lat[cnt] = dec;
1049  cnt++;
1050 
1051  }
1052  cout << cnt << endl;
1053 
1054  in.close();
1055 
1056  drawWorldMap = false;
1057 
1058  return size;
1059 }
1060 
1061 //______________________________________________________________________________
1062 void
1064 //
1065 // clear the axis labels
1066 //
1067 
1068  for(int i=0; i<(int)axisT.size(); i++) {if(axisT[i]) delete axisT[i];}
1069  axisT.clear();
1070  return;
1071 }
1072 
1073 //______________________________________________________________________________
1074 void
1076 //
1077 // clear galactic disk
1078 //
1079 
1080  for(int i=0; i<(int)gdL.size(); i++) {if(gdL[i]) delete gdL[i];}
1081  gdL.clear();
1082  return;
1083 }
1084 
1085 //______________________________________________________________________________
1086 void
1088 //
1089 // clear world map
1090 //
1091 
1092  for(int i=0; i<(int)wmM.size(); i++) {if(wmM[i]) delete wmM[i];}
1093  wmM.clear();
1094  return;
1095 }
1096 
1097 //______________________________________________________________________________
1098 void
1100 //
1101 // clear grids along the x axis
1102 //
1103 
1104  for(int i=0; i<(int)gridxL.size(); i++) {if(gridxL[i]) delete gridxL[i];}
1105  gridxL.clear();
1106 }
1107 
1108 //______________________________________________________________________________
1109 void
1111 //
1112 // clear grids along the y axis
1113 //
1114 
1115  for(int i=0; i<(int)gridyL.size(); i++) {if(gridyL[i]) delete gridyL[i];}
1116  gridyL.clear();
1117  return;
1118 }
1119 
1120 //______________________________________________________________________________
1121 void
1123 //
1124 // save plot to file
1125 //
1126 // Input: pname - output file name
1127 //
1128 
1129  if(canvas==NULL) {cout << "gskymap::Print: Error - canvas not initialized " << endl;exit(1);}
1130 
1131  TGaxis::SetMaxDigits(3);
1132 
1133 /*
1134  if(TString(pname).Contains(".png")!=0) { // fix gray background for png plots
1135  TString gname=pname;
1136  gname.ReplaceAll(".png",".gif");
1137  canvas->Print(gname);
1138  char cmd[1024];
1139  sprintf(cmd,"convert %s %s",gname.Data(),pname.Data());
1140  //cout << cmd << endl;
1141  gSystem->Exec(cmd);
1142  sprintf(cmd,"rm %s",gname.Data());
1143  //cout << cmd << endl;
1144  gSystem->Exec(cmd);
1145  } else {
1146  pname.ReplaceAll(".PNG",".png");
1147  canvas->Print(pname);
1148  }
1149 */
1150 
1151  pname.ReplaceAll(".PNG",".png");
1152  canvas->Print(pname);
1153 
1154  TGaxis::SetMaxDigits();
1155 }
1156 
1157 //______________________________________________________________________________
1158 void
1160 //
1161 // dump skymap to ascii file
1162 //
1163 // Input: fname - output file name
1164 //
1165 // format :
1166 //
1167 // header : sky_res -> area of a pixel (degrees)
1168 // theta_1 -> theta min
1169 // theta_2 -> theta max
1170 // phi_1 -> phi min
1171 // phi_2 -> phi max
1172 // lenght -> number of entries
1173 //
1174 // list of data: sky_index value
1175 //
1176 
1177  int L = skymap::size();
1178 
1179  double x;
1180  FILE* fp; // dump file
1181 
1182  if((fp = fopen(fname, "w")) == NULL) {
1183  cout << "netevent::DumpSkyMap() error: cannot open file " << fname <<". \n";
1184  return;
1185  };
1186  fprintf(fp,"wat %s\n",watversion('f'));
1187  fprintf(fp,"class skymap\n");
1188  x = cos(this->theta_1*PI/180.)-cos(this->theta_2*PI/180.);
1189  x*= (this->phi_2-this->phi_1)*180/PI/L;
1190  x = double(int(1000*x))/1000.;
1191  fprintf(fp,"sky_res %f\n",sqrt(fabs(x)));
1192  fprintf(fp,"theta_1 %f\n",this->theta_1);
1193  fprintf(fp,"theta_2 %f\n",this->theta_2);
1194  fprintf(fp,"phi_1 %f\n",this->phi_1);
1195  fprintf(fp,"phi_2 %f\n",this->phi_2);
1196  fprintf(fp,"lenght %d\n",L);
1197 
1198  for(int l=0;l<L;l++) fprintf(fp,"%d %e\n",l,this->get(l));
1199 
1200  fclose(fp);
1201  return;
1202 }
1203 
1204 //______________________________________________________________________________
1205 void
1207 //
1208 // reverse the x axis
1209 //
1210 
1211  char xlabel[16];
1212  for (int i=1;i<=h2->GetNbinsX();i++) {
1213  //cout << i << " " << h2->GetXaxis()->GetBinCenter(i) << endl;
1214  double xvalue = h2->GetXaxis()->GetBinCenter(i)+h2->GetXaxis()->GetBinWidth(i)/2.;
1215  int nbin=int(h2->GetNbinsX()/4.);
1216  if(i%nbin==0) {
1217  sprintf(xlabel,"%d",int(360-xvalue));
1218  //cout << i << " " << xvalue << endl;
1219  h2->GetXaxis()->SetBinLabel(i,xlabel);
1220  h2->GetXaxis()->SetLabelSize(0.06);
1221  h2->GetXaxis()->LabelsOption("h");
1222  h2->GetXaxis()->SetNdivisions(604);
1223  h2->GetXaxis()->SetLabelFont(42);
1224  h2->GetXaxis()->SetLabelOffset(0.010);
1225  h2->GetXaxis()->SetTitleOffset(1.5);
1226  }
1227  }
1228 }
1229 
1230 //______________________________________________________________________________
1231 void gskymap::DumpObject(const char* file, const char* name)
1232 {
1233 //
1234 // dump skymap into root file
1235 //
1236 
1237  TFile* rfile = new TFile(const_cast<char*>(file), "RECREATE");
1238  this->Write(const_cast<char*>(name)); // write this object
1239  rfile->Close();
1240 }
1241 
1242 //______________________________________________________________________________
1243 void gskymap::LoadObject(const char* file, const char* name)
1244 {
1245 //
1246 // load gskymap object from root file
1247 //
1248 
1249  TFile* rfile = new TFile(const_cast<char*>(file));
1250  gskymap* gsm = (gskymap*)rfile->Get(const_cast<char*>(name));
1251  if(gsm==NULL) {
1252  cout << "gskymap::LoadObject : Error - input file don't contains object gskymap" << endl;
1253  exit(1);
1254  }
1255  *this=*gsm;
1256 
1257  gridxL.clear();
1258  gridyL.clear();
1259  gdL.clear();
1260  wmM.clear();
1261  axisT.clear();
1262 
1263  FillData();
1264  rfile->Close();
1265 }
1266 
1267 //______________________________________________________________________________
1269 {
1270 //
1271 // Used to draw skymap from TBrowser
1272 //
1273 
1274  gridxL.clear();
1275  gridyL.clear();
1276  gdL.clear();
1277  wmM.clear();
1278  axisT.clear();
1279 
1280  FillData();
1281  Draw();
1282 }
1283 
void CreateCanvas()
Definition: gskymap.cc:182
Double_t green[nRGBs]
par [0] value
TString ifileName
Definition: MergeTrees.C:35
double delta
void CwbToCelestial(double ilongitude, double ilatitude, double &olongitude, double &olatitude, double gps=0)
Definition: skycoord.hh:428
void SetPlotStyle(int paletteId=1)
Definition: gskymap.cc:911
gx Draw(GWAT_TIME)
par [0] name
int n
Definition: cwb_net.C:28
char * watversion(char c='s')
Definition: watversion.hh:21
TString("c")
int palette
Definition: DrawGnetwork2.C:17
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
float theta
void DrawMarker(double phi, double theta, int marker, Size_t msize=1, Color_t tcolor=1)
Definition: gskymap.cc:742
void DrawText(double phi, double theta, TString text, double tsize=0.04, Color_t tcolor=1)
Definition: gskymap.cc:799
TH2F * ph
return wmap canvas
Double_t blue[nRGBs]
STL namespace.
void Draw(int dpaletteId=1, Option_t *option="colfz")
Definition: gskymap.cc:460
Long_t size
int j
Definition: cwb_net.C:28
i drho i
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
#define PI
Definition: watfun.hh:32
#define DUMMY_PALETTE_ID
Definition: gskymap.hh:65
void ClearGridx()
Definition: gskymap.cc:1099
void ClearGridy()
Definition: gskymap.cc:1110
tlive_fix Write()
float phi
Double_t stops[nRGBs]
double ra
Definition: ConvertGWGC.C:46
void Plot()
Definition: gskymap.cc:1268
static double r2
Definition: geodesics.cc:26
TText * text
void ClearGalacticDisk()
Definition: gskymap.cc:1075
i() int(T_cor *100))
double Pi
#define NCont
int l
char fname[1024]
int k
double RA2phi(double ph, double gps)
Definition: skymap.hh:213
#define WM_ENTRIES
Definition: gskymap.hh:64
void ClearAxisLabel()
Definition: gskymap.cc:1063
#define NRGBs
WSeries< double > ww
Definition: Regression_H1.C:33
void ReverseXAxis(TH2D *h2)
Definition: gskymap.cc:1206
#define WorlMapCoastLine
Definition: gskymap.hh:63
char title[256]
Definition: SSeriesExample.C:1
void CelestialToCwb(double ilongitude, double ilatitude, double &olongitude, double &olatitude, double gps=0)
Definition: skycoord.hh:437
double gps
ifstream in
void ProjectParabolic(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
Definition: gskymap.cc:893
wavearray< int > index
double fabs(const Complex &x)
Definition: numpy.cc:55
void ProjectHammer(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
Definition: gskymap.cc:836
void FillData()
Definition: gskymap.cc:357
void LoadObject(const char *file, const char *name="gskymap")
Definition: gskymap.cc:1243
void ClearWorldMap()
Definition: gskymap.cc:1087
void CwbToGeographic(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:414
int cnt
void DumpObject(const char *file, const char *name="gskymap")
Definition: gskymap.cc:1231
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TObjString * tra
Definition: ConvertGWGC.C:40
void GalacticToEquatorial(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:47
float distance
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:122
void ProjectSinusoidal(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
Definition: gskymap.cc:875
DataType_t * data
Definition: wavearray.hh:319
void DumpSkyMap(char *fname)
Definition: gskymap.cc:1159
TObjString * tdec
Definition: ConvertGWGC.C:41
double get(size_t i)
param: sky index
Definition: skymap.cc:699
void GeographicToCwb(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:421
fclose(ftrig)
int ReadWorlMapCoastLine(double *&wm_lon, double *&wm_lat)
Definition: gskymap.cc:1001
size_t size()
Definition: skymap.hh:136
void Print(TString pname)
Definition: gskymap.cc:1122
wavearray< double > y
Definition: Test10.C:31
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:84
Double_t red[nRGBs]
exit(0)