SimMockEvent.cc
Go to the documentation of this file.
1 
10 #include "SimMockEvent.h"
11 
12 #include <vector>
13 #include <map>
14 
15 #include <utl/TabulatedFunction.h>
16 
17 #include <utl/UTMPoint.h>
18 #include <utl/ReferenceEllipsoid.h>
19 #include <utl/Vector.h>
20 #include <utl/AxialVector.h>
21 #include <utl/TimeStamp.h>
22 
23 #include <utl/MathConstants.h>
24 #include <utl/PhysicalConstants.h>
25 #include <utl/AugerUnits.h>
26 #include <utl/CoordinateSystem.h>
27 #include <utl/AugerCoordinateSystem.h>
28 
29 #include <utl/Trace.h>
30 
31 #include <evt/Event.h>
32 #include <evt/ShowerRecData.h>
33 #include <evt/ShowerFRecData.h>
34 #include <evt/ShowerSimData.h>
35 #include <evt/GaisserHillas4Parameter.h>
36 #include <evt/DefaultShowerGeometryProducer.h>
37 
38 #include <fevt/FEvent.h>
39 #include <fevt/Eye.h>
40 #include <fevt/EyeHeader.h>
41 #include <fevt/Telescope.h>
42 #include <fevt/EyeRecData.h>
43 #include <fevt/TelescopeRecData.h>
44 #include <fevt/TelescopeSimData.h>
45 #include <fevt/PixelRecData.h>
46 #include <fevt/Pixel.h>
47 #include <fevt/FdConstants.h>
48 
49 #include <det/Detector.h>
50 #include <atm/Atmosphere.h>
51 
52 #include <fdet/FDetector.h>
53 #include <fdet/Eye.h>
54 #include <fdet/Pixel.h>
55 #include <fdet/Channel.h>
56 #include <fdet/Camera.h>
57 #include <fdet/Telescope.h>
58 
59 #include <utl/AugerException.h>
60 #include <utl/Vector.h>
61 
62 #include <sstream>
63 
64 // modules to be remote controlled
66 
67 using namespace FdLightCollectionEfficiencyKG;
68 using namespace fwk;
69 using namespace utl;
70 using namespace evt;
71 using namespace fevt;
72 using namespace det;
73 using namespace fdet;
74 using namespace std;
75 
76 
77 /*************************************************************************/
78 SimMockEvent::SimMockEvent(const double xBinning) :
79  fVerbosity(0),
80  fXBinning(xBinning)
81 {
84 }
85 
86 
87 /*************************************************************************/
88 void
90 {
91  if (fVerbosity > 0)
92  cout << " --[FdLightCollectionEfficiency]--> Preparing Mock SimEvent..." << endl;
93 
94  if (!fEvent.HasSimShower())
96 
97  ShowerSimData& simShower = fEvent.GetSimShower();
98 
99  const Point& position = recData.GetCorePosition();
100  const Vector axis = recData.GetAxis();
101 
102  const ReferenceEllipsoid& e = ReferenceEllipsoid::GetWGS84();
103  const CoordinateSystemPtr cs = AugerCoordinateSystem::Create(position, e, e.GetECEF());
104 
105  const double zenith = axis.GetTheta(cs);
106  const double azimuth = axis.GetPhi(cs);
107  simShower.SetGroundParticleCoordinateSystemZenith(zenith);
108  simShower.SetGroundParticleCoordinateSystemAzimuth(azimuth);
109  simShower.MakeGeometry(position);
110 
111  // Need to do this before SetLongitudinalProfilesFromGH
112  simShower.MakeGHParameters(recData.GetGHParameters());
113  simShower.SetEnergyCutoff(recData.GetEnergyCutoff());
115 }
116 
117 
118 /*************************************************************************/
119 void
121 {
122  const VGaisserHillasParameter& ghParam = simShower.GetGHParameters();
123  const GaisserHillas4Parameter& gh4Param =
124  dynamic_cast<const GaisserHillas4Parameter&>(ghParam);
125 
126  simShower.SetXFirst(fmax(0.2*g/cm2, gh4Param.GetShapeParameter(gh::eX0)));
127  if (fVerbosity > 0)
128  cout << " X1 is: " << simShower.GetXFirst()/g*cm2 << endl;
129 
130  const double enCut = simShower.GetEnergyCutoff();
131 
132  TabulatedFunction dEdX;
134 
135  double depth = 0.2*g/cm2;
136  const double xMax = ghParam.GetXMax();
137 
138  for (;;) {
139  const double age = utl::ShowerAge(depth, xMax);
140 
141  double thisdEdX = ghParam.Eval(depth);
142  if (age < 1. && thisdEdX < 2.*MeV/g*cm2)
143  thisdEdX = 2.*MeV/g*cm2;
144 
145  const double thisNe = thisdEdX / utl::EnergyDeposit(age, enCut); // lives in utl::PhysicalFunctions
146 
147  if (age > 2. || depth > 3000.*g/cm2)
148  break;
149 
150  dEdX.PushBack(depth, thisdEdX);
151  Ne.PushBack(depth, thisNe);
152 
153  depth += fXBinning;
154  }
155 
156  simShower.MakedEdX(dEdX);
157  simShower.MakeLongitudinalProfile(Ne);
158 }
159 
160 
161 /*************************************************************************/
162 bool
163 SimMockEvent::PrepareEvent(const unsigned int eyeId,
164  const evt::ShowerFRecData& recData,
165  const evt::Event& event,
166  const fevt::Eye& eye)
167 {
168  ostringstream output;
169  string oindent = " ";
170  if (fVerbosity > -1)
171  output << " --[FdLightCollectionEfficiency]--> Preparing Mock FEvent...\n";
172 
173  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
174  const fdet::Eye& theDetEye = detFD.GetEye(eyeId);
175 
176  // Create the event structures
177  if (!event.GetFEvent().HasEye(eyeId, ComponentSelector::eHasData))
178  return false;
179 
180  const int eyeDaqStatus = theDetEye.GetDAQStatus();
181  if (eyeDaqStatus == 0) {
182  if (fVerbosity > 0)
183  output << oindent << "Skipping eye " << eyeId << " (not in DAQ)\n";
184  return false;
185  }
186 
187  if (fVerbosity > 0)
188  output << oindent << "Creating eye " << eyeId << " (Telescopes in DAQ:";
189 
192 
193  bool hasTelescope = false;
194  // Only what is written into the FEvent HERE will be considered by any Modules
195  // further donwstream in the efficiency-calculation-sequence!
196  for (fdet::Eye::TelescopeIterator iTel = theDetEye.TelescopesBegin(), end = theDetEye.TelescopesEnd();
197  iTel != end; ++iTel) {
198 
199  const unsigned int telId = iTel->GetId();
200 
201  const int telDaqStatus = iTel->GetDAQStatus();
202  if (telDaqStatus == 0)
203  continue;
204 
205  hasTelescope = true;
206 
207  if (fVerbosity > 0)
208  output << " " << telId;
209 
212  if (event.GetFEvent().HasEye(eyeId, fevt::ComponentSelector::eHasData)) {
213  const fevt::Eye& refEye = event.GetFEvent().GetEye(eyeId, fevt::ComponentSelector::eHasData);
214  if (refEye.HasTelescope(telId, fevt::ComponentSelector::eHasData)) {
215  // FIXME: It is entirely unclear whether this makes any sense at all.
216  //tel.SetTracesStartTime( refEye.GetTelescope(telId, fevt::ComponentSelector::eHasData).GetTracesStartTime() );
218  }
219  }
220 
221  } // end for telescopes
222  output << ")\n";
223 
224  cout << output.str() << endl;
225 
226  // Direction, core position, etc.
227  FillSimEvent(recData);
228 
229  // The following code computes the time-at-core which is needed
230  // for the simShower. (See also: OfflineKG's SetAxis does the opposite)
231  ShowerSimData& simShower = fEvent.GetSimShower();
232 
233  const Point& corePosition = simShower.GetPosition();
234  const Vector axis = simShower.GetDirection();
235 
236  const double T0 = eye.GetRecData().GetTZero();
237  utl::TimeStamp eyeTriggerTime =
239 
240  const utl::Point& eyePos = detFD.GetEye(eye).GetPosition();
241  const Vector eyeToCore = corePosition-eyePos;
242  const double distCoreEye = eyeToCore.GetMag();
243  const double beta = Angle(-axis, eyeToCore);
244 
245  const utl::TimeStamp timeAtCore =
246  eyeTriggerTime + TimeInterval(T0) - TimeInterval(distCoreEye/kSpeedOfLight * cos(beta));
247 
248  /*cout << "Eye Trigger time: " << eyeTriggerTime << endl;
249  cout << "time at core. " << timeAtCore << endl;
250  cout << "T0 " << T0 << endl;
251  cout << "beta " << beta << endl;
252  cout << "distcoreeye " << distCoreEye << endl;
253  */
254 
255  simShower.MakeTimeStamp(timeAtCore);
256 
257  return hasTelescope;
258 }
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
Definition: FEvent/Eye.cc:57
double GetEnergyCutoff(const ProfileType type=eElectron) const
Get the energy cutoff for which the profile of charged particles was calculated.
double GetShapeParameter(const gh::EShapeParameter par) const
access to all variants of shape parameters (see GaisserHillasTypes.h)
unsigned int GetId() const
Definition: FEvent/Eye.h:54
Point object.
Definition: Point.h:32
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Definition: FEvent/Eye.cc:180
unsigned int GetTimeOffset() const
Time offset of this Telescope compared to fevt::Header::GetTime [ns].
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
const evt::VGaisserHillasParameter & GetGHParameters() const
Get the Gaisser-Hillas parameters of the shower.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
double fXBinning
The depth binning for the profile that&#39;s calculated from the GH fit.
Definition: SimMockEvent.h:67
Class to hold collection (x,y) points and provide interpolation between them.
void SetTimeOffset(const unsigned int toffset)
void SetEnergyCutoff(const double energy, const ProfileType type=eElectron)
Set the enegy cutoff for which the profile of charged particles was calculated.
bool HasSimShower() const
void SetGroundParticleCoordinateSystemAzimuth(const double azimuth)
Set the azimuth angle of the shower. Angle in x-y plane wrt. to the x axis (0 is from east)...
void MakeEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Definition: FEvent.cc:115
void MakeGHParameters(const evt::VGaisserHillasParameter &ghPar)
Make the Gaisser-Hillas parameters of the shower.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
Detector description interface for Eye-related data.
Definition: FDetector/Eye.h:45
void PushBack(const double x, const double y)
void MakeTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Telescope telescopeId.
Definition: FEvent/Eye.cc:102
void MakedEdX(const utl::TabulatedFunction &dEdX)
Make the energy deposit of the shower.
double GetMag() const
Definition: Vector.h:58
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
constexpr double MeV
Definition: AugerUnits.h:184
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
double GetXFirst() const
Get depth of first interaction.
void MakeLongitudinalProfile(const utl::TabulatedFunction &lp, const ProfileType type=eCharged)
Make the longitudinal charge profile of the shower.
void FillSimEvent(const evt::ShowerFRecData &recData)
Definition: SimMockEvent.cc:89
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.
TelescopeIterator TelescopesBegin() const
Beginning of the collection of telescopes.
Definition: FDetector/Eye.h:79
const utl::Point & GetPosition() const
Get the position of the shower core.
bool PrepareEvent(const unsigned int eyeId, const evt::ShowerFRecData &recData, const evt::Event &event, const fevt::Eye &eye)
ShowerSimData & GetSimShower()
virtual double Eval(const double depth) const =0
evt::Event fEvent
Container for the actual event.
Definition: SimMockEvent.h:70
constexpr double g
Definition: AugerUnits.h:200
const CoordinateSystemPtr GetECEF() const
Get the ECEF.
void SetLongitudinalProfilesFromGH(evt::ShowerSimData &simShower)
Eye & GetEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
return Eye by id
Definition: FEvent.cc:70
void SetXFirst(const double xFirst)
Set depth of first interaction.
boost::filter_iterator< TelIsCommissioned, InternalConstTelescopeIterator > TelescopeIterator
An iterator over telescopes.
Definition: FDetector/Eye.h:76
fevt::FEvent & GetFEvent()
bool HasEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Definition: FEvent.cc:57
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
void SetGroundParticleCoordinateSystemZenith(const double zenith)
Set the zenith angle of the shower. Room angle between z-axis and direction from where the shower is ...
double ShowerAge(const double slantDepth, const double showerMax)
General definition of shower age.
utl::TimeStamp GetTimeStamp() const
Time of the Eye Event as tagged by FD-DAS (== eye trigger time plus pixel trace length) ...
Definition: EyeHeader.h:118
void MakeGeometry(const utl::Point &pointOnShowerAxis)
initialize the shower geometry. Pos is a point on the shower axis, but not necessarily the core ...
bool HasTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the telescope is in the event.
Definition: FEvent/Eye.cc:117
double EnergyDeposit(const double age, const double enCut)
Parametrization for the average energy deposit per particle.
Interface class for access to the Gaisser-Hillas parameters.
int GetDAQStatus() const
0 == not in DAQ
Vector object.
Definition: Vector.h:30
void MakeSimShower(const evt::VShowerGeometryProducer &p)
Interface class to access to Fluorescence reconstruction of a Shower.
void MakeTimeStamp(const utl::TimeStamp &ts)
Make the TimeStamp of the shower.
TelescopeIterator TelescopesEnd() const
End of the collection of telescopes.
Definition: FDetector/Eye.h:83
double GetTZero() const
Definition: EyeRecData.h:83
Fluorescence Detector Telescope Event.
Gaisser Hillas with 4 parameters.
int fVerbosity
global verbosity flag
Definition: SimMockEvent.h:64
constexpr double microsecond
Definition: AugerUnits.h:147
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
double GetEnergyCutoff() const
retrieve energy cutoff for which the profile of charged particles was calculated. ...
utl::Point GetPosition() const
Eye position.
constexpr double cm2
Definition: AugerUnits.h:118
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.

, generated on Tue Sep 26 2023.