LightAtDiaphragmSimulator.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <algorithm>
3 #include <vector>
4 #include <locale>
5 
6 #include <utl/Reader.h>
7 #include <utl/ErrorLogger.h>
8 #include <utl/AugerUnits.h>
9 #include <utl/AugerException.h>
10 #include <utl/MathConstants.h>
11 #include <utl/PhysicalConstants.h>
12 #include <utl/PhysicalFunctions.h>
13 #include <utl/Point.h>
14 #include <utl/Vector.h>
15 #include <utl/AxialVector.h>
16 #include <utl/TabulatedFunction.h>
17 #include <utl/TabulatedFunctionErrors.h>
18 #include <utl/UTMPoint.h>
19 #include <utl/ReferenceEllipsoid.h>
20 #include <utl/TransformationMatrix.h>
21 #include <utl/TimeStamp.h>
22 #include <utl/AugerCoordinateSystem.h>
23 
24 #include <utl/Particle.h>
25 
26 #include <evt/Event.h>
27 #include <evt/ShowerSimData.h>
28 #include <evt/LaserData.h>
29 
30 #include <fevt/FEvent.h>
31 #include <fevt/Eye.h>
32 #include <fevt/TelescopeSimData.h>
33 #include <fevt/Telescope.h>
34 
35 #include <fwk/CentralConfig.h>
36 #include <fwk/LocalCoordinateSystem.h>
37 
38 #include <det/Detector.h>
39 #include <fdet/FDetector.h>
40 #include <fdet/Eye.h>
41 #include <fdet/Telescope.h>
42 #include <fdet/Camera.h>
43 
44 #include <atm/AttenuationResult.h>
45 #include <atm/ScatteringResult.h>
46 #include <atm/Atmosphere.h>
47 #include <atm/ProfileResult.h>
48 #include <atm/InclinedAtmosphericProfile.h>
49 
51 
52 #include <TH2D.h> // for debug
53 #include <TH1D.h> // for debug
54 #include <TCanvas.h>// for debug
55 #include <TGraph.h>// for debug
56 #include <TFile.h>// for debug
57 
58 using namespace std;
59 using namespace LightAtDiaphragmSimulatorKG;
60 using namespace utl;
61 using namespace evt;
62 using namespace fwk;
63 using namespace det;
64 using namespace fdet;
65 using namespace atm;
66 
67 
70 {
71  Branch topB =
72  CentralConfig::GetInstance()->GetTopBranch("LightAtDiaphragmSimulatorKG");
73 
74  topB.GetChild("fluorDirect").GetData(fFluorDirect);
75 
76  topB.GetChild("cherDirect").GetData(fCherDirect);
77  topB.GetChild("cherDirectCORSIKA").GetData(fCherDirectCORSIKA);
78  topB.GetChild("cherMieScattered").GetData(fCherMieScattered);
79  topB.GetChild("cherRayleighScattered").GetData(fCherRayleighScattered);
80 
81  topB.GetChild("laserMieScattered").GetData(fLaserMieScattered);
82  topB.GetChild("laserRayleighScattered").GetData(fLaserRayleighScattered);
83  topB.GetChild("wavelengthDepRefraction").GetData(fWlRefrac);
84 
85  const bool showerMode = fFluorDirect ||
86  fCherDirect || fCherDirectCORSIKA || fCherRayleighScattered || fCherMieScattered;
87 
88  const bool laserMode = fLaserMieScattered || fLaserRayleighScattered;
89 
90  if (showerMode && laserMode) {
91  ERROR("You cannot propagate shower and laser light simultanously. "
92  "Check your xml data card!");
93  return eFailure;
94  }
95 
96  if (fCherDirect && fCherDirectCORSIKA) {
97  ERROR("You cannot simulate direct Cherenkov from parameterization and CORSIKA at the same time. Check your xml settings!");
98  return eFailure;
99  }
100 
101  // -------- do some output ------------
102  // info output
103  ostringstream info;
104  info << " Version: "
105  << GetVersionInfo(VModule::eRevisionNumber) << "\n"
106  " Parameters:\n";
107  if (showerMode) {
108  info << " -- shower mode -- \n"
109  " fluorescence: " << fFluorDirect << "\n"
110  " cherenkov direct: " << fCherDirect << " " << (fCherDirectCORSIKA ? "[CORSIKA]" : "[model]") << "\n"
111  " cherenkov Mie: " << fCherMieScattered << "\n"
112  " cherenkov Rayleigh: " << fCherRayleighScattered << "\n"
113  " wavelength dep. n: " << fWlRefrac << "\n";
114  } else if (laserMode) {
115  info << " -- laser mode -- \n"
116  " laser Mie scattered: " << fLaserMieScattered << "\n"
117  " laser Rayleigh scat: " << fLaserRayleighScattered << "\n";
118  } else {
119  info << " -- unknown mode !!! -- \n";
120  }
121  INFO(info);
122 
123  return eSuccess;
124 }
125 
126 
128 LightAtDiaphragmSimulator::Run(evt::Event& event)
129 {
130  if (!event.HasFEvent()) {
131  ERROR("Missing FEvent. Check your module configurations and ModuleSequence.");
132  return eFailure;
133  }
134 
135  if (!event.HasSimShower()) {
136  ERROR("Event has no simulated shower.");
137  return eFailure;
138  }
139 
140  evt::ShowerSimData& simShower = event.GetSimShower();
141  fIsLaserEvent = simShower.HasLaserData();
142  const TimeStamp timeAtCore = simShower.GetTimeStamp();
143 
144  if (!simShower.HasLongitudinalProfile() && !fIsLaserEvent) {
145  ERROR("Event has no longitudinal profile for the simulated shower.");
146  return eFailure;
147  }
148 
149  const CoordinateSystemPtr showerCS = simShower.GetShowerCoordinateSystem();
150  const CoordinateSystemPtr localCS = simShower.GetLocalCoordinateSystem();
151 
152  const Point core(0, 0, 0, showerCS);
153  const Vector showerAxis(0, 0, -1, showerCS);
154  const double zenith = (-simShower.GetDirection()).GetTheta(localCS); // only for flat earth ....
155  const double absCosZenith = std::fabs(cos(zenith));
156 
157  const ReferenceEllipsoid& wgs84 = ReferenceEllipsoid::GetWGS84();
158  const double coreZ = wgs84.PointToLatitudeLongitudeHeight(core).get<2>();
159 
160  Detector& detector = Detector::GetInstance();
161  const Atmosphere& atmo = detector.GetAtmosphere();
162 
163  bool flatEarth = false;
164  ProfileResult const * slantDepthVsDistance = 0;
165  ProfileResult const * depthProfile = 0;
166  try {
167  slantDepthVsDistance = &atmo.EvaluateSlantDepthVsDistance();
169  WARNING("using flat earth!");
170  flatEarth = true;
171  depthProfile = &atmo.EvaluateDepthVsHeight();
172  }
173 
174  // get shower/laser specific information
175  double Xmax = 0;
176  vector <double> WLengthLaser;
177  if (fIsLaserEvent) {
178  double laserWavelength = event.GetSimShower().GetLaserData().GetLaserWavelength();
179  WLengthLaser.push_back (laserWavelength);
180  } else {
181  if (!simShower.HasGHParameters()) {
182  ERROR("Shower without GH-fit: Cannot compute 3D shower structure ! SKIPPING !");
183  // return eFailure;
184  return eContinueLoop;
185  }
186  Xmax = simShower.GetGHParameters().GetXMax();
187  }
188 
189  const vector<double>& WLengthFluo = atmo.GetWavelengths(Atmosphere::eFluorescence);
190  const vector<double>& WLengthCkov = atmo.GetWavelengths(Atmosphere::eCerenkov);
191  const unsigned int NWLengthFluo = WLengthFluo.size();
192  const unsigned int NWLengthCkov = WLengthCkov.size();
193  //const unsigned int nWaveLengths = (fIsLaserEvent ? 1 : NWLengthCkov+NWLengthFluo);
194 
195  /*
196  ----------------------------------------------------------------------------------
197  Now loop over all diaphragm time traces, and fill them
198  */
199 
200  INFO(" ... computing, this may take a while ... ");
201 
202  const FDetector& detFD = detector.GetFDetector();
203  fevt::FEvent& fevent = event.GetFEvent();
204 
206  iEye != fevent.EyesEnd(fevt::ComponentSelector::eInDAQ) ; ++iEye) {
207 
208  fevt::Eye& eyeEvent = *iEye;
209 
211  continue;
212 
214  iTel != eyeEvent.TelescopesEnd(fevt::ComponentSelector::eInDAQ); ++iTel) {
215 
216  fevt::Telescope& telEvent = *iTel;
217  const fdet::Telescope& detTel = detFD.GetTelescope(telEvent);
218  const Point& telPosition = detTel.GetPosition();
219 
220  if (!telEvent.HasSimData())
221  continue;
222  fevt::TelescopeSimData& telSim = telEvent.GetSimData();
223 
224  if (!telSim.HasDistanceTrace())
225  continue;
226  TraceD& distanceTrace = telSim.GetDistanceTrace();
227 
228  const double tracebin = distanceTrace.GetBinning();
229  const double nBins = distanceTrace.GetSize();
230 
231  if (nBins<2)
232  continue;
233 
234  const TimeStamp photonStartTimeAtDia = telSim.GetPhotonsStartTime();
235  const double tMinAtDia = photonStartTimeAtDia - timeAtCore;
236 
237  const Vector telToCore = telPosition - core;
238  const double distTelToCore = telToCore.GetMag();
239  const double cosBeta = CosAngle(telToCore, showerAxis);
240  const double Rp = cross(showerAxis, telToCore).GetMag() / showerAxis.GetMag();
241  const double T0 = distTelToCore * cosBeta / kSpeedOfLight;
242 
243  // USE: dist0 = T0 * kSpeedOfLight
244  // const double dist0 = std::fabs(distStartCore) + distTelToCore * cosBeta;
245  // OLD CALCULATION: sqrt (pow ((showerInitialPos-telPosition).GetMag(), 2) - Rp*Rp);
246 
247  // loop over all bins of trace at diaphragm
248  for (int iBin = 0; iBin < nBins; ++iBin) {
249 
250  const double timeBinStart = tMinAtDia + tracebin * iBin; // at diaphragm, relative to photonStartTime
251  const double timeBin = timeBinStart + 0.5*tracebin;
252  const double timeBinEnd = timeBinStart + tracebin;
253 
254  //const double delta = CalculatePointOnAxis(timeBin, Rp, dist0);
255  const double distance = CalculateDistanceFromCore(timeBin, Rp, T0);
256  const Point pave = core + showerAxis * distance;
257 
258  // cout << " timeBinStart=" << timeBinStart << " " << ((telPosition-pave).GetMag()-(pave-core).GetMag())/kSpeedOfLight << " beta=" << acos(cosBeta)/deg << endl;
259 
260  //const double deltaStart = CalculatePointOnAxis(timeBinStart, Rp, dist0);
261  const double distanceStart = CalculateDistanceFromCore(timeBinStart, Rp, T0);
262  const Point stepStart = core + showerAxis * distanceStart;
263 
264  //const double deltaEnd = CalculatePointOnAxis(timeBinEnd, Rp, dist0);
265  const double distanceEnd = CalculateDistanceFromCore(timeBinEnd, Rp, T0);
266  const Point stepEnd = core + showerAxis * distanceEnd;
267 
268  const double xStepWidth = std::fabs(distanceEnd-distanceStart);
269  distanceTrace[iBin] = distance;
270 
271  if (slantDepthVsDistance &&
272  (distance > slantDepthVsDistance->MaxX() ||
273  distance < slantDepthVsDistance->MinX())) {
274  /*
275  ostringstream warn;
276  warn << " skipping trace bin #" << iBin << " ["
277  << timeBinStart/ns << ", " << timeBinEnd/ns << "] ns, "
278  << " d = " << distance/km << " km, slant table = ["
279  << slantDepthVsDistance->MinX()/km << ", "
280  << slantDepthVsDistance->MaxX()/km << "] km";
281  WARNING(warn);
282  */
283  continue;
284  }
285 
286  const Vector paveDir = pave - telPosition;
287  const double paveDist2 = paveDir.GetMag2();
288  const double paveDist = sqrt(paveDist2);
289  const double geoFactor = 1. / (4.*kPi*paveDist2);
290 
291  //const double diaphragmArea = detTel.GetDiaphragmArea();
292  //const double projectedDiaphragmArea = diaphragmArea * paveDir.GetCosTheta(telCS); // unused -- silence warning
293 
294  /*
295  cout << " light: eye/tel: " << eyeId << "/" << telId
296  << " i " << iBin
297  << " distance/m=" << distance/m
298  << " r=" << paveDist/m
299  << " t=" << timeBin/ns
300  << " Rp=" << Rp/m
301  << " T0=" << T0/ns
302  << " tMinAtDia=" << tMinAtDia/ns
303  << " Xmax=" << slantDepthVsDistance->MaxX()/m
304  << " Xmin=" << slantDepthVsDistance->MinX()/m
305  << endl;
306  */
307 
308  if (!fIsLaserEvent) {
309 
310  // FLUORESCENCE PART
311 
312  // prepare fluorescence
313  // --- read all needed atmospheric properties -------
314  const TabulatedFunctionErrors* rAttFluo = 0;
315  const TabulatedFunctionErrors* mAttFluo = 0;
316 
317  // this is needed HERE because the Atmosphere does not return references ! TODO: change !
318  static AttenuationResult rAttenFluo;
319  static AttenuationResult mAttenFluo;
320  // -----------------------
321 
322  if (fFluorDirect) {
323  rAttenFluo = atmo.EvaluateRayleighAttenuation(pave, telPosition, WLengthFluo);
324  rAttFluo = &rAttenFluo.GetTransmissionFactor();
325  mAttenFluo = atmo.EvaluateMieAttenuation(telPosition, pave, WLengthFluo);
326  mAttFluo = &mAttenFluo.GetTransmissionFactor();
327  }
328  // --- properties read end -
329 
330  // All the calculations are now wavelength dependent
331  for (unsigned int iwl = 0; iwl < NWLengthFluo; ++iwl) {
332 
333  if (!simShower.HasFluorescencePhotons(iwl))
334  continue;
335 
336  const TabulatedFunction& fluoPhotons =
337  simShower.GetFluorescencePhotons(iwl);
338 
339  // DIRECT FLUORESCENCE ----------------------------------
340  if (fFluorDirect) {
341 
342  const double att = (*rAttFluo)[iwl].Y() * (*mAttFluo)[iwl].Y();
343 
345  telSim.MakePhotonTrace(fevt::FdConstants::eFluorDirect, iwl, nBins, tracebin);
346  TraceD& fluorDirectTrace = telSim.GetPhotonTrace(fevt::FdConstants::eFluorDirect, iwl);
347 
348  double auxPh = 0;
349  if (fluoPhotons.GetNPoints() &&
350  *(fluoPhotons.XBegin()) < distance &&
351  *(fluoPhotons.XEnd() - 1) > distance)
352  auxPh = fluoPhotons.Y(distance);
353  const double photons = auxPh * geoFactor * att * xStepWidth; // * projectedDiaphragmArea;
354  fluorDirectTrace[iBin] += photons;
355  } // end of DirectFluorescence
356 
357  } // end of fluorescence only wavelength loop
358 
359  //cerr << " ph_ax " << photonsAtAxis << " ph_dia " << photonsAtDia;
360 
361  // CHERENKOV PART
362 
363  if (fCherDirect || fCherMieScattered || fCherRayleighScattered) {
364 
365  // prepare cherenkov
366 
367  const double Xslant = (flatEarth ?
368  depthProfile->Y(coreZ-distance*absCosZenith)/absCosZenith :
369  slantDepthVsDistance->Y(distance));
370  const double showerAge = utl::ShowerAge(Xslant, Xmax);
371 
372  // --- read all needed atmospheric properties -------
373 
374  // Attenuation and geometrical factors
375  const TabulatedFunctionErrors* rAttCkov = 0;
376  const TabulatedFunctionErrors* mAttCkov = 0;
377  const TabulatedFunctionErrors* mFactor = 0;
378  const TabulatedFunctionErrors* rFactor = 0;
379  double directCher = 0;
380 
381  // this is needed because the Atmosphere does not return references ! TODO: change !
382  static AttenuationResult rAttenCkov; // static is evil, mkay?
383  static AttenuationResult mAttenCkov;
384  static ScatteringResult rScat;
385  static ScatteringResult mScat;
386 
387  rAttenCkov = atmo.EvaluateRayleighAttenuation(pave, telPosition, WLengthCkov);
388  mAttenCkov = atmo.EvaluateMieAttenuation(telPosition, pave, WLengthCkov);
389  // -----------------------
390  rAttCkov = &rAttenCkov.GetTransmissionFactor();
391  mAttCkov = &mAttenCkov.GetTransmissionFactor();
392 
393  const double scattAngle = acos(-showerAxis*paveDir / paveDir.GetMag());
394 
395  // mie scattering factors
396  if (fCherMieScattered) {
397  mScat = atmo.EvaluateMieScattering(stepStart, stepEnd,
398  scattAngle, paveDist,
399  WLengthCkov);
400  mFactor = &mScat.GetScatteringFactor();
401  }
402 
403  // rayleight scattering factors
404  if (fCherRayleighScattered) {
405  rScat = atmo.EvaluateRayleighScattering(stepStart, stepEnd,
406  scattAngle, paveDist,
407  WLengthCkov);
408  rFactor = &rScat.GetScatteringFactor();
409  }
410 
411  // direct cerenkov
412  if (fCherDirect)
413  directCher = fWlRefrac ? 1. : atmo.EvaluateDirectCherenkovProbability(stepStart, stepEnd, telPosition,
414  showerAge);
415  // --- properties read end -
416 
417  // All the calculations are now wavelength dependent
418  for (unsigned int iwl = 0; iwl < NWLengthCkov; ++iwl) {
419 
420  if (!simShower.HasCherenkovPhotons(iwl))
421  continue;
422 
423  const double att = (*rAttCkov)[iwl].Y() * (*mAttCkov)[iwl].Y(); // * projectedDiaphragmArea;
424 
425  double beamPhotons = 0;
426  if (simShower.HasCherenkovBeamPhotons(iwl)) {
427  const TabulatedFunction& cherPhotons = simShower.GetCherenkovBeamPhotons(iwl);
428  if (cherPhotons.GetNPoints() &&
429  *cherPhotons.XBegin() < distance &&
430  *(cherPhotons.XEnd() - 1) > distance)
431  beamPhotons += cherPhotons.Y(distance);
432  }
433 
434  double directPhotons = 0;
435  if (simShower.HasCherenkovPhotons(iwl)) {
436  const TabulatedFunction& cherPhotons = simShower.GetCherenkovPhotons(iwl);
437  if (cherPhotons.GetNPoints() &&
438  *cherPhotons.XBegin() < distance &&
439  *(cherPhotons.XEnd() - 1) > distance)
440  directPhotons += cherPhotons.Y (distance);
441  }
442 
443  // MIE-SCATTERED CHERENKOV LIGHT --------------------------
444  if (fCherMieScattered) {
446  telSim.MakePhotonTrace(fevt::FdConstants::eCherMieScattered, iwl, nBins, tracebin);
447  TraceD& cherMieTrace = telSim.GetPhotonTrace(fevt::FdConstants::eCherMieScattered, iwl);
448  const double photons = beamPhotons * (*mFactor)[iwl].Y() * att;
449  cherMieTrace[iBin] += photons;
450  }
451 
452  // RAYLEIGH-SCATTERED CERENKOV LIGHT -----------------------
453  if (fCherRayleighScattered) {
455  telSim.MakePhotonTrace(fevt::FdConstants::eCherRayleighScattered, iwl, nBins, tracebin);
456  TraceD& cherRayleighTrace = telSim.GetPhotonTrace (fevt::FdConstants::eCherRayleighScattered, iwl);
457  const double photons = beamPhotons * (*rFactor)[iwl].Y() * att;
458  cherRayleighTrace[iBin] += photons;
459  }
460 
461  // DIRECT CERENKOV -----------------------------------------
462  if (fCherDirect) {
463  const double directCherWl = fWlRefrac ? atmo.EvaluateDirectCherenkovProbability(stepStart, stepEnd, telPosition,
464  showerAge, WLengthCkov[iwl]) : 1.;
466  telSim.MakePhotonTrace(fevt::FdConstants::eCherDirect, iwl, nBins, tracebin);
467  TraceD& cherDirectTrace = telSim.GetPhotonTrace (fevt::FdConstants::eCherDirect, iwl);
468  const double photons = directPhotons * directCher*directCherWl * att * xStepWidth;
469  cherDirectTrace[iBin] += photons;
470  }
471 
472  } // end Cerenkov only loop over wavelengths
473 
474  } // end of cherenkov
475 
476  } else { // if LASER
477 
478  // -----------------------------------------------
479  // LASER PART
480 
481  // prepare laser
482 
483  // --- read all needed atmospheric properties -------
484  const TabulatedFunctionErrors* rAttLaser;
485  const TabulatedFunctionErrors* mAttLaser;
486 
487  const double scattAngle = acos(-showerAxis*paveDir / paveDir.GetMag());
488 
489  AttenuationResult rAttenLaser = atmo.EvaluateRayleighAttenuation(pave, telPosition,
490  WLengthLaser);
491  rAttLaser = &rAttenLaser.GetTransmissionFactor();
492 
493  AttenuationResult mAttenLaser = atmo.EvaluateMieAttenuation(telPosition, pave, WLengthLaser);
494  mAttLaser = &mAttenLaser.GetTransmissionFactor();
495 
496  ScatteringResult rScat = atmo.EvaluateRayleighScattering(stepStart, stepEnd,
497  scattAngle, paveDist,
498  WLengthLaser);
499  const TabulatedFunctionErrors& rFactor = rScat.GetScatteringFactor();
500 
501  ScatteringResult mScat = atmo.EvaluateMieScattering(stepStart, stepEnd,
502  scattAngle, paveDist,
503  WLengthLaser);
504  const TabulatedFunctionErrors& mFactor = mScat.GetScatteringFactor();
505 
506  // there is only one laser wavelength
507  double att = (*rAttLaser)[0].Y() * (*mAttLaser)[0].Y();// * projectedDiaphragmArea;
508  double laserPhotons = 0;
509 
510  const TabulatedFunction& laserLight = simShower.GetFluorescencePhotons(0);
511  if (laserLight.GetNPoints() &&
512  *laserLight.XBegin() < distance &&
513  *(laserLight.XEnd() - 1) > distance)
514  laserPhotons += laserLight.Y(distance);
515 
516  if (fLaserMieScattered) {
517 
518  // Mie-scattered Laser light simulation
520  telSim.MakePhotonTrace(fevt::FdConstants::eLaserMieScattered, 0, nBins, tracebin);
521  TraceD& laserMieTrace = telSim.GetPhotonTrace(fevt::FdConstants::eLaserMieScattered, 0);
522  const double photons = laserPhotons * att * mFactor[0].Y();
523  laserMieTrace[iBin] += photons;
524  }
525 
526  if (fLaserRayleighScattered) {
527 
530  TraceD& laserRayleighTrace = telSim.GetPhotonTrace(fevt::FdConstants::eLaserRayleighScattered, 0);
531  const double photons = laserPhotons * att * rFactor[0].Y();
532  laserRayleighTrace[iBin] += photons;
533  }
534 
535  } // end laser sim
536 
537  // cerr << endl;
538 
539  } // loop bins
540 
541  } // loop tels
542 
543  } // end loop eyes
544 
545  if (fCherDirectCORSIKA) {
546  EvaluateDirectCherenkovHits(event);
547  }
548 
549  return eSuccess;
550 }
551 
552 
553 
555 LightAtDiaphragmSimulator::Finish()
556 {
557  return eSuccess;
558 }
559 
560 
561 /*
562 inline double
563 LightAtDiaphragmSimulator::CalculatePointOnAxis(const double time,
564  const double Rp,
565  const double dist0)
566 {
567  // corresponding distance: d = t*c
568  const double dist = time * utl::kSpeedOfLight;
569 
570  const double delta =
571  0.5*(dist0*dist0 + Rp*Rp - dist*dist) / (dist0 - dist);
572 
573  return delta;
574 }
575 */
576 
577 
578 inline double
579 LightAtDiaphragmSimulator::CalculateDistanceFromCore(const double tDia,
580  const double Rp,
581  const double T0)
582 {
583  // corresponding distance: d = t*c
584  // const double dist = time * utl::kSpeedOfLight;
585  //return (pow(T0,2) + pow(Rp/kSpeedOfLight,2) - pow(tDia,2)) / (T0 - tDia) / 2;
586  return kSpeedOfLight/2 * (pow(Rp/kSpeedOfLight,2) - pow(tDia,2) + pow(T0,2)) / (T0 - tDia);
587 }
588 
589 
590 
591 struct my_facet : public std::numpunct<char> {
592  explicit my_facet(size_t refs = 0) : std::numpunct<char>(refs) {}
593  virtual char do_thousands_sep() const { return '.'; }
594  virtual std::string do_grouping() const { return "\003"; }
595 };
596 
597 void
598 LightAtDiaphragmSimulator::EvaluateDirectCherenkovHits(evt::Event &event)
599 {
600  ShowerSimData& simShower = event.GetSimShower();
601  const TimeStamp timeAtCore = simShower.GetTimeStamp();
602  Detector& detector = Detector::GetInstance();
603  const Atmosphere& atmo = detector.GetAtmosphere();
604  const FDetector& detFD = detector.GetFDetector();
605  fevt::FEvent& fevent = event.GetFEvent();
606 
607  // Histograms for debugging !!!!!!!
608  TH2D* hist2D = new TH2D("hist2D", "hist2D", 600, -0e3, 10e3, 600, 50e3, 60e3); // photon density [km]
609  TH2D* histObs2D = new TH2D("histObs2D", "histObs2D", 600, -0e3, 10e3, 600, 50e3, 60e3); // photon density [km]
610  TH2D* histCore2D = new TH2D("histCore2D", "histCore2D", 300, -40e3, 40e3, 300, -40e3, 40e3); // photon density [km]
611  TH2D* hist2Demit = new TH2D("hist2Demit_site", "hist2Demit_site", 300, -5e3, 75e3, 300, 0e3, 85e3); // photon density [km]
612  TH2D* histObs2Demit = new TH2D("histObs2Demit_site", "histObs2Demit_site", 300, -5e3, 75e3, 300, 0e3, 85e3); // photon density [km]
613  TH2D* histCore2Demit = new TH2D("histCore2Demit_site", "histCore2Demit_site", 300, -40e3, 40e3, 300, -40e3, 40e3); // photon density [km]
614  const double deltaZoom = 5.e3; // meters
615  TH2D* hist2DzoomLL = new TH2D("hist2DzoomLL", "hist2DzoomLL", 300, -deltaZoom, deltaZoom, 300, -deltaZoom, deltaZoom); // photon density [km]
616  TH2D* hist2DzoomLA = new TH2D("hist2DzoomLA", "hist2DzoomLA", 300, -deltaZoom, deltaZoom, 300, -deltaZoom, deltaZoom); // photon density [km]
617  TH2D* hist2DzoomLM = new TH2D("hist2DzoomLM", "hist2DzoomLM", 300, -deltaZoom, deltaZoom, 300, -deltaZoom, deltaZoom); // photon density [km]
618  TH2D* hist2DzoomCO = new TH2D("hist2DzoomCO", "hist2DzoomCO", 300, -deltaZoom, deltaZoom, 300, -deltaZoom, deltaZoom); // photon density [km]
619  TH2D* angle2D = new TH2D("angle2D", "angle2D", 100, -1, 1, 100, -1, 1);
620  TH2D* onTel2D = new TH2D("onTel2D", "onTel2D(telCS)", 500, -100, 100, 500, -100, 100); // photon density [m]
621  TH1D* histCos = new TH1D("histCos", "histCos", 100,-1,1);
622  TH1D* histCosEmission = new TH1D("histCosEmission", "histCosEmission", 100,-1,1);
623  TH1D* histTimeCher = new TH1D("histTimeCher", "histTimeCher", 100,1,0);
624  TH1D* histTimeArrival = new TH1D("histTimeArrival", "histTimeArrival", 100,1,0);
625  vector<double> eyesX, eyesY;
626 
627  map<int, fevt::TelescopeSimData*> tel_sim;
628  map<int, map<int, double>> tel_time_bin_trace;
629  map<int, double> tel_time_bin_width;
630  map<int, double> tel_time_nbins;
631 
632  /*
633  keep this stupid snipplet of code, since it produces the data needed for CORSIKA steering cards:
634  */
635  /*
636  cout << "* \tx-pos [cm] \ty-pos [cm] \tz-pos[cm] \tradius [cm] ID comment" << endl;
637  for (fevt::FEvent::EyeIterator iEye = fevent.EyesBegin(fevt::ComponentSelector::eExists);
638  iEye != fevent.EyesEnd(fevt::ComponentSelector::eExists) ; ++iEye) {
639 
640  const CoordinateSystemPtr refCS = detector.GetReferenceCoordinateSystem();
641  const UTMPoint theUTMPoint = UTMPoint(Point(0,0,0,refCS), ReferenceEllipsoid::eWGS84);
642  const double origin_height = theUTMPoint.GetHeight();
643 
644  const fdet::Eye& detEye = detFD.GetEye(*iEye);
645  const utl::Point eyePosition = detEye.GetPosition();
646  //eyesX.push_back(eyePosition.GetX(refCS)/meter);
647  //eyesY.push_back(eyePosition.GetY(refCS)/meter);
648  cout << std::fixed << std::setprecision(2);
649  cout << "TELESCOPE \t"
650  << setw(10) << eyePosition.GetX(refCS)/centimeter << " \t"
651  << setw(10) << eyePosition.GetY(refCS)/centimeter << " \t"
652  << setw(10) << (eyePosition.GetZ(refCS)+origin_height)/centimeter << " \t"
653  << setw(7) << 2*meter/centimeter << " \t" << 0 << " \t" << detEye.GetName() <<endl;
654 
655  }
656  */
657  /* ------- */
658 
659 
660  map<int, int> countPhot;
661  map<int, double> weightPhot;
662  map<int, double> weightSqrPhot;
663  unsigned int countAll = 0;
664 
665  /*
666  The most economic way to look photons and telescopes is to first
667  make a list of all telescope eye combinations, then later start to
668  read photons on telescope level first, then on eye level and last
669  on global level. Telescope that have been already processed are
670  skipped.
671  */
672 
673  map<int, map<int, bool> > doneThis;
674 
675  vector<utl::AttributeMap> allTelEyeCombinations;
677  iEye != fevent.EyesEnd(fevt::ComponentSelector::eInDAQ) ; ++iEye) {
678 
679  fevt::Eye& eyeEvent = *iEye;
680 
682  continue;
683 
684  unsigned int eyeId = eyeEvent.GetId();
685 
687  iTel != eyeEvent.TelescopesEnd(fevt::ComponentSelector::eInDAQ); ++iTel) {
688 
689  unsigned int telId = iTel->GetId();
690  fevt::Telescope& telEvent = *iTel;
691 
692  if (!telEvent.HasSimData())
693  continue;
694  fevt::TelescopeSimData& telSim = telEvent.GetSimData();
695  if (!telSim.HasDistanceTrace())
696  continue;
697  utl::AttributeMap thisDet;
698  thisDet["eye"] = std::to_string(eyeId);
699  thisDet["tel"] = std::to_string(telId);
700  allTelEyeCombinations.push_back(thisDet);
701  } // loop tels
702  utl::AttributeMap thisDet;
703  thisDet["eye"] = std::to_string(eyeId);
704  allTelEyeCombinations.push_back(thisDet); // now catch all the remaining telescopes of this eye
705  } // loop eyes
706  utl::AttributeMap thisDet;
707  allTelEyeCombinations.push_back(thisDet); // now catch everything left over
708 
709 
710 
711  for (const auto& itCombi:allTelEyeCombinations) {
712 
713  utl::AttributeMap am = itCombi;
714 
715  const bool hasTelAttribute = am.count("tel");
716  const unsigned int telAttribute = hasTelAttribute ? std::stoi(am["tel"]) : 0;
717  const bool hasEyeAttribute = am.count("eye");
718  const unsigned int eyeAttribute = hasEyeAttribute ? std::stoi(am["eye"]) : 0;
719 
720  if (!simShower.HasGroundCherenkov(am))
721  continue;
722 
723  /*
724  cerr << "found iterator for " << (hasEyeAttribute ? am["eye"] : "-") << " " << (hasTelAttribute ? am["tel"] : "-") << " " << eyeAttribute << " " << telAttribute << endl;
725 
726  for (auto flagEye : doneThis)
727  for (auto flagTel : flagEye.second)
728  cout << " doneThis[" << flagEye.first << "][" << flagTel.first <<"] = true" << endl;
729  */
730 
731  map<int, map<int, bool> > flagThis;
732  unsigned int countThis = 0;
733 
734  for (utl::ShowerParticleIterator iCher = simShower.GroundCherenkovBegin(am);
735  iCher != simShower.GroundCherenkovEnd(am);
736  ++iCher) {
737 
738  if (iCher->GetType() != utl::Particle::ePhoton) {
739  ostringstream err;
740  err << "Cherenkov input particle not of type \'photon\': " << iCher->GetName();
741  ERROR(err);
742  continue;
743  }
744 
745  ++countAll;
746  ++countThis;
747 
748  const Vector& nIn = iCher->GetDirection();
749  const Point& pIn = iCher->GetPosition();
750  double weight = iCher->GetWeight();
751  const double energy = iCher->GetTotalEnergy();
752 
753  if (true) { // debugging only
754  // wow, my first C++ lambda function ! cool stuff.
755  std::function<void (CoordinateSystemPtr,TH2D*,TH2D*)> func = [pIn,nIn,weight](CoordinateSystemPtr csDet, TH2D* hist, TH2D* hist2) {
756  const Point site(0,0,0,csDet);
757  const CoordinateSystemPtr refCS = det::Detector::GetInstance().GetSiteCoordinateSystem();
758  Vector shift = site - Point(0,0,0,refCS);
759  // now move refCS origin to core
760  CoordinateSystemPtr cs = CoordinateSystem::Translation(shift, refCS);
761 
762  const Point site_pos = site;
763  const Vector site_normal(0,0,1,cs);
764  const Vector emission_location = site_pos - pIn;
765  // const double emission_distance = emission_location.GetMag(); // positive // unused -- silence warning
766  const double distance_perp = emission_location * site_normal; // negative value
767  const double cosTheta = site_normal*nIn;
768  const double distance = distance_perp / cosTheta; // positive value
769  const Point pGround = pIn + distance*nIn;
770  if (hist2) {
771  hist2->Fill(pIn.GetX(cs)/meter, pIn.GetY(cs)/meter, weight);
772  }
773  hist->Fill(pGround.GetX(cs)/meter, pGround.GetY(cs)/meter, weight);
774  };
775 
776  const CoordinateSystemPtr llCS = detFD.GetEye("Los Leones").GetEyeCoordinateSystem();
777  const CoordinateSystemPtr laCS = detFD.GetEye("Loma Amarilla").GetEyeCoordinateSystem();
778  const CoordinateSystemPtr lmCS = detFD.GetEye("Los Morados").GetEyeCoordinateSystem();
779  //const CoordinateSystemPtr coCS = detFD.GetEye("Coihueco").GetEyeCoordinateSystem();
780  const CoordinateSystemPtr coCS = detFD.GetEye(4).GetEyeCoordinateSystem();
781 
782  CoordinateSystemPtr coreCS = simShower.GetLocalCoordinateSystem();
783  const CoordinateSystemPtr siteCS = detector.GetSiteCoordinateSystem();
784  CoordinateSystemPtr obsCS = CoordinateSystem::Translation(Vector(0,0,1300.*meter,siteCS),siteCS);
785 
786  func(coreCS, histCore2D, histCore2Demit);
787  func(siteCS, hist2D, hist2Demit);
788  func(obsCS, histObs2D, histObs2Demit);
789  func(llCS, hist2DzoomLL,0);
790  func(laCS, hist2DzoomLA,0);
791  func(lmCS, hist2DzoomLM,0);
792  func(coCS, hist2DzoomCO,0);
793  } // end debugging
794 
795 
797  iEye != fevent.EyesEnd(fevt::ComponentSelector::eInDAQ) ; ++iEye) {
798 
799  fevt::Eye& eyeEvent = *iEye;
800 
802  continue;
803 
804  const unsigned int eyeId = eyeEvent.GetId();
805  if (hasEyeAttribute && eyeAttribute != eyeId)
806  continue;
807 
809  iTel != eyeEvent.TelescopesEnd(fevt::ComponentSelector::eInDAQ); ++iTel) {
810 
811  unsigned int telId = iTel->GetId();
812  if (hasTelAttribute && telAttribute != telId)
813  continue;
814 
815  if (doneThis.count(eyeId) && doneThis[eyeId].count(telId) && doneThis[eyeId][telId])
816  continue; // already done this
817 
818  flagThis[eyeId][telId] = true; // remember this... only process each telescope exactly one time
819 
820  fevt::Telescope& telEvent = *iTel;
821 
822  if (!telEvent.HasSimData())
823  continue;
824  fevt::TelescopeSimData& telSim = telEvent.GetSimData();
825 
826  if (!telSim.HasDistanceTrace())
827  continue;
828  TraceD& distanceTrace = telSim.GetDistanceTrace();
829 
830  const int tel_unique = eyeId * 100000 + telId;
831 
832  const fdet::Telescope& detTel = detFD.GetTelescope(telEvent);
833  const double rDia = detTel.GetDiaphragmRadius();
834  const Point telPosition = detTel.GetPosition();
835  const Vector telNormal = detTel.GetAxis();
836  const CoordinateSystemPtr telCS = detTel.GetTelescopeCoordinateSystem();
837 
838  const double cosTheta = telNormal*nIn;
839 
840  const Vector emission_location = telPosition - pIn;
841  const double emission_distance = emission_location.GetMag(); // positive value
842  const double distance_perp = emission_location * telNormal; // negative value
843 
844  const double cosThetaEmission = distance_perp / emission_distance; // negative
845 
846  histCos->Fill(cosTheta);
847  histCosEmission->Fill(cosThetaEmission);
848  angle2D->Fill(cosThetaEmission,cosTheta);
849  const double cosFOV = cos(detTel.GetCamera().GetFieldOfView());
850  if (-cosThetaEmission<cosFOV) { // cannot hit, FOV-Auger is ~16 deg (FModelConfig: 23.07deg (?) )
851  continue;
852  }
853  // check photon travel direction. Is it in FOV of telescope?
854  if (-cosTheta<cosFOV) { // cannot hit, FOV-Auger is ~16 deg (FModelConfig: 23.07deg (?) )
855  continue;
856  }
857 
858  const double distance = distance_perp / cosTheta; // positive value
859  const Point onDia = pIn + distance*nIn;
860  const double radial = sqrt(pow(onDia.GetX(telCS),2) + pow(onDia.GetY(telCS),2));
861 
862  onTel2D->Fill(onDia.GetX(telCS)/meter, onDia.GetY(telCS)/meter, weight);
863 
864  if (radial>rDia) { // did not hit
865  continue;
866  }
867 
868  // attenuation
869  const double wavelength = utl::kPlanck / energy;
870  const double rAttCkov = atmo.EvaluateRayleighAttenuation(pIn, onDia, wavelength);
871  const double mAttCkov = atmo.EvaluateMieAttenuation(pIn, onDia, wavelength);
872  weight *= rAttCkov * mAttCkov;
873 
874  countPhot[tel_unique] ++;
875  weightPhot[tel_unique] += weight;
876  weightSqrPhot[tel_unique] += weight*weight;
877 
878  tel_sim[tel_unique] = &telSim;
879 
880  const TimeStamp traceAtTelTime = telSim.GetPhotonsStartTime();
881  const TimeStamp timePhoton = timeAtCore + iCher->GetTime() + utl::TimeInterval(distance/utl::kSpeedOfLight);
882  const TimeInterval timeDia = timePhoton - traceAtTelTime;
883 
884  histTimeCher->Fill(iCher->GetTime()/ns);
885  histTimeArrival->Fill(timeDia/ns);
886 
887  /*
888  static int deli = 0;
889  if (deli++<100) {
890  ostringstream inf;
891  inf << "phot-time prod_tel=" << distance/utl::kSpeedOfLight/nanosecond << "ns coreToStart=" << coreToStart/ns << "ns, tMin=" << iTelFOV->Tmin/nanosecond << "ns ";
892  //inf << "phot-time prod_tel=" << distance_perp/utl::kSpeedOfLight/nanosecond << "ns coreToStart=" << coreToStart/m << "m, tMin=" << iTelFOV->Tmin/nanosecond << "ns ";
893  // inf << " t_abs=" << timeDia/ns << "ns ";
894  inf << ", t_cher_prod=" << iCher->GetTime().GetInterval()/ns << "ns ";
895  inf << ", t_tel_start=" << traceAtTelTime.GetInterval()/ns << "ns ";
896  inf << ", t_cher_abs=" << timePhoton.GetInterval()/ns << "ns ";
897  inf << ", t_cher_rel=" << timeDia.GetInterval()/ns << "ns ";
898  inf << ", cosTheta=" << cosTheta << " cosThetaEmission=" << cosThetaEmission;
899  inf << ", z_prod=" << pIn.GetZ(siteCS)/m;
900  inf << ", distance_perp=" << distance_perp/m << " distance=" << distance/m << " radial=" << radial/m;
901  inf << ", nIn=" << nIn.GetX(siteCS) << "," << nIn.GetY(siteCS) << "," << nIn.GetZ(siteCS);
902  INFO(inf);
903  }
904  */
905 
907  utl::Photon photonIn(onDia, nIn, wavelength, weight, lightSource);
908  photonIn.SetTime(timeDia);
909  telSim.AddPhoton(photonIn);
910 
911 
912  // the code in the following code is NOT essential. It
913  // produces (if working) only the sim-light traces in the
914  // EventBrowser. The simualtion does not depend on it.
915  {
916  //do not recalculate weight to keep it for other telescopes
917  //weight /= detTel.GetDiaphragmArea() * (-cosTheta);
918  double weight_loc = weight / (detTel.GetDiaphragmArea() * (-cosTheta));
919 
920  const vector<double>& WLengthCkov = atmo.GetWavelengths(atm::Atmosphere::eCerenkov);
921  const int CkovBin = WLengthCkov.size()/2;
922  static const double telEffWL = detTel.GetModelRelativeEfficiency(WLengthCkov[CkovBin]);
923  try {
924  weight_loc *= detTel.GetModelRelativeEfficiency(wavelength) / telEffWL;
925  } catch (utl::OutOfBoundException&) {
926  weight_loc = 0;
927  }
928 
929  TimeInterval timeDiaAbs = timeDia;
930 
931  if (tel_time_bin_trace.count(tel_unique) == 0) {
932  tel_time_bin_width[tel_unique] = distanceTrace.GetBinning();
933  tel_time_nbins[tel_unique] = distanceTrace.GetSize();
934  tel_time_bin_trace[tel_unique] = map<int, double>();
935  }
936  const int tel_time_bin = timeDiaAbs.GetInterval() / tel_time_bin_width[tel_unique];
937  tel_time_bin_trace[tel_unique][tel_time_bin] += weight_loc;
938  } // end light binningv-------------------
939 
940  //restore weight to original value to process photon in other telescopes
941  weight /= rAttCkov * mAttCkov;
942 
943  // done with this photon -> next photon - update: do not skip other telescopes
944  //goto next_photon;
945 
946  } // loop tels
947  } // loop eyes
948  //next_photon: ;
949  } // end loop cherenkov photons
950 
951  // remember for next cherenkov input file
952  for (const auto& flagEye : flagThis)
953  for (const auto& flagTel : flagEye.second)
954  doneThis[flagEye.first][flagTel.first] = true; // remember this... only process each telescope exactly one time
955 
956  ostringstream info;
957  info << "Read " << countThis << " photons with attributes: eye=\""
958  << (hasEyeAttribute ? am["eye"] : "-") << "\", tel=\"" << (hasTelAttribute ? am["tel"] : "-") << "\" ";
959  INFO(info.str());
960 
961  } // end loop cherenkov files
962 
963  // final output
964  bool lowQualityProblem = false;
965 
966  for (map<int,double>::const_iterator iDT = tel_time_bin_width.begin();
967  iDT != tel_time_bin_width.end(); ++iDT) {
968  const int tel_unique = iDT->first; // eyeId * 100000 + telId;
969  unsigned int eyeId = tel_unique /100000;
970  unsigned int telId = tel_unique % 100000;
971  ostringstream info;
972  if (countPhot.count(tel_unique)) {
973  const double weight = weightPhot[tel_unique] / countPhot[tel_unique];
974  const double weightRMS = sqrt(weightSqrPhot[tel_unique] / countPhot[tel_unique] - weight*weight);
975  info << "Eye=" << eyeId << ", Tel=" << telId << ": ";
976  info << "detected " << countPhot[tel_unique] << " photons on diaphragm with total weight= " << weightPhot[tel_unique];
977  info << ": <weight>=" << weight << ", RMS(weight)=" << weightRMS;
978  if (weight>10000 || weightRMS>1000) {
979  lowQualityProblem = true;
980  info << " [WEIGHTS TOO LARGE! CANNOT HANDLE!]";
981  }
982  INFO(info);
983  }
984  }
985 
986  if (lowQualityProblem) {
987  ostringstream err;
988  err << "Please consider to run CORSIKA with less thinning. Cherenkov simulation makes no sense with huge weights";
989  ERROR(err);
990  throw AugerException(err.str());
991  }
992 
993  {
994  ostringstream inf;
995 
996  std::locale global;
997  std::locale withgroupings(global, new my_facet);
998  inf.imbue(withgroupings);
999 
1000  inf << "Found a total of " << countAll << " Cherenkov photons in input file" << endl;
1001  INFO(inf);
1002  }
1003 
1004  // RUDEBUG ------
1005  // some plots
1006  static int iSave = 0;
1007  iSave++;
1008  ostringstream savename;
1009  savename << "save_" << iSave << ".root";
1010 
1011  TDirectory* saveDir = gDirectory;
1012  TFile* file = TFile::Open(savename.str().c_str(), "recreate");
1013  file->cd();
1014 
1015  TCanvas* can2D = new TCanvas("can2D");
1016  can2D->Divide(4,2);
1017 
1018  can2D->cd(1);
1019  gPad->SetLogz(1);
1020  hist2Demit->Draw("colz");
1021 
1022  can2D->cd(2);
1023  gPad->SetLogz(1);
1024  hist2D->Draw("colz");
1025 
1026  can2D->cd(3);
1027  gPad->SetLogz(1);
1028  histCore2D->Draw("colz");
1029 
1030  can2D->cd(4);
1031  gPad->SetLogz(1);
1032  histObs2D->Draw("colz");
1033 
1034  can2D->cd(5);
1035  gPad->SetLogz(1);
1036  hist2DzoomLL->Draw("colz");
1037 
1038  can2D->cd(6);
1039  gPad->SetLogz(1);
1040  hist2DzoomLA->Draw("colz");
1041 
1042  can2D->cd(7);
1043  gPad->SetLogz(1);
1044  hist2DzoomLM->Draw("colz");
1045 
1046  can2D->cd(8);
1047  gPad->SetLogz(1);
1048  hist2DzoomCO->Draw("colz");
1049 
1050  TGraph* geyes = new TGraph(eyesX.size(), &eyesX.front(), &eyesY.front());
1051  geyes->SetMarkerStyle(20);
1052  geyes->SetMarkerSize(1.5);
1053 
1054  can2D->cd(1);
1055  geyes->Draw("p");
1056  can2D->cd(2);
1057  geyes->Draw("p");
1058  can2D->cd(3);
1059  geyes->Draw("p");
1060  can2D->cd(4);
1061  geyes->Draw("p");
1062  /*
1063  can2D->cd(3);
1064  geyes->Draw("p");
1065  can2D->cd(4);
1066  geyes->Draw("p");
1067  can2D->cd(5);
1068  geyes->Draw("p");
1069  can2D->cd(6);
1070  geyes->Draw("p");
1071  */
1072 
1073  can2D->Write();
1074 
1075  hist2D->Write();
1076  histObs2D->Write();
1077  histCore2D->Write();
1078  hist2Demit->Write();
1079  histObs2Demit->Write();
1080  histCore2Demit->Write();
1081  hist2DzoomLL->Write();
1082  hist2DzoomLA->Write();
1083  hist2DzoomLM->Write();
1084  hist2DzoomCO->Write();
1085  onTel2D->Write();
1086  histCosEmission->Write();
1087  histCos->Write();
1088  angle2D->Write();
1089  histTimeArrival->Write();
1090  histTimeCher->Write();
1091 
1092  file->Write();
1093  file->Close();
1094  saveDir->cd();
1095  // ------------- end plotting ----------
1096 
1097  // save light traces at diaphragm. This is just for EventBrowser
1098  map<int,double>::const_iterator iDT = tel_time_bin_width.begin();
1099  map<int,map<int,double>>::const_iterator iPh = tel_time_bin_trace.begin();
1100  map<int,fevt::TelescopeSimData*>::const_iterator iTS = tel_sim.begin();
1101 
1102  for (; iDT!=tel_time_bin_width.end(); ++iDT, ++iPh, ++iTS) {
1103 
1104  const vector<double>& WLengthCkov = atmo.GetWavelengths(atm::Atmosphere::eCerenkov);
1105  const int CkovBin = WLengthCkov.size()/2; // all in one central wavelength bin
1106 
1107  fevt::TelescopeSimData& telSim = *(iTS->second);
1108 
1109  if (telSim.HasPhotonTrace(fevt::FdConstants::eCherDirect, CkovBin)) {
1110  ERROR("ERROR too! RUDEBUG ");
1111  continue;
1112  }
1113 
1114  const int firstBin = (iPh->second).begin()->first;
1115  const int nBins = (iPh->second).rbegin()->first - firstBin + 1;
1116 
1117  telSim.MakePhotonTrace(fevt::FdConstants::eCherDirect, CkovBin, nBins, iDT->second);
1118  TraceD& cherDirectTrace = telSim.GetPhotonTrace (fevt::FdConstants::eCherDirect, CkovBin);
1119  for (map<int,double>::const_iterator iBin=iPh->second.begin(); iBin!=iPh->second.end(); ++iBin) {
1120  //cherDirectTrace[iBin->first - firstBin] = iBin->second;
1121  if (iBin->first >= 0 && iBin->first < nBins-1)
1122  cherDirectTrace[iBin->first] = iBin->second;
1123  }
1124  }
1125 }
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
Definition: OperationsAV.h:32
Branch GetTopBranch() const
Definition: Branch.cc:63
double GetModelRelativeEfficiency(const double wl) const
unsigned int GetId() const
Definition: FEvent/Eye.h:54
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
Iterator to retrieve particles from utl::VShowerParticlList.
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
Point object.
Definition: Point.h:32
bool HasLaserData() const
Check initialization of the LaserData.
const utl::TimeStamp & GetTimeStamp() const
Get the TimeStamp of the absolute shower core-time.
constexpr double kPlanck
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
double GetFieldOfView() const
bool HasPhotonTrace(const fevt::FdConstants::LightSource source, const int wl) const
Check that light trace for source /par source is present for the given wavelength bin...
Base class for all exceptions used in the auger offline code.
const std::vector< double > & GetWavelengths(const EmissionMode mode=eFluorescence) const
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
const evt::VGaisserHillasParameter & GetGHParameters() const
Get the Gaisser-Hillas parameters of the shower.
bool HasFEvent() const
virtual std::string do_grouping() const
utl::ShowerParticleIterator GroundCherenkovEnd(const utl::AttributeMap &am) const
ArrayIterator XEnd()
end of array of X
my_facet(size_t refs=0)
Class to hold collection (x,y) points and provide interpolation between them.
bool HasCherenkovPhotons(const int wavelength) const
bool HasSimShower() const
std::map< std::string, std::string > AttributeMap
Definition: Branch.h:24
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
const utl::TabulatedFunction & GetFluorescencePhotons(const int wavelength) const
Get the fluorescence photons generated along the shower axis.
double GetBinning() const
size of one slot
Definition: Trace.h:138
double GetDiaphragmRadius() const
bool HasFluorescencePhotons(const int wavelength) const
double GetMag() const
Definition: AxialVector.h:56
const utl::TabulatedFunction & GetCherenkovBeamPhotons(const int wavelength) const
Get the beam of Cherenkov beam photons along the shower axis.
utl::Vector GetAxis() const
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void AddPhoton(const utl::Photon &p)
void Init()
Initialise the registry.
bool HasCherenkovBeamPhotons(const int wavelength) const
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Definition: FEvent.h:55
utl::TimeStamp GetPhotonsStartTime() const
Start Time of the photons trace.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
utl::CoordinateSystemPtr GetSiteCoordinateSystem() const
Get the coordinate system for the site.
Definition: Detector.h:137
double pow(const double x, const unsigned int i)
double GetMag() const
Definition: Vector.h:58
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Exception for reporting variable out of valid range.
Class holding the output of the ScatteringResult function.
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
const atm::Atmosphere & GetAtmosphere() const
Definition: Detector.h:113
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
const utl::TabulatedFunction & GetCherenkovPhotons(const int wavelength) const
Get the Cherenkov photon production along the shower axis.
fevt::TelescopeSimData & GetSimData()
Description of simulated data for one Telescope.
Class representing a document branch.
Definition: Branch.h:107
bool HasGroundCherenkov(const utl::AttributeMap &am) const
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
void MakePhotonTrace(const fevt::FdConstants::LightSource source, const int wl, const unsigned int size=0, const double binSize=0)
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.
LightSource
Possible light sources.
Definition: FdConstants.h:9
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
const double ns
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
constexpr double kPi
Definition: MathConstants.h:24
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
utl::TraceD & GetPhotonTrace(const fevt::FdConstants::LightSource source, const int wl)
Photon trace at diaphragm.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
const fdet::FDetector & GetFDetector() const
Definition: Detector.cc:131
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
Definition: FEvent/Eye.h:72
SizeType GetSize() const
Definition: Trace.h:156
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
const string file
bool HasDistanceTrace() const
Check that trace for the distance along the shower axis is present.
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
double GetInterval() const
Get the time interval as a double (in Auger base units)
Definition: TimeInterval.h:69
const utl::TabulatedFunctionErrors & GetScatteringFactor() const
Scattering factor.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
constexpr double kSpeedOfLight
Detector description interface for Telescope-related data.
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
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
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
double GetDiaphragmArea() const
double ShowerAge(const double slantDepth, const double showerMax)
General definition of shower age.
ArrayIterator XBegin()
begin of array of X
virtual char do_thousands_sep() const
bool HasGHParameters() const
Check initialization of the Gaisser-Hillas parameters.
utl::Point GetPosition() const
execption handling for calculation/access for inclined atmosphere model
Vector object.
Definition: Vector.h:30
double EvaluateDirectCherenkovProbability(const utl::Point &xA, const utl::Point &xB, const utl::Point &xEye, const double showerAge) const
double CosAngle(const Vector &l, const Vector &r)
Definition: OperationsVV.h:71
Fluorescence Detector Telescope Event.
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
void SetTime(const utl::TimeInterval &t)
Definition: Photon.h:36
const atm::ProfileResult & EvaluateSlantDepthVsDistance() const
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
ComponentSelector::Status GetStatus() const
Definition: FEvent/Eye.h:118
bool HasSimData() const
utl::ShowerParticleIterator GroundCherenkovBegin(const utl::AttributeMap &am) const
bool HasLongitudinalProfile(const ProfileType type=eCharged) const
Check initialization of the longitudinal profile.
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const
Class describing the Atmospheric attenuation.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
utl::TraceD & GetDistanceTrace()
Trace for the distance along the shower axis of the light at the diaphragm.
double GetMag2() const
Definition: Vector.h:61
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.