RdAirplaneTiming.cc
Go to the documentation of this file.
1 #include "RdAirplaneTiming.h"
2 #include "AirplaneUtil.h"
3 #include "Ads_bDataBase.h"
4 #include "Airplane.h"
5 #include "Flight.h"
6 #include "DataWriter.h"
7 #include "PulseInfoWriter.h"
8 
9 using namespace evt;
10 using namespace revt;
11 using namespace std;
12 using namespace utl;
13 using namespace fwk;
14 using namespace RdAirplane;
15 using namespace boost;
16 namespace fs = filesystem;
17 
18 RdAirplaneTiming::RdAirplaneTiming() :
19  _maxAngleBetweenAirplaneAndEventInRadians_(0),
20  _ads_bAntennaPosition_(),
21  _ads_bDataBase_(NULL),
22  _dataWriter_(NULL) {}
23 
25  delete _dataWriter_;
26 }
27 
29 
30  _globalCoordinateSystem_ = det::Detector::GetInstance().GetReferenceCoordinateSystem();
31  string outputDirectory;
32  // for debugging: true -> for every airplane some information is streamed to the console
33  bool shouldPrintAirplaneInfo = false;
34 
35  CentralConfig* centralConfig = CentralConfig::GetInstance();
36  Branch timingTopBranch = centralConfig->GetTopBranch("RdAirplaneTiming");
37  timingTopBranch.GetChild("OutputDirectoy").GetData(outputDirectory);
38  timingTopBranch.GetChild("MaxAngleBetweenAirplaneAndEvent").GetData(_maxAngleBetweenAirplaneAndEventInRadians_);
39 
41  _dataWriter_ = new DataWriter(outputDirectory, _globalCoordinateSystem_);
42 
43  // Check the configuration of the RdWaveFitModule. This is necessary to have consistent coordinate system origins.
44  // This way we know how to interpret eShowerAxisX, eShowerAxisY and eShowerAxisZ.
45  string usedCorePositionForReconstruction;
46  CentralConfig::GetInstance()->GetTopBranch("RdWaveFit").GetChild("UsedCorePosition").GetData(usedCorePositionForReconstruction);
47  if(usedCorePositionForReconstruction!="RadioCoordinateOrigin") {
48  ERROR("The parameter 'UsedCorePosition' of the 'RdWaveFit'-Module must be set to 'RadioCoordinateOrigin' to have consistent coordinate systems.");
49  return eFailure;
50  }
51 
52  INFO("The max. allowed angle between the reconstructed and the real airplane position in radians is "+ lexical_cast<string>(_maxAngleBetweenAirplaneAndEventInRadians_));
53 
54  // see diploma thesis by A. Lang
55  _ads_bAntennaPosition_=UTMPoint(-35.108397*degree, -69.533337*degree, 1560.63*meter, ReferenceEllipsoid::eWGS84).GetPoint(_globalCoordinateSystem_);
56  INFO(
57  "The ADS-B antenna is at ("+
58  lexical_cast<string>(_ads_bAntennaPosition_.GetX(_globalCoordinateSystem_))+", " +
59  lexical_cast<string>(_ads_bAntennaPosition_.GetY(_globalCoordinateSystem_))+", " +
61  ") in the global coordinate system."
62  );
63 
64  //reading the ADS-B data that is grouped by airplane and by flight over the AERA field
66 
67  INFO("Assuming a time shift of the capture time of the ADS-B signal and the real position measurement on the airplane of " + lexical_cast<string>(_ads_bDataBase_->getTimeShift().GetInterval()/ms) + "ms.");
68 
69  if(shouldPrintAirplaneInfo)
71 
72  return eSuccess;
73 }
74 
75 
77 
78  string eventIdAsString = event.GetHeader().GetId();
79  INFO("Processing event " + eventIdAsString);
80 
81  if(!event.HasREvent())
82  return eContinueLoop;
83 
84  REvent& rEvent = event.GetREvent();
85  const det::Detector& detector = det::Detector::GetInstance();
86  const rdet::RDetector& radioDetector = detector.GetRDetector();
87  const TimeStamp& eventTime = event.GetHeader().GetTime();
88 
89  const ShowerRRecData& showerRRecData = event.GetRecShower().GetRRecShower();
90  if(!(showerRRecData.HasParameter(eShowerAxisX) &&
91  showerRRecData.HasParameter(eShowerAxisY) &&
92  showerRRecData.HasParameter(eShowerAxisZ) &&
93  showerRRecData.HasParameter(eCoreX) &&
94  showerRRecData.HasParameter(eCoreY) &&
95  showerRRecData.HasParameter(eCoreZ))) {
96 
97  INFO("Radio event was not successfully reconstructed.");
98  return eContinueLoop;
99  }
100 
101  CoordinateSystemPtr coreCoordinateSystem = LocalCoordinateSystem::Create(showerRRecData.GetCorePosition());
102 
103  Point reconstructedRadioEventOrigin(showerRRecData.GetParameter(eShowerAxisX),
104  showerRRecData.GetParameter(eShowerAxisY),
105  showerRRecData.GetParameter(eShowerAxisZ),
106  coreCoordinateSystem);
107 
108 
109  // find the airplanes near the event origin
110  // the returned list is sorted by the distance to the reconstructed event source
112  eventTime,
113  reconstructedRadioEventOrigin,
115  coreCoordinateSystem);
116 
117  if(flightCandidates.empty()) {
118  INFO("No airplane corresponds this event.");
119  return eContinueLoop;
120  }
121 
122  if(flightCandidates.size()>1) {
123  WARNING("Multiple airplanes correspond this event. Using closest one to the reconstructed position.");
124  }
125 
126  INFO("Association of an airplane with this event was successful.");
127 
128  const Flight& flight = *flightCandidates.begin()->getFlight();
129  Point coreCoordinateSystemOrigin(0, 0, 0, coreCoordinateSystem);
130 
131  // memory is managed by the dataWriter
132  PulseInfoWriter* pulseInfoWriter = _dataWriter_->registerEvent(
133  event,
134  flight,
135  reconstructedRadioEventOrigin,
136  coreCoordinateSystem);
137 
138  for(REvent::CandidateStationIterator stationsIter = rEvent.CandidateStationsBegin(); stationsIter != rEvent.CandidateStationsEnd(); ++stationsIter) {
139  const Station& station = *stationsIter;
140 
141  if(!station.GetRecData().GetPulseFound() || station.GetRejectionStatus() != 0) {
142  continue;
143  }
144 
145  const rdet::Station& radioStation = radioDetector.GetStation(station);
146  _dataWriter_->registerStationInfo(radioStation);
147  pulseInfoWriter->writePulseInfo(station, radioStation);
148  }
149  return eSuccess;
150 }
151 
152 
155  return eFailure;
156  return eSuccess;
157 }
158 
159 
bool HasParameter(const Parameter i) const
const double degree
Point object.
Definition: Point.h:32
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
Detector description interface for Station-related data.
std::list< FlightAndPositionPair > FlightsAndCoordinatesList
Definition: Ads_bDataBase.h:34
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
Class to hold and convert a point in geodetic coordinates.
Definition: UTMPoint.h:40
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 utl::TimeInterval & getTimeShift() const
Definition: Ads_bDataBase.h:68
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
bool writePulseInfo(const revt::Station &pStation, const rdet::Station &pRadioStation)
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
bool HasREvent() const
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
constexpr double ms
Definition: AugerUnits.h:164
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
class to hold data at the radio Station level.
utl::CoordinateSystemPtr _globalCoordinateSystem_
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
CandidateStationIterator CandidateStationsBegin()
Definition: REvent.h:144
#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
FlightsAndCoordinatesList getFlights(const utl::TimeStamp &pTime, const utl::Point &pReconstructedEventPosition, const double &pMaxAngleDifferenceInRadian, utl::CoordinateSystemPtr pCoreCoordinateSystem)
double GetInterval() const
Get the time interval as a double (in Auger base units)
Definition: TimeInterval.h:69
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
std::string getInformations() const
PulseInfoWriter * registerEvent(evt::Event &pEvent, const Flight &pFlight, const utl::Point &pReconstructedRadioEventOrigin, utl::CoordinateSystemPtr pCoreCoordinateSystem)
static Ads_bDataBase * getSharedDataBase()
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
Main configuration utility.
Definition: CentralConfig.h:51
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
double GetParameter(const Parameter i) const
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
Definition: UTMPoint.cc:45
#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
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)

, generated on Tue Sep 26 2023.