7 #include <utl/config.h>
11 #include <utl/NumericalErrorPropagation.h>
12 #include <utl/AugerException.h>
13 #include <utl/TimeStamp.h>
14 #include <utl/UTCDateTime.h>
15 #include <utl/ModifiedJulianDate.h>
16 #include <utl/Vector.h>
17 #include <utl/AxialVector.h>
18 #include <utl/Point.h>
19 #include <utl/UTMPoint.h>
20 #include <utl/PhysicalConstants.h>
21 #include <utl/AugerUnits.h>
22 #include <utl/CoordinateSystemPtr.h>
23 #include <utl/Transformation.h>
24 #include <utl/Vector.h>
26 #include <evt/Event.h>
27 #include <evt/ShowerFRecData.h>
30 #include <fevt/EyeRecData.h>
32 #include <det/Detector.h>
33 #include <fdet/FDetector.h>
36 #include <fwk/LocalCoordinateSystem.h>
37 #include <fwk/CoordinateSystemRegistry.h>
44 using namespace otoa::err;
50 CalculateEquatorialCoordinates::operator()(
const std::vector<double>&
p)
55 msg <<
"CalculateEquatorialCoordinates needs 7 parameters, but was called with " << p.size();
59 const double julianDay = p[0];
60 const double gmst = p[1];
61 const double easting = p[2];
62 const double northing = p[3];
63 const double altitude = p[4];
67 const char band =
'H';
69 const UTMPoint pt(northing, easting, altitude, zone, band, ReferenceEllipsoid::eWGS84);
74 boost::tuple<double&, double&, double&>(latitude, longitude, height) =
80 theta = 0.5*
kPi - theta;
82 const double sinTheta = sin(theta);
83 const double cosTheta = cos(theta);
84 const double cosPhi = cos(phi);
85 const double sinLatitude = sin(latitude);
86 const double cosLatitude = cos(latitude);
87 const double dec = asin(sinLatitude*sinTheta - cosLatitude*cosTheta*cosPhi);
88 const double secDec = 1 / cos(dec);
89 const double haSin = cosTheta * sin(phi) * secDec;
90 const double haCos = (cosLatitude*sinTheta + sinLatitude*cosTheta*cosPhi) * secDec;
92 const double ha = (haSin < 0) ? 2*
kPi - acos(haCos) : acos(haCos);
97 double lmst = fmod(gmst + nutHour, 24.)*15 + longitude/
deg;
101 lmst -= int(lmst/360)*360;
103 lmst += 360 - int(lmst/360)*360;
105 double ra = lmst*
deg - ha;
113 if (-2*
kPi <= ra && ra <= 2*
kPi) {
123 CalculateGalacticCoordinates::operator()(
const std::vector<double>&
p)
128 msg <<
"CalculateGalacticCoordinates needs 7 parameters, but was called with " << p.size();
133 const vector<double> q = calcEqu(p);
135 const double ra = q[0];
136 const double dec = q[1];
138 const double raGalEq = 282.86*
deg;
139 const double galLg2000 = 32.933*
deg;
140 const double eqGal = 27.13*
deg;
142 const double cosDec = cos(dec);
143 const double sinDec = sin(dec);
144 const double cosEqGal = cos(eqGal);
145 const double galLatitude = asin(sinDec*sin(eqGal) - cosDec*sin(ra - raGalEq)*cosEqGal);
146 const double secGalLatitude = 1 / cos(galLatitude);
147 const double cosLon = cosDec*cos(ra - raGalEq) * secGalLatitude;
148 const double sinLon = (cosDec*sin(ra - raGalEq)*sin(eqGal) + sinDec*cosEqGal) * secGalLatitude;
150 double galLongitude = ((cosLon < 0 && sinLon < 0) || (cosLon > 0 && sinLon < 0)) ?
151 2*
kPi - acos(cosLon) + galLg2000 : acos(cosLon) + galLg2000;
154 galLongitude = fmod(galLongitude, 2*
kPi);
155 if (galLongitude < 0)
156 galLongitude += 2*
kPi;
159 result[0] = galLongitude;
160 result[1] = galLatitude;
165 CalculateFdCorePosition::CalculateFdCorePosition(
const fevt::Eye& eye) :
174 const double rp = p[0];
175 const double chi0 = p[1];
176 const double sDPtheta = p[2];
177 const double sDPphi = p[3];
180 const fdet::Eye& detEye = det::Detector::GetInstance().GetFDetector().GetEye(
fEye);
184 const Vector sdp(1, sDPtheta, sDPphi, eyeCS, Vector::kSpherical);
186 const Vector vertical(0, 0, 1, eyeCS);
189 const Vector coreEyeVec = rp / sin(
kPi - chi0) * horizontalInSDP;
190 const Point core = eyeposition + coreEyeVec;
201 ERROR(
"UTMZoneException: fd rec shower invalid");
203 ERROR(
"UTMException: fd rec shower invalid");
206 std::vector<double>
result(2);
208 result[1] = northing;
223 const double chi0 = p[0];
224 const double sDPtheta = p[1];
225 const double sDPphi = p[2];
229 const fdet::Eye& detEye = det::Detector::GetInstance().GetFDetector().GetEye(
fEye);
233 const Vector sdp(1, sDPtheta, sDPphi, eyeCS, Vector::kSpherical);
235 const Vector vertical(0, 0, 1, eyeCS);
238 const Transformation rot = Transformation::Rotation(-chi0, sdp, eyeCS);
244 result[1] = axis.
GetPhi(localCS);
AxialVector Cross(const Vector &l, const Vector &r)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Fluorescence Detector Eye Event.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Class to hold and convert a point in geodetic coordinates.
std::vector< double > operator()(const std::vector< double > &p) const
Detector description interface for Eye-related data.
double GetNorthing() const
Get the northing.
Report attempts to use invalid UTM zone.
double CalculateNutationCorrection(const double julianDay)
Used by the calculation of the equatorial coordinates. TODO: Move such calculations to utl or use lib...
Exception for reporting variable out of valid range.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Reference ellipsoids for UTM transformations.
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
double GetEasting() const
Get the easting.
AxialVector Normalized(const AxialVector &v)
Report problems in UTM handling.
Interface class to access to Fluorescence reconstruction of a Shower.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
std::vector< double > operator()(const std::vector< double > &p) const
CalculateFdArrivalDirection(const fevt::Eye &eye)
#define ERROR(message)
Macro for logging error messages.
boost::tuple< double, double, double > GetGeodeticCoordinates() const
Get geodetic latitude, longitude, height.
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
utl::Point GetPosition() const
Eye position.
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.