Logo coherent WaveBurst  
Library Reference Guide
Logo
gskymap.hh
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  * Package: graphic wat Class Library
21  * File name: gskymap.hh
22  * Author: Gabriele Vedovato (vedovato@lnl.infn.it)
23  **********************************************************/
24 
25 
26 #ifndef GSKYMAP_HH
27 #define GSKYMAP_HH
28 
29 #include "TCanvas.h"
30 #include "TH2F.h"
31 #include "TPolyLine.h"
32 #include "TStyle.h"
33 #include "TColor.h"
34 #include "TObjString.h"
35 #include "TObjArray.h"
36 #include "TString.h"
37 #include "TMarker.h"
38 #include "TROOT.h"
39 #include "TMath.h"
40 #include "TPaveText.h"
41 #include "TVector3.h"
42 #include "TRotation.h"
43 #include "TPolyLine.h"
44 #include "Math/Rotation3D.h"
45 #include "Math/Vector3Dfwd.h"
46 #include "TSystem.h"
47 #include "TLatex.h"
48 #include "TRandom.h"
49 #include "TGaxis.h"
50 
51 #include <iostream>
52 #include <fstream>
53 #include <stdlib.h>
54 #include "skymap.hh"
55 #include "network.hh"
56 #include "detector.hh"
57 #include "wavecomplex.hh"
58 #include "watversion.hh"
59 #include "skycoord.hh"
60 
61 #include "gwat.hh"
62 
63 #define WorlMapCoastLine "WorlMapCoastLine.txt"
64 #define WM_ENTRIES 426345
65 #define DUMMY_PALETTE_ID 1000000000
66 
67 #define GSKYMAP_INIT canvas(NULL), h2(NULL), changed(false), isGridx(true), colorGridx(kBlack), \
68  isGridy(true), colorGridy(kBlack), isLogz(false), title(""), \
69  drawWorldMap(false), goff(0), wm_size(0), paletteId(1), gpsGalacticDisk(-1.), \
70  colorGalacticDisk(kBlack), zAxisTitle("")
71 
72 using namespace ROOT::Math;
73 
74 class gskymap : public skymap
75 {
76 
77 public:
78 
79  // Constructors
81  gskymap(double sms,double t1=0.,double t2=180.,double p1=0.,double p2=360.) :
82  skymap(sms,t1,t2,p1,p2),GSKYMAP_INIT {SetOptions();}
83  gskymap(char* ifile) : skymap(ifile),GSKYMAP_INIT {SetOptions();changed=true;}
84  gskymap(int healpix_order) : skymap(healpix_order),GSKYMAP_INIT {SetOptions();}
85  gskymap(TString ifile, TString name="gskymap") :
86  skymap(ifile,name),GSKYMAP_INIT {SetOptions();changed=true;}
87  gskymap(const skymap& sm) : skymap(sm),GSKYMAP_INIT {SetOptions();changed=true;}
88  virtual ~gskymap();
89 
90  // operators
91  gskymap& operator = (const gskymap& sm) {
93  isGridx=sm.isGridx;
94  colorGridx=sm.colorGridx;
95  isGridy=sm.isGridy;
96  colorGridy=sm.colorGridy;
97  isLogz=sm.isLogz;
98  title=sm.title;
99  drawWorldMap=sm.drawWorldMap;
100  resolution=sm.resolution;
101  goff=sm.goff;
102  wm_size=0;
103  worldMapPath=sm.worldMapPath;
104  paletteId=sm.paletteId;
105  coordinate=sm.coordinate;
106  projection=sm.projection;
107  gpsGalacticDisk=sm.gpsGalacticDisk;
108  colorGalacticDisk=sm.colorGalacticDisk;
109  zAxisTitle=sm.zAxisTitle;
110  name="";
111  wtopx=sm.wtopx;
112  wtopy=sm.wtopy;
113  ww=sm.ww;
114  wh=sm.wh;
115  canvas = NULL;
116  h2 = new TH2D(*sm.h2);
117  return *this;
118  }
119  gskymap& operator = (const skymap& sm) {skymap::operator=(sm);changed=true;return *this;}
120  gskymap& operator += (const skymap& sm) {skymap::operator+=(sm);changed=true;return *this;}
121  gskymap& operator -= (const skymap& sm) {skymap::operator-=(sm);changed=true;return *this;}
122  gskymap& operator *= (const skymap& sm) {skymap::operator*=(sm);changed=true;return *this;}
123  gskymap& operator /= (const skymap& sm) {skymap::operator/=(sm);changed=true;return *this;}
124  gskymap& operator = (const double a) {skymap::operator =(a);changed=true;return *this;}
125  gskymap& operator *= (const double a) {skymap::operator*=(a);changed=true;return *this;}
126  gskymap& operator += (const double a) {skymap::operator+=(a);changed=true;return *this;}
127 
128  void set(size_t i, double a) {skymap::set(i,a);changed=true;}
129 
130  void SetOptions(TString projection = "hammer", TString coordinate = "Geographic",
131  double resolution = 1, bool goff = false);
132  void SetOptions(const char* name, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) {
133  char sname[64];sprintf(sname,"%s-%d",name,int(gRandom->Rndm(13)*1.e9));
134  this->name=sname;this->wtopx=wtopx;this->wtopy=wtopy;this->ww=ww;this->wh=wh;
135  if(canvas!=NULL) Draw();}
136 
137  TCanvas* GetCanvas() {return canvas;}
138  TH2D* GetHistogram() {return h2;}
139 
140  void SetGridx(bool isGridx=true) {this->isGridx=isGridx;}
141  bool GetGridx() {return isGridx;}
142  void SetGridxColor(Color_t colorGridx = kBlack) {this->colorGridx=colorGridx;}
143  bool GetGridxColor() {return colorGridx;}
144  void SetGridy(bool isGridy=true) {this->isGridy=isGridy;}
145  bool GetGridy() {return isGridy;}
146  void SetGridyColor(Color_t colorGridy = kBlack) {this->colorGridy=colorGridy;}
147  bool GetGridyColor() {return colorGridy;}
148  void SetLogz(bool isLogz=true) {this->isLogz=isLogz;}
149  bool GetLogz() {return isLogz;}
150  void SetZaxisTitle(TString zAxisTitle) {h2->GetZaxis()->SetTitle(zAxisTitle);this->zAxisTitle=zAxisTitle;}
151  TString GetZaxisTitle() {return zAxisTitle;}
152  void SetTitle(TString title) {h2->SetTitle(title);this->title=title;}
153  TString GetTitle() {return title;}
154  void SetWorldMap(bool drawWorldMap=true) {this->drawWorldMap=drawWorldMap;}
155  bool GetWorldMap() {return drawWorldMap;}
156  void SetWorldMapPath(TString worldMapPath) {this->worldMapPath=worldMapPath;}
157  TString GetWorldMapPath() {return worldMapPath;}
158  double GetResolution() {return resolution;}
159  void SetPalette(int paletteId=kBird) {this->paletteId=paletteId;}
160  int GetPaletteId() {return paletteId;}
161  TString GetProjection() {return projection;}
162  TString GetCoordinate() {return coordinate;}
163  void SetGalacticDisk(double gpsGalacticDisk=0.0) {this->gpsGalacticDisk=gpsGalacticDisk;}
164  double GetGalacticDisk() {return gpsGalacticDisk;}
165  void SetGalacticDiskColor(Color_t colorGalacticDisk = kBlack) {this->colorGalacticDisk=colorGalacticDisk;}
166  bool GetGalacticDiskColor() {return colorGalacticDisk;}
167 
168  void FillData(int size, double* phi, double* theta, double* binc);
169  void FillData(char* fname);
170 
171  void Plot(); // *MENU*
172  void Draw(int dpaletteId = 1, Option_t* option = "colfz");
173  void Print(TString pname); // *MENU*
174 
175  void ProjectHammer(Double_t l,Double_t b,Double_t &Al,Double_t &Ab);
176  void ProjectSinusoidal(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
177  void ProjectParabolic(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
178 
179  void DrawMarker(double phi, double theta, int marker, Size_t msize = 1, Color_t tcolor = 1);
180  void DrawText(double phi, double theta, TString text, double tsize = 0.04, Color_t tcolor = 1);
181 
182  void DrawMarker(double ra, double dec, double gps, int marker, Size_t msize = 1, Color_t tcolor = 1);
183  void DrawText(double ra, double dec, double gps, TString text, double tsize = 0.04, Color_t tcolor = 1);
184 
185  virtual void Browse(TBrowser *b) {Plot();}
186 
187  void ClearAxisLabel();
188  void ClearGalacticDisk();
189  void ClearWorldMap();
190  void ClearGridx();
191  void ClearGridy();
192 
193  //: dump to ascii file
194  void DumpSkyMap(char* fname);
195 
196  //: dump skymap into root file
197  void DumpObject(const char* file, const char* name="gskymap");
198  //: load gnetwork object from root file
199  void LoadObject(const char* file, const char* name="gskymap");
200 
201  friend class gnetwork;
202 
203 private:
204 
205  void SetPlotStyle(int paletteId = 1);
206  int ReadWorlMapCoastLine(double*& wm_lon, double*& wm_lat);
207  void HeapSort( double* data, double lenght);
208  void ReverseXAxis(TH2D *h2);
209  void FillData();
210  void CreateCanvas();
211 
212  TCanvas* canvas; //!`
213  TH2D* h2; //!
214 
215  bool changed;
216 
217  bool isGridx;
218  Color_t colorGridx;
219  bool isGridy;
220  Color_t colorGridy;
221  bool isLogz;
224  double resolution;
225  bool goff;
226  int wm_size;
234 
235  // canvas parameters
237  Int_t wtopx, wtopy, ww, wh;
238 
239  std::vector<TPolyLine*> gridxL; //!
240  std::vector<TPolyLine*> gridyL; //!
241  std::vector<TPolyLine*> gdL; //!
242  std::vector<TMarker*> wmM; //!
243  std::vector<TText*> axisT; //!
244 
245  double *wm_lon; //!
246  double *wm_lat; //!
247 
248  ClassDef(gskymap,1)
249 };
250 
251 #endif
TH2D * GetHistogram()
Definition: gskymap.hh:138
double GetGalacticDisk()
Definition: gskymap.hh:164
#define GSKYMAP_INIT
Definition: gskymap.hh:67
Color_t colorGridy
Definition: gskymap.hh:220
double * wm_lon
Definition: gskymap.hh:245
TGraphErrors * Plot(int mtype, TString ptitle, TString xtitle, TString ytitle, bool save=true)
Definition: cwb_mkfad.C:744
virtual void Browse(TBrowser *b)
Definition: gskymap.hh:185
TH1 * t1
TString GetWorldMapPath()
Definition: gskymap.hh:157
std::vector< TPolyLine * > gdL
Definition: gskymap.hh:241
std::vector< TPolyLine * > gridxL
Definition: gskymap.hh:239
wavearray< double > a(hp.size())
Color_t colorGridx
Definition: gskymap.hh:218
double gpsGalacticDisk
Definition: gskymap.hh:231
skymap & operator-=(const skymap &)
Definition: skymap.cc:317
gx Draw(GWAT_TIME)
par [0] name
bool GetGalacticDiskColor()
Definition: gskymap.hh:166
TString("c")
void SetGridx(bool isGridx=true)
Definition: gskymap.hh:140
Int_t ww
Definition: gskymap.hh:237
TString GetProjection()
Definition: gskymap.hh:161
bool GetGridyColor()
Definition: gskymap.hh:147
float theta
double GetResolution()
Definition: gskymap.hh:158
TString coordinate
Definition: gskymap.hh:229
skymap & operator*=(const skymap &)
Definition: skymap.cc:346
return wmap canvas
int GetPaletteId()
Definition: gskymap.hh:160
bool GetWorldMap()
Definition: gskymap.hh:155
bool GetGridx()
Definition: gskymap.hh:141
Long_t size
void SetOptions(const char *name, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
Definition: gskymap.hh:132
TCanvas * canvas
Definition: gskymap.hh:212
bool isGridx
Definition: gskymap.hh:217
i drho i
int wm_size
Definition: gskymap.hh:226
void SetGridxColor(Color_t colorGridx=kBlack)
Definition: gskymap.hh:142
TH2D * h2
`
Definition: gskymap.hh:213
bool GetGridxColor()
Definition: gskymap.hh:143
watplot p2(const_cast< char *>("TFMap2"))
TString zAxisTitle
Definition: gskymap.hh:233
float phi
double ra
Definition: ConvertGWGC.C:46
TString title
Definition: gskymap.hh:222
void SetGridy(bool isGridy=true)
Definition: gskymap.hh:144
MDC Print()
TString GetCoordinate()
Definition: gskymap.hh:162
TText * text
bool isGridy
Definition: gskymap.hh:219
skymap & operator+=(const skymap &)
Definition: skymap.cc:288
gSM SetOptions(cwb_antpat_projection, COORDINATES, RESOLUTION/2)
iNET LoadObject(const_cast< char *>(ROOT_FILE))
void SetGalacticDiskColor(Color_t colorGalacticDisk=kBlack)
Definition: gskymap.hh:165
Int_t wtopy
Definition: gskymap.hh:237
watplot p1(const_cast< char *>("TFMap1"))
std::vector< TText * > axisT
Definition: gskymap.hh:243
int l
TCanvas * GetCanvas()
Definition: gskymap.hh:137
void SetWorldMapPath(TString worldMapPath)
Definition: gskymap.hh:156
char fname[1024]
void SetGalacticDisk(double gpsGalacticDisk=0.0)
Definition: gskymap.hh:163
double * wm_lat
Definition: gskymap.hh:246
TString GetZaxisTitle()
Definition: gskymap.hh:151
bool GetLogz()
Definition: gskymap.hh:149
Definition: skymap.hh:63
void SetGridyColor(Color_t colorGridy=kBlack)
Definition: gskymap.hh:146
TFile * ifile
bool isLogz
Definition: gskymap.hh:221
WSeries< double > ww
Definition: Regression_H1.C:33
void SetTitle(TString title)
Definition: gskymap.hh:152
int paletteId
Definition: gskymap.hh:228
double resolution
Definition: gskymap.hh:224
bool GetGridy()
Definition: gskymap.hh:145
char title[256]
Definition: SSeriesExample.C:1
double gps
TString worldMapPath
Definition: gskymap.hh:227
Int_t wtopx
Definition: gskymap.hh:237
void SetWorldMap(bool drawWorldMap=true)
Definition: gskymap.hh:154
bool changed
Definition: gskymap.hh:215
skymap & operator=(const skymap &)
Definition: skymap.cc:256
TString GetTitle()
Definition: gskymap.hh:153
void SetLogz(bool isLogz=true)
Definition: gskymap.hh:148
void HeapSort(double *data, double length)
Definition: skycoord.hh:258
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:122
TString name
Definition: gskymap.hh:236
bool goff
Definition: gskymap.hh:225
Color_t colorGalacticDisk
Definition: gskymap.hh:232
std::vector< TPolyLine * > gridyL
Definition: gskymap.hh:240
std::vector< TMarker * > wmM
Definition: gskymap.hh:242
TString projection
Definition: gskymap.hh:230
void SetPalette(int paletteId=kBird)
Definition: gskymap.hh:159
skymap & operator/=(const skymap &)
Definition: skymap.cc:373
void SetZaxisTitle(TString zAxisTitle)
Definition: gskymap.hh:150
bool drawWorldMap
Definition: gskymap.hh:223
Int_t wh
Definition: gskymap.hh:237