]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFDataDCS.cxx
Removed FSTR/FLT extrusions in the res/full TOF misalignment geometries
[u/mrichter/AliRoot.git] / TOF / AliTOFDataDCS.cxx
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: AliTOFDataDCS.cxx,v $
18 Revision 1.9  2007/05/04 14:02:45  decaro
19 AliTOFDataDCS::Draw(Option_t *) method declared const: compiling warning suppression
20
21 Revision 1.8  2007/05/03 09:45:09  decaro
22 Coding convention: RN11 violation -> suppression
23
24 Revision 1.7  2007/05/02 14:09:39  arcelli
25 Retrieval of Env. Temperature removed (will get it from the GRP)
26
27 Revision 1.6  2007/04/04 17:19:19  arcelli
28 Moved some printout to debug level
29
30 Revision 1.5  2007/02/20 15:57:00  decaro
31 Raw data update: to read the TOF raw data defined in UNPACKED mode
32
33 Revision 1.4  2007/02/19 15:41:55  decaro
34 Coding convention: few corrections
35
36 Revision 1.3  2007/01/24 11:19:58  arcelli
37 Modify ProcessData to return a logical (CZ)
38
39 Revision 1.2  2006/12/18 18:17:38  arcelli
40 Updated Aliases for DCS TOF datapoints (C.Zampolli)
41
42 Revision 1.1  2006/10/26 09:10:52  arcelli
43 Class for handling the TOF DCS data in the Shuttle (C.Zampolli)
44
45 */  
46
47 #include "TString.h"
48 //#include "TF1.h"
49 //#include "TH1F.h"
50 #include "TTimeStamp.h"
51 #include "TMap.h"
52 #include "TCanvas.h"
53
54 #include "AliDCSValue.h"
55 #include "AliLog.h"
56
57 #include "AliTOFDataDCS.h"
58 #include "AliTOFFormatDCS.h"
59
60 class TH2;
61 class AliCDBMetaData;
62 class 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
70 ClassImp(AliTOFDataDCS)
71
72 //---------------------------------------------------------------
73 AliTOFDataDCS::AliTOFDataDCS():
74         TObject(),
75         fRun(0),
76         fStartTime(0),
77         fEndTime(0),
78         fStartTimeDCSQuery(0),
79         fEndTimeDCSQuery(0),
80         fIsProcessed(kFALSE),
81         fFDR(kFALSE)
82 {
83
84   // main constructor 
85
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   }
92     
93   
94 }
95
96 //---------------------------------------------------------------
97 AliTOFDataDCS::AliTOFDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery):
98         TObject(),
99         fRun(nRun),
100         fStartTime(startTime),
101         fEndTime(endTime),
102         fStartTimeDCSQuery(startTimeDCSQuery),
103         fEndTimeDCSQuery(endTimeDCSQuery),
104         fIsProcessed(kFALSE),
105         fFDR(kFALSE)
106 {
107
108   // constructor with arguments
109
110         AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", nRun,
111         TTimeStamp(startTime).AsString(),
112         TTimeStamp(endTime).AsString(), 
113         TTimeStamp(startTimeDCSQuery).AsString(), 
114         TTimeStamp(endTimeDCSQuery).AsString()));
115
116         Init();
117
118 }
119
120 //---------------------------------------------------------------
121
122 AliTOFDataDCS::AliTOFDataDCS(const AliTOFDataDCS & data):
123   TObject(), 
124   fRun(0),
125   fStartTime(0),
126   fEndTime(0),
127   fStartTimeDCSQuery(0),
128   fEndTimeDCSQuery(0),
129   fIsProcessed(kFALSE),
130   fFDR(kFALSE)
131
132 {
133
134 // copy constructor
135
136   fRun=data.fRun;
137   fStartTime=data.fStartTime;
138   fEndTime=data.fEndTime;
139   fStartTimeDCSQuery=data.fStartTimeDCSQuery;
140   fEndTimeDCSQuery=data.fEndTimeDCSQuery;
141   fIsProcessed=data.fIsProcessed;
142   fFDR=data.fFDR;
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++) {
149     fHVvp[i]=data.fHVvp[i];
150     fHVvn[i]=data.fHVvn[i];
151     fHVip[i]=data.fHVip[i];
152     fHVin[i]=data.fHVin[i];
153   }
154   
155     
156 }
157 //---------------------------------------------------------------
158
159 AliTOFDataDCS& 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();
166   this->fStartTimeDCSQuery=data.GetStartTimeDCSQuery();
167   this->fEndTimeDCSQuery=data.GetEndTimeDCSQuery();
168
169   for(int i=0;i<kNAliases;i++) {
170     this->fAliasNames[i]=data.GetAliasName(i);
171   }
172
173   for(int i=0;i<kNHV;i++) {
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);
178   }
179
180
181   return *this;
182 }
183 //---------------------------------------------------------------
184 AliTOFDataDCS::~AliTOFDataDCS() {
185
186   // destructor
187
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   
199 }
200
201 //---------------------------------------------------------------
202 Bool_t AliTOFDataDCS::ProcessData(TMap& aliasMap){
203
204   // method to process the data
205
206   if(!(fAliasNames[0])) Init();
207
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
214   AliInfo(Form(" Start Time = %i",fStartTime));
215   AliInfo(Form(" End Time = %i",fEndTime));
216   AliInfo(Form(" Start Time DCS Query= %i",fStartTimeDCSQuery));
217   AliInfo(Form(" End Time DCS Query= %i",fEndTimeDCSQuery));
218
219   if (fEndTime==fStartTime){
220     AliError(Form(" Run with null time length: start time = %i = end time = %i",fStartTime,fEndTime));
221     return kFALSE;
222   }
223
224   TObjArray *aliasArr;
225   AliDCSValue* aValue;
226   AliDCSValue* aValue1;
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()));
238       if (!fFDR){
239         return kFALSE;    // returning only in case we are not in a FDR run
240       }
241       else {
242         continue;
243       }
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();
257     Int_t deltaTimeStamp = (Int_t) nentries/3;
258     Int_t deltaTimeStamp1 = (Int_t) nentries/2;
259
260     // filling aliases with 10 floats+1 Usign
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;
266       }
267       else if (k==1) {
268         index=deltaTimeStamp1;
269       } 
270       else if (k==2) {
271         index=nentries-1; 
272       }
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       }
292     }
293   
294     //computing the most significant variations
295
296     //Float_t timeDiff = (Float_t)(fEndTime-fStartTime);
297     Float_t timeDiff = (Float_t)(fEndTimeDCSQuery-fStartTimeDCSQuery);
298     Int_t deltamin = (Int_t)(60/timeDiff*nentries); //sampling every minute
299     Int_t klast = nentries-deltamin;
300       
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++){
321       if (j<kNHV){
322         fHVvp[j]->SetDelta(kk,delta[kk]);
323         fHVvp[j]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
324       }
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       }
337     }
338   }
339   
340   fIsProcessed=kTRUE;
341
342   return kTRUE;
343 }
344
345 //---------------------------------------------------------------
346 void AliTOFDataDCS::Init(){
347
348   // initialization of aliases and DCS data
349
350   TString sindex;
351   for(int i=0;i<kNAliases;i++){
352     //HV, v
353     if (i<kNHV){
354         fAliasNames[i] = "tof_hv_vp_";
355         sindex.Form("%02i",i);
356         fAliasNames[i] += sindex;
357         fHVvp[i] = new AliTOFFormatDCS();
358     }
359     else if (i<kNHV*2){
360         fAliasNames[i] = "tof_hv_vn_";
361         sindex.Form("%02i",i-kNHV);
362         fAliasNames[i] += sindex;
363         fHVvn[i-kNHV] = new AliTOFFormatDCS();
364     }
365     //HV, i
366     else if (i<kNHV*3){
367         fAliasNames[i] = "tof_hv_ip_";
368         sindex.Form("%02i",i-2*kNHV);
369         fAliasNames[i] += sindex;
370         fHVip[i-2*kNHV] = new AliTOFFormatDCS();
371     }
372     else if (i<kNHV*4){
373         fAliasNames[i] = "tof_hv_in_";
374         sindex.Form("%02i",i-3*kNHV);
375         fAliasNames[i] += sindex;
376         fHVin[i-3*kNHV] = new AliTOFFormatDCS();
377     }
378   }
379 }
380
381
382 //---------------------------------------------------------------
383 void 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;
392   AliDebug(2,Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
393   AliDebug(2,Form("     %d DP values collected",entries));
394
395 }
396
397 //---------------------------------------------------------------
398 void AliTOFDataDCS::Draw(const Option_t* /*option*/)
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