RdStationBeamFormer.cc
Go to the documentation of this file.
1 
9 #include "RdStationBeamFormer.h"
10 
11 #include <fwk/CentralConfig.h>
12 #include <fwk/VModule.h>
13 #include <fwk/CoordinateSystemRegistry.h>
14 
15 #include <utl/ErrorLogger.h>
16 #include <utl/Reader.h>
17 // #include <utl/config.h>
18 // #include <utl/TraceAlgorithm.h>
19 // #include <utl/AugerUnits.h>
20 #include <utl/PhysicalConstants.h>
21 #include <utl/TimeStamp.h>
22 #include <utl/TimeInterval.h>
23 
24 #include <det/Detector.h>
25 #include <rdet/RDetector.h>
26 
27 #include <evt/Event.h>
28 #include <evt/ShowerRecData.h>
29 #include <evt/ShowerRRecData.h>
30 
31 #include <revt/REvent.h>
32 // #include <revt/Header.h>
33 #include <revt/Station.h>
34 // #include <revt/Channel.h>
35 
36 using namespace fwk;
37 using namespace utl;
38 using namespace std;
39 using namespace evt;
40 using namespace revt;
41 
43 
45  fInfoLevel(0),
46  fWaveFront(0),
47  fRefractionIndex(1),
48  fSpeedOfLight(kSpeedOfLight)
49  {
50  }
51 
52 
53  RdStationBeamFormer::~RdStationBeamFormer()
54  {
55  }
56 
57 
60  {
61  // Initialize your module here. This method
62  // is called once at the beginning of the run.
63  // The eSuccess flag indicates the method ended
64  // successfully. For other possible return types,
65  // see the VModule documentation.
66 
67  INFO("RdStationBeamFormer::Init()");
68 
69 
70  // Read in the configurations of the xml file
71  Branch topBranch =
72  CentralConfig::GetInstance()->GetTopBranch("RdStationBeamFormer");
73 
74  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
75  topBranch.GetChild("WaveFront").GetData(fWaveFront);
76  topBranch.GetChild("RefractionIndex").GetData(fRefractionIndex);
78 
79  return eSuccess;
80  }
81 
82 
84  RdStationBeamFormer::Run(evt::Event& event)
85  {
86  if (fInfoLevel >= eObscure)
87  INFO("RdStationBeamFormer::Run()");
88 
89  // Check if there is an radio event at all
90  if(!event.HasREvent()) {
91  if (fInfoLevel >= eFinal)
92  WARNING("No radio event found!");
93  return eContinueLoop;
94  }
95 
96  // get the event and the detector (for antenna positions)
97  REvent& rEvent = event.GetREvent();
98 
99  // Check if there are at least 2 stations (otherwise beam forming does not make sense)
100  if(rEvent.GetNumberOfStations() < 2) {
101  if (fInfoLevel >= eFinal)
102  WARNING("At least 2 stations are needed for beam forming!");
103  return eContinueLoop;
104  }
105  // get detector description (for antenna positions)
106  const det::Detector& detector = det::Detector::GetInstance();
107  const rdet::RDetector& rDetector = detector.GetRDetector();
108 
109  // Look if reconstruction information is available
110  if (!event.HasRecShower()) {
111  ERROR("No shower reconstruction found, but needed as input.");
112  return eContinueLoop;
113  }
114  const ShowerRecData& showerrec = event.GetRecShower();
115 
116  // for now, work only with the RD reconstruction
117  // later also input from FD or SD could be used to get core and direction for the beam forming
118  if (!showerrec.HasRRecShower()) {
119  ERROR("No radio reconstruction (e.g. from RDPlaneFit) found, but needed as input.");
120  return eContinueLoop;
121  }
122  const ShowerRRecData& showerrrec = showerrec.GetRRecShower();
123 
124  // get core position and axis
125  const Point& core = showerrrec.GetCorePosition();
126  const Vector& axis = showerrrec.GetAxis();
127 
128  stringstream fMessage;
129  fMessage << "Output of core and axis: (work in progress) ";
130  if (fInfoLevel >= eDebug)
131  INFO(fMessage.str());
132 
133  // store time stamp of the first station as reference:
134  // the time stamps of different stations might be different and this "additional delay"
135  // has to be taken into account for the beam forming
136  TimeStamp firstTimeStamp = rEvent.StationsBegin()->GetTraceStartTime();
137 
138  // loop through all stations and calculate the delays for beam forming
139  for (REvent::StationIterator sIt = rEvent.StationsBegin();
140  sIt != rEvent.StationsEnd(); ++sIt) {
141  // get the time stamp and store eventual differences to correct for them later
142  Station& station = *sIt;
143  TimeStamp stationTimeStamp = station.GetTraceStartTime();
144  TimeInterval timeStampDelay = stationTimeStamp-firstTimeStamp;
145 
146  // get the position of each station and calculate the distance from the shower plane
147  // distance to shower plane = (antenna position - core) * (axis)
148  const rdet::Station& dStation = rDetector.GetStation(*sIt);
149  const Vector vStationPosition = (dStation.GetPosition() - core);
150  const double distance = vStationPosition * axis;
151 
152  // convert the distance in a geometrical delay to shift the data
153  const TimeInterval geomDelay = distance / fSpeedOfLight;
154  fMessage.str("");
155  fMessage << "Distance of Station: "
156  << distance/meter
157  << " m; \t geom. Delay: "
158  << geomDelay/nanosecond
159  << " ns; \t TimeStampDelay: "
160  << timeStampDelay/nanosecond
161  << " ns";
162  if (fInfoLevel >= eDebug)
163  INFO(fMessage.str());
164 
165  const TimeInterval totalDelay = timeStampDelay + geomDelay;
166  }
167 
168  return eSuccess;
169  }
170 
171 
173  RdStationBeamFormer::Finish()
174  {
175  // Put any termination or cleanup code here.
176  // This method is called once at the end of the run.
177 
178  if (fInfoLevel >= eFinal)
179  INFO("RdStationBeamFormer::Finish()");
180 
181  return eSuccess;
182  }
183 
184  void
185  RdStationBeamFormer::timeShift(revt::Station& station,
186  const utl::TimeInterval& shift) const
187  {
188  // Get the frequency spectrum
190  station.GetStationFrequencySpectrum();
191 
192  // multiply phase gradient to each value of the spectrum
193  for (StationFrequencySpectrum::SizeType i = 0; i < spectrum.GetSize(); ++i)
194  spectrum[i] *=
195  exp(- complex<double>(0,1) * kTwoPi * station.GetFrequencyOfBin(i) * shift.GetInterval());
196  }
197 
198 
199 }
Branch GetTopBranch() const
Definition: Branch.cc:63
utl::Vector GetAxis() const
Returns vector of the shower axis.
Point object.
Definition: Point.h:32
StationFrequencySpectrum & GetStationFrequencySpectrum()
retrieve Station Frequency Spectrum (write access, only use this if you intend to change the data) ...
Report success to RunController.
Definition: VModule.h:62
Detector description interface for Station-related data.
double GetFrequencyOfBin(const StationFrequencySpectrum::SizeType bin) const
Get the frequency corresponding to a bin of the frequency spectrum.
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
bool HasRecShower() const
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
Interface class to access to the RD Reconstruction of a Shower.
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
StationIterator StationsEnd()
Definition: REvent.h:130
StationIterator StationsBegin()
Definition: REvent.h:128
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 fRefractionIndex
index of refraction used to calculate speed of light
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
Definition: REvent.h:125
bool HasREvent() const
ShowerRRecData & GetRRecShower()
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
Class representing a document branch.
Definition: Branch.h:107
class to hold data at the radio Station level.
std::vector< T >::size_type SizeType
Definition: Trace.h:58
constexpr double nanosecond
Definition: AugerUnits.h:143
bool HasRRecShower() const
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
constexpr double kTwoPi
Definition: MathConstants.h:27
int GetNumberOfStations() const
Get total number of stations in the event.
Definition: REvent.h:206
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
double GetInterval() const
Get the time interval as a double (in Auger base units)
Definition: TimeInterval.h:69
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
int fInfoLevel
xml settings: info level (verbosity)
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
Vector object.
Definition: Vector.h:30
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
double fSpeedOfLight
speed of light used for beam forming
int fWaveFront
wave front type used for beam forming

, generated on Tue Sep 26 2023.