ParametricXMLRayleighModel.cc
Go to the documentation of this file.
1 
14 #include <det/Detector.h>
15 
16 #include <atm/ParametricXMLRayleighModel.h>
17 #include <atm/InclinedAtmosphericProfile.h>
18 #include <atm/ScatteringResult.h>
19 #include <atm/AttenuationResult.h>
20 #include <atm/ProfileResult.h>
21 
22 #include <fwk/CentralConfig.h>
23 #include <fwk/CoordinateSystemRegistry.h>
24 
25 #include <utl/Point.h>
26 #include <utl/Vector.h>
27 #include <utl/AugerUnits.h>
28 #include <utl/Reader.h>
29 #include <utl/ErrorLogger.h>
30 #include <utl/MathConstants.h>
31 #include <utl/PhysicalConstants.h>
32 #include <utl/ReferenceEllipsoid.h>
33 #include <utl/TabulatedFunctionErrors.h>
34 
35 #include <iostream>
36 #include <string>
37 #include <sstream>
38 #include <vector>
39 
40 using namespace det;
41 using namespace atm;
42 using namespace utl;
43 using namespace std;
44 using namespace fwk;
45 
46 
47 inline
48 double
49 RefractiveIndex(const double wl)
50 {
51  // A. Bucholtz, Applied Optics 34, 2765 (1995), eq. 5
52  // Refractive index at STP: requires input wavelength in microns
53  const double invWl2 = pow(wl / micrometer, -2);
54 
55  return 1 + 1e-8 * (5791817. / (238.0185 - invWl2) + 167909. / (57.362 - invWl2));
56 }
57 
58 
59 ParametricXMLRayleighModel::ParametricXMLRayleighModel() :
60  fIntegratedGDistance(false),
61  fIntegrationStepWidth(0)
62 { }
63 
64 
65 void
67 {
68  CentralConfig* cc = CentralConfig::GetInstance();
69  Branch topB = cc->GetTopBranch("ParametricXMLRayleighModel");
70 
71  topB.GetChild("RhoN").GetData(fRhoN);
72  fIntegratedGDistance = bool(topB.GetChild("SlantDepthIntegrationStepWidth"));
74  topB.GetChild("SlantDepthIntegrationStepWidth").GetData(fIntegrationStepWidth);
75 
76  ostringstream info;
77  info << "do grammage integration in curved geometry using deltaDist="
79  << " m";
80  INFO(info);
81  }
82 }
83 
84 
104  const utl::Point& xB,
105  const double angle,
106  const double distance,
107  const std::vector<double>& wLength)
108  const
109 {
110  AttenuationResult attenuation = EvaluateRayleighAttenuation(xA, xB, wLength);
111  return EvaluateRayleighScattering(xA, xB, angle, distance, attenuation);
112 }
113 
114 
117  const utl::Point& xB,
118  const double angle,
119  const double distance,
120  const AttenuationResult& raylAtt)
121  const
122 {
123  double fractionError = 0;
124  double wError = 0;
126  const utl::TabulatedFunctionErrors& attenuation = raylAtt.GetTransmissionFactor();
127 
128  const unsigned int nWl = attenuation.GetNPoints();
129  for (unsigned int iWl = 0; iWl < nWl; ++iWl) {
130  const double wl = attenuation.GetX(iWl);
131  const double sct = EvaluateRayleighScattering(xA, xB, angle, distance, wl, attenuation.GetY(iWl));
132  // Errors to be implemented
133  frac.PushBack(wl, wError, sct, fractionError);
134  }
135 
136  return ScatteringResult(frac, angle);
137 }
138 
139 
140 double
142  const utl::Point& /*xB*/,
143  const double angle,
144  const double distance,
145  double wLength,
146  const double raylAtt)
147  const
148 {
149  return (1 - raylAtt)
150  * EvaluateScatteringAngle(xA, angle, wLength)
151  / (distance * distance);
152 }
153 
154 
155 double
157  const utl::Point& xB,
158  const double angle,
159  const double distance,
160  double wLength)
161  const
162 {
163  const double raylAtt = EvaluateRayleighAttenuation(xA, xB, wLength);
164  return EvaluateRayleighScattering(xA, xB, angle, distance, wLength, raylAtt);
165 }
166 
167 
184  const utl::Point& xFinal,
185  const vector<double>& wLength)
186  const
187 {
188  utl::TabulatedFunctionErrors attenuation;
189  const double rAttError = 0;
190  const double wError = 0;
191  const double slantDistance = GDistance(xInit, xFinal);
192 
193  for (std::vector<double>::const_iterator it = wLength.begin();
194  it != wLength.end(); ++it) {
195  const double attenuationLength = GetAttenuationLength(xInit, *it);
196  const double transAtt = exp(-slantDistance/attenuationLength);
197  attenuation.PushBack(*it, wError, transAtt, rAttError);
198  }
199 
200  return AttenuationResult(attenuation);
201 }
202 
203 
204 double
206  const utl::Point& xFinal,
207  double wLength)
208  const
209 {
210  return exp(-GDistance(xInit, xFinal) / GetAttenuationLength(xInit, wLength));
211 }
212 
213 
220 double
222  const utl::Point& xB)
223  const
224 {
225  Detector& theDetector = Detector::GetInstance();
226  const Atmosphere& atmosphere = theDetector.GetAtmosphere();
227 
228  double xDistance = 0;
229 
230  if (fIntegratedGDistance) {
231  xDistance = atmosphere.IntegratedGrammage(xA, xB, fIntegrationStepWidth);
232  } else {
233  ReferenceEllipsoid wgs84(ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84));
234  double zA = (wgs84.PointToLatitudeLongitudeHeight(xA)).get<2>();
235  double zB = (wgs84.PointToLatitudeLongitudeHeight(xB)).get<2>();
236 
237  const ProfileResult& dvh = atmosphere.EvaluateDepthVsHeight();
238  double atmHeightMin = dvh.MinX();
239  double atmHeightMax = dvh.MaxX();
240  double depthA, depthB;
241 
242  if (zA < atmHeightMin)
243  depthA = dvh.Y(atmHeightMin);
244  else if (zA > atmHeightMax)
245  depthA = dvh.Y(atmHeightMax);
246  else
247  depthA = dvh.Y(zA);
248 
249  if (zB < atmHeightMin)
250  depthB = dvh.Y(atmHeightMin);
251  else if (zB > atmHeightMax)
252  depthB = dvh.Y(atmHeightMax);
253  else
254  depthB = dvh.Y(zB);
255 
256  double distAB = (xA - xB).GetMag();
257 
258  if (zA != zB)
259  xDistance = distAB * abs((depthA - depthB) / (zA - zB));
260  else if (zA <= 12.0*km)
261  xDistance = distAB * abs(depthA / (0.19 * (44340 * m - zB)));
262  else if (zA <= 45.470*km)
263  xDistance = distAB * abs(depthA / (6.340*km));
264  else
265  xDistance = 0.0;
266  }
267 
268  return xDistance;
269 }
270 
271 
272 double
274  const double wLength)
275  const
276 {
277  // N_s = molecules per cubic centimetre at T=15deg, 760mm Hg (Bucholtz)
278  const double N_s = 2.54743e19 / cm3;
279  const double factorKing = (6 + 3.*fRhoN) / (6 - 7.*fRhoN);
280 
281  const double refIndex = RefractiveIndex(wLength);
282  const double refIndex2 = refIndex * refIndex;
283 
284  const double sigma_molecule =
285  24 * pow(kPi, 3)
286  * pow(((refIndex2 - 1) / (refIndex2 + 2)), 2)
287  / pow(wLength, 4) / (N_s * N_s) * factorKing;
288 
289  return kDryAirMolarMass / (sigma_molecule * kAvogadro);
290 }
291 
292 
293 double
295  const double angle,
296  const double /*wLength*/)
297  const
298 {
299  const double gamRay = fRhoN / (2. - fRhoN);
300  const double factor = 3 / (16 * kPi);
301  return factor / (1 + 2*gamRay) *
302  ((1 + 3*gamRay) + (1 - gamRay) * pow(cos(angle), 2));
303 }
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
double RefractiveIndex(const double wl)
Point object.
Definition: Point.h:32
constexpr double atmosphere
Definition: AugerUnits.h:215
constexpr double cm3
Definition: AugerUnits.h:119
constexpr double kDryAirMolarMass
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Calculate the Rayleigh attenuation between two points for a vector of wavelengths.
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &wLength) const
Calculate the fraction of Rayleigh scattering photons in the beam.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
double pow(const double x, const unsigned int i)
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
Class holding the output of the ScatteringResult function.
double EvaluateScatteringAngle(const utl::Point &p, const double angle, const double wLength) const
const atm::Atmosphere & GetAtmosphere() const
Definition: Detector.h:113
constexpr double micrometer
Definition: AugerUnits.h:101
Class representing a document branch.
Definition: Branch.h:107
Reference ellipsoids for UTM transformations.
constexpr double kAvogadro
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
constexpr double kPi
Definition: MathConstants.h:24
double abs(const SVector< n, T > &v)
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
const double km
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.
Definition: Branch.cc:644
const double & GetY(const unsigned int idx) const
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
const double & GetX(const unsigned int idx) const
double GetAttenuationLength(const utl::Point &p, const double wLength) const
Attenuation [slant depth]; assumes const Rayleigh X-section vs height.
Main configuration utility.
Definition: CentralConfig.h:51
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double IntegratedGrammage(const utl::Point &pStart, const utl::Point &pStop, const double delta) const
constexpr double m
Definition: AugerUnits.h:121
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
double GDistance(const utl::Point &xA, const utl::Point &xB) const
Get the distance between two points in massive length.
Class describing the Atmospheric attenuation.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.

, generated on Tue Sep 26 2023.