source: trunk/MagicSoft/Mars/mbase/MTime.h@ 2194

Last change on this file since 2194 was 2150, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.3 KB
Line 
1#ifndef MARS_MTime
2#define MARS_MTime
3
4/////////////////////////////////////////////////////////////////////////////
5// //
6// MTime //
7// //
8// A generalized MARS time stamp //
9// //
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef MARS_MParContainer
13#include "MParContainer.h"
14#endif
15
16class MTime : public MParContainer
17{
18private:
19 UInt_t fTimeStamp[2]; // type of raw event which should be processed by this task
20 UInt_t fDuration; // time of validity
21
22 Byte_t fHour;
23 Byte_t fMin;
24 Byte_t fSec;
25 UInt_t fNanoSec;
26
27public:
28 MTime(const char *name=NULL, const char *title=NULL)
29 {
30 fName = name ? name : ClassName();
31 fTitle = title;
32
33 SetTime(0, 0);
34 }
35
36 MTime(UInt_t t1, UInt_t t0)
37 {
38 SetTime(t1, t0);
39 }
40
41 MTime(MTime& t)
42 {
43 fTimeStamp[0] = t.fTimeStamp[0];
44 fTimeStamp[1] = t.fTimeStamp[1];
45 fDuration = t.fDuration;
46 }
47
48 void operator=(MTime &t)
49 {
50 fTimeStamp[0] = t.fTimeStamp[0];
51 fTimeStamp[1] = t.fTimeStamp[1];
52 fDuration = t.fDuration;
53 }
54
55 ~MTime() {}
56
57 void Print(Option_t *t=NULL) const;
58
59 void SetTime(UInt_t t1, UInt_t t0)
60 {
61 fTimeStamp[0] = t1;
62 fTimeStamp[1] = t0;
63 }
64
65 void SetCT1Time(UInt_t t1, UInt_t t0)
66 {
67 // int isecs_since_midday; // seconds passed since midday before sunset (JD of run start)
68 // int isecfrac_200ns; // fractional part of isecs_since_midday
69 // fTime->SetTime(isecfrac_200ns, isecs_since_midday);
70 fNanoSec = 200*t1;
71 fSec = t0%60;
72 t0 /= 60;
73 fMin = t0%60;
74 t0 /= 60;
75 fHour = (t0+12)%24;
76 }
77
78 void SetTime(Byte_t h, Byte_t m, Byte_t s, UShort_t ns)
79 {
80 fHour = h;
81 fMin = m;
82 fSec = s;
83 fNanoSec = ns;
84 }
85
86 void SetDuration(UInt_t t)
87 {
88 fDuration = t;
89 }
90
91 MTime *GetTime()
92 {
93 return this;
94 }
95
96 UInt_t GetTimeLo()
97 {
98 return fTimeStamp[0];
99 }
100 UInt_t GetTimeHi()
101 {
102 return fTimeStamp[1];
103 }
104
105 UInt_t GetDuration()
106 {
107 return fDuration;
108 }
109
110 ClassDef(MTime, 1) //A generalized MARS time stamp
111};
112
113inline Double_t operator-(MTime &t1, MTime &t2)
114{
115 return (Double_t)t1.GetTimeLo()-(Double_t)t2.GetTimeLo();
116}
117
118inline Bool_t operator<(MTime &t1, MTime &t2)
119{
120 return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<t2.GetTimeLo());
121}
122
123inline Bool_t operator>(MTime &t1, MTime &t2)
124{
125 return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>t2.GetTimeLo());
126}
127
128inline Bool_t operator<=(MTime &t1, MTime &t2)
129{
130 return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<=t2.GetTimeLo());
131}
132
133inline Bool_t operator>=(MTime &t1, MTime &t2)
134{
135 return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>=t2.GetTimeLo());
136}
137
138inline Bool_t operator==(MTime &t1, MTime &t2)
139{
140 return (t1.GetTimeLo()==t2.GetTimeLo()) && (t1.GetTimeHi()==t2.GetTimeHi());
141}
142
143#endif
Note: See TracBrowser for help on using the repository browser.