2 #include <fwk/VModule.h>
3 #include <fwk/CoordinateSystemRegistry.h>
4 #include <fwk/CentralConfig.h>
5 #include <utl/ErrorLogger.h>
8 #include <revt/REvent.h>
9 #include <revt/Header.h>
10 #include <revt/Station.h>
11 #include <revt/Channel.h>
12 #include <revt/StationRecData.h>
14 #include <det/Detector.h>
15 #include <rdet/RDetector.h>
16 #include <rdet/Station.h>
18 #include <utl/Trace.h>
19 #include <utl/TraceAlgorithm.h>
20 #include <utl/ErrorLogger.h>
21 #include <utl/Reader.h>
22 #include <utl/config.h>
23 #include <utl/AugerUnits.h>
24 #include <utl/MathConstants.h>
25 #include <utl/PhysicalConstants.h>
26 #include <utl/TimeStamp.h>
27 #include <utl/TimeInterval.h>
28 #include <utl/FFTDataContainerAlgorithm.h>
29 #include <utl/AugerException.h>
30 #include <utl/CoordinateSystem.h>
31 #include <utl/Point.h>
32 #include <utl/Vector.h>
59 fReferenceAntennaID(145),
65 fEllipsoidName(
"WGS84")
78 INFO(
"RdTimeCalibration::Init()");
82 CentralConfig::GetInstance()->
GetTopBranch(
"RdTimeCalibration");
84 if (fInfoLevel < eNone || fInfoLevel >
eDebug) {
85 ERROR(
"<infoLevel> out of bounds");
96 WARNING(
"Incorrect choice of position: One or more coordinates are missing!");
106 const UTMPoint utmPosSource(posSource, ellipsoid);
107 ostringstream message;
108 message <<
"Position of source in UTM: "
109 "Easting " << utmPosSource.
GetEasting() <<
", "
122 INFO(
"RdTimeCalibration::Run()");
123 ostringstream message;
127 WARNING(
"RdTimeCalibration::No radio event found!");
131 REvent& rEvent =
event.GetREvent();
135 WARNING(
"RdTimeCalibration::Reference Antenne is not in this event!");
147 INFO(
"Entering branch for 'first run'.");
154 const double referenceDelay = (position - sourcePosition).GetMag() /
speedOfLight;
161 const Point position = rdIt->GetPosition();
163 vector<double> distanceDelayRelativeDelay;
164 distanceDelayRelativeDelay.reserve(3);
165 distanceDelayRelativeDelay.push_back((position - sourcePosition).GetMag());
166 distanceDelayRelativeDelay.push_back(distanceDelayRelativeDelay[0] /
speedOfLight);
167 distanceDelayRelativeDelay.push_back(distanceDelayRelativeDelay[1] - referenceDelay);
178 map<int, double> constTimeOffset;
185 const unsigned int sumIndex[2] = { (
unsigned int)((0.5 - 0.15)*referenceSampleLength), (
unsigned int)((0.5 + 0.15)*referenceSampleLength) };
188 INFO(
"Iterating over stations");
201 for (Station::ConstChannelIterator cIt = station.
ChannelsBegin();
219 double offsetOfMax = 0;
225 if ((offsetStop + sumIndex[1]) >= timeSeries.
GetSize()) {
228 message <<
"Trace of station " << station.
GetId() <<
" has only "
229 << timeSeries.
GetSize() <<
" samples, but a mimimum of "
230 << offsetStop + sumIndex[1] + 1 <<
" samples required - station rejected!";
235 if ((offsetStart < 0) && (
std::abs(offsetStart) > sumIndex[0])) {
236 ERROR(
"Trace to short!");
240 for (
int offset = offsetStart; offset <= offsetStop; ++offset) {
244 for (
unsigned int j = sumIndex[0]; j <= sumIndex[1]; ++j) {
245 cc += timeSeriesRef[j] * timeSeries[
std::abs(
int(j) + offset)];
253 offset > offsetStart + round(1100.0 / binSize) &&
254 offset < offsetStop - round(1100.0 / binSize)) {
258 offsetOfMax = offset * binSize;
285 message <<
"Shifted trace start time of Station " << station.
GetId() <<
" by "
286 << constTimeOffset[station.
GetId()] <<
" ns";
296 RdTimeCalibration::Finish()
301 INFO(
"RdTimeCalibration::Finish()");
312 INFO(
"Matching station time stamps");
315 const double firstTimeStamp = rEvent.
CandidateStationsBegin()->GetRecData().GetParameter(eTraceStartTime);
323 if (stationTimeStamp != firstTimeStamp) {
329 FFTDataContainerAlgorithm::ShiftTimeSeries(channel.
GetFFTDataContainer(), stationTimeStamp-firstTimeStamp);
ChannelFFTDataContainer & GetFFTDataContainer()
retrieve Channel FFTDataContainer (write access)
Branch GetTopBranch() const
boost::transform_iterator< InternalStationFunctor, InternalStationIterator, const Station & > StationIterator
StationIterator returns a pointer to a station.
boost::filter_iterator< CandidateStationFilter, AllStationIterator > CandidateStationIterator
Iterator over all CandidateStations (i.e., HasSignal, HasNoSignal)
int GetId() const
Return Id of the Channel.
Report success to RunController.
Detector description interface for Station-related data.
StationRecData & GetRecData()
Get station level reconstructed data.
CandidateStationIterator CandidateStationsEnd()
Interface class to access to the Radio part of an event.
Class to hold and convert a point in geodetic coordinates.
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
Skip remaining modules in the current loop and continue with next iteration of the loop...
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
double GetBinning() const
size of one slot
#define INFO(message)
Macro for logging informational messages.
const double speedOfLight
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
ChannelIterator ChannelsBegin()
begin Channel iterator for read/write
std::string fEllipsoidName
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
double GetNorthing() const
Get the northing.
ChannelTimeSeries & GetChannelTimeSeries()
retrieve Channel Time Series (write access, only use this if you intend to change the data) ...
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
Detector description interface for RDetector-related data.
void MatchStationTimeStamps(revt::REvent &) const
int fReferenceChannel
Reference channel (ususally 1 = NS, high gain)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Break current loop. It works for nested loops too!
class to hold data at the radio Station level.
double GetHeight() const
Get the height.
std::vector< double >::size_type SizeType
double abs(const SVector< n, T > &v)
bool fFirstRun
flag, that the expectation is calculated just once
Top of the hierarchy of the detector description interface.
std::map< int, std::vector< double > > fRunTimeExpectation
map of the expected runtime
double GetEasting() const
Get the easting.
CandidateStationIterator CandidateStationsBegin()
int fReferenceAntennaID
Reference Antenna (ususally 113)
bool fAdjustTime
adjust time yes or no (usually no = 0)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
int GetId() const
Get the station Id.
double GetParameter(const Parameter i) const
Channel & GetChannel(const int pmtId)
Retrieve a Channel by Id.
constexpr double kSpeedOfLight
ResultFlag
Flag returned by module methods to the RunController.
std::vector< double > fSourcePosition
Postion of the calibration source.
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
void SetParameter(Parameter i, double value, bool lock=true)
Class that holds the data associated to an individual radio channel.
Report failure to RunController, causing RunController to terminate execution.
const rdet::RDetector & GetRDetector() const
bool HasStation(const int stationId) const
Check whether station exists.
EllipsoidID
ID's of known reference ellipsoid's.
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
int fInfoLevel
xml settings: info level (verbosity)
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.