Corrected protection.
[u/mrichter/AliRoot.git] / STEER / AliGRPDCS.cxx
CommitLineData
3dedb44a 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
9edefa04 16/* $Id$ */
17
3dedb44a 18//-----------------------------------------------------------------
19// AliGRPDCS class
20// This class deals with the DCS related info of the GRP
21// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
e7a6790f 22// Modified: Ernesto.Lopez.Torres@cern.ch CEADEN-CERN
3dedb44a 23//-----------------------------------------------------------------
d18640d0 24#include "Riostream.h"
25#include "TError.h"
3dedb44a 26
27#include "AliGRPDCS.h"
3dedb44a 28#include "AliDCSValue.h"
e97cc90e 29#include "AliLog.h"
3dedb44a 30
3dedb44a 31class TObjString;
32
9edefa04 33#include <TObjArray.h>
3dedb44a 34
35ClassImp(AliGRPDCS)
36
37//_______________________________________________________________
38AliGRPDCS::AliGRPDCS():
e7a6790f 39 TObject(), fStartTime(0), fStopTime(0), fDCSArray(new TObjArray())
40{
3dedb44a 41 // default constructor
42
43}
44
45//_______________________________________________________________
1f9bf847 46AliGRPDCS::AliGRPDCS(TObjArray *dcsArray, UInt_t fStart, UInt_t fStop):
47 TObject(), fStartTime(fStart), fStopTime(fStop), fDCSArray(new TObjArray()) {
3dedb44a 48 // constructor
3dedb44a 49 fDCSArray = dcsArray;
50}
51
52//___________________________________________________________________________
53AliGRPDCS::AliGRPDCS(const AliGRPDCS& grpDcs):
d18640d0 54 TObject(grpDcs),
958ecabf 55 fStartTime(grpDcs.fStartTime), fStopTime(grpDcs.fStopTime),
e7a6790f 56 fDCSArray(grpDcs.fDCSArray)
57{
3dedb44a 58 //copy constructor
59
958ecabf 60 //if (grpDcs.fDCSArray) fDCSArray = new TObjArray();
3dedb44a 61}
62
63//_______________________________________________________________
e7a6790f 64const char* AliGRPDCS::ProcessDCS(Int_t iType)
65{
e97cc90e 66 // process the dcs dps
d18640d0 67 if(!fDCSArray->GetEntries()) {
68 Error("AliGRPDCS::ProcessDCS","No entries in array!!!");
69 return 0;
70 }
71
e7a6790f 72 // 1:Bool - 2:Char - 3:Int - 4:UInt - 5:Float
e97cc90e 73 TString fDCSDataPointValue;
74 switch (iType) {
e7a6790f 75 case 1: {
76 fDCSDataPointValue += ProcessBoolean();
77 break;
78 }
79 case 2: {
80 fDCSDataPointValue += ProcessChar();
81 break;
82 }
83 case 3: {
84 fDCSDataPointValue += ProcessInt();
85 break;
86 }
87 case 4: {
88 fDCSDataPointValue += ProcessUInt();
89 break;
90 }
91 case 5: {
92 fDCSDataPointValue += ProcessFloat();
93 break;
94 }
95// case 6: {
96// fDCSDataPointValue += ProcessString();
97// break;
98// }
99 default: {
100 Error("AliGRPDCS::ProcessDCS", "Unknown type!!!" );
101 break;
102 }
e97cc90e 103 }//switch
104
958ecabf 105 //cout<<fDCSDataPointValue.Data()<<endl;
e97cc90e 106 return fDCSDataPointValue.Data();
107}
108
109//_______________________________________________________________
e7a6790f 110const char* AliGRPDCS::ProcessBoolean()
111{
112 Bool_t fDCSBool = kTRUE;
e152570c 113 Bool_t previousBool = kTRUE;
e7a6790f 114
115 AliDCSValue *v = 0x0;
116
117 for(Int_t iCount = 0; iCount < fDCSArray->GetEntries(); iCount++) {
118 v = (AliDCSValue *)fDCSArray->At(iCount);
e152570c 119 if ((v->GetTimeStamp() < fStartTime) || (v->GetTimeStamp() > fStopTime)) {
120 AliError(Form("DCS values for the parameter outside the queried interval"));
121 continue;
122 }
e7a6790f 123 fDCSBool = v->GetBool();
e152570c 124 if (iCount > 0) {
125 if (fDCSBool != previousBool)
126 AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (Int_t)previousBool, (Int_t)fDCSBool));
127 }
128 previousBool = fDCSBool;
e7a6790f 129 }
130
131 TString fDCSDataPointValue = (fDCSBool)? "1" : "0";
132
133 return fDCSDataPointValue.Data();
134}
135
136//_______________________________________________________________
137const char* AliGRPDCS::ProcessInt()
138{
e97cc90e 139 Float_t fFDCSArraySum = 0.0, fFDCSArrayMean = 0.0;
1f9bf847 140 Int_t iCounts = 0;
e97cc90e 141 for(Int_t i = 0; i < fDCSArray->GetEntries(); i++) {
142 AliDCSValue *v = (AliDCSValue *)fDCSArray->At(i);
1f9bf847 143 if((v->GetTimeStamp() >= fStartTime) &&(v->GetTimeStamp() <= fStopTime)) {
144 fFDCSArraySum += v->GetInt();
145 iCounts += 1;
146 }
e97cc90e 147 }
1f9bf847 148 if(iCounts != 0) fFDCSArrayMean = fFDCSArraySum/iCounts;
149 else fFDCSArrayMean = -10.;
150
e97cc90e 151 TString fDCSDataPointValue; fDCSDataPointValue += fFDCSArrayMean;
152
153 return fDCSDataPointValue.Data();
154}
155
156//_______________________________________________________________
e7a6790f 157const char* AliGRPDCS::ProcessUInt()
158{
e97cc90e 159 Float_t fFDCSArraySum = 0.0, fFDCSArrayMean = 0.0;
1f9bf847 160 Int_t iCounts = 0;
e97cc90e 161 for(Int_t i = 0; i < fDCSArray->GetEntries(); i++) {
162 AliDCSValue *v = (AliDCSValue *)fDCSArray->At(i);
1f9bf847 163 if((v->GetTimeStamp() >= fStartTime) &&(v->GetTimeStamp() <= fStopTime)) {
164 fFDCSArraySum += v->GetUInt();
165 iCounts += 1;
166 }
e97cc90e 167 }
1f9bf847 168 if(iCounts != 0) fFDCSArrayMean = fFDCSArraySum/iCounts;
169 else fFDCSArrayMean = -10.;
170
e97cc90e 171 TString fDCSDataPointValue; fDCSDataPointValue += fFDCSArrayMean;
172
173 return fDCSDataPointValue.Data();
174}
175
176//_______________________________________________________________
e7a6790f 177const char* AliGRPDCS::ProcessFloat()
178{
3dedb44a 179 Float_t fFDCSArraySum = 0.0, fFDCSArrayMean = 0.0;
1f9bf847 180 Int_t iCounts = 0;
958ecabf 181 //printf("Entries: %d\n",fDCSArray->GetEntries());
182 //printf("Start: %d - Stop: %d\n",fStartTime,fStopTime);
3dedb44a 183 for(Int_t i = 0; i < fDCSArray->GetEntries(); i++) {
184 AliDCSValue *v = (AliDCSValue *)fDCSArray->At(i);
1f9bf847 185 if((v->GetTimeStamp() >= fStartTime) &&(v->GetTimeStamp() <= fStopTime)) {
186 fFDCSArraySum += v->GetFloat();
187 iCounts += 1;
188 }
3dedb44a 189 }
1f9bf847 190 if(iCounts != 0) fFDCSArrayMean = fFDCSArraySum/iCounts;
191 else fFDCSArrayMean = -10.;
192
3dedb44a 193 TString fDCSDataPointValue; fDCSDataPointValue += fFDCSArrayMean;
194
195 return fDCSDataPointValue.Data();
196}
197
e97cc90e 198//_______________________________________________________________
e7a6790f 199const char* AliGRPDCS::ProcessChar()
200{
201 TString fDCSString;
1f9bf847 202
203 AliDCSValue *v = 0x0;
d18640d0 204
958ecabf 205 //printf("Entries: %d\n",fDCSArray->GetEntries());
206 //printf("Start: %d - Stop: %d\n",fStartTime,fStopTime);
207
208 for(Int_t iCount = 0; iCount < fDCSArray->GetEntries(); iCount++) {
1f9bf847 209 v = (AliDCSValue *)fDCSArray->At(iCount);
958ecabf 210 if ((v->GetTimeStamp() >= fStartTime) && (v->GetTimeStamp() <= fStopTime))
211 AliError(Form("DCS values for the parameter changed within the queried interval"));
212 if (v->GetTimeStamp() > fStopTime) continue;
e7a6790f 213 fDCSString = v->GetChar();
e97cc90e 214 }
958ecabf 215
e97cc90e 216 TString fDCSDataPointValue = fDCSString;
e7a6790f 217
e97cc90e 218 return fDCSDataPointValue.Data();
219}
220
e7a6790f 221/*
e97cc90e 222//_______________________________________________________________
e7a6790f 223const char* AliGRPDCS::ProcessString()
224{
225 TString fDCSString;
1f9bf847 226
227 AliDCSValue *v = 0x0;
958ecabf 228
e7a6790f 229 //printf("Entries: %d\n",fDCSArray->GetEntries());
230 //printf("Start: %d - Stop: %d\n",fStartTime,fStopTime);
231
958ecabf 232 for(Int_t iCount = 0; iCount < fDCSArray->GetEntries(); iCount++) {
e7a6790f 233 v = (TObjString *)fDCSArray->At(iCount);
958ecabf 234 if ((v->GetTimeStamp() >= fStartTime) && (v->GetTimeStamp() <= fStopTime))
235 AliError(Form("DCS values for the parameter changed within the queried interval"));
236 if (v->GetTimeStamp() > fStopTime) continue;
e7a6790f 237 fDCSString = v->GetChar(); // FIXME should be something like v->GetString()
e97cc90e 238 }
e7a6790f 239
240 TString fDCSDataPointValue = fDCSString;
241 //cout<<"Returned String: "<<fDCSDataPointValue.Data()<<endl;
e97cc90e 242
243 return fDCSDataPointValue.Data();
244}
e7a6790f 245*/