]>
Commit | Line | Data |
---|---|---|
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 | ||
38 | ClassImp(AliTimeStamp) | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | ||
42 | const Int_t AliTimeStamp::fNanosecPerBC = 25; // nanosecs per bunch cross | |
43 | ||
44 | //_____________________________________________________________________________ | |
45 | AliTimeStamp::AliTimeStamp(): | |
46 | fOrbit(0), | |
47 | fPeriod(0), | |
48 | fBunchCross(0) | |
49 | { | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period, | |
54 | ULong64_t bunchcross ): | |
55 | fOrbit(orbit), | |
56 | fPeriod(period), | |
57 | fBunchCross( bunchcross ) | |
58 | { | |
59 | } | |
60 | //_____________________________________________________________________________ | |
61 | AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period, | |
62 | UInt_t seconds, UInt_t microsecs): | |
63 | fOrbit(orbit), | |
64 | fPeriod(period), | |
65 | fBunchCross( (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5) ) | |
66 | { | |
67 | } | |
68 | //_____________________________________________________________________________ | |
69 | void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period, | |
70 | ULong64_t bunchcross ) | |
71 | { | |
72 | fOrbit = orbit; | |
73 | fPeriod = period; | |
74 | fBunchCross = bunchcross; | |
75 | } | |
76 | ||
77 | //_____________________________________________________________________________ | |
78 | void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period, | |
79 | UInt_t seconds, UInt_t microsecs ) | |
80 | { | |
81 | fOrbit = orbit; | |
82 | fPeriod = period; | |
83 | fBunchCross = (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5); | |
84 | } | |
85 | ||
86 | ||
87 | ||
88 | //_____________________________________________________________________________ | |
89 | Int_t AliTimeStamp::Compare( const TObject* obj ) const | |
90 | { | |
91 | // Compare | |
92 | ||
93 | if( fOrbit < ((AliTimeStamp*)obj)->fOrbit ) return -1; | |
94 | if( fOrbit > ((AliTimeStamp*)obj)->fOrbit ) return 1; | |
95 | if( fPeriod < ((AliTimeStamp*)obj)->fPeriod ) return -1; | |
96 | if( fPeriod > ((AliTimeStamp*)obj)->fPeriod ) return 1; | |
97 | if( fBunchCross < ((AliTimeStamp*)obj)->fBunchCross ) return -1; | |
98 | if( fBunchCross > ((AliTimeStamp*)obj)->fBunchCross ) return 1; | |
99 | return 0; | |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________ | |
103 | void AliTimeStamp::Print( const Option_t* ) const | |
104 | { | |
105 | ||
106 | cout << "Timestamp: " << endl; | |
107 | cout << " Orbit: " << fOrbit << " Period: " << fPeriod << endl; | |
108 | cout << " Bunch Cross: " << GetBunchCross() << endl; | |
109 | cout << " Seconds: " << GetSeconds() << " MicroSecs: " << GetMicroSecs() << endl; | |
110 | } |