Moving the classes that belong to the following libraries: STEERBase, ESD, CDB, AOD...
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliTimeStamp.cxx
CommitLineData
d7dd8a54 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id: AliTimeStamp.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
17
18///////////////////////////////////////////////////////////////////////////////
19//
20// Class to define Event Timestamp from :
21//
22// Orbit
23// Period counter
24// Seconds |
25// + | <===> Bunch cross
26// Microsecs |
27//
28//////////////////////////////////////////////////////////////////////////////
29
30#include <Riostream.h>
31
32
33#include "TObject.h"
34
35#include "AliLog.h"
36#include "AliTimeStamp.h"
37
38ClassImp(AliTimeStamp)
39
40//_____________________________________________________________________________
41
42const Int_t AliTimeStamp::fNanosecPerBC = 25; // nanosecs per bunch cross
43
44//_____________________________________________________________________________
45AliTimeStamp::AliTimeStamp():
46 fOrbit(0),
47 fPeriod(0),
48 fBunchCross(0)
49{
54654472 50 // Default constructor
d7dd8a54 51}
52
53//_____________________________________________________________________________
54AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period,
55 ULong64_t bunchcross ):
56 fOrbit(orbit),
57 fPeriod(period),
58 fBunchCross( bunchcross )
59{
60}
61//_____________________________________________________________________________
62AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period,
63 UInt_t seconds, UInt_t microsecs):
64 fOrbit(orbit),
65 fPeriod(period),
66 fBunchCross( (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5) )
67{
68}
54654472 69//___________________________________________________________________________
70AliTimeStamp::AliTimeStamp(const AliTimeStamp &stamp):
71 TObject(stamp),
72 fOrbit(stamp.fOrbit),
73 fPeriod(stamp.fPeriod),
74 fBunchCross(stamp.fBunchCross)
75{
76 // copy constructor
77}
78//_____________________________________________________________________________
79AliTimeStamp& AliTimeStamp::operator=(const AliTimeStamp &stamp)
80{
81 //assignment operator
82 if(this==&stamp) return *this;
83 ((TObject *)this)->operator=(stamp);
84 fOrbit=stamp.fOrbit;
85 fPeriod=stamp.fPeriod;
86 fBunchCross=stamp.fBunchCross;
87 return *this;
88}
d7dd8a54 89//_____________________________________________________________________________
90void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period,
91 ULong64_t bunchcross )
92{
93 fOrbit = orbit;
94 fPeriod = period;
95 fBunchCross = bunchcross;
96}
97
98//_____________________________________________________________________________
99void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period,
100 UInt_t seconds, UInt_t microsecs )
101{
102 fOrbit = orbit;
103 fPeriod = period;
104 fBunchCross = (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5);
105}
106
107
108
109//_____________________________________________________________________________
110Int_t AliTimeStamp::Compare( const TObject* obj ) const
111{
112 // Compare
33d4a580 113
114 if( fPeriod > ((AliTimeStamp*)obj)->fPeriod ) return 1;
115 else { if( fPeriod < ((AliTimeStamp*)obj)->fPeriod ) return -1;
116 else { if( fOrbit > ((AliTimeStamp*)obj)->fOrbit ) return 1;
117 else { if( fOrbit < ((AliTimeStamp*)obj)->fOrbit ) return -1;
118 else { if( fBunchCross > ((AliTimeStamp*)obj)->fBunchCross ) return 1;
119 else { if( fBunchCross < ((AliTimeStamp*)obj)->fBunchCross ) return -1;
120 else return 0;
121}}}}}
122
d7dd8a54 123}
124
125//_____________________________________________________________________________
126void AliTimeStamp::Print( const Option_t* ) const
127{
128 // Print
129 cout << "Timestamp: " << endl;
130 cout << " Orbit: " << fOrbit << " Period: " << fPeriod << endl;
131 cout << " Bunch Cross: " << GetBunchCross() << endl;
132 cout << " Seconds: " << GetSeconds() << " MicroSecs: " << GetMicroSecs() << endl;
133}