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