RdPolarizationReconstructor.h
Go to the documentation of this file.
1 #ifndef _RdPolarizationReconstructor_h_
2 #define _RdPolarizationReconstructor_h_
3 
4 #include <tls/MuonProfile.h>
5 #include <tls/MuonProfileUtilities.h>
6 #include <fwk/VModule.h>
7 #include <revt/Station.h>
8 #include <revt/StationRecData.h>
9 #include <revt/Channel.h>
10 #include <utl/ParameterStorage.h>
11 #include <rdet/RDetector.h>
12 #include <utl/AxialVector.h>
13 #include <utl/GeometryUtilities.h>
14 
15 #include <boost/numeric/ublas/vector.hpp>
16 #include <boost/numeric/ublas/vector_proxy.hpp>
17 
18 #include <string>
19 #include <map>
20 
21 
22 namespace evt {
23  class Event;
24 }
25 
26 namespace revt {
27  class Channel;
28 }
29 
31 
32  const Complex I(0.0, 1.0);
33 
34 
35  // Functionality for slicing the vectors is needed therefore we choose a boost
36  // vector and a boost vector_range as a proxy in stead of an offline Trace
37  typedef boost::numeric::ublas::vector<Complex> BoostVecC;
38  typedef boost::numeric::ublas::vector_range<BoostVecC> BoostVecRangeC;
39  typedef boost::numeric::ublas::vector<double> BoostVecD;
40  typedef utl::TraceV3C::SizeType SizeT; // Shorthand
41 
42 
43  // These maps are for storing intermediate values of the analytic error estimation method
44  // The first map is used to store the covariances when the Analytic error calculation
45  // method is used. It stores key value pairs with the value covariance (Complex) between
46  // channel1 (char), channel2 (char) as the key. It is used in the
47  // StokesParameters::GetSampleCovariance() method.
48  // The second map is also only used for the analytic method. It stores the estimated
49  // uncertainties of the single channels as a variance.
50  typedef std::map< std::pair< char, char >, BoostVecC > SampleCovariancesT;
51  typedef std::map< char, double > OneChannelPulseVariancesT;
52 
53 
54  // The objects of this class contain the raw polarization data that are obtained from the background
55  // and the raw polarization data that are obtained from the signal
57 
58  public:
60 
61  template<class T>
62  RawStokesParameters(const T& slice_x, const T& slice_y) :
63  fSliceX(slice_x),
64  fSliceY(slice_y),
65  fSliceA((slice_x + slice_y)/sqrt(2)),
66  fSliceB((slice_x - slice_y)/sqrt(2)),
67  fSliceL((slice_x + I*slice_y)/sqrt(2)),
68  fSliceR((slice_x - I*slice_y)/sqrt(2)),
69  fAverageAbs2X(pow(norm_2(fSliceX), 2)/fSliceX.size()),
70  fAverageAbs2Y(pow(norm_2(fSliceY), 2)/fSliceY.size()),
71  fAverageAbs2A(pow(norm_2(fSliceA), 2)/fSliceA.size()),
72  fAverageAbs2B(pow(norm_2(fSliceB), 2)/fSliceB.size()),
73  fAverageAbs2L(pow(norm_2(fSliceL), 2)/fSliceL.size()),
74  fAverageAbs2R(pow(norm_2(fSliceR), 2)/fSliceR.size()) //,
75  //fRawStokesI(fAverageAbs2X + fAverageAbs2Y), // unused. LN.
76  //fRawStokesQ(fAverageAbs2X - fAverageAbs2Y), // unused. LN.
77  //fRawStokesU(fAverageAbs2A - fAverageAbs2B), // unused. LN.
78  //fRawStokesV(fAverageAbs2L - fAverageAbs2R) // unused. LN.
79  { }
80 
81  double GetRawStokesI() const { return fAverageAbs2X + fAverageAbs2Y; }
82  double GetRawStokesQ() const { return fAverageAbs2X - fAverageAbs2Y; }
83  double GetRawStokesU() const { return fAverageAbs2A - fAverageAbs2B; }
84  double GetRawStokesV() const { return fAverageAbs2L - fAverageAbs2R; }
85  SizeT GetSize() const { return fSliceX.size(); }
86  BoostVecRangeC GetSliceX(SizeT pos, SizeT size); // this method should in principle be declared as const but boost doesn't like that
87  BoostVecRangeC GetSliceY(SizeT pos, SizeT size); // idem
88  Complex GetIndex(char channel, int index) const;
89  private:
96  double fAverageAbs2X;
97  double fAverageAbs2Y;
98  double fAverageAbs2A;
99  double fAverageAbs2B;
102  //double fRawStokesI; // unused. LN.
103  //double fRawStokesQ; // unused. LN.
104  //double fRawStokesU; // unused. LN.
105  //double fRawStokesV; // unused. LN.
106  };
107 
108 
109  // The objects of this class contain the corrected polarization data for the signal
111 
112  public:
113  StokesParameters(const BoostVecRangeC& signal_x, const BoostVecRangeC& signal_y,
114  const BoostVecRangeC& noise_x, const BoostVecRangeC& noise_y, bool subtract_noise);
115  double GetStokesI() const { return fStokesI; }
116  double GetStokesQ() const { return fStokesQ; }
117  double GetStokesU() const { return fStokesU; }
118  double GetStokesV() const { return fStokesV; }
119  double GetStokesRatioQdivI() const { return fStokesRatioQdivI; }
120  double GetStokesRatioUdivI() const { return fStokesRatioUdivI; }
121  double GetStokesRatioVdivI() const { return fStokesRatioVdivI; }
122  double GetPolarizationAngle() const { return 0.5*atan(fStokesU/fStokesQ); }
123  double GetNoiseAdditionCovariance(const revt::StationRRecDataQuantities, revt::StationRRecDataQuantities);
124  double GetAnalyticMethodVariance(const revt::StationRRecDataQuantities);
125  private:
126  // For private and internal internal use only (no pun intended), when noise levels have already been calculated
127  StokesParameters(const BoostVecC& signal_x, const BoostVecC& signal_y, RawStokesParameters& noise, double multiply_noise);
128  void NoiseAdditionCovarianceHelper(BoostVecD& quanities, const revt::StationRRecDataQuantities quantity_enum,
129  const StokesParameters& sliding_stokes, SizeT index);
130  void NoiseAdditionCovariancePolarizationAngleHelper(double& angle, double origval) const;
131 
132  // Sample Covariances are not to be confused with the (Co)variances between the stokes parameters
133  Complex AnalyticMethodSampleCovarianceHelper(char channel1, char channel2, SizeT index);
134  double AnalyticMethodOneChannelVarianceHelper(char channel);
135 
138 
139  // These maps are for storing intermediate values of the analytic error estimation method
142 
143  double fStokesI;
144  double fStokesQ;
145  double fStokesU;
146  double fStokesV;
150  };
151 
152 
154 
155  public:
158 
159  fwk::VModule::ResultFlag Init() override;
160  fwk::VModule::ResultFlag Run(evt::Event& event) override;
161  fwk::VModule::ResultFlag Finish() override;
162 
163  private:
164  enum InfoLevel {
165  eNone = 0,
166  eFinal = 1,
168  eObscure = 3,
170  };
171 
175  //bool fCorrectForOpeningAngle; // unused. LN.
177  std::string fGeometrySource;
179 
184 
185  void GetRotatedPolarizationTraces(const evt::Event& event, const revt::Station& station,
186  const rdet::RDetector& rDetector, const utl::TraceV3C& stationTimeSeries,
187  BoostVecC& traceX, BoostVecC& traceY, double& observerAngle,
188  double& alpha) const;
190  BoostVecC& traceY, double observerAngle,
191  double alpha);
192  void CheckSignalAndNoiseRanges(SizeT signal_start_bin, SizeT signal_stop_bin,
193  SizeT noise_start_bin, SizeT noise_stop_bin,
194  SizeT size) const;
195  void CalculateAndFillChargeExcessFraction(revt::Station& station, double& alpha,
196  double& chxfraction);
197  utl::Vector GetArrivalDirection(const evt::Event& event) const;
198  utl::CoordinateSystemPtr GetCS(const evt::Event& event) const;
199  void GetCoreXY(const evt::Event& event, const utl::CoordinateSystemPtr& CS, double& CoreX, double& CoreY) const;
200  utl::Point GetCore(const evt::Event& event) const;
201  utl::Vector GetPerpVector(const utl::Point& point, const utl::Line& line) const;
202 
203  REGISTER_MODULE("RdPolarizationReconstructor", RdPolarizationReconstructor);
204 
205  };
206 
207 }
208 
209 
210 #endif
void GetRotatedPolarizationTraces(const evt::Event &event, const revt::Station &station, const rdet::RDetector &rDetector, const utl::TraceV3C &stationTimeSeries, BoostVecC &traceX, BoostVecC &traceY, double &observerAngle, double &alpha) const
Point object.
Definition: Point.h:32
boost::numeric::ublas::vector< double > BoostVecD
void CalculateAndFillStokesParameters(revt::Station &station, BoostVecC &traceX, BoostVecC &traceY, double observerAngle, double alpha)
void NoiseAdditionCovariancePolarizationAngleHelper(double &angle, double origval) const
const Complex I(0.0, 1.0)
double GetNoiseAdditionCovariance(const revt::StationRRecDataQuantities, revt::StationRRecDataQuantities)
fwk::VModule::ResultFlag Run(evt::Event &event) override
Run: invoked once per event.
double GetAnalyticMethodVariance(const revt::StationRRecDataQuantities)
double pow(const double x, const unsigned int i)
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
std::map< std::pair< char, char >, BoostVecC > SampleCovariancesT
std::complex< double > Complex
Definition: fftw++.h:83
void GetCoreXY(const evt::Event &event, const utl::CoordinateSystemPtr &CS, double &CoreX, double &CoreY) const
class to hold data at the radio Station level.
std::vector< T >::size_type SizeType
Definition: Trace.h:58
utl::Vector GetPerpVector(const utl::Point &point, const utl::Line &line) const
boost::numeric::ublas::vector< Complex > BoostVecC
Determines the observables related to polarization determined by the electric field, the geomagnetic field and the shower geometry.
void CalculateAndFillChargeExcessFraction(revt::Station &station, double &alpha, double &chxfraction)
std::map< char, double > OneChannelPulseVariancesT
void NoiseAdditionCovarianceHelper(BoostVecD &quanities, const revt::StationRRecDataQuantities quantity_enum, const StokesParameters &sliding_stokes, SizeT index)
utl::Vector GetArrivalDirection(const evt::Event &event) const
Complex AnalyticMethodSampleCovarianceHelper(char channel1, char channel2, SizeT index)
Module interface.
Definition: VModule.h:53
void CheckSignalAndNoiseRanges(SizeT signal_start_bin, SizeT signal_stop_bin, SizeT noise_start_bin, SizeT noise_stop_bin, SizeT size) const
utl::CoordinateSystemPtr GetCS(const evt::Event &event) const
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
StokesParameters(const BoostVecRangeC &signal_x, const BoostVecRangeC &signal_y, const BoostVecRangeC &noise_x, const BoostVecRangeC &noise_y, bool subtract_noise)
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
Definition: Trace-fwd.h:19
boost::numeric::ublas::vector_range< BoostVecC > BoostVecRangeC
Vector object.
Definition: Vector.h:30
fwk::VModule::ResultFlag Finish() override
Finish: invoked at end of the run (NOT end of the event)
fwk::VModule::ResultFlag Init() override
Initialize: invoked at beginning of run (NOT beginning of event)
REGISTER_MODULE("RdPolarizationReconstructor", RdPolarizationReconstructor)
Definition: Line.h:17

, generated on Tue Sep 26 2023.