1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTimeStamp.cxx 22322 2007-11-22 11:43:14Z cvetan $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // Class to define Event Timestamp from :
25 // + | <===> Bunch cross
28 //////////////////////////////////////////////////////////////////////////////
30 #include <Riostream.h>
36 #include "AliTimeStamp.h"
40 ClassImp(AliTimeStamp)
42 //_____________________________________________________________________________
44 const Int_t AliTimeStamp::fNanosecPerBC = 25; // nanosecs per bunch cross
46 //_____________________________________________________________________________
47 AliTimeStamp::AliTimeStamp():
52 // Default constructor
55 //_____________________________________________________________________________
56 AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period,
57 ULong64_t bunchcross ):
60 fBunchCross( bunchcross )
63 //_____________________________________________________________________________
64 AliTimeStamp::AliTimeStamp( UInt_t orbit, UInt_t period,
65 UInt_t seconds, UInt_t microsecs):
68 fBunchCross( (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5) )
71 //___________________________________________________________________________
72 AliTimeStamp::AliTimeStamp(const AliTimeStamp &stamp):
75 fPeriod(stamp.fPeriod),
76 fBunchCross(stamp.fBunchCross)
80 //_____________________________________________________________________________
81 AliTimeStamp& AliTimeStamp::operator=(const AliTimeStamp &stamp)
84 if(this==&stamp) return *this;
85 ((TObject *)this)->operator=(stamp);
87 fPeriod=stamp.fPeriod;
88 fBunchCross=stamp.fBunchCross;
91 //_____________________________________________________________________________
92 void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period,
93 ULong64_t bunchcross )
97 fBunchCross = bunchcross;
100 //_____________________________________________________________________________
101 void AliTimeStamp::SetTimeStamp( UInt_t orbit, UInt_t period,
102 UInt_t seconds, UInt_t microsecs )
106 fBunchCross = (ULong64_t)((seconds*1000000.+microsecs)*1000./fNanosecPerBC+0.5);
111 //_____________________________________________________________________________
112 Int_t AliTimeStamp::Compare( const TObject* obj ) const
116 if( fPeriod > ((AliTimeStamp*)obj)->fPeriod ) return 1;
117 else { if( fPeriod < ((AliTimeStamp*)obj)->fPeriod ) return -1;
118 else { if( fOrbit > ((AliTimeStamp*)obj)->fOrbit ) return 1;
119 else { if( fOrbit < ((AliTimeStamp*)obj)->fOrbit ) return -1;
120 else { if( fBunchCross > ((AliTimeStamp*)obj)->fBunchCross ) return 1;
121 else { if( fBunchCross < ((AliTimeStamp*)obj)->fBunchCross ) return -1;
127 //_____________________________________________________________________________
128 void AliTimeStamp::Print( const Option_t* ) const
131 cout << "Timestamp: " << endl;
132 cout << " Orbit: " << fOrbit << " Period: " << fPeriod << endl;
133 cout << " Bunch Cross: " << GetBunchCross() << endl;
134 cout << " Seconds: " << GetSeconds() << " MicroSecs: " << GetMicroSecs() << endl;