FdProfileFinder.cc
Go to the documentation of this file.
1 
9 #include "FdProfileFinder.h"
10 
11 #include <utl/ErrorLogger.h>
12 #include <utl/MathConstants.h>
13 #include <utl/Vector.h>
14 #include <utl/PhysicalConstants.h>
15 #include <utl/PhysicalFunctions.h>
16 #include <utl/Reader.h>
17 
18 #include <utl/TabulatedFunctionErrors.h>
19 #include <utl/UTMPoint.h>
20 
21 #include <evt/Event.h>
22 #include <evt/ShowerRecData.h>
23 #include <evt/ShowerFRecData.h>
24 
25 #include <fevt/FEvent.h>
26 #include <fevt/Eye.h>
27 #include <fevt/Telescope.h>
28 #include <fevt/EyeRecData.h>
29 
30 #include <det/Detector.h>
31 #include <atm/Atmosphere.h>
32 #include <atm/AttenuationResult.h>
33 #include <atm/ProfileResult.h>
34 
35 #include <fdet/FDetector.h>
36 #include <fdet/Eye.h>
37 #include <fdet/Telescope.h>
38 #include <fdet/Pixel.h>
39 #include <fdet/Channel.h>
40 
41 #include <fwk/LocalCoordinateSystem.h>
42 #include <fwk/CentralConfig.h>
43 
44 
45 using namespace FdProfileFinderOG;
46 using namespace fwk;
47 using namespace utl;
48 using namespace evt;
49 using namespace fevt;
50 using namespace det;
51 using namespace fdet;
52 using namespace std;
53 using namespace atm;
54 
55 
57 {
58 }
59 
62 {
63  CentralConfig* cc = CentralConfig::GetInstance();
64 
65  Branch topB = cc->GetTopBranch("FdProfileFinder");
66  topB.GetChild("energyCutoff").GetData(fEnergyCutoff);
67 
68  return eSuccess;
69 }
70 
73 {
74  return eSuccess;
75 }
76 
79 {
80  if (!event.HasFEvent())
81  return eSuccess;
82 
83  FEvent::EyeIterator eyeiter;
84  for (eyeiter= event.GetFEvent().EyesBegin();
85  eyeiter != event.GetFEvent().EyesEnd();
86  ++eyeiter)
87  { // loop on showers
88  fevt::Eye& eye = *eyeiter;
89 
90  if (! eye.GetRecData().HasLightFlux())
91  continue;
92 
93  CoordinateSystemPtr eyeCS =
94  det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
95 
96  Point eyepos =
97  det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
98 
99  if (!eye.HasRecData()) {
100  INFO("Eye has no geometry info");
101  continue;
102  }
103 
104  // retrieve geometrical parameters
105  fAxis = eye.GetRecData().GetFRecShower().GetAxis();
106 
107  fT0 = eye.GetRecData().GetTZero();
108  fChi0 = eye.GetRecData().GetChiZero();
109  fRp = eye.GetRecData().GetRp();
110 
111  // use geometry as seen by this eye.
112  // The vector fCore_Eye_vec needs to be in the
113  // horizontal plane of the eye
114  //
115 
116  Vector vertical(0,0,1,eyeCS);
117  Vector sdp = eye.GetRecData().GetSDP();
118  Vector horizontalInSDP = cross(sdp,vertical);
119  horizontalInSDP.Normalize();
120  double core_distance = fRp / sin( kPi - fChi0);
121 
122  fCore_Eye_vec = core_distance * horizontalInSDP;
123  fCore = eyepos + fCore_Eye_vec;
124 
125  LightAtApertureToSize(eye);
126 
127  } // for eye
128  return eSuccess;
129 }
130 
131 
132 
133 
134 void
136 {
137  const ReferenceEllipsoid& wgs84 =
138  ReferenceEllipsoid::Get (ReferenceEllipsoid::eWGS84);
139 
140  if (!eye.GetRecData().HasFRecShower())
141  eye.GetRecData().MakeFRecShower();
142  evt::ShowerFRecData& frecdata = eye.GetRecData().GetFRecShower();
143 
144  // Book energy cutoff
145  frecdata.SetEnergyCutoff(fEnergyCutoff);
146 
147  double showerMax = 800*g/cm/cm;
148  if (frecdata.HasGHParameters())
149  showerMax = frecdata.GetGHParameters().GetXMax();
150 
151  CoordinateSystemPtr coreCS=
153 
154  const Atmosphere& atm = det::Detector::GetInstance().GetAtmosphere();
155  double dEdX0 = atm.GetdEdX0();
156 
160  double atmHeightMin = max( tvh.MinX(), max(dvh.MinX(), denvh.MinX()));
161  double atmHeightMax = min( tvh.MaxX(), max(dvh.MaxX(), denvh.MaxX()));
162 
164 
165  const TabulatedFunctionErrors& lightflux =
167 
169 
170  // BRD Using the model efficiency of the first telescope as the eye
171  // efficiency
173  const fdet::Telescope& dettel =
174  det::Detector::GetInstance().GetFDetector().GetTelescope(*itTel);
175  const double refLambda =
176  det::Detector::GetInstance().GetFDetector().GetReferenceLambda();
177  // detector efficiency at reference wavelength
178  const double detector_eff_ref = dettel.GetModelMeanEfficiency(dettel.GetConfigSignature("TelescopeSimulatorKG"), refLambda);
179 
180  // clear long profile if it exists
181  if (frecdata.HasLongitudinalProfile())
182  frecdata.GetLongitudinalProfile().Clear();
183  if (frecdata.HasFluorescencePhotons())
184  frecdata.GetFluorescencePhotons().Clear();
185 
186  for (iter = lightflux.Begin(); // loop on light profile at diaphragm
187  iter != lightflux.End();
188  ++iter)
189  {
190  double time = iter->X();
191  double dtime = iter->XErr();
192  double ph_at_dia = iter->Y();
193  double ph_at_dia_err = iter->YErr();
194 
195  double chi_i = fChi0 - 2* atan ( kSpeedOfLight/fRp *(time - fT0) );
196  double l = fCore_Eye_vec.GetMag() * sin (chi_i) / sin (fChi0 - chi_i);
197  if (l<0) l*=-1;
198 
199  // vector detector-shower at t=time
200  Vector chi_i_vec = fCore_Eye_vec + l * fAxis;
201 
202  // point where the shower is at t=time
203  Point chi_i_point = fCore + l * fAxis;
204 
205  // height of shower at t=time
206  // note: we have to trasform to a UTM point to know
207  // the z of the point above the ellipsoid
208  double height = wgs84.PointToLatitudeLongitudeHeight(chi_i_point).get<2>();
209  if (height>atmHeightMax || height<atmHeightMin) {
210  //longitudinalprofile.PushBack (0,0,0,0);
211  //photons_at_track.PushBack (0,0,0,0);
212  continue;
213  }
214 
215  // create a profile if none exists yet
216  if (!frecdata.HasLongitudinalProfile() )
217  frecdata.MakeLongitudinalProfile();
218  TabulatedFunctionErrors& longitudinalprofile =
219  frecdata.GetLongitudinalProfile() ;
220  if (!frecdata.HasFluorescencePhotons())
221  frecdata.MakeFluorescencePhotons();
222  TabulatedFunctionErrors& photons_at_track=
223  frecdata.GetFluorescencePhotons();
224 
225  double time1 = time/ns - dtime/ns;
226  double time2 = time/ns + dtime/ns;
227 
228  double chi_1 = fChi0 - 2* atan ( kSpeedOfLight/fRp *(time1 - fT0) );
229  double l1 = fCore_Eye_vec.GetMag() * sin (chi_1) / sin (fChi0 - chi_1);
230  double chi_2 = fChi0 - 2* atan ( kSpeedOfLight/fRp *(time2 - fT0) );
231  double l2 = fCore_Eye_vec.GetMag() * sin (chi_2) / sin (fChi0 - chi_2);
232 
233  // traveled track length
234  double deltaL = abs (l2 - l1);
235 
236  // vertdepth
237  double verticalDepth = dvh.Y(height);
238 
239  // slant depth
240  double Xdepth = verticalDepth / abs (cos(fAxis.GetTheta(coreCS)));
241 
242  double solidangle = 1 / (4.0 * kPi* chi_i_vec.GetMag2());
243 
244  // Evaluate fluorescence yield for that height
245  const TabulatedFunction fluoyield_tab =
246  atm.EvaluateFluorescenceYield(height);
247 
248  std::vector<double> relfluorescenceYield_vec( fluoyield_tab.GetNPoints());
249  std::vector<double> waveLength_vec( fluoyield_tab.GetNPoints());
250 
251  // copy the fluo yield into the vector
252  copy(fluoyield_tab.YBegin(),fluoyield_tab.YEnd(),
253  relfluorescenceYield_vec.begin());
254  // normalize the spectrum to 1
255  double fluoyield_normalization = fluoyield_tab.SumY();
256 
257  double dEdX = EnergyDeposit(Xdepth, showerMax, fEnergyCutoff);
258 
260  // dEdX = 2;
261 
262  double totalyield = fluoyield_normalization * dEdX / dEdX0;
263 
264  for ( vector<double>::iterator it= relfluorescenceYield_vec.begin();
265  it != relfluorescenceYield_vec.end();
266  ++it)
267  (*it) /= fluoyield_normalization;
268 
269  // copy the wavelength
270  copy(fluoyield_tab.XBegin(), fluoyield_tab.XEnd(),
271  waveLength_vec.begin());
272 
273  // Rayleigh attenuation
274  Point eyepos =
275  det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
276  Point trackpos = eyepos + chi_i_vec;
277 
278 
279  AttenuationResult rAttenuation =
280  atm.EvaluateRayleighAttenuation(eyepos,trackpos,waveLength_vec);
281 
282  const utl::TabulatedFunctionErrors& rayleighAtt =
283  rAttenuation.GetTransmissionFactor();
284 
285  // Mie Attenuation
286  AttenuationResult mAttenuation =
287  atm.EvaluateMieAttenuation(eyepos,trackpos,waveLength_vec);
288 
289  const utl::TabulatedFunctionErrors& mieAtt =
290  mAttenuation.GetTransmissionFactor();
291 
292  // calculation of shower size
293  double n_e = 0; // size
294  double L = 0; // light at track
295  double convert = 0; // conversion factor
296 
297  // wavelength dependent part
298  for (unsigned int i = 0; i<waveLength_vec.size(); i++){
299  convert += relfluorescenceYield_vec[i]* dettel.GetModelMeanEfficiency(dettel.GetConfigSignature("TelescopeSimulatorKG"), waveLength_vec[i])
300  * rayleighAtt.Y(waveLength_vec[i]) * mieAtt.Y(waveLength_vec[i]);
301  } // for wavelength
302 
303  // non wavelength dependent part
304  n_e = ph_at_dia * detector_eff_ref/solidangle/deltaL/totalyield/convert;
305  L = ph_at_dia * detector_eff_ref/solidangle/convert;
306  // n_e error: only error on number of photons at diaphragm considered
307  double n_e_err= ph_at_dia_err* n_e / ph_at_dia;
308 
309  longitudinalprofile.PushBack(Xdepth,0,n_e,n_e_err);
310 
311  // L error: only error on number of photons at diaphragm considered
312  double L_err= ph_at_dia_err* L / ph_at_dia;
313 
314  photons_at_track.PushBack(Xdepth,0,L,L_err);
315 
316  }// loop on light profile
317 }
318 
319 // Configure (x)emacs for this file ...
320 // Local Variables:
321 // mode:c++
322 // compile-command: "make -C .. -k"
323 // End:
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
Definition: OperationsAV.h:32
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
double YErr() const
Definition: PairErr.h:29
const utl::TabulatedFunction & EvaluateFluorescenceYield(const double heightAboveSeaLevel) const
Evaluated Fluorescence Yield for a specific model.
bool HasLightFlux(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that light profile for source /par source is present.
Definition: EyeRecData.h:297
void Normalize()
Definition: Vector.h:64
Point object.
Definition: Point.h:32
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
bool HasRecData() const
Definition: FEvent/Eye.h:116
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
bool HasFluorescencePhotons() const
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
bool HasFEvent() const
double GetChiZero() const
Definition: EyeRecData.h:85
ArrayIterator XEnd()
end of array of X
Class to hold collection (x,y) points and provide interpolation between them.
fRp(t.GetRp())
const atm::ProfileResult & EvaluateDensityVsHeight() const
Tabulated function giving Y=density as a function of X=height.
const std::string & GetConfigSignature(const std::string &module) const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Definition: FEvent.h:55
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
double GetModelMeanEfficiency(const std::string &configSignature, const double wl) const
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
const int dtime
Definition: XbAlgo.h:7
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
double X() const
Definition: PairErr.h:25
double SumY() const
return the sum of Y values
#define max(a, b)
Class representing a document branch.
Definition: Branch.h:107
void MakeFRecShower()
Allocate reconstructed shower info.
Definition: EyeRecData.cc:58
Reference ellipsoids for UTM transformations.
bool HasLongitudinalProfile() const
const double ns
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
constexpr double kPi
Definition: MathConstants.h:24
double abs(const SVector< n, T > &v)
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
bool HasFRecShower() const
Check if reconstructed shower info has been allocated.
Definition: EyeRecData.h:330
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Definition: EyeRecData.h:323
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
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.
constexpr double g
Definition: AugerUnits.h:200
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
Definition: FEvent/Eye.h:72
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
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
const utl::AxialVector & GetSDP() const
Definition: EyeRecData.h:75
fevt::FEvent & GetFEvent()
ArrayIterator YBegin()
begin of array of Y
bool HasGHParameters() const
constexpr double kSpeedOfLight
Detector description interface for Telescope-related data.
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void SetEnergyCutoff(const double energy)
utl::TabulatedFunctionErrors & GetLongitudinalProfile()
retrieve longitudinal profile information (size vs depth)
double Y() const
Definition: PairErr.h:26
double XErr() const
Definition: PairErr.h:28
utl::TabulatedFunctionErrors & GetFluorescencePhotons()
retrieve number of fluorescence photons versus depth
double GetRp() const
Definition: EyeRecData.h:87
ArrayIterator XBegin()
begin of array of X
constexpr double cm
Definition: AugerUnits.h:117
double EnergyDeposit(const double age, const double enCut)
Parametrization for the average energy deposit per particle.
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
double GetdEdX0() const
get reference energy deposit for fluorescence yield model
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Main configuration utility.
Definition: CentralConfig.h:51
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double GetTZero() const
Definition: EyeRecData.h:83
ArrayIterator YEnd()
end of array of Y
utl::TabulatedFunctionErrors & GetLightFlux(const FdConstants::LightSource source=fevt::FdConstants::eTotal)
Light flux at diaphragm, photons/m^2 versus time in ns.
Definition: EyeRecData.h:286
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
void LightAtApertureToSize(fevt::Eye &eye)
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class describing the Atmospheric attenuation.
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Tabulated function giving Y=temperature as a function of X=height.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130
double GetMag2() const
Definition: Vector.h:61
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.

, generated on Tue Sep 26 2023.