Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CreateCelestialSkyMask.C
Go to the documentation of this file.
1 //
2 // CreateCelestialSkyMask
3 // Create a cwb sky mask : use the source coordinates
4 // Author : Gabriele Vedovato
5 
6 // ---------------------------------------------
7 // source definitions
8 // ---------------------------------------------
9 #define SOURCE_NAME "SOURCE"
10 
11 #define SOURCE_GPS -931158395
12 
13 // if SOURCE_GPS>0 : SOURCE_RA and SOURCE_DEC are in Celestial coordinated
14 // if SOURCE_GPS=0 : SOURCE_RA and SOURCE_DEC are in Geographic coordinated (used for earth skymask)
15 // if SOURCE_GPS<0 : SOURCE_RA and SOURCE_DEC are in Geographic coordinated
16 // SOURCE_GPS is used to convert them into Celestial coordinates
17 // Geographic : theta [-90,90] , phi [0,360]
18 #define SOURCE_RA 60
19 #define SOURCE_DEC 30
20 
21 // if uncommented then GPS time is computed from UTC time
22 //#define SOURCE_UTC "2004-12-27 21:30:26.68 UTC Mon"
23 
24 // SGR_1806_20
25 /*
26 #define SOURCE_NAME "SGR_1806_20"
27 #define SOURCE_GPS 788218239.68 // SGR_1806_20
28 #define SOURCE_RA 270.095
29 #define SOURCE_DEC -20.41666
30 #define SOURCE_UTC "2004-12-27 21:30:26.68 UTC Mon"
31 */
32 
33 // ---------------------------------------------
34 // draw definitions
35 // ---------------------------------------------
36 #define RESOLUTION 2
37 //#define RESOLUTION 4
38 
39 //#define COORDINATES "cWB"
40 #define COORDINATES "Geographic"
41 
42 #define PROJECTION ""
43 //#define PROJECTION "hammer"
44 //#define PROJECTION "sinusoidal"
45 
46 #define DISPLAY_WORLD_MAP
47 #define WORLD_MAP_DIR "$CWB_GWAT/data/"
48 
49 // ---------------------------------------------
50 // skymask definitions
51 // ---------------------------------------------
52 #define SKYMASK_RADIUS 20 // degrees
53 //#define SAVE_SKYMASK
54 #define DRAW_SKYMASK
55 
56 using namespace ROOT::Math;
57 
59 
60  gSystem->Load("libMathCore");
61 
62  gskymap* gSM = new gskymap(0.4,0,180,0,360);
64  int L = gSM->size();
65 
66  double gps = SOURCE_GPS;
67  double ph=SOURCE_RA;
68  double th=SOURCE_DEC;
69  th=90-th; // geographic -> CWB
70 
71 #if (SOURCE_GPS!=0)
72 #if (SOURCE_GPS<0)
73  gps=-gps;
74  ph = gSM->phi2RA(ph,gps);
75 #else
76  wat::Time time(gps);
77 #ifdef SOURCE_UTC // if SOURCE_UTC is defined then it is used as source gps time
78  gps = time.GetGPS();
79 #endif
80  // RA -> phi conversion
81  ph = gSM->RA2phi(ph,gps);
82 #endif
83 #endif
84 
85  cout.precision(14);
86  cout << endl;
87  cout << "-----------------------------------------------------" << endl;
88  cout << "Source Coordinates " << endl;
89  cout << "-----------------------------------------------------" << endl;
90 #if (SOURCE_GPS!=0)
91  cout << "Time " << endl;
92  cout << "UTC - " << wat::Time(gps).GetDateString() << endl;
93  cout << "GPS - " << gps << endl;
94  cout << endl;
95  cout << "Celestial coordinates " << endl;
96  cout << "DEC (deg) - " << SOURCE_DEC << endl;
97  cout << "RA (deg) - " << SOURCE_RA << endl;
98  cout << endl;
99 #endif
100  cout << "CWB coodinates " << endl;
101  cout << "THETA (deg) - " << th << endl;
102  cout << "PHI (deg) - " << ph << endl;
103  cout << "-----------------------------------------------------" << endl;
104  cout << endl;
105 
106  Polar3DVector ov1(1, th*TMath::Pi()/180, ph*TMath::Pi()/180);
107 
108  int n=0;
109  for (int l=0;l<L;l++) {
110  double phi = gSM->getPhi(l);
111  double theta = gSM->getTheta(l);
112 
113  Polar3DVector ov2(1, theta*TMath::Pi()/180, phi*TMath::Pi()/180 );
114  double Dot = ov1.Dot(ov2);
115  double dOmega = 180.*TMath::ACos(Dot)/TMath::Pi();
116  //cout << "dOmega : " << dOmega << endl;
117 
118  if(dOmega<SKYMASK_RADIUS) gSM->set(l,1); else gSM->set(l,0);
119  }
120 
121 #ifdef SAVE_SKYMASK
122  char oFile[256];
123 #if (SOURCE_GPS<0)
124  sprintf(oFile,"CelestialSkyMask_DEC_%3.1f_RA_%3.1f_GPS_N%3.1f_RADIUS_%3.1f",
125  SOURCE_DEC,ph,gps,SKYMASK_RADIUS);
126 #else
127  sprintf(oFile,"CelestialSkyMask_DEC_%3.1f_RA_%3.1f_GPS_%3.1f_RADIUS_%3.1f",
129 #endif
130  TString oFileName = oFile;
131  oFileName.ReplaceAll(".","d");
132  oFileName=oFileName+".txt";
133  cout << "Save File : " << oFileName.Data() << endl;
134  ofstream out;
135  out.open(oFileName.Data(), ios::out);
136  if (!out.good()) {cout << "Error Opening File : " << oFileName.Data() << endl;exit(1);}
137  for (int l=0;l<L;l++) out << l << " " << gSM->get(l) << endl;
138  out.close();
139  exit(0);
140 #endif
141 
142 // Draw SkyMask in geographical coordinates
143 #ifdef DRAW_SKYMASK
144 
145 #ifdef DISPLAY_WORLD_MAP
146  TString world_map = gSystem->ExpandPathName(WORLD_MAP_DIR);
147  gSM->SetWorldMapPath(world_map.Data());
148  gSM->SetWorldMap();
149 #endif
150 
151  double th1,ph1;
152  CwbToGeographic(ph,th,ph1,th1);
153 
154  char title[256];
155  sprintf(title,"Sky Mask : radius = %d^{0} - center = (DEC=%3.3f,RA=%3.3f)",SKYMASK_RADIUS,th1,ph1);
156  gSM->SetTitle(title);
157 
158  gSM->Draw(0);
159 
160  gSM->DrawMarker(ph1,th1, 29, 2.0, kYellow);
161  gSM->DrawText(ph1-14, th1+8, SOURCE_NAME, 0.04, kBlack);
162  //gSM->DrawCircles(ph1,th1,(Color_t)kWhite);
163 #endif
164 
165 }
gskymap * gSM
void CreateCelestialSkyMask()
INT_4S GetGPS()
Definition: time.hh:107
TString GetDateString()
Definition: time.cc:443
int n
Definition: cwb_net.C:10
TString("c")
void set(size_t i, double a)
Definition: gskymap.hh:110
float theta
void DrawMarker(double phi, double theta, int marker, Size_t msize=1, Color_t tcolor=1)
Definition: gskymap.cc:724
void DrawText(double phi, double theta, TString text, double tsize=0.04, Color_t tcolor=1)
Definition: gskymap.cc:781
TH2F * ph
double getTheta(size_t i)
Definition: skymap.hh:206
void Draw(int dpaletteId=0, Option_t *option="colfz")
Definition: gskymap.cc:442
#define PROJECTION
#define SOURCE_DEC
ofstream out
Definition: cwb_merge.C:196
TString world_map
Definition: DrawGNET.C:16
#define RESOLUTION
float phi
double time[6]
Definition: cbc_plots.C:435
#define COORDINATES
double Pi
void SetWorldMapPath(TString worldMapPath)
Definition: gskymap.hh:138
#define SOURCE_NAME
double RA2phi(double ph, double gps)
Definition: skymap.hh:195
#define SKYMASK_RADIUS
double phi2RA(double ph, double gps)
Definition: skymap.hh:194
void SetTitle(TString title)
Definition: gskymap.hh:134
double getPhi(size_t i)
Definition: skymap.hh:146
char title[256]
Definition: SSeriesExample.C:1
double gps
void SetWorldMap(bool drawWorldMap=true)
Definition: gskymap.hh:136
#define SOURCE_GPS
void CwbToGeographic(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:396
int l
Definition: cbc_plots.C:434
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
#define SOURCE_RA
double get(size_t i)
param: sky index
Definition: skymap.cc:681
size_t size()
Definition: skymap.hh:118
#define WORLD_MAP_DIR
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:66
exit(0)