A TimeStamp holds GPS second and nanosecond for some event. More...
#include "utl/TimeStamp.h"
Public Member Functions | |
double | GetGPSNanoSecond () const |
GPS nanosecond. More... | |
unsigned long | GetGPSSecond () const |
GPS second. More... | |
operator bool () const | |
bool | operator!= (const TimeStamp &ts) const |
TimeStamp | operator+ (const TimeInterval &ti) const |
[TimeStamp] + [TimeInterval] = [TimeStamp] More... | |
TimeStamp & | operator+= (const TimeInterval &ti) |
[TimeStamp] += [TimeInterval] = [TimeStamp] More... | |
TimeInterval | operator- (const TimeStamp &ts) const |
[TimeStamp] - [TimeStamp] = [TimeInterval] More... | |
TimeStamp | operator- (const TimeInterval &ti) const |
[TimeStamp] - [TimeInterval] = [TimeStamp] More... | |
TimeStamp & | operator-= (const TimeInterval &ti) |
[TimeStamp] -= [TimeInterval] = [TimeStamp] More... | |
bool | operator< (const TimeStamp &ts) const |
bool | operator<= (const TimeStamp &ts) const |
bool | operator== (const TimeStamp &ts) const |
bool | operator> (const TimeStamp &ts) const |
bool | operator>= (const TimeStamp &ts) const |
void | SetGPSTime (const unsigned long sec, const double nsec=0) |
Set GPS second and (optionally) nanosecond. More... | |
TimeStamp () | |
TimeStamp (const long sec, const double nsec=0) | |
Construct from GPS second and nanosecond. More... | |
Static Public Member Functions | |
static TimeStamp | Max () |
Private Member Functions | |
void | SetNormalized (long sec, double nsec) |
Take care of positive nanosecond and GPS epoch. More... | |
Private Attributes | |
double | fGPSNanoSecond |
unsigned long | fGPSSecond |
A TimeStamp holds GPS second and nanosecond for some event.
This class holds a GPS second and nanosecond and provides methods to convert to seconds since Unix Epoch or to UTC, with proper accounting for leap seconds. Methods are also provided to return Modified Julian Date and formatted strings with UTC printout consistent with the conventions document, as well as strings of XML with date and time information.
A utl::TimeStamp represents the time of occurrence of some event. To represent time intervals between events, use the TimeInterval class. A number of arithmetic operations are defined between utl::TimeStamp and utl::TimeInterval. For example:
TimeStamp - TimeStamp = TimeInterval TimeStamp - TimeInterval = TimeStamp TimeStamp + TimeInterval = TimeStamp TimeInterval + TimeInterval = TimeInterval
What is time? This is a brief summary of time systems, relevant for the Auger project operation (see http://tycho.usno.navy.mil/gpstt.html for details).
International Atomic Time (TAI) is a statistical time scale based on a large number of atomic clocks operating at standards laboratories around the world. Its unit interval is exactly one SI second at sea level. Neglecting the relativistic effects, this is probably the time scale in which Auger physics is happening.
Universal Time (UT) (and its variant UT1) is a time scale with unit of duration the mean solar day. It is based on the Earth's rotation and thus important for transformation of events into the galactic coordinates. Otherwise, not very useful for physics.
Coordinated Universal Time (UTC) differs from TAI by an integral number of seconds. UTC is kept within 0.9 seconds of UT1 by the introduction of one-second steps to UTC, the leap seconds. In contrast to UT1, UTC is running in parallel to TAI with piecewise constant offset.
The utl::TimeStamp class will not allow you to initialize a TimeStamp using a unix time_t. You may wonder why this is, or wonder why we don't just use unix time for everything, since the c time library has functions already built in for converting unix seconds to UTC.
The reason is that, in a nutshell, unix time is broken. For some reason the POSIX standard requires the time_t to count seconds since Unix epoch not including leap seconds. This means calculating time intervals by subtracting unix times across a leap second will give the wrong result. Furthermore, initializing a TimeStamp with a time_t at the leap second boundary would be ambiguous; there are two GPS seconds corresponding to the unix second at the time of the leap second. It may seem that this would only rarely pose a problem, but on the other hand it is not particularly difficult to just do it correctly.
Definition at line 110 of file TimeStamp.h.
|
inline |
Definition at line 113 of file TimeStamp.h.
Referenced by Max(), operator+(), and operator-().
|
inline |
Construct from GPS second and nanosecond.
Definition at line 116 of file TimeStamp.h.
References SetNormalized().
|
inline |
GPS nanosecond.
Definition at line 127 of file TimeStamp.h.
References fGPSNanoSecond.
Referenced by RdAirplane::Util::ApproximatedGPSTimeStampFromTimestamp(), CentralTriggerEventBuilderNS::CentralTriggerEventBuilder::BuildEvent(), FdLightCollectionEfficiencyKG::FdLightCollectionEfficiency::CalculateTelescopeEfficiency(), io::cevtStation_ROOT::cevtStation_ROOT(), FdAxisFinderOG::FdAxisFinder::CheckForLasers(), evt::ConvertEventToEr(), evt::ConvertEventToIoSd(), RdREASSimPreparatorNG::RdREASSimPreparatorNG::CreateCoREASContent(), RdZHAireSSimPreparator::RdZHAireSSimPreparator::CreateFiles(), SdRecPlotterOG::SdRecPlotter::DrawEvent(), RdEVASimPreparator::RdEVASimPreparator::EVAFileWriter(), otoa::FD2ADST::FillEyeHeader(), otoa::FD2ADST::FillFdCoreAxis(), otoa::FD2ADST::FillFdRecStations(), otoa::RdFiller::FillRadioEventInfo(), otoa::MD2ADST::FillRecShower(), StereoGeometryFinderOG::StereoGeometryFinder::FindAxisStereo(), StereoGeometryFinderOG::StereoGeometryFinder::FindAxisStereoHybrid(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::GetNoiseFileName(), FdTriggerSimulatorOG::FdTriggerSimulator::MakeMirrorEvent(), HdAxisFinderUU::HdAxisFinder::MinuitFitFunc(), HybridGeometryFinderOG::HybridGeometryFinder::MinuitFitFuncHybrid(), StereoGeometryFinderOG::StereoGeometryFinder::MinuitFitFuncStereo(), StereoGeometryFinderOG::StereoGeometryFinder::MinuitFitFuncStereoHybrid(), utl::operator<<(), UnivFitterKG::Fitter::printResults(), io::ZHAireSFile::Read(), RdREASSimPreparator::RdREASSimPreparator::REASFileWriter(), SdMonteCarloPropagatorKVI::SdMonteCarloPropagator::Run(), RdREASSimPreparator::RdREASSimPreparator::Run(), RdCOREASSimulationCreator::RdCOREASSimulationCreator::Run(), UnderGrdInjectorAG::UnderGrdInjector::Run(), Validatrix::Validatrix::Run(), io::TimeStamp_ROOT::Set(), TestTime::TestArithmetic(), TestTime::TestTimeStampInitialization(), utl::UTCDateTime::UTCDateTime(), utlPython(), and RdChannelBeaconTimingCalibrator::RdChannelBeaconTimingCalibrator::writeDebugFile().
|
inline |
GPS second.
Definition at line 124 of file TimeStamp.h.
References fGPSSecond.
Referenced by FdTriggerSimulatorOG::FdTriggerSimulator::AddEyeEvent(), RdAirplane::Util::ApproximatedGPSTimeStampFromTimestamp(), rdet::MonitoringSQLManager::BufferTemperature(), CentralTriggerEventBuilderNS::CentralTriggerEventBuilder::BuildEvent(), io::cevtStation_ROOT::cevtStation_ROOT(), evt::ConvertEventToIoSd(), RdREASSimPreparatorNG::RdREASSimPreparatorNG::CreateCoREASContent(), RdZHAireSSimPreparator::RdZHAireSSimPreparator::CreateFiles(), SdRecPlotterOG::SdRecPlotter::DrawEvent(), FdSimEventCheckerOG::FdSimEventChecker::DumpDB(), RdEVASimPreparator::RdEVASimPreparator::EVAFileWriter(), otoa::Detector2ADST::FillDetector(), otoa::FD2ADST::FillEyeHeader(), otoa::FD2ADST::FillFdCoreAxis(), otoa::RdFiller::FillRadioEventInfo(), otoa::MD2ADST::FillRecShower(), FdCalibratorOG::FdCalibrator::FillTriggerData(), rdet::RBadStationSQLManager::GetBadPeriodFromBuffer(), SdSimpleSimKG::SdSimpleSim::GetCDASTriggerTimeWindow(), rdet::RChannelSQLManager::GetChannelListFromBuffer(), rdet::RChannelSQLManager::GetComponentFromBuffer(), atm::AGOESSQLManager::GetDBResFundamental(), atm::ALidarSQLManager::GetDBResFundamental(), atm::ACloudSQLManager::GetDBResFundamental(), atm::AOverallQualitySQLManager::GetDBResFundamental(), atm::AAerosolSQLManager::GetDBResFundamental(), atm::AMolecularSQLManager::GetDBResFundamental(), atm::AMolecularSQLManager::GetDBResVector(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::GetNoiseFileName(), fdet::FParametricOpticalEfficiencyLossManager::GetOpticalEfficiencyCorrectionForTelescope(), fdet::FOpticalEfficiencyLossSQLManager::GetOpticalEfficiencyCorrectionForTelescope(), fdet::FdAlwaysUpManager::GetStatus(), rdet::MonitoringSQLManager::GetTemperature(), fdet::FCalibSQLManager::GetWorkingCalibId(), RdStationNoiseAnalyser::Init(), UniversalityFitter::UniversalityFitter::InitBarilocheReconstruction(), FdTriggerSimulatorOG::FdTriggerSimulator::MakeMirrorEvent(), HybridGeometryFinderOG::HybridGeometryFinder::MinuitFitFuncHybrid(), utl::ModifiedJulianDate(), io::operator<<(), utl::operator<<(), UnivFitterKG::Fitter::printResults(), io::ZHAireSFile::Read(), RdREASSimPreparator::RdREASSimPreparator::REASFileWriter(), SdInspectorOG::SdInspector::Run(), RdStationSimPulseFinder::RdStationSimPulseFinder::Run(), RdChannelDebugWriter::RdChannelDebugWriter::Run(), SdMonteCarloPropagatorKVI::SdMonteCarloPropagator::Run(), RdEventPreSelector::RdEventPreSelector::Run(), RdEventInitializer::RdEventInitializer::Run(), RdREASSimPreparator::RdREASSimPreparator::Run(), RdStationNoiseAnalyser::Run(), RdCOREASSimulationCreator::RdCOREASSimulationCreator::Run(), RdEventMerger::RdEventMerger::Run(), RdGalacticDatasetMaker::RdGalacticDatasetMaker::Run(), RdChannelNoisePulseCounter::RdChannelNoisePulseCounter::Run(), UnderGrdInjectorAG::UnderGrdInjector::Run(), RdMonitoring::RdMonitoring::Run(), RdChannelNoisePowerAnalyser::RdChannelNoisePowerAnalyser::Run(), Validatrix::Validatrix::Run(), io::TimeStamp_ROOT::Set(), un2::SimpleReco(), TestTime::TestConversions3(), TestTime::TestConversions5(), TestTime::TestTimeStampInitialization(), utl::UTCDateTime::UTCDateTime(), utlPython(), RdChannelBeaconTimingCalibrator::RdChannelBeaconTimingCalibrator::writeDebugFile(), and RdGlobalFit::RdGlobalFit::XmaxFromRmax().
|
inlinestatic |
Definition at line 177 of file TimeStamp.h.
References TimeStamp().
Referenced by TestTime::TestTimeConsistency().
|
inlineexplicit |
Definition at line 175 of file TimeStamp.h.
References fGPSNanoSecond, and fGPSSecond.
|
inline |
Definition at line 156 of file TimeStamp.h.
References operator==().
|
inline |
[TimeStamp] + [TimeInterval] = [TimeStamp]
Definition at line 210 of file TimeStamp.h.
References fGPSNanoSecond, fGPSSecond, utl::TimeInterval::GetNanoSecond(), utl::TimeInterval::GetSecond(), and TimeStamp().
|
inline |
[TimeStamp] += [TimeInterval] = [TimeStamp]
Definition at line 222 of file TimeStamp.h.
References fGPSNanoSecond, fGPSSecond, utl::TimeInterval::GetNanoSecond(), utl::TimeInterval::GetSecond(), and SetNormalized().
|
inline |
[TimeStamp] - [TimeStamp] = [TimeInterval]
Definition at line 232 of file TimeStamp.h.
References fGPSNanoSecond, fGPSSecond, utl::nanosecond, and utl::second.
|
inline |
[TimeStamp] - [TimeInterval] = [TimeStamp]
Definition at line 245 of file TimeStamp.h.
References fGPSNanoSecond, fGPSSecond, utl::TimeInterval::GetNanoSecond(), utl::TimeInterval::GetSecond(), and TimeStamp().
|
inline |
[TimeStamp] -= [TimeInterval] = [TimeStamp]
Definition at line 257 of file TimeStamp.h.
References fGPSNanoSecond, fGPSSecond, utl::TimeInterval::GetNanoSecond(), utl::TimeInterval::GetSecond(), and SetNormalized().
|
inline |
Definition at line 167 of file TimeStamp.h.
References fGPSNanoSecond, and fGPSSecond.
Referenced by operator>=().
|
inline |
Definition at line 172 of file TimeStamp.h.
References operator>().
|
inline |
Definition at line 152 of file TimeStamp.h.
References fGPSNanoSecond, and fGPSSecond.
Referenced by operator!=().
|
inline |
Definition at line 159 of file TimeStamp.h.
References fGPSNanoSecond, and fGPSSecond.
Referenced by operator<=().
|
inline |
Definition at line 164 of file TimeStamp.h.
References operator<().
|
inline |
Set GPS second and (optionally) nanosecond.
Definition at line 120 of file TimeStamp.h.
References SetNormalized().
Referenced by io::RadioFileAERA::Read(), io::IoAugerEventFile::Read(), io::RadioFileAERAroot::Read(), Parser::ReadStrToTime(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::Run(), and TestTime::TestArithmetic().
|
private |
Take care of positive nanosecond and GPS epoch.
Definition at line 15 of file TimeStamp.cc.
References ERROR, utl::nanosecond, and galactic::second.
Referenced by operator+=(), operator-=(), SetGPSTime(), and TimeStamp().
|
private |
Definition at line 183 of file TimeStamp.h.
Referenced by GetGPSNanoSecond(), operator bool(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator==(), and operator>().
|
private |
Definition at line 182 of file TimeStamp.h.
Referenced by GetGPSSecond(), operator bool(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator==(), and operator>().