uuhhhhaaa - what did I change? Added the run number and fixed coding conventions ;-)
[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/*
17$Log$
18*/
19
20#include "AliTOFDataDCS.h"
21
22#include "AliDCSValue.h"
23#include "AliLog.h"
24
25#include "TString.h"
26#include "AliTOFFormatDCS.h"
27#include "TF1.h"
28#include "TCanvas.h"
29#include "TH1F.h"
30#include "TTimeStamp.h"
31#include "TMap.h"
32
33class TH2;
34class AliCDBMetaData;
35class TDatime;
36
37// AliTOFDataDCS class
38// main aim to introduce the aliases for the TOF DCS
39// data points to be then
40// stored in the OCDB, and to process them.
41// Process() method called by TOFPrepr
42
43ClassImp(AliTOFDataDCS)
44
45//---------------------------------------------------------------
46AliTOFDataDCS::AliTOFDataDCS():
47 TObject(),
48 fRun(0),
49 fStartTime(0),
50 fEndTime(0),
51 fIsProcessed(kFALSE)
52{
53
54 // main constructor
55
56 for(int i=0;i<kNHV;i++) {
57 fHVvpos[i]=0x0;
58 fHVvneg[i]=0x0;
59 fHVcpos[i]=0x0;
60 fHVcneg[i]=0x0;
61 }
62
63 for(int i=0;i<kNLV;i++) {
64 fLVv[i]=0x0;
65 fLVc[i]=0x0;
66 }
67
68 for(int i=0;i<kNFEEthr;i++) {
69 fFEEthr[i]=0x0;
70 }
71
72 for(int i=0;i<kNFEEt;i++) {
73 fFEEt[i]=0x0;
74 }
75
76 for(int i=0;i<3;i++) {
77 fT[i]=0;
78 fP[i]=0;
79 }
80
81}
82
83//---------------------------------------------------------------
84AliTOFDataDCS::AliTOFDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
85 TObject(),
86 fRun(nRun),
87 fStartTime(startTime),
88 fEndTime(endTime),
89 fIsProcessed(kFALSE)
90{
91
92 // constructor with arguments
93
94 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
95 TTimeStamp(startTime).AsString(),
96 TTimeStamp(endTime).AsString()));
97
98 Init();
99
100}
101
102//---------------------------------------------------------------
103
104AliTOFDataDCS::AliTOFDataDCS(const AliTOFDataDCS & data):
105 TObject(),
106 fRun(0),
107 fStartTime(0),
108 fEndTime(0),
109 fIsProcessed(kFALSE)
110
111{
112
113// copy constructor
114
115 fRun=data.fRun;
116 fStartTime=data.fStartTime;
117 fEndTime=data.fEndTime;
118 fIsProcessed=data.fIsProcessed;
119
120 for(int i=0;i<kNAliases;i++) {
121 fAliasNames[i]=data.fAliasNames[i];
122 }
123
124 for(int i=0;i<kNHV;i++) {
125 fHVvpos[i]=data.fHVvpos[i];
126 fHVvneg[i]=data.fHVvneg[i];
127 fHVcpos[i]=data.fHVcpos[i];
128 fHVcneg[i]=data.fHVcneg[i];
129 }
130
131 for(int i=0;i<kNLV;i++) {
132 fLVv[i]=data.fLVv[i];
133 fLVc[i]=data.fLVc[i];
134 }
135
136 for(int i=0;i<kNFEEthr;i++) {
137 fFEEthr[i]=data.fFEEthr[i];
138 }
139
140 for(int i=0;i<kNFEEt;i++) {
141 fFEEt[i]=data.fFEEt[i];
142 }
143
144 for(int i=0;i<3;i++) {
145 fT[i]=data.fT[i];
146 fP[i]=data.fP[i];
147 }
148
149}
150//---------------------------------------------------------------
151
152AliTOFDataDCS& AliTOFDataDCS:: operator=(const AliTOFDataDCS & data) {
153
154// assignment operator
155
156 this->fRun=data.GetRun();
157 this->fStartTime=data.GetStartTime();
158 this->fEndTime=data.GetEndTime();
159
160 for(int i=0;i<kNAliases;i++) {
161 this->fAliasNames[i]=data.GetAliasName(i);
162 }
163
164 for(int i=0;i<3;i++) {
165 this->fT[i]=data.GetT(i);
166 this->fP[i]=data.GetP(i);
167 }
168
169 //this->fCal=data.GetCal();
170
171 for(int i=0;i<kNHV;i++) {
172 this->fHVvpos[i]=data.GetHVvpos(i);
173 this->fHVvneg[i]=data.GetHVvneg(i);
174 this->fHVcpos[i]=data.GetHVcpos(i);
175 this->fHVcneg[i]=data.GetHVcneg(i);
176 }
177
178 for(int i=0;i<kNLV;i++) {
179 this->fLVv[i]=data.GetLVv(i);
180 this->fLVc[i]=data.GetLVc(i);
181 }
182
183 for(int i=0;i<kNFEEthr;i++) {
184 this->fFEEthr[i]=data.GetFEEthr(i);
185 }
186
187 for(int i=0;i<kNFEEt;i++) {
188 this->fFEEt[i]=data.GetFEEt(i);
189 }
190
191 this->fIsProcessed=data.fIsProcessed;
192
193 return *this;
194}
195//---------------------------------------------------------------
196AliTOFDataDCS::~AliTOFDataDCS() {
197
198 // destructor
199
200 for(int i=0;i<kNHV;i++) {
201 delete fHVvpos[i];
202 fHVvpos[i]=0;
203 delete fHVvneg[i];
204 fHVvneg[i]=0;
205 delete fHVcpos[i];
206 fHVcpos[i]=0;
207 delete fHVcneg[i];
208 fHVcneg[i]=0;
209 }
210
211 for(int i=0;i<kNLV;i++) {
212 delete fLVv[i];
213 fLVv[i]=0;
214 delete fLVc[i];
215 fLVc[i]=0;
216 }
217
218 for(int i=0;i<kNFEEthr;i++) {
219 delete fFEEthr[i];
220 fFEEthr[i]=0;
221 }
222
223 for(int i=0;i<kNFEEt;i++) {
224 delete fFEEt[i];
225 fFEEt[i]=0;
226 }
227}
228
229//-----------------------------------------------------------------------------
230Float_t* AliTOFDataDCS::GetT()const {
231
232 // method to retrieve environment temperature info
233
234 Float_t* t=0;
235 for (Int_t i=0;i<3;i++){
236 t[i]=this->fT[i];
237 }
238 return t;
239}
240//-----------------------------------------------------------------------------
241Float_t* AliTOFDataDCS::GetP() const{
242
243 // method to retrieve environment pressure info
244
245 Float_t* p=0;
246 for (Int_t i=0;i<3;i++){
247 p[i]=this->fP[i];
248 }
249 return p;
250}
251
252//---------------------------------------------------------------
253void AliTOFDataDCS::ProcessData(TMap& aliasMap){
254
255 if(!(fAliasNames[0])) Init();
256
257 Float_t timeMin = (Float_t)fStartTime;
258 Float_t timeMax = (Float_t)fEndTime;
259 Int_t nminutes = (Int_t)((timeMax-timeMin)/60);
260 Float_t val=0;
261 Float_t val1=0;
262 Float_t time=0;
263 Float_t delta[2];
264 Float_t timedelta[2];
265
266 TObjArray *aliasArr;
267 AliDCSValue* aValue;
268 AliDCSValue* aValue1;
269 TH1F * histoT=0x0;
270 TH1F * histoP=0x0;
271
272 // starting loop on aliases
273 for(int j=0; j<kNAliases; j++){
274 for (Int_t k=0;k<2;k++) {
275 delta[k]=0;
276 timedelta[k]=0;
277 }
278 //AliInfo(Form("j = %i, with alias = %s",j,fAliasNames[j].Data()));
279 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
280 if(!aliasArr){
281 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
282 continue;
283 }
284
285 Introduce(j, aliasArr);
286
287 if(aliasArr->GetEntries()<3){
288 AliError(Form("Alias %s has just %d entries!",
289 fAliasNames[j].Data(),aliasArr->GetEntries()));
290 continue;
291 }
292
293 TIter iterarray(aliasArr);
294
295 Int_t nentries = aliasArr->GetEntries();
296 //AliInfo(Form("entries = %i",nentries));
297 Int_t deltaTimeStamp = (Int_t) nentries/3;
298 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
299 AliDCSValue *lastDCSvalue = (AliDCSValue*) aliasArr->At(nentries-1);
300 Float_t maxTimeStamp = (Float_t) (lastDCSvalue->GetTimeStamp());
301 Float_t minTimeStamp = 0;
302
303 // filling aliases with 10 floats+1 Usign
304 if (j < kNHV*4+kNLV*2+kNFEEthr+kNFEEt){
305 Int_t index = 0;
306 for (Int_t k=0;k<3;k++){
307 index = deltaTimeStamp*k;
308 if (k==0) {
309 index=0;
310 }
311 else if (k==1) {
312 index=deltaTimeStamp1;
313 }
314 else if (k==2) {
315 index=nentries-1;
316 }
317 aValue = (AliDCSValue*) aliasArr->At(index);
318 val = aValue->GetFloat();
319 time = (Float_t) (aValue->GetTimeStamp());
320 if (j<kNHV){
321 fHVvpos[j]->SetFloat(k,val);
322 fHVvpos[j]->SetTimeStampFloat(k,time);
323 }
324 else if (j<kNHV*2){
325 fHVvneg[j-kNHV]->SetFloat(k,val);
326 fHVvneg[j-kNHV]->SetTimeStampFloat(k,time);
327 }
328 else if (j<kNHV*3){
329 fHVcpos[j-2*kNHV]->SetFloat(k,val);
330 fHVcpos[j-2*kNHV]->SetTimeStampFloat(k,time);
331 }
332 else if (j<kNHV*4){
333 fHVcneg[j-3*kNHV]->SetFloat(k,val);
334 fHVcneg[j-3*kNHV]->SetTimeStampFloat(k,time);
335 }
336 else if (j<kNHV*4+kNLV){
337 fLVv[j-4*kNHV]->SetFloat(k,val);
338 fLVv[j-4*kNHV]->SetTimeStampFloat(k,time);
339 }
340 else if (j<kNHV*4+kNLV*2){
341 fLVc[j-4*kNHV-kNLV]->SetFloat(k,val);
342 fLVc[j-4*kNHV-kNLV]->SetTimeStampFloat(k,time);
343 }
344 else if (j<kNHV*4+kNLV*2+kNFEEthr){
345 fFEEthr[j-4*kNHV-2*kNLV]->SetFloat(k,val);
346 fFEEthr[j-4*kNHV-2*kNLV]->SetTimeStampFloat(k,time);
347 }
348 else {
349 fFEEt[j-4*kNHV-2*kNLV-kNFEEthr]->SetFloat(k,val);
350 fFEEt[j-4*kNHV-2*kNLV-kNFEEthr]->SetTimeStampFloat(k,time);
351 }
352 }
353 }
354
355 //filling Temperature and Pressure aliases
356
357 else {
358 Int_t entriesT=0;
359 Int_t entriesP=0;
360 if (j<kNHV*4+kNLV*2+kNFEEthr+kNFEEt+1){
361 histoT=new TH1F("histoT","histoT",nentries,minTimeStamp,maxTimeStamp);
362 }
363 else if (j<kNHV*4+kNLV*2+kNFEEthr+kNFEEt+2) {
364 histoP=new TH1F("histoP","histoP",nentries,minTimeStamp,maxTimeStamp);
365 }
366 while ((aValue = (AliDCSValue*) iterarray.Next())) {
367 val = aValue->GetFloat();
368 time = (Float_t) (aValue->GetTimeStamp());
369 if (j<kNHV*4+kNLV*2+kNFEEthr+kNFEEt+1){
370 histoT->Fill(time,val);
371 entriesT = (Int_t)(histoT->GetEntries());
372 }
373 else if (j<kNHV*4+kNLV*2+kNFEEthr+kNFEEt+2){
374 histoP->Fill(time,val);
375 entriesP = (Int_t)(histoP->GetEntries());
376 }
377 }
378
379 if (j==kNHV*4+kNLV*2+kNFEEthr+kNFEEt+1){
380 entriesT = (Int_t)(histoT->GetEntries());
381 histoT->Fit("pol1","Q","");
382 histoP->Fit("pol1","Q","");
383
384 TF1 *tempFunc = histoT->GetFunction("pol1");
385 TF1 *pressFunc = histoP->GetFunction("pol1");
386
387 SetInterceptT((Float_t)tempFunc->GetParameter(0));
388 SetSlopeT((Float_t)tempFunc->GetParameter(1));
389 SetMaxT((Float_t)histoT->GetMaximum());
390 SetInterceptP((Float_t)pressFunc->GetParameter(0));
391 SetSlopeP((Float_t)pressFunc->GetParameter(1));
392 SetMaxP((Float_t)histoP->GetMaximum());
393
394 TCanvas *chT;
395 TString canvasHistoNameT="HistosT";
396 chT=new TCanvas(canvasHistoNameT,canvasHistoNameT,20,20,600,600);
397 chT->cd();
398 histoT->Draw();
399 TCanvas *chP;
400 TString canvasHistoNameP="HistosP";
401 chP=new TCanvas(canvasHistoNameP,canvasHistoNameP,20,20,600,600);
402 chP->cd();
403 histoP->Draw();
404 }
405 }
406
407 //computing the most significant variations
408
409 Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries);
410 Int_t klast = nentries-deltamin;
411
412 for (Int_t k=0;k<klast;k++){
413 aValue = (AliDCSValue*) aliasArr->At(k);
414 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
415 val = aValue->GetFloat();
416 val1 = aValue1->GetFloat();
417 if (delta[0]<=TMath::Abs(val1-val)) {
418 delta[0]=TMath::Abs(val1-val);
419 timedelta[0] = (Float_t)k;
420 }
421 if (delta[1]<=delta[0]) {
422 Float_t temp = delta[1];
423 Float_t timetemp = timedelta[1];
424 delta[1]=delta[0];
425 delta[0]=temp;
426 timedelta[1]=timedelta[0];
427 timedelta[0]=timetemp;
428 }
429 }
430
431 for (Int_t kk=0;kk<2;kk++){
432 if (j < kNHV*4+kNLV*2+kNFEEthr){
433 if (j<kNHV){
434 fHVvpos[j]->SetDelta(kk,delta[kk]);
435 fHVvpos[j]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
436 }
437 else if (j<kNHV*2){
438 fHVvneg[j-kNHV]->SetDelta(kk,delta[kk]);
439 fHVvneg[j-kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
440 }
441 else if (j<kNHV*3){
442 fHVcpos[j-2*kNHV]->SetDelta(kk,delta[kk]);
443 fHVcpos[j-2*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
444 }
445 else if (j<kNHV*4){
446 fHVcneg[j-3*kNHV]->SetDelta(kk,delta[kk]);
447 fHVcneg[j-3*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
448 }
449 else if (j<kNHV*4+kNLV){
450 fLVv[j-4*kNHV]->SetDelta(kk,delta[kk]);
451 fLVv[j-4*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
452 }
453 else if (j<kNHV*4+kNLV*2){
454 fLVc[j-4*kNHV-kNLV]->SetDelta(kk,delta[kk]);
455 fLVc[j-4*kNHV-kNLV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
456 }
457 else if (j<kNHV*4+kNLV*2+kNFEEthr){
458 fFEEthr[j-4*kNHV-2*kNLV]->SetDelta(kk,delta[kk]);
459 fFEEthr[j-4*kNHV-2*kNLV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
460 }
461 else if (j<kNHV*4+kNLV*2+kNFEEthr+kNFEEt){
462 fFEEt[j-4*kNHV-2*kNLV+kNFEEthr]->SetDelta(kk,delta[kk]);
463 fFEEt[j-4*kNHV-2*kNLV+kNFEEthr]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
464 }
465 }
466
467
468 //filling for temperature and pressure
469
470 else if (j==kNHV*4+kNLV*2+kNFEEthr+kNFEEt){
471 fT[2]=delta[1];
472 }
473 else if (j==kNHV*4+kNLV*2+kNFEEthr+kNFEEt+1){
474 fP[2]=delta[1];
475 }
476
477 }
478 }
479
480 fIsProcessed=kTRUE;
481
482}
483
484//---------------------------------------------------------------
485void AliTOFDataDCS::Init(){
486
487 // initialization of aliases and DCS data
488
489 for(int i=0;i<kNAliases;i++){
490 if (i<kNHV){
491 fAliasNames[i] = "HVvpos";
492 fAliasNames[i] += i;
493 //AliInfo(Form("i = %i, alias name = %s ", i, fAliasNames[i].Data()));
494 fHVvpos[i] = new AliTOFFormatDCS();
495 }
496 else if (i<kNHV*2){
497 fAliasNames[i] = "HVvneg";
498 fAliasNames[i] += i-kNHV;
499 fHVvneg[i-kNHV] = new AliTOFFormatDCS();
500 }
501 else if (i<kNHV*3){
502 fAliasNames[i] = "HVcpos";
503 fAliasNames[i] += i-2*kNHV;
504 fHVcpos[i-2*kNHV] = new AliTOFFormatDCS();
505 }
506 else if (i<kNHV*4){
507 fAliasNames[i] = "HVcneg";
508 fAliasNames[i] += i-3*kNHV;
509 fHVcneg[i-3*kNHV] = new AliTOFFormatDCS();
510 }
511 else if (i<(kNHV*4+kNLV)){
512 fAliasNames[i] = "LVv";
513 fAliasNames[i] += i-4*kNHV;
514 fLVv[i-4*kNHV] = new AliTOFFormatDCS();
515 }
516 else if (i<(kNHV*4+kNLV*2)){
517 fAliasNames[i] = "LVc";
518 fAliasNames[i] += i-4*kNHV-kNLV;
519 fLVc[i-4*kNHV-kNLV] = new AliTOFFormatDCS();
520 }
521 else if (i<(kNHV*4+kNLV*2+kNFEEthr)){
522 fAliasNames[i] = "FEEthr";
523 fAliasNames[i] += i-4*kNHV-2*kNLV;
524 fFEEthr[i-4*kNHV-2*kNLV] = new AliTOFFormatDCS();
525 }
526 else if (i<(kNHV*4+kNLV*2+kNFEEthr+kNFEEt)){
527 fAliasNames[i] = "FEEt";
528 fAliasNames[i] += i-4*kNHV-2*kNLV-kNFEEthr;
529 fFEEt[i-4*kNHV-2*kNLV-kNFEEthr] = new AliTOFFormatDCS();
530 }
531 else if (i<(kNHV*4+kNLV*2+kNFEEthr+kNFEEt+1)){
532 fAliasNames[i] = "Temperature";
533 }
534 else if (i<(kNHV*4+kNLV*2+kNFEEthr+kNFEEt+2)){
535 fAliasNames[i] = "Pressure";
536 }
537 }
538}
539
540
541//---------------------------------------------------------------
542void AliTOFDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
543{
544
545 // method to introduce new aliases
546
547 int entries=0;
548 entries = aliasArr->GetEntries();
549 int nal=0;
550 nal=numAlias;
551 //AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
552 //AliInfo(Form(" %d DP values collected",entries));
553
554}
555
556//---------------------------------------------------------------
557void AliTOFDataDCS::Draw(const Option_t* /*option*/)
558{
559// Draw all histos and graphs
560
561 if(!fIsProcessed) return;
562
563 TCanvas *ch;
564 TString canvasHistoName="Histos";
565 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
566 ch->cd();
567
568 // to be implemented
569
570}
571