]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliTimestamp.h
Fix Coverity 15062, 15063
[u/mrichter/AliRoot.git] / RALICE / AliTimestamp.h
1 #ifndef ALITIMESTAMP_H
2 #define ALITIMESTAMP_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 // $Id$
7
8 #include <math.h>
9
10 #include "TTimeStamp.h"
11 #include "TString.h"
12
13 class AliTimestamp : public TTimeStamp
14 {
15  public:
16   AliTimestamp();                               // Default constructor
17   AliTimestamp(TTimeStamp& t);                  // Constructor
18   virtual ~AliTimestamp();                      // Destructor
19   AliTimestamp(const AliTimestamp& t);          // Copy constructor
20   void Date(Int_t mode=3,Double_t offset=0);    // Print date/time info
21   Double_t GetJD(Int_t y,Int_t m,Int_t d,Int_t hh,Int_t mm,Int_t ss,Int_t ns) const; // Julian Date from input args.
22   Double_t GetMJD(Int_t y,Int_t m,Int_t d,Int_t hh,Int_t mm,Int_t ss,Int_t ns) const;// Modified JD from input args.
23   Double_t GetTJD(Int_t y,Int_t m,Int_t d,Int_t hh,Int_t mm,Int_t ss,Int_t ns) const;// Truncated JD from input args.
24   Double_t GetJE(Double_t date,TString mode="jd") const; // Julian Epoch corresponding to specified Julian Date
25   Double_t GetBE(Double_t date,TString mode="jd") const; // Besselian Epoch corresponding to specified Julian Date
26   void Convert(Double_t date,Int_t& days,Int_t& secs,Int_t& ns) const;// Convert frac. day count into days, secs and ns 
27   Double_t Convert(Int_t days,Int_t secs,Int_t ns) const;             // Convert days, secs and ns into frac. day count
28   void Convert(Double_t h,Int_t& hh,Int_t& mm,Int_t& ss,Int_t& ns,Int_t& ps) const;// Convert frac. hour count
29   Double_t Convert(Int_t hh,Int_t mm,Int_t ss,Int_t ns,Int_t ps) const; // Convert hh:mm:ss:ns:ps into frac. hour
30   void Convert(Double_t h,Int_t& hh,Int_t& mm,Double_t& ss) const;// Convert frac. hour count
31   Double_t Convert(Int_t hh,Int_t mm,Double_t ss) const;          // Convert hh:mm:ss.s into frac. hours
32   void PrintTime(Double_t h,Int_t ndig=1) const;// Print time in hh:mm:ss.sss format
33   void GetMJD(Int_t& mjd,Int_t& sec,Int_t& ns); // Provide corresponding Modified Julian Date and time
34   Double_t GetMJD();                            // Provide corresponding Modified Julian Date in fractional days
35   void GetTJD(Int_t& mjd,Int_t& sec,Int_t& ns); // Provide corresponding Truncated Julian Date and time
36   Double_t GetTJD();                            // Provide corresponding Truncated Julian Date in fractional days
37   void GetJD(Int_t& jd,Int_t& sec,Int_t& ns);   // Provide corresponding Julian Date and time
38   Double_t GetJD();                             // Provide corresponding Julian Date in fractional days
39   Double_t GetJE();                             // Provide corresponding Julian Epoch
40   Double_t GetBE();                             // Provide corresponding Besselian Epoch
41   Double_t GetJD(Double_t e,TString mode="J") const;  // Provide fractional Julian Date from Epoch
42   Double_t GetMJD(Double_t e,TString mode="J") const; // Provide fractional Modified Julian Date from Epoch
43   Double_t GetTJD(Double_t e,TString mode="J") const; // Provide fractional Truncated Julian Date from Epoch
44   void SetMJD(Int_t mjd,Int_t sec,Int_t ns,Int_t ps=0); // Set Modified Julian Date and time
45   void SetMJD(Double_t mjd);                            // Set Modified Julian Date and time
46   void SetJD(Int_t jd,Int_t sec,Int_t ns,Int_t ps=0);   // Set Julian Date and time
47   void SetJD(Double_t jd);                              // Set Julian Date and time
48   void SetTJD(Int_t tjd,Int_t sec,Int_t ns,Int_t ps=0); // Set Truncated Julian Date and time
49   void SetTJD(Double_t tjd);                            // Set Truncated Julian Date and time
50   void SetNs(Int_t ns);                                 // Set the remaining fractional number of sec in nanoseconds
51   Int_t GetNs() const;                                  // Provide remaining fractional number of sec in nanoseconds
52   void SetPs(Int_t ps);                                 // Set the remaining fractional number of ns in picoseconds
53   Int_t GetPs() const;                                  // Provide remaining fractional number of ns in picoseconds
54   using TTimeStamp::Add;
55   void Add(Int_t d,Int_t s,Int_t ns,Int_t ps=0);        // Add (or subtract) a certain time difference
56   void Add(Double_t hours);                             // Add (or subtract) a certain time difference
57   Int_t GetDifference(AliTimestamp* t,Int_t& days,Int_t& sec,Int_t& ns,Int_t& ps); // Provide time difference
58   Int_t GetDifference(AliTimestamp& t,Int_t& days,Int_t& sec,Int_t& ns,Int_t& ps); // Provide time difference
59   Double_t GetDifference(AliTimestamp* t,TString u,Int_t mode=1); // Provide time diff. in specified units
60   Double_t GetDifference(AliTimestamp& t,TString u,Int_t mode=1); // Provide time diff. in specified units
61   void SetUT(Int_t y,Int_t m,Int_t d,Int_t hh,Int_t mm,Int_t ss,Int_t ns=0,Int_t ps=0); // Set specified UT
62   void SetUT(Int_t y,Int_t d,Int_t s,Int_t ns=0,Int_t ps=0); // Set UT based on elapsed days, secs etc...
63   void GetUT(Int_t& hh,Int_t& mm,Int_t& ss,Int_t& ns,Int_t& ps); // Provide corresponding UT
64   Double_t GetUT(); // Provide corresponding UT in fractional hours
65   void GetGMST(Int_t& hh,Int_t& mm,Int_t& ss,Int_t& ns,Int_t& ps); // Corresponding Greenwich Mean Sidereal Time (GMST)
66   Double_t GetGMST(); // Provide corresponding Greenwich Mean Sidereal Time (GMST) in fractional hours
67   Double_t GetGAST(); // Provide corresponding Greenwich Apparent Sidereal Time (GAST) in fractional hours
68   Double_t GetLT(Double_t offset);  // Provide corresponding Local Time (LT) in fractional hours
69   Double_t GetLMST(Double_t offset); // Provide corresponding Local Mean Sidereal Time (LMST) in fractional hours
70   Double_t GetLAST(Double_t offset); // Provide corresponding Local Apparent Sidereal Time (LAST) in fractional hours
71   void SetLT(Double_t dt,Int_t y,Int_t m,Int_t d,Int_t hh,Int_t mm,Int_t ss,Int_t ns=0,Int_t ps=0); // Set data according to LT
72   void SetLT(Double_t dt,Int_t y,Int_t d,Int_t s,Int_t ns=0,Int_t ps=0); // Set data according to LT based on elapsed days, secs etc...
73   Double_t Almanac(Double_t* dpsi=0,Double_t* deps=0,Double_t* eps=0); // Provide astronomical observables
74   void SetEpoch(Double_t e,TString mode); // Set time parameters according to the specified epoch
75   Double_t GetEpoch(TString mode);        // Provide the requested epoch
76
77  protected:
78   Int_t fMJD;  // Modified Julian Date
79   Int_t fJsec; // Number of seconds elapsed within the MJD
80   Int_t fJns;  // Remaining fractional number of seconds (in nanoseconds) elapsed within the MJD
81   Int_t fJps;  // Remaining fractional number of nanoseconds (in picoseconds) elapsed within the MJD
82
83  private:
84   void FillJulian(); // Calculation and setting of the corresponding Julian parameters  
85   Int_t fCalcs;      // The TTimeStamp seconds counter value at Julian parameter calculation
86   Int_t fCalcns;     // The TTimeStamp nanoseconds counter value at Julian parameter calculation
87
88  ClassDef(AliTimestamp,11) // Handling of timestamps for (astro)particle physics research.
89 };
90 #endif