10 #include <det/Detector.h>
12 #include <fdet/FDetector.h>
15 #include <atm/ParametricXMLMieModel.h>
16 #include <atm/ScatteringResult.h>
17 #include <atm/AttenuationResult.h>
19 #include <fwk/CentralConfig.h>
20 #include <fwk/CoordinateSystemRegistry.h>
22 #include <utl/Point.h>
23 #include <utl/AugerUnits.h>
24 #include <utl/MathConstants.h>
25 #include <utl/Reader.h>
26 #include <utl/ErrorLogger.h>
27 #include <utl/Vector.h>
28 #include <utl/ReferenceEllipsoid.h>
29 #include <utl/TabulatedFunctionErrors.h>
30 #include <utl/TabulatedFunction.h>
31 #include <utl/RandomSamplerFromPDF.h>
50 CentralConfig::GetInstance()->
GetTopBranch(
"ParametricXMLMieModel");
93 ParametricXMLMieModel::EvaluateMieScattering(
const utl::Point& xA,
96 const double distance,
97 const vector<double>& wLength)
100 const AttenuationResult& mieAttenuation = EvaluateMieAttenuation(xA, xB, wLength);
101 return EvaluateMieScattering(xA, xB, angle, distance, mieAttenuation);
109 ParametricXMLMieModel::EvaluateMieScattering(
const utl::Point& xA,
112 const double distance,
118 const double fractionError = 0;
119 const double wError = 0;
121 const unsigned int nWl = attenuation.
GetNPoints();
122 for (
unsigned int iWl = 0; iWl < nWl; ++iWl) {
123 const double wl = attenuation.
GetX(iWl);
124 const double value = EvaluateMieScattering(xA, xB, angle, distance, wl, attenuation.
GetY(iWl));
125 frac.
PushBack(wl, wError, value, fractionError);
136 ParametricXMLMieModel::EvaluateMieScattering(
const utl::Point& xA,
139 const double distance,
140 const double wLength)
144 const double mAtt = EvaluateMieAttenuation(xA, xB, wLength);
145 return EvaluateMieScattering(xA, xB, angle, distance, wLength, mAtt);
153 ParametricXMLMieModel::EvaluateMieScattering(
const utl::Point& xA,
156 const double distance,
157 const double wLength,
158 const double mieAttenuation)
161 const double xphs = EvaluateScatteringAngle(xA, angle, wLength);
162 return (1 - mieAttenuation) * xphs /
pow(distance, 2);
171 ParametricXMLMieModel::EvaluateMieAttenuation(
const utl::Point& xInit,
173 const std::vector<double>& wLength)
177 const double wError = 0;
178 const double mieAttError = 0;
180 for (std::vector<double>::const_iterator wlIter = wLength.begin();
181 wlIter != wLength.end(); ++wlIter) {
182 const double mieAtt = EvaluateMieAttenuation(xInit, xFinal, *wlIter);
183 attenuation.
PushBack(*wlIter, wError, mieAtt, mieAttError);
195 ParametricXMLMieModel::EvaluateMieAttenuation(
const utl::Point& xInit,
197 const double wLength)
205 const double alphaM = 1. / fLMix;
206 const double distance = (xInit-xFinal).GetMag();
207 const double deltaHeight =
abs(hFinal - hInit);
208 const double cosTheta = deltaHeight / distance;
212 if (deltaHeight > 1*
m) {
218 if (hInit < fHMix && hFinal < fHMix)
219 vaodSlant = alphaM * (hFinal - hInit);
220 else if (hInit < fHMix && hFinal > fHMix)
221 vaodSlant = alphaM * (fHMix - hInit +
222 fHScl * (1. - exp(-(hFinal - fHMix) / fHScl)));
224 vaodSlant = alphaM * fHScl *
225 (exp(-(hInit - fHMix)/fHScl) - exp(-(hFinal - fHMix)/fHScl));
228 vaodSlant /= cosTheta;
232 vaodSlant = alphaM * distance;
234 vaodSlant = alphaM * exp(-(hInit - fHMix) / fHScl) * distance;
238 const double arg = -vaodSlant *
pow(wLength/355./
nanometer, -fGamma);
240 if (arg < std::numeric_limits<double>::max_exponent10 *
kLn10)
251 ParametricXMLMieModel::GetVerticalAerosolOpticalDepth(
const unsigned int eyeId,
252 const double altitude)
258 det::Detector::GetInstance().GetFDetector().GetEye(eyeId).GetPosition();
261 const double hFinal = altitude - fHGnd;
263 const double alphaM = 1. / fLMix;
267 if ((hFinal - hEye) > 1*
m) {
269 if (hEye < fHMix && hFinal < fHMix)
270 return alphaM * (hFinal - hEye);
271 else if (hEye < fHMix && hFinal > fHMix)
272 return alphaM * (fHMix - hEye +
273 fHScl * (1. - exp(-(hFinal - fHMix) / fHScl)));
275 return alphaM * fHScl *
276 (exp(-(hEye - fHMix)/fHScl) - exp(-(hFinal - fHMix)/fHScl));
288 const double wLength)
293 const double height =
301 alpha = 1. / (fLMix * exp((height - fHMix) / fHScl));
303 return 1. / (alpha *
pow(wLength / 355. /
nanometer, -fGamma));
311 ParametricXMLMieModel::EvaluateScatteringAngle(
const Point& ,
316 const double g2 = fPhaseFunction.g * fPhaseFunction.g;
317 const double mu = cos(angle);
318 const double a = 0.25 * (1 - g2) /
kPi;
319 const double b =
pow(1 + g2 - 2 * fPhaseFunction.g * mu, -1.5);
320 const double c = fPhaseFunction.f * 0.5 * (3*mu*mu - 1) *
pow(1 + g2, -1.5);
Branch GetTopBranch() const
unsigned int GetNPoints() const
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
void swap(utl::TabulatedFunction &t1, utl::TabulatedFunction &t2)
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
static const ReferenceEllipsoid & Get(const EllipsoidID theID)
Get known ellipsoid by registered ID.
double pow(const double x, const unsigned int i)
constexpr double nanometer
Class holding the output of the ScatteringResult function.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Reference ellipsoids for UTM transformations.
double abs(const SVector< n, T > &v)
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
void PushBack(const double x, const double xErr, const double y, const double yErr)
void GetData(bool &b) const
Overloads of the GetData member template function.
const double & GetY(const unsigned int idx) const
const double & GetX(const unsigned int idx) const
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
Class describing the Atmospheric attenuation.