]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFDataDCS.cxx
corrected warnings with gcc 4.3
[u/mrichter/AliRoot.git] / TOF / AliTOFDataDCS.cxx
CommitLineData
345932e4 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/*
7fffa85b 17$Log: AliTOFDataDCS.cxx,v $
18Revision 1.9 2007/05/04 14:02:45 decaro
19AliTOFDataDCS::Draw(Option_t *) method declared const: compiling warning suppression
20
b52b97c2 21Revision 1.8 2007/05/03 09:45:09 decaro
22Coding convention: RN11 violation -> suppression
23
9d5fd6fe 24Revision 1.7 2007/05/02 14:09:39 arcelli
25Retrieval of Env. Temperature removed (will get it from the GRP)
26
38e3bbf1 27Revision 1.6 2007/04/04 17:19:19 arcelli
28Moved some printout to debug level
29
72bf252d 30Revision 1.5 2007/02/20 15:57:00 decaro
31Raw data update: to read the TOF raw data defined in UNPACKED mode
32
15ec34b9 33Revision 1.4 2007/02/19 15:41:55 decaro
34Coding convention: few corrections
35
3a3ece53 36Revision 1.3 2007/01/24 11:19:58 arcelli
37Modify ProcessData to return a logical (CZ)
38
ebab534a 39Revision 1.2 2006/12/18 18:17:38 arcelli
40Updated Aliases for DCS TOF datapoints (C.Zampolli)
41
8259e6f8 42Revision 1.1 2006/10/26 09:10:52 arcelli
43Class for handling the TOF DCS data in the Shuttle (C.Zampolli)
44
345932e4 45*/
46
5c7c93fa 47#include "TString.h"
48//#include "TF1.h"
49//#include "TH1F.h"
50#include "TTimeStamp.h"
51#include "TMap.h"
52#include "TCanvas.h"
345932e4 53
54#include "AliDCSValue.h"
55#include "AliLog.h"
56
5c7c93fa 57#include "AliTOFDataDCS.h"
345932e4 58#include "AliTOFFormatDCS.h"
345932e4 59
60class TH2;
61class AliCDBMetaData;
62class TDatime;
63
64// AliTOFDataDCS class
65// main aim to introduce the aliases for the TOF DCS
66// data points to be then
67// stored in the OCDB, and to process them.
68// Process() method called by TOFPrepr
69
70ClassImp(AliTOFDataDCS)
71
72//---------------------------------------------------------------
73AliTOFDataDCS::AliTOFDataDCS():
74 TObject(),
75 fRun(0),
76 fStartTime(0),
77 fEndTime(0),
ff326f84 78 fStartTimeDCSQuery(0),
79 fEndTimeDCSQuery(0),
7fffa85b 80 fIsProcessed(kFALSE),
81 fFDR(kFALSE)
345932e4 82{
83
84 // main constructor
85
8259e6f8 86 for(int i=0;i<kNHV;i++) {
87 fHVvp[i]=0x0;
88 fHVvn[i]=0x0;
89 fHVip[i]=0x0;
90 fHVin[i]=0x0;
91 }
d202b31a 92
8259e6f8 93
345932e4 94}
95
96//---------------------------------------------------------------
ff326f84 97AliTOFDataDCS::AliTOFDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery):
345932e4 98 TObject(),
99 fRun(nRun),
100 fStartTime(startTime),
101 fEndTime(endTime),
ff326f84 102 fStartTimeDCSQuery(startTimeDCSQuery),
103 fEndTimeDCSQuery(endTimeDCSQuery),
7fffa85b 104 fIsProcessed(kFALSE),
105 fFDR(kFALSE)
345932e4 106{
107
108 // constructor with arguments
109
ff326f84 110 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", nRun,
345932e4 111 TTimeStamp(startTime).AsString(),
ff326f84 112 TTimeStamp(endTime).AsString(),
113 TTimeStamp(startTimeDCSQuery).AsString(),
114 TTimeStamp(endTimeDCSQuery).AsString()));
345932e4 115
116 Init();
117
118}
119
120//---------------------------------------------------------------
121
122AliTOFDataDCS::AliTOFDataDCS(const AliTOFDataDCS & data):
123 TObject(),
124 fRun(0),
125 fStartTime(0),
126 fEndTime(0),
ff326f84 127 fStartTimeDCSQuery(0),
128 fEndTimeDCSQuery(0),
7fffa85b 129 fIsProcessed(kFALSE),
130 fFDR(kFALSE)
345932e4 131
132{
133
134// copy constructor
135
136 fRun=data.fRun;
137 fStartTime=data.fStartTime;
138 fEndTime=data.fEndTime;
ff326f84 139 fStartTimeDCSQuery=data.fStartTimeDCSQuery;
140 fEndTimeDCSQuery=data.fEndTimeDCSQuery;
345932e4 141 fIsProcessed=data.fIsProcessed;
7fffa85b 142 fFDR=data.fFDR;
345932e4 143
144 for(int i=0;i<kNAliases;i++) {
145 fAliasNames[i]=data.fAliasNames[i];
146 }
147
148 for(int i=0;i<kNHV;i++) {
8259e6f8 149 fHVvp[i]=data.fHVvp[i];
150 fHVvn[i]=data.fHVvn[i];
151 fHVip[i]=data.fHVip[i];
152 fHVin[i]=data.fHVin[i];
345932e4 153 }
154
38e3bbf1 155
345932e4 156}
157//---------------------------------------------------------------
158
159AliTOFDataDCS& AliTOFDataDCS:: operator=(const AliTOFDataDCS & data) {
160
161// assignment operator
162
163 this->fRun=data.GetRun();
164 this->fStartTime=data.GetStartTime();
165 this->fEndTime=data.GetEndTime();
ff326f84 166 this->fStartTimeDCSQuery=data.GetStartTimeDCSQuery();
167 this->fEndTimeDCSQuery=data.GetEndTimeDCSQuery();
345932e4 168
169 for(int i=0;i<kNAliases;i++) {
170 this->fAliasNames[i]=data.GetAliasName(i);
171 }
172
345932e4 173 for(int i=0;i<kNHV;i++) {
8259e6f8 174 this->fHVvp[i]=data.GetHVvp(i);
175 this->fHVvn[i]=data.GetHVvn(i);
176 this->fHVip[i]=data.GetHVip(i);
177 this->fHVin[i]=data.GetHVin(i);
345932e4 178 }
179
345932e4 180
181 return *this;
182}
183//---------------------------------------------------------------
184AliTOFDataDCS::~AliTOFDataDCS() {
185
186 // destructor
187
8259e6f8 188 for(int i=0;i<kNHV;i++) {
189 delete fHVvp[i];
190 fHVvp[i]=0;
191 delete fHVvn[i];
192 fHVvn[i]=0;
193 delete fHVip[i];
194 fHVip[i]=0;
195 delete fHVin[i];
196 fHVin[i]=0;
197 }
198
345932e4 199}
200
345932e4 201//---------------------------------------------------------------
ebab534a 202Bool_t AliTOFDataDCS::ProcessData(TMap& aliasMap){
345932e4 203
3a3ece53 204 // method to process the data
205
345932e4 206 if(!(fAliasNames[0])) Init();
207
345932e4 208 Float_t val=0;
209 Float_t val1=0;
210 Float_t time=0;
211 Float_t delta[2];
212 Float_t timedelta[2];
213
e83a0dd0 214 AliInfo(Form(" Start Time = %i",fStartTime));
215 AliInfo(Form(" End Time = %i",fEndTime));
ff326f84 216 AliInfo(Form(" Start Time DCS Query= %i",fStartTimeDCSQuery));
217 AliInfo(Form(" End Time DCS Query= %i",fEndTimeDCSQuery));
e83a0dd0 218
219 if (fEndTime==fStartTime){
220 AliError(Form(" Run with null time length: start time = %i = end time = %i",fStartTime,fEndTime));
221 return kFALSE;
96fec15b 222 }
223
345932e4 224 TObjArray *aliasArr;
225 AliDCSValue* aValue;
226 AliDCSValue* aValue1;
345932e4 227
228 // starting loop on aliases
229 for(int j=0; j<kNAliases; j++){
230 for (Int_t k=0;k<2;k++) {
231 delta[k]=0;
232 timedelta[k]=0;
233 }
234 //AliInfo(Form("j = %i, with alias = %s",j,fAliasNames[j].Data()));
235 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
236 if(!aliasArr){
237 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
7fffa85b 238 if (!fFDR){
239 return kFALSE; // returning only in case we are not in a FDR run
240 }
241 else {
242 continue;
243 }
345932e4 244 }
245
246 Introduce(j, aliasArr);
247
248 if(aliasArr->GetEntries()<3){
249 AliError(Form("Alias %s has just %d entries!",
250 fAliasNames[j].Data(),aliasArr->GetEntries()));
251 continue;
252 }
253
254 TIter iterarray(aliasArr);
255
256 Int_t nentries = aliasArr->GetEntries();
345932e4 257 Int_t deltaTimeStamp = (Int_t) nentries/3;
258 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
345932e4 259
260 // filling aliases with 10 floats+1 Usign
38e3bbf1 261 Int_t index = 0;
262 for (Int_t k=0;k<3;k++){
263 index = deltaTimeStamp*k;
264 if (k==0) {
265 index=0;
345932e4 266 }
38e3bbf1 267 else if (k==1) {
268 index=deltaTimeStamp1;
269 }
270 else if (k==2) {
271 index=nentries-1;
345932e4 272 }
38e3bbf1 273 aValue = (AliDCSValue*) aliasArr->At(index);
274 val = aValue->GetFloat();
275 time = (Float_t) (aValue->GetTimeStamp());
276 if (j<kNHV){
277 fHVvp[j]->SetFloat(k,val);
278 fHVvp[j]->SetTimeStampFloat(k,time);
279 }
280 else if (j<kNHV*2){
281 fHVvn[j-kNHV]->SetFloat(k,val);
282 fHVvn[j-kNHV]->SetTimeStampFloat(k,time);
283 }
284 else if (j<kNHV*3){
285 fHVip[j-2*kNHV]->SetFloat(k,val);
286 fHVip[j-2*kNHV]->SetTimeStampFloat(k,time);
287 }
288 else if (j<kNHV*4){
289 fHVin[j-3*kNHV]->SetFloat(k,val);
290 fHVin[j-3*kNHV]->SetTimeStampFloat(k,time);
291 }
345932e4 292 }
38e3bbf1 293
345932e4 294 //computing the most significant variations
295
ff326f84 296 //Float_t timeDiff = (Float_t)(fEndTime-fStartTime);
297 Float_t timeDiff = (Float_t)(fEndTimeDCSQuery-fStartTimeDCSQuery);
e83a0dd0 298 Int_t deltamin = (Int_t)(60/timeDiff*nentries); //sampling every minute
345932e4 299 Int_t klast = nentries-deltamin;
38e3bbf1 300
345932e4 301 for (Int_t k=0;k<klast;k++){
302 aValue = (AliDCSValue*) aliasArr->At(k);
303 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
304 val = aValue->GetFloat();
305 val1 = aValue1->GetFloat();
306 if (delta[0]<=TMath::Abs(val1-val)) {
307 delta[0]=TMath::Abs(val1-val);
308 timedelta[0] = (Float_t)k;
309 }
310 if (delta[1]<=delta[0]) {
311 Float_t temp = delta[1];
312 Float_t timetemp = timedelta[1];
313 delta[1]=delta[0];
314 delta[0]=temp;
315 timedelta[1]=timedelta[0];
316 timedelta[0]=timetemp;
317 }
318 }
319
320 for (Int_t kk=0;kk<2;kk++){
38e3bbf1 321 if (j<kNHV){
322 fHVvp[j]->SetDelta(kk,delta[kk]);
323 fHVvp[j]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
345932e4 324 }
38e3bbf1 325 else if (j<kNHV*2){
326 fHVvn[j-kNHV]->SetDelta(kk,delta[kk]);
327 fHVvn[j-kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
328 }
329 else if (j<kNHV*3){
330 fHVip[j-2*kNHV]->SetDelta(kk,delta[kk]);
331 fHVip[j-2*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
332 }
333 else if (j<kNHV*4){
334 fHVin[j-3*kNHV]->SetDelta(kk,delta[kk]);
335 fHVin[j-3*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
336 }
8259e6f8 337 }
345932e4 338 }
38e3bbf1 339
345932e4 340 fIsProcessed=kTRUE;
341
ebab534a 342 return kTRUE;
345932e4 343}
344
345//---------------------------------------------------------------
346void AliTOFDataDCS::Init(){
347
348 // initialization of aliases and DCS data
349
8259e6f8 350 TString sindex;
345932e4 351 for(int i=0;i<kNAliases;i++){
8259e6f8 352 //HV, v
345932e4 353 if (i<kNHV){
8259e6f8 354 fAliasNames[i] = "tof_hv_vp_";
355 sindex.Form("%02i",i);
356 fAliasNames[i] += sindex;
357 fHVvp[i] = new AliTOFFormatDCS();
345932e4 358 }
359 else if (i<kNHV*2){
8259e6f8 360 fAliasNames[i] = "tof_hv_vn_";
361 sindex.Form("%02i",i-kNHV);
362 fAliasNames[i] += sindex;
363 fHVvn[i-kNHV] = new AliTOFFormatDCS();
345932e4 364 }
8259e6f8 365 //HV, i
345932e4 366 else if (i<kNHV*3){
8259e6f8 367 fAliasNames[i] = "tof_hv_ip_";
368 sindex.Form("%02i",i-2*kNHV);
369 fAliasNames[i] += sindex;
370 fHVip[i-2*kNHV] = new AliTOFFormatDCS();
345932e4 371 }
372 else if (i<kNHV*4){
8259e6f8 373 fAliasNames[i] = "tof_hv_in_";
374 sindex.Form("%02i",i-3*kNHV);
375 fAliasNames[i] += sindex;
376 fHVin[i-3*kNHV] = new AliTOFFormatDCS();
345932e4 377 }
345932e4 378 }
379}
380
381
382//---------------------------------------------------------------
383void AliTOFDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
384{
385
386 // method to introduce new aliases
387
388 int entries=0;
389 entries = aliasArr->GetEntries();
390 int nal=0;
391 nal=numAlias;
72bf252d 392 AliDebug(2,Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
393 AliDebug(2,Form(" %d DP values collected",entries));
345932e4 394
395}
396
397//---------------------------------------------------------------
b52b97c2 398void AliTOFDataDCS::Draw(const Option_t* /*option*/)
345932e4 399{
400// Draw all histos and graphs
401
402 if(!fIsProcessed) return;
403
404 TCanvas *ch;
405 TString canvasHistoName="Histos";
406 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
407 ch->cd();
408
409 // to be implemented
410
411}
412