]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliDCSValue.cxx
- The part of JETAN dealing with ESD data has been separated from the one using MC...
[u/mrichter/AliRoot.git] / STEER / AliDCSValue.cxx
CommitLineData
57459306 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/*
17$Log$
fe12e09c 18Revision 1.3 2006/07/20 09:43:46 jgrosseo
19removing dynamic types
20
60d864bd 21Revision 1.2 2006/07/04 14:58:11 jgrosseo
22revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
23
45a493ce 24Revision 1.1 2006/06/02 14:14:36 hristov
25Separate library for CDB (Jan)
26
57459306 27Revision 1.2 2006/03/07 07:52:34 hristov
28New version (B.Yordanov)
29
30Revision 1.2 2005/11/17 14:43:23 byordano
31import to local CVS
32
33Revision 1.1.1.1 2005/10/28 07:33:58 hristov
34Initial import as subdirectory in AliRoot
35
36Revision 1.1.1.1 2005/09/12 22:11:40 byordano
37SHUTTLE package
38
39Revision 1.2 2005/08/30 10:53:23 byordano
40some more descriptions added
41
42*/
43
44//
45a493ce 45// This class represents the value(s) of
46// a DCS data point at a given timestamp.
47// It stores different data types, the current implementation has a member for all of them.
48// This is definitly not efficient, but the only way to use the automatic streamers generated by ROOT.
49//
57459306 50// Each element of this value series has two fields:
51// fValue - primitive value which represents the real measured value
52// fTimestamp - timestamp when the measurement was made
53//
54
55#include "AliDCSValue.h"
56
57#include "TTimeStamp.h"
45a493ce 58#include <TString.h>
57459306 59
60ClassImp(AliDCSValue)
61
fe12e09c 62AliDCSValue::AliDCSValue() :
63 TObject(),
64 fType(kInvalid),
65 fBool(kFALSE),
66 fChar(0),
67 fInt(0),
68 fUInt(0),
69 fFloat(0),
70 fTimeStamp(0)
45a493ce 71{
72 // default constructor
45a493ce 73}
74
fe12e09c 75AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) :
76 TObject(),
77 fType(kBool),
78 fBool(value),
79 fChar(0),
80 fInt(0),
81 fUInt(0),
82 fFloat(0),
83 fTimeStamp(timeStamp)
45a493ce 84{
85 // constructor
45a493ce 86}
87
fe12e09c 88AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) :
89 TObject(),
90 fType(kChar),
91 fBool(kFALSE),
92 fChar(value),
93 fInt(0),
94 fUInt(0),
95 fFloat(0),
96 fTimeStamp(timeStamp)
45a493ce 97{
98 // constructor
45a493ce 99}
100
fe12e09c 101AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) :
102 TObject(),
103 fType(kInt),
104 fBool(kFALSE),
105 fChar(0),
106 fInt(value),
107 fUInt(0),
108 fFloat(0),
109 fTimeStamp(timeStamp)
45a493ce 110{
111 // constructor
45a493ce 112}
113
fe12e09c 114AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) :
115 TObject(),
116 fType(kUInt),
117 fBool(kFALSE),
118 fChar(0),
119 fInt(0),
120 fUInt(value),
121 fFloat(0),
122 fTimeStamp(timeStamp)
45a493ce 123{
124 // constructor
45a493ce 125}
126
fe12e09c 127AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) :
128 TObject(),
129 fType(kFloat),
130 fBool(kFALSE),
131 fChar(0),
132 fInt(0),
133 fUInt(0),
134 fFloat(value),
135 fTimeStamp(timeStamp)
45a493ce 136{
137 // constructor
138
139 Init();
140
141 fTimeStamp = timeStamp;
142
143 fType = kFloat;
144 fFloat = value;
145}
146
fe12e09c 147AliDCSValue::AliDCSValue(const AliDCSValue& c) :
148 TObject(c),
149 fType(c.fType),
150 fBool(c.fBool),
151 fChar(c.fChar),
152 fInt(c.fInt),
153 fUInt(c.fUInt),
154 fFloat(c.fFloat),
155 fTimeStamp(c.fTimeStamp)
45a493ce 156{
157 // copy constructor
45a493ce 158}
159
160void AliDCSValue::Init()
161{
162 // init helper, that initializes everything to 0
163
164 fType = kInvalid;
165
166 fBool = kFALSE;
167 fChar = 0;
168 fInt = 0;
169 fUInt = 0;
170 fFloat = 0;
171
45a493ce 172 fTimeStamp = 0;
173}
174
175AliDCSValue::~AliDCSValue()
176{
177 // destructor
57459306 178}
179
45a493ce 180AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c)
57459306 181{
45a493ce 182 // assigment operator
57459306 183
45a493ce 184 if (this != &c)
185 ((AliDCSValue &) c).Copy(*this);
186
187 return *this;
57459306 188}
189
45a493ce 190void AliDCSValue::Copy(TObject& c) const
191{
192 // copy function
193
194 AliDCSValue& target = (AliDCSValue &) c;
195
196 target.Init();
197
198 target.fType = fType;
57459306 199
45a493ce 200 target.fBool = fBool;
201 target.fChar = fChar;
202 target.fInt = fInt;
203 target.fUInt = fUInt;
204 target.fFloat = fFloat;
57459306 205
45a493ce 206 target.fTimeStamp = fTimeStamp;
57459306 207}
208
45a493ce 209Int_t AliDCSValue::GetSize() const
210{
211 // returns size in bytes of stored structure
212
213 Int_t size = sizeof(fTimeStamp);
214
215 switch (fType)
216 {
217 case kBool: size += sizeof(Bool_t); break;
218 case kChar: size += sizeof(Char_t); break;
219 case kInt: size += sizeof(Int_t); break;
220 case kUInt: size += sizeof(UInt_t); break;
221 case kFloat: size += sizeof(Float_t); break;
222
45a493ce 223 case kInvalid: break;
224 }
57459306 225
45a493ce 226 return size;
227}
228
45a493ce 229const Char_t* AliDCSValue::ToString() const
230{
231 TString str;
232
233 switch (fType)
234 {
235 case kBool: str.Form("%d", fBool); break;
236 case kChar: str.Form("%d", fChar); break;
237 case kInt: str.Form("%d", fInt); break;
238 case kUInt: str.Form("%d", fUInt); break;
239 case kFloat: str.Form("%f", fFloat); break;
240
45a493ce 241 case kInvalid: break;
242 }
243
244 return Form("%s Timestamp: %s", str.Data(), TTimeStamp(fTimeStamp).AsString());
245}