LaserLightSimulator.cc
Go to the documentation of this file.
1 
10 #include "LaserLightSimulator.h"
11 
12 #include <fwk/CentralConfig.h>
13 #include <fwk/CoordinateSystemRegistry.h>
14 #include <fwk/RandomEngineRegistry.h>
15 
16 #include <evt/Event.h>
17 #include <evt/ShowerSimData.h>
18 
19 #include <evt/LaserData.h>
20 
21 #include <det/Detector.h>
22 
23 #include <fdet/FDetector.h>
24 #include <fdet/Eye.h>
25 
26 #include <atm/AttenuationResult.h>
27 #include <atm/ProfileResult.h>
28 #include <atm/ScatteringResult.h>
29 #include <atm/Atmosphere.h>
30 
31 #include <utl/Reader.h>
32 #include <utl/ErrorLogger.h>
33 #include <utl/AugerUnits.h>
34 #include <utl/MathConstants.h>
35 #include <utl/PhysicalConstants.h>
36 #include <utl/Vector.h>
37 #include <utl/Point.h>
38 #include <utl/TabulatedFunction.h>
39 #include <utl/TabulatedFunctionErrors.h>
40 #include <utl/MultiTabulatedFunction.h>
41 #include <utl/ReferenceEllipsoid.h>
42 #include <utl/UTMPoint.h>
43 #include <utl/AugerCoordinateSystem.h>
44 #include <utl/Photon.h>
45 #include <utl/RandomEngine.h>
46 
47 #include <cmath>
48 #include <sstream>
49 #include <vector>
50 
51 #include <CLHEP/Random/RandGauss.h>
52 
53 using namespace LaserLightSimulatorNA;
54 using CLHEP::RandGauss;
55 
56 using namespace fwk;
57 using namespace evt;
58 using namespace det;
59 using namespace fdet;
60 using namespace atm;
61 using namespace utl;
62 
63 using namespace std;
64 
66  fMaxLaserHeight(0),
67  fEnergy(0),
68  fNPhotons(0),
69  fDoPoissonFluctuate(false),
70  fRandomEngine(0)
71 {
72 }
73 
75 {
76 }
77 
80 {
81  CentralConfig* cc = CentralConfig::GetInstance();
82 
83  Branch topBranch =
84  cc->GetTopBranch("LaserLightSimulatorNA");
85 
86  topBranch.GetChild("maxLaserHeight").GetData(fMaxLaserHeight);
87  topBranch.GetChild("poissonFluctuate").GetData(fDoPoissonFluctuate);
88  topBranch.GetChild("gpsTimingFluctuation").GetData(fGpsTimingFluctuation);
89 
91  &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
92 
93  ostringstream info;
94  info << "Version: " << GetVersionInfo(VModule::eRevisionNumber)
95  << "\n Parameters:\n"
96  << " Maximum laser height: "
97  << fMaxLaserHeight / km << " km\n"
98  << " Poisson-fluctuate the photon count: "
99  << (fDoPoissonFluctuate ? "yes\n" : "no\n")
100  << " GPS timing fluctuation: "
101  << fGpsTimingFluctuation / nanosecond << " ns\n";
102  INFO(info);
103 
104  return eSuccess;
105 }
106 
109 {
110  INFO("Calculating laser track");
111 
112  if (!theEvent.HasSimShower()){
113  ERROR ("Event has no simulated shower.");
114  return eFailure;
115  }
116  evt::ShowerSimData& theShower = theEvent.GetSimShower();
117 
118  if (!theShower.HasLaserData()){
119  ERROR ("Event has no simulated laser.");
120  return eFailure;
121  }
122  LaserData& theLaser = theShower.GetLaserData();
123 
124  fEnergy = theShower.GetEnergy();
125  fLaserWavelength.push_back(theLaser.GetLaserWavelength());
126 
128  ostringstream info;
129  info << " Laser energy = " << fEnergy / (1e-3*joule) << " mJ;"
130  << " wavelength = " << fLaserWavelength[0] / nanometer << " nm;"
131  << " <N> = " << fNPhotons;
132 
133  if (fDoPoissonFluctuate) {
134  const double N = RandGauss::shoot(&fRandomEngine->GetEngine(),
135  fNPhotons,
136  sqrt(fNPhotons));
137  info << "; N - <N> = " << N - fNPhotons;
138  fNPhotons = N;
139  }
140 
141  double gpsTimingOffset = 0;
142  if(fGpsTimingFluctuation != 0)
143  gpsTimingOffset = RandGauss::shoot(&fRandomEngine->GetEngine(),
144  gpsTimingOffset,
146  info << "; Laser offset = " << gpsTimingOffset / m;
147 
148  INFO(info);
149 
150  utl::Point posLsr = theShower.GetPosition();
151  ReferenceEllipsoid wgs84(ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84));
152  CoordinateSystemPtr coreCS =
153  AugerCoordinateSystem::Create(posLsr, wgs84, wgs84.GetECEF());
154 
155  Vector vecLsr = theShower.GetDirection();
156 
157  posLsr = posLsr + gpsTimingOffset * vecLsr;
158 
159  const CoordinateSystemPtr localCS = theEvent.GetSimShower().GetLocalCoordinateSystem();
160  double zenith = (-theEvent.GetSimShower().GetDirection()).GetTheta(localCS);
161  if (zenith > (0.5*kPi)) {
162  zenith = kPi - zenith;
163  INFO("UPGOING -> Inverting Zenith Angle for CosTheta Calculation");
164  }
165  double cosTheta = cos(zenith);
166 
167  double zLaserGround = (wgs84.PointToLatitudeLongitudeHeight(posLsr)).get<2>();
168 
169  const double fluorLightBin = 50.*ns;
170  double delta = kSpeedOfLight * fluorLightBin;
171  int nPoints = int(abs((zLaserGround - fMaxLaserHeight)/cosTheta/delta));
172 
173  const int nWaves = 1;
174  vector<double> distance;
175  vector<double> laserPhotons[nWaves];
176  double photons = fNPhotons;
177 
178  fLsrInitialPos = posLsr;
179  fLsrFinalPos = posLsr + (fMaxLaserHeight - zLaserGround)/cosTheta*vecLsr;
180 
181  // first point
182  utl::Point LsrPoint = fLsrInitialPos + delta * 0.5 * vecLsr;
183  photons = EvaluatePhotons(photons, fLsrInitialPos, LsrPoint);
184  (laserPhotons[0]).push_back(photons);
185  double height_point = (wgs84.PointToLatitudeLongitudeHeight(LsrPoint)).get<2>();
186  double distance_point = (height_point - zLaserGround) / cosTheta;
187  distance.push_back(distance_point);
188 
189  info.str("");
190  info << " first point "
192  << "; last point "
193  << (wgs84.PointToLatitudeLongitudeHeight(fLsrFinalPos)).get<2>();
194  INFO(info);
195 
196  for (int i=1; i<nPoints; i++){
197  utl::Point LsrPoint2 = LsrPoint + delta *vecLsr;
198  height_point =
199  (wgs84.PointToLatitudeLongitudeHeight(LsrPoint2)).get<2>();
200 
201  distance_point = (height_point-zLaserGround)/cosTheta;
202  distance.push_back(distance_point);
203 
204  photons = EvaluatePhotons(photons, LsrPoint, LsrPoint2);
205  (laserPhotons[0]).push_back(photons);
206 
207  LsrPoint = LsrPoint2;
208  }
209 
210  for (int iwl=0; iwl<nWaves; iwl++) {
211  vector<double> laserLight = laserPhotons[iwl];
212 
213  TabulatedFunction f = TabulatedFunction(distance, laserLight);
214  if (!theEvent.GetSimShower().HasFluorescencePhotons(iwl)) {
215  theEvent.GetSimShower().AddFluorescencePhotons(f, iwl);
216  }
217  }
218 
219  return eSuccess;
220 }
221 
224 {
225  return eSuccess;
226 }
227 
228 double
230  const utl::Point& LsrPos1, const utl::Point& LsrPos2)
231  const
232 {
233  const Atmosphere& atmos = Detector::GetInstance().GetAtmosphere();
234 
235  // Estimate how many photons in the laser beam survive molecular and
236  // aerosol attenuation
237  AttenuationResult rAttenLaserPoint =
238  atmos.EvaluateRayleighAttenuation(LsrPos1, LsrPos2, fLaserWavelength);
239  utl::TabulatedFunctionErrors rAtt = rAttenLaserPoint.GetTransmissionFactor();
240 
241  AttenuationResult mAttenLaserPoint =
242  atmos.EvaluateMieAttenuation(LsrPos1, LsrPos2, fLaserWavelength);
243  utl::TabulatedFunctionErrors mAtt = mAttenLaserPoint.GetTransmissionFactor();
244 
245  const double att = rAtt[0].Y() * mAtt[0].Y();
246 
247  return Nph * att;
248 }
249 
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
LaserData & GetLaserData()
Get the laser data.
Top of the interface to Atmosphere information.
Point object.
Definition: Point.h:32
bool HasLaserData() const
Check initialization of the LaserData.
constexpr double kPlanckSI
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
double GetLaserWavelength() const
Definition: LaserData.h:32
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Report success to RunController.
Definition: VModule.h:62
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
RandomEngineType & GetEngine()
Definition: RandomEngine.h:32
constexpr double kSpeedOfLightSI
Class to hold collection (x,y) points and provide interpolation between them.
bool HasSimShower() const
bool HasFluorescencePhotons(const int wavelength) const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
double EvaluatePhotons(const double Nph, const utl::Point &p1, const utl::Point &p2) const
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
std::string GetVersionInfo(const VersionInfoType v) const
Retrieve different sorts of module version info.
Definition: VModule.cc:26
constexpr double nanometer
Definition: AugerUnits.h:102
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
Reference ellipsoids for UTM transformations.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
const double ns
constexpr double kPi
Definition: MathConstants.h:24
constexpr double nanosecond
Definition: AugerUnits.h:143
double abs(const SVector< n, T > &v)
const utl::Point & GetPosition() const
Get the position of the shower core.
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
ShowerSimData & GetSimShower()
const double km
double GetEnergy() const
Get the energy of the shower primary particle.
Definition: ShowerSimData.h:89
const CoordinateSystemPtr GetECEF() const
Get the ECEF.
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
constexpr double joule
Definition: AugerUnits.h:181
Data structure for Laser simulation and reconstruction.
Definition: LaserData.h:29
constexpr double kSpeedOfLight
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void AddFluorescencePhotons(const utl::TabulatedFunction &fp, const int wavelength)
Vector object.
Definition: Vector.h:30
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
Main configuration utility.
Definition: CentralConfig.h:51
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class describing the Atmospheric attenuation.

, generated on Tue Sep 26 2023.