3 #include <fwk/LocalCoordinateSystem.h>
4 #include <fwk/CentralConfig.h>
6 #include <det/VManager.h>
7 #include <rdet/RDetector.h>
9 #include <utl/ReadStream.h>
10 #include <utl/UTMPoint.h>
11 #include <utl/Point.h>
12 #include <utl/Vector.h>
13 #include <utl/PhysicalConstants.h>
14 #include <utl/UTCDateTime.h>
16 #include <evt/Event.h>
17 #include <revt/REvent.h>
18 #include <revt/Header.h>
19 #include <revt/StationRecData.h>
31 namespace RdStationPositionCorrectionOG {
68 Branch topB = CentralConfig::GetInstance()->
GetTopBranch(
"RdStationPositionCorrection");
70 fDistanceTolerance = topB.
GetChild(
"DistanceTolerance").
Get<
double>();
71 const double effectiveVerticalDelay = topB.
GetChild(
"EffectiveVerticalDelay").
Get<
double>();
72 const string rdStationGPSPositionsFile = topB.
GetChild(
"RdStationGPSPositionsFile").
Get<
string>();
79 ifstream posFile(rdStationGPSPositionsFile.c_str());
80 if (!posFile.is_open()) {
82 err <<
"Cannot open GPS positions file '" << rdStationGPSPositionsFile <<
"'!";
87 vector<KnownPositions> positions;
91 fValidityTimes.clear();
94 const char band =
'H';
98 for (
const auto& pos : positions) {
100 const unsigned int sId = pos.fStationId;
101 const UTM& usedpos = pos.fUsedPosition;
107 const UTM& truepos = pos.fTruePosition;
112 const double dt = (truePosition - usedPosition).GetZ(localCS) * effectiveVerticalDelay;
115 if (fOffsets.find(sId) != fOffsets.end()) {
117 err <<
"Duplicate entry for station id " << sId <<
" found in the positions file!";
123 fOffsets.emplace(sId, dt);
124 fValidityTimes.emplace(sId, pos.fCorrectionValidUntil.GetTimeStamp());
129 const double posDistance = (truePosition - detPosition).GetMag();
131 if (posDistance > fDistanceTolerance) {
133 err <<
"Distance of " << posDistance /
meter <<
" m between current station position in RDetector"
134 " and GPS corrections file for station id " << sId <<
" is too large!";
141 warn <<
"Station id " << sId <<
" has a GPS position in the corrections file but is not found in the RDetector!";
151 RdStationPositionCorrection::Run(
Event& event)
156 REvent& rEvent =
event.GetREvent();
158 for (
auto& station : rEvent.StationsRange()) {
159 if (!station.HasRecData())
166 err <<
"Trying to correct trace start time for station id " << station.GetId()
167 <<
", but no trace start time available in ParameterStorage!";
173 const auto offsetIt = fOffsets.find(station.GetId());
175 if (offsetIt == fOffsets.end())
183 recData.
SetParameter(eTraceStartTime, oldTime - offset,
false);
184 recData.
SetParameter(eTraceStartTimeCorrectionByGPSPosition, -offset);
196 RdStationPositionCorrection::Finish()
void operator>>(const Event &theEvent, IoSdEvent &rawSEvent)
Branch GetTopBranch() const
Class to access station level reconstructed data.
Detector description interface for Station-related data.
Interface class to access to the Radio part of an event.
Class to hold and convert a point in geodetic coordinates.
bool is(const double a, const double b)
void Init()
Initialise the registry.
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Detector description interface for RDetector-related data.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Reference ellipsoids for UTM transformations.
Header & GetHeader()
access to REvent Header
Top of the hierarchy of the detector description interface.
UTCDateTime fCorrectionValidUntil
#define WARNING(message)
Macro for logging warning messages.
double GetParameter(const Parameter i) const
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
bool HasParameter(const Parameter i) const
void SetParameter(Parameter i, double value, bool lock=true)
TimeStamp GetCurrentSystemTime()
get current time as reported by system
void GetLines(std::vector< T > &v, const bool filterComments=true, const bool trim=false)
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.