]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFDataDCS.cxx
Bug fixed into equipmentID-volume correspondence
[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),
7fffa85b 78 fIsProcessed(kFALSE),
79 fFDR(kFALSE)
345932e4 80{
81
82 // main constructor
83
8259e6f8 84 for(int i=0;i<kNHV;i++) {
85 fHVvp[i]=0x0;
86 fHVvn[i]=0x0;
87 fHVip[i]=0x0;
88 fHVin[i]=0x0;
89 }
d202b31a 90
8259e6f8 91
345932e4 92}
93
94//---------------------------------------------------------------
95AliTOFDataDCS::AliTOFDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
96 TObject(),
97 fRun(nRun),
98 fStartTime(startTime),
99 fEndTime(endTime),
7fffa85b 100 fIsProcessed(kFALSE),
101 fFDR(kFALSE)
345932e4 102{
103
104 // constructor with arguments
105
106 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
107 TTimeStamp(startTime).AsString(),
108 TTimeStamp(endTime).AsString()));
109
110 Init();
111
112}
113
114//---------------------------------------------------------------
115
116AliTOFDataDCS::AliTOFDataDCS(const AliTOFDataDCS & data):
117 TObject(),
118 fRun(0),
119 fStartTime(0),
120 fEndTime(0),
7fffa85b 121 fIsProcessed(kFALSE),
122 fFDR(kFALSE)
345932e4 123
124{
125
126// copy constructor
127
128 fRun=data.fRun;
129 fStartTime=data.fStartTime;
130 fEndTime=data.fEndTime;
131 fIsProcessed=data.fIsProcessed;
7fffa85b 132 fFDR=data.fFDR;
345932e4 133
134 for(int i=0;i<kNAliases;i++) {
135 fAliasNames[i]=data.fAliasNames[i];
136 }
137
138 for(int i=0;i<kNHV;i++) {
8259e6f8 139 fHVvp[i]=data.fHVvp[i];
140 fHVvn[i]=data.fHVvn[i];
141 fHVip[i]=data.fHVip[i];
142 fHVin[i]=data.fHVin[i];
345932e4 143 }
144
38e3bbf1 145
345932e4 146}
147//---------------------------------------------------------------
148
149AliTOFDataDCS& AliTOFDataDCS:: operator=(const AliTOFDataDCS & data) {
150
151// assignment operator
152
153 this->fRun=data.GetRun();
154 this->fStartTime=data.GetStartTime();
155 this->fEndTime=data.GetEndTime();
156
157 for(int i=0;i<kNAliases;i++) {
158 this->fAliasNames[i]=data.GetAliasName(i);
159 }
160
345932e4 161 for(int i=0;i<kNHV;i++) {
8259e6f8 162 this->fHVvp[i]=data.GetHVvp(i);
163 this->fHVvn[i]=data.GetHVvn(i);
164 this->fHVip[i]=data.GetHVip(i);
165 this->fHVin[i]=data.GetHVin(i);
345932e4 166 }
167
345932e4 168
169 return *this;
170}
171//---------------------------------------------------------------
172AliTOFDataDCS::~AliTOFDataDCS() {
173
174 // destructor
175
8259e6f8 176 for(int i=0;i<kNHV;i++) {
177 delete fHVvp[i];
178 fHVvp[i]=0;
179 delete fHVvn[i];
180 fHVvn[i]=0;
181 delete fHVip[i];
182 fHVip[i]=0;
183 delete fHVin[i];
184 fHVin[i]=0;
185 }
186
345932e4 187}
188
345932e4 189//---------------------------------------------------------------
ebab534a 190Bool_t AliTOFDataDCS::ProcessData(TMap& aliasMap){
345932e4 191
3a3ece53 192 // method to process the data
193
345932e4 194 if(!(fAliasNames[0])) Init();
195
345932e4 196 Float_t val=0;
197 Float_t val1=0;
198 Float_t time=0;
199 Float_t delta[2];
200 Float_t timedelta[2];
201
e83a0dd0 202 AliInfo(Form(" Start Time = %i",fStartTime));
203 AliInfo(Form(" End Time = %i",fEndTime));
204
205 if (fEndTime==fStartTime){
206 AliError(Form(" Run with null time length: start time = %i = end time = %i",fStartTime,fEndTime));
207 return kFALSE;
96fec15b 208 }
209
345932e4 210 TObjArray *aliasArr;
211 AliDCSValue* aValue;
212 AliDCSValue* aValue1;
345932e4 213
214 // starting loop on aliases
215 for(int j=0; j<kNAliases; j++){
216 for (Int_t k=0;k<2;k++) {
217 delta[k]=0;
218 timedelta[k]=0;
219 }
220 //AliInfo(Form("j = %i, with alias = %s",j,fAliasNames[j].Data()));
221 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
222 if(!aliasArr){
223 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
7fffa85b 224 if (!fFDR){
225 return kFALSE; // returning only in case we are not in a FDR run
226 }
227 else {
228 continue;
229 }
345932e4 230 }
231
232 Introduce(j, aliasArr);
233
234 if(aliasArr->GetEntries()<3){
235 AliError(Form("Alias %s has just %d entries!",
236 fAliasNames[j].Data(),aliasArr->GetEntries()));
237 continue;
238 }
239
240 TIter iterarray(aliasArr);
241
242 Int_t nentries = aliasArr->GetEntries();
345932e4 243 Int_t deltaTimeStamp = (Int_t) nentries/3;
244 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
345932e4 245
246 // filling aliases with 10 floats+1 Usign
38e3bbf1 247 Int_t index = 0;
248 for (Int_t k=0;k<3;k++){
249 index = deltaTimeStamp*k;
250 if (k==0) {
251 index=0;
345932e4 252 }
38e3bbf1 253 else if (k==1) {
254 index=deltaTimeStamp1;
255 }
256 else if (k==2) {
257 index=nentries-1;
345932e4 258 }
38e3bbf1 259 aValue = (AliDCSValue*) aliasArr->At(index);
260 val = aValue->GetFloat();
261 time = (Float_t) (aValue->GetTimeStamp());
262 if (j<kNHV){
263 fHVvp[j]->SetFloat(k,val);
264 fHVvp[j]->SetTimeStampFloat(k,time);
265 }
266 else if (j<kNHV*2){
267 fHVvn[j-kNHV]->SetFloat(k,val);
268 fHVvn[j-kNHV]->SetTimeStampFloat(k,time);
269 }
270 else if (j<kNHV*3){
271 fHVip[j-2*kNHV]->SetFloat(k,val);
272 fHVip[j-2*kNHV]->SetTimeStampFloat(k,time);
273 }
274 else if (j<kNHV*4){
275 fHVin[j-3*kNHV]->SetFloat(k,val);
276 fHVin[j-3*kNHV]->SetTimeStampFloat(k,time);
277 }
345932e4 278 }
38e3bbf1 279
345932e4 280 //computing the most significant variations
281
e83a0dd0 282 Float_t timeDiff = (Float_t)(fEndTime-fStartTime);
283 Int_t deltamin = (Int_t)(60/timeDiff*nentries); //sampling every minute
345932e4 284 Int_t klast = nentries-deltamin;
38e3bbf1 285
345932e4 286 for (Int_t k=0;k<klast;k++){
287 aValue = (AliDCSValue*) aliasArr->At(k);
288 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
289 val = aValue->GetFloat();
290 val1 = aValue1->GetFloat();
291 if (delta[0]<=TMath::Abs(val1-val)) {
292 delta[0]=TMath::Abs(val1-val);
293 timedelta[0] = (Float_t)k;
294 }
295 if (delta[1]<=delta[0]) {
296 Float_t temp = delta[1];
297 Float_t timetemp = timedelta[1];
298 delta[1]=delta[0];
299 delta[0]=temp;
300 timedelta[1]=timedelta[0];
301 timedelta[0]=timetemp;
302 }
303 }
304
305 for (Int_t kk=0;kk<2;kk++){
38e3bbf1 306 if (j<kNHV){
307 fHVvp[j]->SetDelta(kk,delta[kk]);
308 fHVvp[j]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
345932e4 309 }
38e3bbf1 310 else if (j<kNHV*2){
311 fHVvn[j-kNHV]->SetDelta(kk,delta[kk]);
312 fHVvn[j-kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
313 }
314 else if (j<kNHV*3){
315 fHVip[j-2*kNHV]->SetDelta(kk,delta[kk]);
316 fHVip[j-2*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
317 }
318 else if (j<kNHV*4){
319 fHVin[j-3*kNHV]->SetDelta(kk,delta[kk]);
320 fHVin[j-3*kNHV]->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
321 }
8259e6f8 322 }
345932e4 323 }
38e3bbf1 324
345932e4 325 fIsProcessed=kTRUE;
326
ebab534a 327 return kTRUE;
345932e4 328}
329
330//---------------------------------------------------------------
331void AliTOFDataDCS::Init(){
332
333 // initialization of aliases and DCS data
334
8259e6f8 335 TString sindex;
345932e4 336 for(int i=0;i<kNAliases;i++){
8259e6f8 337 //HV, v
345932e4 338 if (i<kNHV){
8259e6f8 339 fAliasNames[i] = "tof_hv_vp_";
340 sindex.Form("%02i",i);
341 fAliasNames[i] += sindex;
342 fHVvp[i] = new AliTOFFormatDCS();
345932e4 343 }
344 else if (i<kNHV*2){
8259e6f8 345 fAliasNames[i] = "tof_hv_vn_";
346 sindex.Form("%02i",i-kNHV);
347 fAliasNames[i] += sindex;
348 fHVvn[i-kNHV] = new AliTOFFormatDCS();
345932e4 349 }
8259e6f8 350 //HV, i
345932e4 351 else if (i<kNHV*3){
8259e6f8 352 fAliasNames[i] = "tof_hv_ip_";
353 sindex.Form("%02i",i-2*kNHV);
354 fAliasNames[i] += sindex;
355 fHVip[i-2*kNHV] = new AliTOFFormatDCS();
345932e4 356 }
357 else if (i<kNHV*4){
8259e6f8 358 fAliasNames[i] = "tof_hv_in_";
359 sindex.Form("%02i",i-3*kNHV);
360 fAliasNames[i] += sindex;
361 fHVin[i-3*kNHV] = new AliTOFFormatDCS();
345932e4 362 }
345932e4 363 }
364}
365
366
367//---------------------------------------------------------------
368void AliTOFDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
369{
370
371 // method to introduce new aliases
372
373 int entries=0;
374 entries = aliasArr->GetEntries();
375 int nal=0;
376 nal=numAlias;
72bf252d 377 AliDebug(2,Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
378 AliDebug(2,Form(" %d DP values collected",entries));
345932e4 379
380}
381
382//---------------------------------------------------------------
b52b97c2 383void AliTOFDataDCS::Draw(const Option_t* /*option*/)
345932e4 384{
385// Draw all histos and graphs
386
387 if(!fIsProcessed) return;
388
389 TCanvas *ch;
390 TString canvasHistoName="Histos";
391 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
392 ch->cd();
393
394 // to be implemented
395
396}
397