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