GeometryExample.cc
Go to the documentation of this file.
1 
9 #include "GeometryExample.h"
10 
11 #include <utl/ErrorLogger.h>
12 
13 #include <evt/Event.h>
14 
15 //#include <fwk/CentralConfig.h>
16 #include <det/Detector.h>
17 #include <sdet/SDetector.h>
18 #include <sdet/Station.h>
19 #include <fdet/FDetector.h>
20 #include <fdet/Eye.h>
21 #include <utl/TimeStamp.h>
22 #include <utl/UTCDateTime.h>
23 
24 #include <fwk/LocalCoordinateSystem.h>
25 #include <fwk/CoordinateSystemRegistry.h>
26 #include <utl/MathConstants.h>
27 #include <utl/CoordinateSystemPtr.h>
28 #include <utl/UTMPoint.h>
29 #include <utl/AxialVector.h>
30 #include <utl/Vector.h>
31 #include <utl/Point.h>
32 #include <utl/PhysicalConstants.h>
33 #include <utl/AugerUnits.h>
34 #include <utl/ReferenceEllipsoid.h>
35 #include <boost/tuple/tuple.hpp>
36 #include <boost/tuple/tuple_io.hpp>
37 
38 using namespace det;
39 using namespace sdet;
40 using namespace fdet;
41 using namespace std;
42 //using namespace sevt;
43 using namespace evt;
44 using namespace fwk;
45 using namespace utl;
46 
47 using namespace GeometryExampleNS;
48 
49 
52 {
53  return eSuccess;
54 }
55 
56 
57 /*
58  The coding example here doesn't include any of addition and subtraction
59  operations and does not include most member functions (Get* /Set*). Those can
60  be found in the class documentation for the geometry classes. The things
61  included here are mostly utm coordinates and coordinate system pointers and an
62  example using dot and cross product.
63 */
64 
66 GeometryExample::Run(evt::Event& /*event*/)
67 {
68  const TimeStamp times = UTCDateTime(2005,1,1,0,0).GetTimeStamp();
69  Detector::GetInstance().Update(times);
70  const SDetector& sDetector = Detector::GetInstance().GetSDetector();
71  const FDetector& fDetector = Detector::GetInstance().GetFDetector();
72  INFO("GeometryExample::Run()");
73 
74  cout << "\nCreating a Coordinate System from scratch\n"
75  "-----------------------------------------\n";
76 
77  const char band = 'H';
78  const string ellipsoidName("WGS84");
79  const int zone = 19;
80  const double northing = 6081459*m;
81  const double easting = 460373*m;
82  const double altitude = 1391*m;
83  const ReferenceEllipsoid::EllipsoidID ellipsoid = ReferenceEllipsoid::GetEllipsoidIDFromString(ellipsoidName);
84 
85  const UTMPoint utmposition(northing, easting, altitude, zone, band, ellipsoid);
86  const CoordinateSystemPtr cs1 = LocalCoordinateSystem::Create(utmposition);
87  cout << "the origin of Coordinate System 1 will be: " << utmposition.GetCoordinates() << "\n";
88 
89  UTMPoint utmposition2(6081479*m, 460363*m, 1400*m, 19, 'H', ReferenceEllipsoid::GetEllipsoidIDFromString("WGS84"));
90  cout << "the origin of Coordinate System 2 will be: " << utmposition2.GetCoordinates() << "\n";
91  const CoordinateSystemPtr cs2 = LocalCoordinateSystem::Create(utmposition2);
92 
93  // create a Point from a UTMPoint
94 
95  const Point cs1_origin = utmposition.GetPoint();
96 
97  cout << "CS 1 origin relative to CS 2: " << cs1_origin.GetCoordinates(cs2) << "\n";
98 
99  // Create a right-handed coordinate system from a point (cs1_origin) and a direction (zenith, azimuth)
100  // z-axis oposite a hypothetical shower direction,
101  // y-axis in the horizontal plane,
102  // x-axis pointing in the upstream direction
103  const double zenith = 30*deg;
104  const double azimuth = 270*deg;
105  const CoordinateSystemPtr cs3(
106  CoordinateSystem::RotationY(
107  zenith,
108  CoordinateSystem::RotationZ(
109  azimuth,
110  LocalCoordinateSystem::Create(cs1_origin)
111  )
112  )
113  );
114 
115  cout << "CS 1 origin relative to CS 3: " << cs1_origin.GetCoordinates(cs3) << "\n";
116 
117  // Calculate the latitude, longitude and height on the WGS84 ellipsoid for a
118  // point defined in PampaAmarilla coordinates system (defined at the approximate
119  // center of the Southern site)
120 
121  const CoordinateSystemPtr pampaCS =
122  CoordinateSystemRegistry::Get("PampaAmarilla");
123  const ReferenceEllipsoid wgs84 = ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84);
124 
125  const Point pointInPampa = Point(0., 0., 2.*km, pampaCS);
126  const boost::tuple<double, double, double> latLonHeight = wgs84.PointToLatitudeLongitudeHeight(pointInPampa);
127  cout << "latitude, longitude, height " << latLonHeight << endl;
128 
129  // create a vector and a point in one coordinate system
130 
131  const Point point1(0,10,20, cs1);
132  const Point point3(-10,10,10, cs1);
133  const Point point2(10,kPi/3,0, cs1, Point::kCylindrical);
134  const Vector vector1(1,0,0, cs1);
135  const Vector vector2(0,1,0, cs1);
136 
137  // read in the other using more than one basis.
138 
139  cout << "\nPoints and vectors in different coordinate systems\n"
140  "--------------------------------------------------\n"
141  "coordinate System 1 \t\tCoordinate System 2\n"
142  << point1.GetCoordinates(cs1) << " \t\t" << point1.GetCoordinates(cs2) << "\n"
143  << point2.GetCoordinates(cs1) << " \t" << point3.GetCoordinates(cs2) << "\n"
144  << point3.GetCoordinates(cs1) << " \t\t\t" << point2.GetCoordinates(cs2) << "\n"
145  << vector1.GetCoordinates(cs1) << " \t" << vector1.GetCoordinates(cs2) << "\n"
146  << vector2.GetCoordinates(cs1) << " \t" << vector2.GetCoordinates(cs2) << "\n" ;
147 
148  cout << "NOTE that the vector's components don't depend on the coordinate system!\n";
149 
150  // The detector interface provides the coordinate systems relative to most things we need and a few default ones:
151 
152  cout << "\nUsing the Coordinate systems provided by the framework\n"
153  "------------------------------------------------------\n";
154 
155  const CoordinateSystemPtr pampaCs = fwk::CoordinateSystemRegistry::Get("PampaAmarilla");
156 
157  const CoordinateSystemPtr llancaneloCs = sDetector.GetStation(221).GetLocalCoordinateSystem();
158 
159  const CoordinateSystemPtr coihuecoCs = fDetector.GetEye("Coihueco").GetEyeCoordinateSystem();
160  const CoordinateSystemPtr losLeonesCs = fDetector.GetEye("Los Leones").GetEyeCoordinateSystem();
161  const CoordinateSystemPtr moradosCs = fDetector.GetEye("Los Morados").GetEyeCoordinateSystem();
162 
163  const CoordinateSystemPtr siteCs = Detector::GetInstance().GetSiteCoordinateSystem();
164 
165  const Point corePosition(0,0,0, pampaCs);
166  cout << "setting a 'core' position at:\n"
167  " " << corePosition.GetCoordinates(pampaCs) << ", in 'Pampa Amarilla' coordinate system, \n"
168  " " << corePosition.GetCoordinates(coihuecoCs) << " relative to Coihueco\n"
169  " " << corePosition.GetCoordinates(siteCs) << " in the site's cs\n";
170 
171  const Vector direction(1,2*kPi/3,kPi/6, pampaCs, Vector::kSpherical);
172  cout << "with direction \n "
173  << direction.GetCoordinates(pampaCs) << " in 'Pampa Amarilla' cartesian system, \n "
174  << "(" << direction.GetR(pampaCs) << ", " << direction.GetTheta(pampaCs)/deg << ", " << direction.GetPhi(pampaCs)/deg
175  << ") in 'Pampa Amarilla' spherical coordinates \n "
176  << direction.GetCoordinates(coihuecoCs) << "cartesian coordinates relative to Coihueco \n";
177 
178  cout << "Note (again) how the direction's component didn't change much, as expected. "
179  "The direction is a Vector, whereas the position is Point. The slight changes are due to the earth curvature.\n";
180 
181  // calculate the distance from the core to Los Leones and to llancanelo:
182 
183  const double ll_core = (fDetector.GetEye("Los Leones").GetPosition() - corePosition).GetMag();
184  const double llancanelo_core = (sDetector.GetStation(221).GetPosition() - corePosition).GetMag();
185 
186  cout << "\nDistance from Los Leones to the core: " << ll_core/km << " km\n"
187  "Distance from LLancanelo (Local Station #221) to the core: " << llancanelo_core/km << " km\n";
188 
189  // use cross product to calculate the SDP normal vector given the direction and core position (for Los Leones)
190 
191  AxialVector sdp = Cross(direction, corePosition - fDetector.GetEye("Los Leones").GetPosition());
192  sdp.Normalize();
193 
194  cout << "SEP plane: the equation for the Shower Eye Plane is "
195  "(" << sdp.GetX(losLeonesCs) << ") x + (" << sdp.GetY(losLeonesCs) << ") y + (" << sdp.GetZ(losLeonesCs) << ") z = 0\n";
196 
197  // use dot product to calculate the angle between vertical vectors at Coihueco and Los Morados.
198 
199  const Vector coihuecoVertical(0,0,1, coihuecoCs);
200  const Vector moradosVertical(0,0,1, moradosCs);
201 
202  cout << "the angle between the vertical line at Coihueco and Los Morados: "
203  << Angle(coihuecoVertical, moradosVertical)/deg << " degrees. The earth is curved!\n"
204  << "same number, measuring the zenithal angle of the Morados vertical in Coihueco's CS: "
205  << moradosVertical.GetTheta(coihuecoCs)/deg << " degrees\n";
206 
207  return eSuccess;
208 }
209 
210 
212 GeometryExample::Finish()
213 {
214  return eSuccess;
215 }
AxialVector Cross(const Vector &l, const Vector &r)
Definition: OperationsAV.h:25
Point object.
Definition: Point.h:32
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
boost::tuple< double, double, double, int, char > GetCoordinates() const
Get norting, easting, height, zone, and band.
Definition: UTMPoint.h:232
double GetR(const CoordinateSystemPtr &coordinateSystem) const
radius r in spherical coordinates coordinates (distance to origin)
Definition: BasicVector.h:257
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
Class to hold and convert a point in geodetic coordinates.
Definition: UTMPoint.h:40
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
utl::Point GetPosition() const
Tank position.
constexpr double deg
Definition: AugerUnits.h:140
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Reference ellipsoids for UTM transformations.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
constexpr double kPi
Definition: MathConstants.h:24
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
const double km
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Vector object.
Definition: Vector.h:30
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
AxialVector object.
Definition: AxialVector.h:30
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
EllipsoidID
ID&#39;s of known reference ellipsoid&#39;s.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
Definition: UTMPoint.cc:45
constexpr double m
Definition: AugerUnits.h:121
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115
utl::Point GetPosition() const
Eye position.

, generated on Tue Sep 26 2023.