EnergyCalculation.cc
Go to the documentation of this file.
1 #include "EnergyCalculation.h"
2 #include <det/Detector.h>
3 #include <utl/Math.h>
4 #include <utl/PhysicalConstants.h>
5 #include <evt/Event.h>
6 #include <sevt/Meteo.h>
7 #include <sevt/SEvent.h>
8 #include <evt/ShowerRecData.h>
9 #include <evt/ShowerSRecData.h>
10 #include <fwk/LocalCoordinateSystem.h>
11 #include <fwk/CentralConfig.h>
12 #include <cmath>
13 
14 using namespace evt;
15 using namespace sevt;
16 using namespace utl;
17 using namespace fwk;
18 using namespace std;
19 
20 
21 namespace EnergyCalculationPG {
22 
23  void
24  EnergyCalculation::GetCorrectedS1000Geomagnetic(const double theta,
25  const double phi,
26  const double s1000,
27  const double s1000Err,
28  double& sGeo1000,
29  double& sGeo1000Err)
30  {
31  const double sinTheta = sin(theta);
32  const double cosTheta = cos(theta);
33  // From Moritz Munchmeyer's Thesis 2012, Eq. (4.3.6):
34  const double thetaB = 54.8 * degree;
35  const double phiB = 87.4 * degree;
36  const double axisBMag =
37  sinTheta * cos(phi) * sin(thetaB) * cos(phiB) +
38  sinTheta * sin(phi) * sin(thetaB) * sin(phiB) +
39  cosTheta * cos(thetaB);
40  const double correctionFactor =
41  1 + 4.2e-3 * pow(cosTheta, -2.8) * (1 - Sqr(axisBMag));
42 
43  sGeo1000 = s1000 / correctionFactor;
44  sGeo1000Err = s1000Err / correctionFactor;
45  }
46 
47 
49  EnergyCalculation::Run(Event& event)
50  {
51  if (!event.HasSEvent() || !event.HasRecShower())
52  return eContinueLoop;
53  auto& recShower = event.GetRecShower();
54  if (!recShower.HasSRecShower())
55  return eContinueLoop;
56 
57  // get the needed variables from the event calculate the energy
58  // and the energy error set the energy to the RecShower
59 
60  auto& sRecShower = recShower.GetSRecShower();
61 
62  const double showerSize = sRecShower.GetShowerSize();
63  const double showerSizeErr = sRecShower.GetShowerSizeError();
64 
65  const Point core = sRecShower.GetCorePosition();
66  const CoordinateSystemPtr coreCS = LocalCoordinateSystem::Create(core);
67  const auto& axis = sRecShower.GetAxis();
68  const double theta = axis.GetTheta(coreCS);
69  const double phi = axis.GetPhi(coreCS);
70 
71  double s1000Geo = 0;
72  double s1000ErrGeo = 0;
73  GetCorrectedS1000Geomagnetic(theta, phi, showerSize, showerSizeErr, s1000Geo, s1000ErrGeo);
74  // only set corrected variable, don't overwrite s1000!
75  sRecShower.SetSizeGeomagneticCorr(s1000Geo, s1000ErrGeo);
76 
77  return eSuccess;
78  }
79 
80 }
const double degree
constexpr T Sqr(const T &x)
Point object.
Definition: Point.h:32
double pow(const double x, const unsigned int i)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasSEvent() const

, generated on Tue Sep 26 2023.