RdLDFChargeExcessCorrector.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 #include <fwk/MagneticFieldModel.h>
5 
6 #include <utl/config.h>
7 #include <utl/ErrorLogger.h>
8 #include <utl/Reader.h>
9 
10 #include <utl/Vector.h>
11 #include <utl/Point.h>
12 #include <utl/BasicVector.h>
13 #include <utl/GeometryUtilities.h>
14 #include <utl/RadioGeometryUtilities.h>
15 #include <utl/CoordinateSystemPtr.h>
16 #include <utl/AxialVector.h>
17 
18 #include <evt/Event.h>
19 #include <evt/ShowerRecData.h>
20 #include <evt/ShowerSRecData.h>
21 #include <evt/ShowerRRecData.h>
22 
23 #include <revt/REvent.h>
24 #include <revt/Station.h>
25 #include <revt/Header.h>
26 #include <revt/StationRecData.h>
27 
28 #include <det/Detector.h>
29 #include <rdet/RDetector.h>
30 #include <det/VManager.h>
31 
32 #include <TF1.h>
33 
34 #include <math.h>
35 
36 using namespace revt;
37 using namespace fwk;
38 using namespace det;
39 
41 
43  fInfoLevel(eNone),
44  fMeanAsymmetry(0.),
45  fMeanAsymmetryError(0.),
46  fAsymmetryParametrization(""),
47  fAsymmetryDefinition("Mean")
48  {
49  }
50 
51  RdLDFChargeExcessCorrector::~RdLDFChargeExcessCorrector()
52  {
53  }
54 
56  {
57  INFO("RdLDFChargeExcessCorrector::Init()");
58 
59  utl::Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdLDFChargeExcessCorrector");
60 
62  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
63  topBranch.GetChild("MeanAsymmetry").GetData(fMeanAsymmetry);
64  topBranch.GetChild("MeanAsymmetryError").GetData(fMeanAsymmetryError);
65  topBranch.GetChild("AsymmetryParametrization").GetData(fAsymmetryParametrization);
66  topBranch.GetChild("AsymmetryDefinition").GetData(fAsymmetryDefinition);
67 
68  return eSuccess;
69 
70  }
71 
72  VModule::ResultFlag RdLDFChargeExcessCorrector::Run(evt::Event& event)
73  {
75  if(!event.HasREvent()) {
76  WARNING("No radio event found!");
77  return eSuccess;
78  }
79 
80  REvent& rEvent = event.GetREvent();
81  evt::ShowerRRecData& showerrrec = event.GetRecShower().GetRRecShower();
82 
84  if(!showerrrec.HasCorePosition() || !showerrrec.HasAxis()) {
85  WARNING("No core or axis. Charge-excess correction is not performed.");
86  return eSuccess;
87  }
88 
90 
92  const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
93 
95  const utl::Vector showerAxis = showerrrec.GetAxis();
96 
98  utl::CoordinateSystemPtr baryCS = det::Detector::GetInstance().GetReferenceCoordinateSystem();
99 
101  const utl::Point core = showerrrec.GetCorePosition();
102 
104  utl::Vector localMagneticField = fwk::MagneticFieldModel::instance().GetMagneticFieldVector(event.GetRecShower().GetRRecShower().GetCoordinateOrigin(), event.GetREvent().GetHeader().GetTime().GetGPSSecond());
105 
107  utl::RadioGeometryUtilities transform(showerAxis,baryCS,fwk::MagneticFieldModel::instance().GetMagneticFieldVector(event.GetRecShower().GetRRecShower().GetCoordinateOrigin(), event.GetREvent().GetHeader().GetTime().GetGPSSecond()));
108 
110  const double geomag_angle = utl::Angle(localMagneticField,showerAxis);
111 
113  for(REvent::CandidateStationIterator sIt = rEvent.CandidateStationsBegin(); sIt != rEvent.CandidateStationsEnd(); ++sIt) {
114 
116  Station& station = *sIt;
117  const StationRecData& sRec = station.GetRecData();
118 
120  if(!sRec.GetPulseFound())
121  continue;
122 
124  const utl::Point sPos = rDetector.GetStation(station).GetPosition();
125 
127  const utl::Vector sVector = sPos - core;
128 
131  double magx(0), magy(0), magz(0);
132  transform.GetVectorInShowerPlaneVxB(magx, magy, magz, utl::Point(sVector.GetX(baryCS), sVector.GetY(baryCS), sVector.GetZ(baryCS), baryCS));
133 
135  const double t_angle = atan2(magy,magx);
136 
138  double eps = 0.0;
139  double eps_err = 0.0;
140 
142  if(fAsymmetryDefinition == "Mean") {
144  eps = fMeanAsymmetry;
145  eps_err = fMeanAsymmetryError;
146  }
147 
148  if(fAsymmetryDefinition == "Polarization") {
151 
152  // Warning / TODO: #warning: not yet fully implemented
153  //eps = station.GetRecData().GetParameter(eChargeExcessAsymmetry);
154  //eps_err = station.GetRecData().GetParameterError(eChargeExcessAsymmetry);
155  }
156 
157  if(fAsymmetryDefinition == "Geometry") {
160  }
161 
162  if(fAsymmetryDefinition == "Parametrization") {
164  const double dist = utl::RadioGeometryUtilities::GetDistanceToAxis(showerAxis, core, sPos);
165  TF1 *asymm_parametrization = new TF1("asymmetry_parametrization",fAsymmetryParametrization.c_str(),0,500);
166  // Warning / TODO: #warning: harcoded to 500 m!
167  eps = asymm_parametrization->Eval(dist);
168  // Warning / TODO: #warning: for parametrization the uncertainty is set to zero!
169  eps_err = 0.0;
170  asymm_parametrization->Delete();
171  }
172 
174  const double Amp = station.GetRecData().GetParameter(eSignal);
175  const double Amp_err = station.GetRecData().GetParameterError(eSignal);
176 
178  double A0 = Amp / sqrt(pow(eps,2) + 2*eps*cos(t_angle)*sin(geomag_angle) + pow(sin(geomag_angle),2));
179  double A0_err = sqrt( pow(Amp_err / sqrt(pow(eps,2) + 2*eps*cos(t_angle)*sin(geomag_angle) + pow(sin(geomag_angle),2)),2)
180  + pow( (eps_err * Amp * (eps + eps*cos(t_angle)*sin(geomag_angle)) ) / ( pow(pow(eps,2) + 2*eps*cos(t_angle)*sin(geomag_angle)
181  + pow(sin(geomag_angle),2),1.5) ) ,2) );
183  station.GetRecData().SetParameter(eSignal, A0);
184  station.GetRecData().SetParameterError(eSignal, A0_err);
185  }
186 
187  return eSuccess;
188  }
189 
190  VModule::ResultFlag RdLDFChargeExcessCorrector::Finish()
191  {
192  INFO("RdLDFChargeExcessCorrector::Finish()");
193  return eSuccess;
194  }
195 
196 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Class to access station level reconstructed data.
utl::Vector GetAxis() const
Returns vector of the shower axis.
void SetParameterError(Parameter i, double value, bool lock=true)
Point object.
Definition: Point.h:32
static double GetDistanceToAxis(const utl::Vector &ShowerAxis, const utl::Point &CorePosition, const utl::Point &AntennaPosition)
computes the distance from the antenna position to the shower &quot;line&quot; defined by the core position and...
boost::filter_iterator< CandidateStationFilter, AllStationIterator > CandidateStationIterator
Iterator over all CandidateStations (i.e., HasSignal, HasNoSignal)
Definition: REvent.h:141
Report success to RunController.
Definition: VModule.h:62
StationRecData & GetRecData()
Get station level reconstructed data.
CandidateStationIterator CandidateStationsEnd()
Definition: REvent.h:146
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
double GetParameterError(const Parameter i) const
bool HasCorePosition() const
Return true if all 3 core parameter are set.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
double pow(const double x, const unsigned int i)
bool HasREvent() const
ShowerRRecData & GetRRecShower()
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
utl::Point GetCoordinateOrigin() const
class to hold data at the radio Station level.
bool HasAxis() const
Return true if all 3 axis parameter are set.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
static MagneticFieldModel & instance()
static utl::Vector GetMagneticFieldVector(const utl::Point &position, const utl::TimeStamp &time)
returns the magnetic field at a specific place at a specific time
CandidateStationIterator CandidateStationsBegin()
Definition: REvent.h:144
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
double eps
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
double GetParameter(const Parameter i) const
void GetVectorInShowerPlaneVxB(double &x, double &y, double &z, const utl::Point &point) const
in case of positions, the positions has to be relative to the core positions!!!
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void SetParameter(Parameter i, double value, bool lock=true)
double Angle(const Vector &left, const Vector &right)
Definition: OperationsVV.h:82
Vector object.
Definition: Vector.h:30
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141

, generated on Tue Sep 26 2023.