ReadAerosolHL.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "ReadAerosolHL.h"
4 #include <utl/ErrorLogger.h>
5 #include <utl/TabulatedFunctionErrors.h>
6 
7 #include <evt/Event.h>
8 
9 #include <det/Detector.h>
10 #include <fdet/FDetector.h>
11 #include <fdet/Eye.h>
12 
13 #include <atm/AttenuationResult.h>
14 #include <atm/ScatteringResult.h>
15 
16 #include <utl/TimeStamp.h>
17 #include <utl/UTCDateTime.h>
18 #include <utl/Point.h>
19 
20 #include <atm/MonthlyAvgDBProfileModel.h>
21 
22 using namespace std;
23 using namespace utl;
24 using namespace fwk;
25 using namespace det;
26 using namespace fdet;
27 using namespace atm;
28 
29 using namespace ReadAerosolHLNS;
30 
31 ReadAerosolHL::ReadAerosolHL(){}
32 
33 ReadAerosolHL::~ReadAerosolHL(){}
34 
36  //
37  //
38  INFO("ReadAerosolHL::Init()");
39  return eSuccess;
40 }
41 
42 VModule::ResultFlag ReadAerosolHL::Run(evt::Event& event){
43  //
44  //
45  INFO("ReadAerosolHL::Run()");
46 
47  Detector& det = Detector::GetInstance();
48 
49  // Set detector time to something
50  //
51  // det.Update(TimeStamp(2005, 5, 11, 9, 0));
52  det.Update(TimeStamp(799837213));
53 
54  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
55 
56  // Define a track segment by specifying two points in the sky. In this
57  // example, we specify the points in the coordinate system of Los Leones
58  //
60  csLL(Detector::GetInstance().GetFDetector().GetEye("Los Leones").GetEyeCoordinateSystem() );
61  Point A(100.*m, 1.*km, 1.*km, csLL);
62  Point B(2500.*m, 1. *km, 50.*m, csLL);
63 
64  // compute Mie attenuation between points A and B. For this calculation
65  // we pass a set of wavelengths at which we want the computation to be carried out.
66  //
67  vector<double> wlength;
68  wlength.push_back(300.*nanometer);
69  wlength.push_back(350.*nanometer);
70  wlength.push_back(400.*nanometer);
71 
72  AttenuationResult attRes;
73  try {
74  attRes = theAtm.EvaluateMieAttenuation(A, B, wlength);
75  } catch (AugerException& ex) {
76  cout << "An exception was thrown with the message " << ex.GetMessage() << endl;
77  exit(EXIT_FAILURE);
78  }
79 
80  cout << endl;
81  cout << "Transmission coefficient at 300 nm = " <<
82  attRes.GetTransmissionFactor().Y(300.*nanometer) << endl;
83 
84  cout << "Transmission coefficient at 350 nm = " <<
85  attRes.GetTransmissionFactor().Y(350.*nanometer) << endl;
86 
87  cout << "Transmission coefficient at 375 nm = " <<
88  attRes.GetTransmissionFactor().Y(375.*nanometer) << endl;
89 
90  cout << "Transmission coefficient at 400 nm = " <<
91  attRes.GetTransmissionFactor().Y(400.*nanometer) << endl;
92 
93 
94  // Compute Mie-scattered photon intensity at angle alpha,
95  // and distance dist away from the track segment defined
96  // by points A and B.
97 
98  ScatteringResult scatRes;
99  try {
100  scatRes = theAtm.EvaluateMieScattering(A, B, 30.*degree, 500.*m, wlength);
101  }
102  catch (...) {
103  cout << "Could not do the computation. " << endl;
104  exit(EXIT_FAILURE);
105  }
106  cout << "scattered photon intensity at 350 nm = " <<
107  scatRes.GetScatteringFactor().Y(350.*nanometer)*meter*meter
108  << " photons/m^2" << endl;
109  cout << endl;
110 
111 
112  // Note that if you request data for a time when there is
113  // no data in the database, a NoDataForModelException will
114  // be thrown. You should check for this possibility.
115  //
116  Detector::GetInstance().Update(UTCDateTime(2001, 1, 1).GetTimeStamp()); // no aerosol data for 2001 !
117 
118  try {
119  theAtm.EvaluateMieAttenuation(A, B, wlength);
120  }
121  catch (NoDataForModelException& ex) {
122  cout << "An exception was thrown when trying to retrieve" << endl;
123  cout << "aerosol data for 2001. This is probably because no data " << endl;
124  cout << "exists in the database for this time." << endl;
125  cout << "Note that if you change the MieModel type in AtmosphereInterfaceConfig " << endl;
126  cout << "to 'ParametricXML' or 'Super' rather than 'MeasuredDB', then the " << endl;
127  cout << "parametric model will be used, and you should NOT see this message" << endl;
128  }
129 
130  // If you request data for a portion of the sky for which
131  // there is no valid data for the current time, you will
132  // get an out of bound exception
133  //
134  det.Update( TimeStamp(799837213)); // reset time to epoch when there is some data
135  Point C(0.*m, 0.*m, 100.*m, csLL);
136  Point D(0.*m, 0.*m, 50.*km, csLL);
137 
138  AttenuationResult wontWork;
139  try {
140  wontWork = theAtm.EvaluateMieAttenuation(C, D, wlength);
141  } catch (AugerException& ex) {
142  cout << "An expected exception of type " << ex.GetExceptionName() << " was thrown. " << endl;
143  cout << "Message from the exception: " << ex.GetMessage() << endl;
144  }
145 
146 
147  return eSuccess;
148 }
149 
150 VModule::ResultFlag ReadAerosolHL::Finish(){
151  //
152  //
153  INFO("ReadAerosolHL::Finish()");
154  return eSuccess;
155 }
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
Top of the interface to Atmosphere information.
const double degree
Point object.
Definition: Point.h:32
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Base class for all exceptions used in the auger offline code.
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
int exit
Definition: dump1090.h:237
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Exception to use in a atmosphere model cannot find data it needs.
constexpr double nanometer
Definition: AugerUnits.h:102
Class holding the output of the ScatteringResult function.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
const double km
const utl::TabulatedFunctionErrors & GetScatteringFactor() const
Scattering factor.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
constexpr double m
Definition: AugerUnits.h:121
const std::string & GetMessage() const
Retrieve the message from the exception.
Class describing the Atmospheric attenuation.
atm::ScatteringResult EvaluateMieScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const

, generated on Tue Sep 26 2023.