AntarcticaGeometry.h
1 #ifndef ANTARCTICA_GEOM_H
2 #define ANTARCTICA_GEOM_H
3 
4 
5 
10 #include "RampdemReader.h"
11 #include <vector>
12 #include "TH2DAntarctica.h"
13 #include "TVector3.h"
14 #include "Adu5Pat.h"
15 #include "RefractionModel.h"
16 
17 
20 {
21  public:
22 
23  enum CoordType
24  {
25  WGS84, // (lat lon alt) [deg, deg, m]
26  STEREOGRAPHIC, // (Easting Northing alt) [m,m,m]
27  CARTESIAN, // (x y z) [m,m,m] ( in the very strange ANITA "convention")
28  };
29 
30 
31  AntarcticCoord(CoordType coord_type = CARTESIAN, double xval = 0, double yval = 0, double zval = 0)
32  {
33  set (coord_type,xval,yval,zval) ;
34  }
35 
36  AntarcticCoord(const TVector3 & v)
37  {
38  set(CARTESIAN, v.x(),v.y(),v.z());
39  }
40 
41  AntarcticCoord(const Adu5Pat * pat)
42  {
43  set(WGS84, pat->latitude, pat->longitude, pat->altitude);
44  }
45 
46  TVector3 v() const
47  {
48  AntarcticCoord c = as(CARTESIAN);
49  return TVector3(c.x,c.y,c.z);
50  }
51 
52  virtual ~AntarcticCoord() { ; }
53 
54  void set(CoordType coord_type , double xval , double yval , double zval )
55  {
56  type = coord_type;
57  x= xval;
58  y= yval;
59  z= zval;
60  }
61 
63  static double surfaceDistance(const AntarcticCoord & a, const AntarcticCoord & b);
64  static double surfaceDistance(double lat0, double lat1, double lon0, double lon1);
65 
66  /* Get a copy of this AntarcticCoord with the chosen coord system */
67  const AntarcticCoord as(CoordType new_type) const { AntarcticCoord c(*this); c.to(new_type); return c; }
68 
69  /* Convert this coordinate to the type you want */
70  void to(CoordType new_type) { if (new_type != type) {convert(new_type);} }
71 
72  CoordType currentType() const { return type; }
73  double x;
74  double y;
75  double z;
76 
77  void asString(TString * str) const;
78  private:
79  CoordType type;
80  void convert(CoordType new_type);
81 
82  ClassDef(AntarcticCoord,1);
83 
84 };
85 
86 
92 {
93 
94  public:
95  CartesianSurfaceMap( double resolution = 1e3, RampdemReader::dataSet d = RampdemReader::rampdem);
96  ~CartesianSurfaceMap() { map->Delete(); }
97  double surface(double x, double y) const;
98  double z(double x, double y) const;
99  double metersAboveIce(double x, double y, double z) const;
100  TH2 * getMap() { return map; }
101 
102  private:
103  TH2 * map;
104 };
105 
106 
107 /* A segmentation scheme divides Antarctica into chunks (segments)
108  *
109  * Each piece has a unique index, which can be accessed from its coordinates.
110  * The center of each segment and samples from it may be queried from the
111  * index. This will need altitude information, the source of which can be
112  * changed with setRampdemDataset().
113  *
114  */
115 
117 
118  public:
119 
120 
134  static AntarcticSegmentationScheme * factory(const char * key);
135 
136  virtual ~AntarcticSegmentationScheme() { ; }
137 
139  virtual int getSegmentIndex(const AntarcticCoord & coord) const= 0;
140 
141  virtual int NSegments() const = 0;
142 
148  virtual void getSegmentCenter(int idx, AntarcticCoord * fillme, bool fillalt = true) const = 0;
149 
151  virtual AntarcticCoord getSegmentCenter(int idx, bool fillalt = true) const { AntarcticCoord c; getSegmentCenter(idx,&c,fillalt); return c; }
152 
157  virtual int getNeighbors(int segment, std::vector<int> * neighbors = NULL) const = 0;
158 
163  virtual AntarcticCoord * sampleSegment(int idx, int N, AntarcticCoord * fillus = 0, bool random = true, bool fillalt = true ) const = 0;
164 
170  virtual void Draw(const char * opt = "colz", const double * data = 0, const double * range = 0 ) const;
171 
172  /* Draw integer data... just implemented in terms of Draw() */
173  virtual void DrawI(const char * opt = "colz", const int * data = 0, const double * range = 0) const;
174 
175 
176 
177  virtual void asString(TString * str) const = 0;
178  virtual void setRampdemDataset( RampdemReader::dataSet d) { dataset = d; }
179 
180  protected:
181  AntarcticSegmentationScheme() : dataset (RampdemReader::rampdem) { ;}
182  RampdemReader::dataSet dataset;
183 
184  ClassDef(AntarcticSegmentationScheme,1);
185 
186 };
187 
188 
189 
190 
192 {
193 
194  public:
195  StereographicGrid(int nx = 512, int ny = 512, double max_E = 3330000, double max_N = 3330000);
196  virtual ~StereographicGrid() {; }
197  virtual int getSegmentIndex(const AntarcticCoord & coord) const;
198  virtual int getNeighbors(int segment, std::vector<int> * neighbors = NULL) const;
199  virtual int NSegments() const { return nx * ny; }
200  virtual void getSegmentCenter(int idx, AntarcticCoord * fill, bool fillalt=true) const;
201  virtual AntarcticCoord * sampleSegment(int idx, int N, AntarcticCoord * fillus = 0, bool random = true, bool fillalt = true) const;
202  virtual void Draw(const char * opt = "colz", const double * data = 0, const double * range = 0) const;
203 
204 
205  virtual void asString(TString * str) const;
206  private:
207 
208  int nx;
209  int ny;
210  double max_E;
211  double max_N;
212  double dx;
213  double dy;
214 
215  ClassDef(StereographicGrid,1);
216 
217 
218 };
219 
220 
226 {
227  public:
228  PayloadParameters(const Adu5Pat * pat, const AntarcticCoord & source_pos, const Refraction::Model * refraction =0);
229  PayloadParameters () { ; }
230  PayloadParameters(const PayloadParameters & other);
231 
232  double source_phi; //the phi of the source, in payload coordinates (degrees).
233  double source_theta; //the theta of the source, in payload coordinates (degrees) such that theta > 0 is coming from below
234  double payload_el; // the elevation of the payload from the source (deg) . positive is UP
235  double payload_az; // the azimuth of the payload from the source (deg).
236  double distance; //distance between source and payload
237 
238  double apparent_source_theta; // The APPARENT source theta (without refraction correction)
239  double apparent_payload_el; // The APPARENT source theta (without refraction correction)
240 
241  /* Checks for collision with the ground */
242  bool checkForCollision(double dx = 100, AntarcticCoord * where = 0, AntarcticCoord * where_exit = 0, RampdemReader::dataSet d = RampdemReader::rampdem, double grace = 20, bool reverse = false) const;
243 
244  AntarcticCoord payload;
245  AntarcticCoord source;
246 
255  static double getHorizon(double phi, const Adu5Pat * gps, const Refraction::Model * refractionModel = 0, double tol = 5e-6, RampdemReader::dataSet rampdemData= RampdemReader::rampdem);
256 
257  static int findSourceOnContinent(double theta, double phi,
258  const Adu5Pat * gps, PayloadParameters * fillme,
259  const Refraction::Model * m = 0,
260  double collision_check_dx = 0, // 0 to not cehck
261  double min_dx = 5,
262  double tol = 5e-6,
263  double min_el = 0,
264  RampdemReader::dataSet d= RampdemReader::rampdem);
265 
266  private:
267 
268  ClassDefNV (PayloadParameters,2);
269 };
270 
271 
272 
273 
274 
275 
276 
277 /*
278 class HealPixSegmentation : public AntarcticSegmentationScheme
279 {
280 
281  public:
282  HealPixSegmentation(int npix, double max_lat = 60);
283  virtual ~HealPixSegmentation();
284  virtual int getSegmentIndex(const AntarcticCoord & coord) const;
285  virtual int NSegments() const { return nx * ny; }
286  virtual void getSegmentCenter(int idx, AntarcticCoord * fill, bool fillalt=true) const;
287  virtual AntarcticCoord * sampleSegment(int idx, int N, AntarcticCoord * fillus = 0, bool random = true, bool fillalt = true) const;
288  virtual void asString(TString * str) const;
289  private:
290 
291 };
292 
293 */
294 
295 #endif
virtual void Draw(const char *opt="colz", const double *data=0, const double *range=0) const
virtual AntarcticCoord * sampleSegment(int idx, int N, AntarcticCoord *fillus=0, bool random=true, bool fillalt=true) const
Adu5Pat – The ADU5 Position and Attitude Data.
Definition: Adu5Pat.h:26
virtual void getSegmentCenter(int idx, AntarcticCoord *fillme, bool fillalt=true) const =0
Float_t latitude
In degrees.
Definition: Adu5Pat.h:42
virtual AntarcticCoord * sampleSegment(int idx, int N, AntarcticCoord *fillus=0, bool random=true, bool fillalt=true) const =0
Float_t longitude
In degrees.
Definition: Adu5Pat.h:43
static double getHorizon(double phi, const Adu5Pat *gps, const Refraction::Model *refractionModel=0, double tol=5e-6, RampdemReader::dataSet rampdemData=RampdemReader::rampdem)
virtual int getNeighbors(int segment, std::vector< int > *neighbors=NULL) const =0
virtual void getSegmentCenter(int idx, AntarcticCoord *fill, bool fillalt=true) const
virtual AntarcticCoord getSegmentCenter(int idx, bool fillalt=true) const
Float_t altitude
In metres.
Definition: Adu5Pat.h:44
static AntarcticSegmentationScheme * factory(const char *key)
static double surfaceDistance(const AntarcticCoord &a, const AntarcticCoord &b)
virtual void Draw(const char *opt="colz", const double *data=0, const double *range=0) const
virtual int getNeighbors(int segment, std::vector< int > *neighbors=NULL) const
virtual int getSegmentIndex(const AntarcticCoord &coord) const
virtual int getSegmentIndex(const AntarcticCoord &coord) const =0