Line data Source code
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: AliTOFLvHvDataPoints.cxx,v $
18 : */
19 :
20 : // AliTOFLvHvDataPoints class
21 : // main aim to introduce the aliases for the TOF LV and HV DCS
22 : // data points to be then
23 : // stored in the OCDB, and to process them.
24 : // Process() method called by TOF preprocessor
25 :
26 : #include "TString.h"
27 : #include "TTimeStamp.h"
28 : #include "TMap.h"
29 : #include "TMath.h"
30 : #include "TH1C.h"
31 :
32 : #include "AliDCSValue.h"
33 : #include "AliLog.h"
34 : #include "AliBitPacking.h"
35 :
36 : #include "AliTOFGeometry.h"
37 : #include "AliTOFDCSmaps.h"
38 : #include "AliTOFLvHvDataPoints.h"
39 :
40 : class AliCDBMetaData;
41 : class TDatime;
42 :
43 26 : ClassImp(AliTOFLvHvDataPoints)
44 :
45 : //---------------------------------------------------------------
46 0 : AliTOFLvHvDataPoints::AliTOFLvHvDataPoints():
47 0 : TObject(),
48 0 : fRun(0),
49 0 : fStartTime(0),
50 0 : fEndTime(0),
51 0 : fStartTimeDCSQuery(0),
52 0 : fEndTimeDCSQuery(0),
53 0 : fIsProcessed(kFALSE),
54 0 : fFDR(kFALSE),
55 0 : fNumberOfLVdataPoints(0),
56 0 : fNumberOfHVdataPoints(0),
57 0 : fNumberOfHVandLVmaps(0),
58 0 : fStartingLVmap(0x0),
59 0 : fStartingHVmap(0x0),
60 0 : fHisto(0x0),
61 0 : fNSecondsBeforeEOR(60)
62 0 : {
63 : // main constructor
64 :
65 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= 0x0;
66 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= 0x0;
67 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= 0x0;
68 :
69 0 : }
70 :
71 : //---------------------------------------------------------------
72 0 : AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery):
73 0 : TObject(),
74 0 : fRun(nRun),
75 0 : fStartTime(startTime),
76 0 : fEndTime(endTime),
77 0 : fStartTimeDCSQuery(startTimeDCSQuery),
78 0 : fEndTimeDCSQuery(endTimeDCSQuery),
79 0 : fIsProcessed(kFALSE),
80 0 : fFDR(kFALSE),
81 0 : fNumberOfLVdataPoints(0),
82 0 : fNumberOfHVdataPoints(0),
83 0 : fNumberOfHVandLVmaps(0),
84 0 : fStartingLVmap(new AliTOFDCSmaps()),
85 0 : fStartingHVmap(new AliTOFDCSmaps()),
86 0 : fHisto(new TH1C("histo","",kNpads,-0.5,kNpads-0.5)),
87 0 : fNSecondsBeforeEOR(60)
88 0 : {
89 :
90 : // constructor with arguments
91 :
92 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= 0x0;
93 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= 0x0;
94 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= 0x0;
95 :
96 0 : AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", nRun,
97 : TTimeStamp(startTime).AsString(),
98 : TTimeStamp(endTime).AsString(),
99 : TTimeStamp(startTimeDCSQuery).AsString(),
100 : TTimeStamp(endTimeDCSQuery).AsString()));
101 :
102 0 : Init();
103 :
104 0 : }
105 :
106 : //---------------------------------------------------------------
107 :
108 0 : AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(const AliTOFLvHvDataPoints & data):
109 0 : TObject(data),
110 0 : fRun(data.fRun),
111 0 : fStartTime(data.fStartTime),
112 0 : fEndTime(data.fEndTime),
113 0 : fStartTimeDCSQuery(data.fStartTimeDCSQuery),
114 0 : fEndTimeDCSQuery(data.fEndTimeDCSQuery),
115 0 : fIsProcessed(data.fIsProcessed),
116 0 : fFDR(data.fFDR),
117 0 : fNumberOfLVdataPoints(data.fNumberOfLVdataPoints),
118 0 : fNumberOfHVdataPoints(data.fNumberOfHVdataPoints),
119 0 : fNumberOfHVandLVmaps(data.fNumberOfHVandLVmaps),
120 0 : fStartingLVmap(data.fStartingLVmap),
121 0 : fStartingHVmap(data.fStartingHVmap),
122 0 : fHisto(data.fHisto),
123 0 : fNSecondsBeforeEOR(data.fNSecondsBeforeEOR)
124 0 : {
125 :
126 : // copy constructor
127 :
128 0 : for(int i=0;i<kNddl;i++)
129 0 : fAliasNamesXLVmap[i]=data.fAliasNamesXLVmap[i];
130 :
131 0 : for(int i=0;i<kNsectors;i++)
132 0 : for(int j=0;j<kNplates;j++)
133 0 : fAliasNamesXHVmap[i][j]=data.fAliasNamesXHVmap[i][j];
134 :
135 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= data.fLVDataPoints[ii];
136 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= data.fLVDataPoints[ii];
137 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= data.fMap[ii];
138 :
139 0 : }
140 : //---------------------------------------------------------------
141 :
142 : AliTOFLvHvDataPoints& AliTOFLvHvDataPoints:: operator=(const AliTOFLvHvDataPoints & data) {
143 :
144 : // assignment operator
145 :
146 0 : if (this == &data)
147 0 : return *this;
148 :
149 0 : TObject::operator=(data);
150 0 : fRun=data.GetRun();
151 0 : fStartTime=data.GetStartTime();
152 0 : fEndTime=data.GetEndTime();
153 0 : fStartTimeDCSQuery=data.GetStartTimeDCSQuery();
154 0 : fEndTimeDCSQuery=data.GetEndTimeDCSQuery();
155 :
156 0 : fNumberOfLVdataPoints=data.fNumberOfLVdataPoints;
157 0 : fNumberOfHVdataPoints=data.fNumberOfHVdataPoints;
158 0 : fNumberOfHVandLVmaps=data.fNumberOfHVandLVmaps;
159 :
160 0 : fStartingLVmap=data.fStartingLVmap;
161 0 : fStartingHVmap=data.fStartingHVmap;
162 :
163 0 : for(int i=0;i<kNddl;i++)
164 0 : fAliasNamesXLVmap[i]=data.fAliasNamesXLVmap[i];
165 :
166 0 : for(int i=0;i<kNsectors;i++)
167 0 : for(int j=0;j<kNplates;j++)
168 0 : fAliasNamesXHVmap[i][j]=data.fAliasNamesXHVmap[i][j];
169 :
170 0 : fHisto=data.fHisto;
171 :
172 0 : fNSecondsBeforeEOR=data.fNSecondsBeforeEOR;
173 :
174 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= data.fLVDataPoints[ii];
175 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= data.fLVDataPoints[ii];
176 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= data.fMap[ii];
177 :
178 0 : return *this;
179 0 : }
180 : //---------------------------------------------------------------
181 0 : AliTOFLvHvDataPoints::~AliTOFLvHvDataPoints() {
182 :
183 : // destructor
184 :
185 0 : delete fStartingLVmap;
186 0 : delete fStartingHVmap;
187 :
188 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++)
189 0 : if (fLVDataPoints[ii]) fLVDataPoints[ii]->Delete();
190 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++)
191 0 : if (fHVDataPoints[ii]) fHVDataPoints[ii]->Delete();
192 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++)
193 0 : if (fMap[ii]) fMap[ii]->Delete();
194 :
195 0 : }
196 :
197 : //---------------------------------------------------------------
198 : Bool_t AliTOFLvHvDataPoints::ProcessData(TMap& aliasMap) {
199 : //
200 : // method to process the data
201 : //
202 :
203 0 : if(!(fAliasNamesXHVmap[0][0]) || !(fAliasNamesXLVmap[0])) Init();
204 :
205 0 : AliInfo(Form(" Start Time = %i",fStartTime));
206 0 : AliInfo(Form(" End Time = %i",fEndTime));
207 0 : AliInfo(Form(" Start Time DCS Query= %i",fStartTimeDCSQuery));
208 0 : AliInfo(Form(" End Time DCS Query= %i",fEndTimeDCSQuery));
209 :
210 0 : if (fEndTime==fStartTime){
211 0 : AliError(Form(" Run with null time length: start time = %d = end time = %d",fStartTime,fEndTime));
212 0 : return kFALSE;
213 : }
214 :
215 :
216 0 : if (!ReadLVDataPoints(aliasMap)) return kFALSE;
217 0 : AliDebug(1,Form(" Number of LV dp value changes = %d",fNumberOfLVdataPoints));
218 :
219 0 : if (!ReadHVDataPoints(aliasMap)) return kFALSE;
220 0 : AliDebug(1,Form(" Number of HV dp value changes = %d",fNumberOfHVdataPoints));
221 :
222 0 : if (!MergeLVmap()) return kFALSE;
223 :
224 0 : if (!MergeHVmap()) return kFALSE;
225 :
226 0 : if (!MergeMaps()) return kFALSE;
227 :
228 0 : fIsProcessed=kTRUE;
229 :
230 0 : return kTRUE;
231 :
232 0 : }
233 :
234 : //---------------------------------------------------------------
235 : Bool_t AliTOFLvHvDataPoints::MergeMaps() {
236 : //
237 : // Merge together LV and HV maps
238 : //
239 :
240 0 : Int_t timeMaps[kNmaxDataPoints];
241 0 : for (Int_t ii=0; ii<kNmaxDataPoints; ii++) timeMaps[ii]=0;
242 :
243 0 : for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++) {
244 0 : AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d, LV=%d) - time=%d",fNumberOfHVandLVmaps,fNumberOfHVdataPoints,fNumberOfLVdataPoints,timeMaps[fNumberOfHVandLVmaps]));
245 0 : timeMaps[fNumberOfHVandLVmaps++]=fHVDataPoints[ii]->GetTime();
246 : }
247 :
248 0 : AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d) ",fNumberOfHVandLVmaps,fNumberOfHVdataPoints));
249 :
250 : Bool_t check = kTRUE;
251 0 : for (Int_t jj=0; jj<fNumberOfLVdataPoints; jj++) {
252 : check = kTRUE;
253 0 : for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++)
254 0 : check=check&&(fLVDataPoints[jj]->GetTime()!=timeMaps[ii]);
255 :
256 0 : if (check) {
257 0 : AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d, LV=%d) - time=%d",fNumberOfHVandLVmaps,fNumberOfHVdataPoints,fNumberOfLVdataPoints,timeMaps[fNumberOfHVandLVmaps]));
258 0 : timeMaps[fNumberOfHVandLVmaps++]=fLVDataPoints[jj]->GetTime();
259 0 : }
260 : }
261 :
262 0 : AliInfo(Form(" TOF HV dps = %d; TOF LV dps = %d; TOF HVandLV dps %d",
263 : fNumberOfHVdataPoints, fNumberOfLVdataPoints, fNumberOfHVandLVmaps));
264 :
265 :
266 0 : Int_t *controller = new Int_t[sizeof(Int_t)*fNumberOfHVandLVmaps]; // fix for coverity
267 0 : for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++) controller[ii]=-1;
268 0 : TMath::Sort(fNumberOfHVandLVmaps,timeMaps,controller,kFALSE); // increasing order
269 :
270 0 : for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++)
271 0 : AliDebug(1, Form(" Time Order - time[controller[%d]] = %d", ii, timeMaps[controller[ii]]));
272 :
273 0 : Short_t array[kNpads];
274 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) array[iPad]=-1;
275 : Int_t time = 0;
276 :
277 : // HVandLV status map during run
278 0 : for (Int_t index=0; index<fNumberOfHVandLVmaps; index++) {
279 0 : time = timeMaps[controller[index]];
280 :
281 0 : AliDebug(2, Form(" Time Order - time[controller[%d]] = %d", index, timeMaps[controller[index]]));
282 :
283 0 : for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++)
284 0 : for (Int_t jj=0; jj<fNumberOfLVdataPoints; jj++) {
285 :
286 0 : AliDebug(2,Form(" time=%d --- HVdp_time[%d]=%d, LVdp_time[%d]=%d",
287 : time,
288 : ii,fHVDataPoints[ii]->GetTime(),
289 : jj,fLVDataPoints[jj]->GetTime()));
290 :
291 0 : if ( (fHVDataPoints[ii]->GetTime()==time && fLVDataPoints[jj]->GetTime()<=time) ||
292 0 : (fLVDataPoints[jj]->GetTime()==time && fHVDataPoints[ii]->GetTime()<=time) ) {
293 :
294 0 : AliDebug(2,Form(" HVdp_time[%d]=%d, LVdp_time[%d]=%d",
295 : ii,fHVDataPoints[ii]->GetTime(),
296 : jj,fLVDataPoints[jj]->GetTime()));
297 0 : for (Int_t iPad=0; iPad<kNpads; iPad++)
298 0 : array[iPad] = fHVDataPoints[ii]->GetCellValue(iPad)*fLVDataPoints[jj]->GetCellValue(iPad);
299 0 : AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
300 0 : fMap[index]= object;
301 : break;
302 :
303 : }
304 0 : else if ( fHVDataPoints[ii]->GetTime()==time && fLVDataPoints[jj]->GetTime()>time ) {
305 :
306 0 : AliDebug(2,Form(" HVdp_time[%d]=%d, (no LVdp)",ii,fHVDataPoints[ii]->GetTime()));
307 0 : for (Int_t iPad=0; iPad<kNpads; iPad++)
308 0 : array[iPad] = fHVDataPoints[ii]->GetCellValue(iPad);
309 0 : AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
310 0 : fMap[index]= object;
311 : break;
312 :
313 0 : } else if ( fLVDataPoints[jj]->GetTime()==time && fHVDataPoints[ii]->GetTime()>time ) {
314 :
315 0 : AliDebug(2,Form(" LVdp_time[%d]=%d, (no HVdp)",jj,fLVDataPoints[jj]->GetTime()));
316 0 : for (Int_t iPad=0; iPad<kNpads; iPad++)
317 0 : array[iPad] = fLVDataPoints[jj]->GetCellValue(iPad);
318 0 : AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
319 0 : fMap[index]= object;
320 : break;
321 :
322 : }
323 :
324 : }
325 :
326 : }
327 :
328 0 : delete [] controller;
329 :
330 0 : for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++)
331 0 : AliDebug(1,Form(" fMap[%d]->GetTime() = %d ",ii,fMap[ii]->GetTime()));
332 :
333 0 : return kTRUE;
334 :
335 0 : }
336 :
337 : //---------------------------------------------------------------
338 : Bool_t AliTOFLvHvDataPoints::MergeHVmap() {
339 : //
340 : // Create HV maps from HV dps
341 : //
342 :
343 : Bool_t check= kFALSE;
344 :
345 0 : if (fNumberOfHVdataPoints==0)
346 0 : return check;
347 : else {
348 :
349 : // first map construction
350 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) {
351 0 : if (fHVDataPoints[0]->GetCellValue(iPad)==-1)
352 0 : fHVDataPoints[0]->SetCellValue(iPad,fStartingHVmap->GetCellValue(iPad));
353 : //else
354 : //fHVDataPoints[0]->SetCellValue(iPad,fHVDataPoints[0]->GetCellValue(iPad)*fStartingHVmap->GetCellValue(iPad));
355 :
356 0 : if (iPad%(96*91)==0)
357 0 : AliDebug(2,Form("HVdp0: channel=%6d -> %1d",iPad,fHVDataPoints[0]->GetCellValue(iPad)));
358 : }
359 :
360 : // other maps construction
361 0 : for (Int_t ii=1; ii<fNumberOfHVdataPoints; ii++) {
362 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) {
363 0 : if (fHVDataPoints[ii]->GetCellValue(iPad)==-1)
364 0 : fHVDataPoints[ii]->SetCellValue(iPad,fHVDataPoints[ii-1]->GetCellValue(iPad));
365 :
366 0 : if (iPad%(96*91)==0)
367 0 : AliDebug(2,Form("HVdp%d: channel=%6d -> %1d",ii,iPad,fHVDataPoints[ii]->GetCellValue(iPad)));
368 : }
369 : }
370 :
371 : check=kTRUE;
372 : }
373 :
374 0 : return kTRUE;
375 :
376 0 : }
377 :
378 : //---------------------------------------------------------------
379 : Bool_t AliTOFLvHvDataPoints::MergeLVmap() {
380 : //
381 : // Create LV maps from LV dps
382 : //
383 :
384 : Bool_t check= kFALSE;
385 :
386 0 : if (fNumberOfLVdataPoints==0)
387 0 : return check;
388 : else {
389 :
390 : // first map construction
391 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) {
392 0 : if (fLVDataPoints[0]->GetCellValue(iPad)==-1)
393 0 : fLVDataPoints[0]->SetCellValue(iPad,fStartingLVmap->GetCellValue(iPad));
394 : //else
395 : //fLVDataPoints[0]->SetCellValue(iPad,fLVDataPoints[0]->GetCellValue(iPad)*fStartingLVmap->GetCellValue(iPad));
396 :
397 0 : if (iPad%(96*91)==0)
398 0 : AliDebug(2,Form("LVdp0: channel=%6d -> %1d",iPad,fLVDataPoints[0]->GetCellValue(iPad)));
399 : }
400 :
401 : // other maps construction
402 0 : for (Int_t ii=1; ii<fNumberOfLVdataPoints; ii++) {
403 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) {
404 0 : if (fLVDataPoints[ii]->GetCellValue(iPad)==-1)
405 0 : fLVDataPoints[ii]->SetCellValue(iPad,fLVDataPoints[ii-1]->GetCellValue(iPad));
406 :
407 0 : if (iPad%(96*91)==0)
408 0 : AliDebug(2,Form("LVdp%d: channel=%6d -> %1d",ii,iPad,fLVDataPoints[ii]->GetCellValue(iPad)));
409 : }
410 : }
411 :
412 : check=kTRUE;
413 : }
414 :
415 0 : return check;
416 :
417 0 : }
418 :
419 : //---------------------------------------------------------------
420 : Bool_t AliTOFLvHvDataPoints::ReadHVDataPoints(TMap& aliasMap) {
421 : //
422 : // Read HV dps
423 : //
424 :
425 : TObjArray *aliasArr;
426 : AliDCSValue* aValue;
427 : AliDCSValue* aValuePrev;
428 : Int_t val = 0;
429 : Int_t time = 0;
430 : Int_t nEntries = 0;
431 :
432 0 : Short_t dummy[kNpads];
433 :
434 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
435 : // starting loop on aliases
436 0 : for (int i=0; i<kNsectors; i++)
437 0 : for (int j=0; j<kNplates; j++) {
438 0 : aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNamesXHVmap[i][j].Data());
439 0 : if (!aliasArr) {
440 0 : AliError(Form("Alias %s not found!", fAliasNamesXHVmap[i][j].Data()));
441 0 : if (!fFDR)
442 0 : return kFALSE; // returning only in case we are not in a FDR run
443 : else
444 : continue;
445 : }
446 :
447 0 : nEntries = aliasArr->GetEntries();
448 :
449 0 : if (nEntries<2) AliDebug(1, Form(" NB: number of values for dp %s %d (less than 2)",fAliasNamesXHVmap[i][j].Data(),nEntries));
450 :
451 0 : if (nEntries==0) {
452 0 : AliError(Form("Alias %s has no entries! Nothing will be stored",
453 : fAliasNamesXHVmap[i][j].Data()));
454 0 : continue;
455 : }
456 : else {
457 :
458 : // read the first value
459 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
460 0 : aValue = (AliDCSValue*) aliasArr->At(0);
461 0 : val = aValue->GetInt();
462 0 : time = aValue->GetTimeStamp();
463 0 : AliDebug(1, Form(" at t=%d, 1st value for dp %s = %d", time, fAliasNamesXHVmap[i][j].Data(), val));
464 0 : FillHVarrayPerDataPoint(i,j,val,dummy);
465 0 : AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,dummy);
466 0 : if (InsertHVDataPoint(object0)!=0) return kTRUE; // to be verified
467 :
468 : // read the values from the second one
469 0 : for (Int_t iEntry=1; iEntry<nEntries; iEntry++) {
470 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
471 0 : aValue = (AliDCSValue*) aliasArr->At(iEntry);
472 0 : val = aValue->GetInt();
473 0 : time = aValue->GetTimeStamp();
474 0 : AliDebug(2, Form(" at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXHVmap[i][j].Data(), val));
475 0 : aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1);
476 0 : if (aValuePrev->GetInt()!=val) {
477 0 : AliDebug(1, Form(" CHANGE - at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXHVmap[i][j].Data(), val));
478 0 : FillHVarrayPerDataPoint(i,j,val,dummy);
479 0 : AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy);
480 0 : if (InsertHVDataPoint(object)!=0) return kTRUE; // to be verified
481 0 : }
482 :
483 : }
484 0 : }
485 : }
486 :
487 0 : if (fNumberOfHVdataPoints==0) {
488 0 : AliInfo("Valid HV dps not found. By default all HV TOF channels (except the ones in the PHOS holes) switched ON, at SOR.");
489 0 : if (InsertHVDataPoint(fStartingHVmap)!=0) return kTRUE; // to be verified
490 : }
491 :
492 0 : return kTRUE;
493 :
494 0 : }
495 :
496 : //---------------------------------------------------------------
497 : Bool_t AliTOFLvHvDataPoints::ReadLVDataPoints(TMap& aliasMap) {
498 : //
499 : // Read LV dps
500 : //
501 :
502 : TObjArray *aliasArr;
503 : AliDCSValue* aValue;
504 : AliDCSValue* aValuePrev;
505 : Int_t val = 0;
506 : Int_t time = 0;
507 : Int_t nEntries = 0;
508 :
509 0 : Short_t dummy[kNpads];
510 :
511 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
512 : // starting loop on aliases
513 0 : for (int i=0; i<kNddl; i++) {
514 0 : aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNamesXLVmap[i].Data());
515 0 : if (!aliasArr) {
516 0 : AliError(Form("Alias %s not found!", fAliasNamesXLVmap[i].Data()));
517 0 : if (!fFDR)
518 0 : return kFALSE; // returning only in case we are not in a FDR run
519 : else
520 : continue;
521 : }
522 :
523 0 : nEntries = aliasArr->GetEntries();
524 :
525 0 : if (nEntries<2) AliDebug(1, Form(" NB: number of values for dp %s %d (less than 2)",fAliasNamesXLVmap[i].Data(),nEntries));
526 :
527 0 : if (nEntries==0) {
528 0 : AliError(Form("Alias %s has no entries! Nothing will be stored",
529 : fAliasNamesXLVmap[i].Data()));
530 0 : continue;
531 : }
532 : else {
533 :
534 : // read the first value
535 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
536 0 : aValue = (AliDCSValue*) aliasArr->At(0);
537 0 : val = aValue->GetInt();
538 0 : time = aValue->GetTimeStamp();
539 0 : AliDebug(1, Form(" at t=%d, 1st value for dp %s = %d", time, fAliasNamesXLVmap[i].Data(), val));
540 0 : FillLVarrayPerDataPoint(i,val,dummy);
541 0 : AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,dummy);
542 0 : if (InsertLVDataPoint(object0)!=0) return kTRUE; // to be verified
543 :
544 : // read the values from the second one
545 0 : for (Int_t iEntry=1; iEntry<nEntries; iEntry++) {
546 0 : for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
547 0 : aValue = (AliDCSValue*) aliasArr->At(iEntry);
548 0 : val = aValue->GetInt();
549 0 : time = aValue->GetTimeStamp();
550 0 : AliDebug(2, Form(" at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXLVmap[i].Data(), val));
551 0 : aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1);
552 0 : if (aValuePrev->GetInt()!=val) {
553 0 : AliDebug(1, Form(" CHANGE - at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXLVmap[i].Data(), val));
554 0 : FillLVarrayPerDataPoint(i,val,dummy);
555 0 : AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy);
556 0 : if (InsertLVDataPoint(object)!=0) return kTRUE; // to be verified
557 0 : }
558 :
559 : }
560 0 : }
561 : }
562 :
563 0 : if (fNumberOfLVdataPoints==0) {
564 0 : AliInfo("Valid LV dps not found. By default all LV TOF channels switched ON, at SOR.");
565 0 : if (InsertLVDataPoint(fStartingLVmap)!=0) return kTRUE; // to be verified
566 : }
567 :
568 0 : return kTRUE;
569 :
570 0 : }
571 :
572 : //---------------------------------------------------------------
573 : Int_t AliTOFLvHvDataPoints::InsertHVDataPoint(AliTOFDCSmaps *object)
574 : {
575 : //
576 : // Insert HV dp in the HV dps array.
577 : // The HV dps array is sorted according to increasing dp timeStamp value
578 : //
579 :
580 0 : if (fNumberOfHVdataPoints==kNmaxDataPoints) {
581 0 : AliError("Too many HV data points!");
582 0 : return 1;
583 : }
584 :
585 0 : if (fNumberOfHVdataPoints==0) {
586 0 : fHVDataPoints[fNumberOfHVdataPoints++] = object;
587 0 : return 0;
588 : }
589 :
590 0 : for (Int_t index=0; index<fNumberOfHVdataPoints; index++) {
591 0 : if (object->GetTime()==fHVDataPoints[index]->GetTime()) {
592 0 : fHVDataPoints[index]->Update(object);
593 0 : return 0;
594 : }
595 : }
596 :
597 0 : Int_t ii = FindHVdpIndex(object->GetTime());
598 0 : memmove(fHVDataPoints+ii+1 ,fHVDataPoints+ii,(fNumberOfHVdataPoints-ii)*sizeof(AliTOFDCSmaps*));
599 0 : fHVDataPoints[ii] = object;
600 0 : fNumberOfHVdataPoints++;
601 :
602 : return 0;
603 :
604 0 : }
605 :
606 : //_________________________________________________________________________
607 : Int_t AliTOFLvHvDataPoints::FindHVdpIndex(Int_t z) const {
608 : //
609 : // This function returns the index of the nearest HV DP in time
610 : //
611 :
612 0 : if (fNumberOfHVdataPoints==0) return 0;
613 0 : if (z <= fHVDataPoints[0]->GetTime()) return 0;
614 0 : if (z > fHVDataPoints[fNumberOfHVdataPoints-1]->GetTime()) return fNumberOfHVdataPoints;
615 0 : Int_t b = 0, e = fNumberOfHVdataPoints-1, m = (b+e)/2;
616 0 : for (; b<e; m=(b+e)/2) {
617 0 : if (z > fHVDataPoints[m]->GetTime()) b=m+1;
618 : else e=m;
619 : }
620 :
621 : return m;
622 :
623 0 : }
624 :
625 : //---------------------------------------------------------------
626 : Int_t AliTOFLvHvDataPoints::InsertLVDataPoint(AliTOFDCSmaps *object)
627 : {
628 : //
629 : // Insert LV dp in the LV dps array.
630 : // The LV dps array is sorted according to increasing dp timeStamp value
631 : //
632 :
633 0 : if (fNumberOfLVdataPoints==kNmaxDataPoints) {
634 0 : AliError("Too many LV data points!");
635 0 : return 1;
636 : }
637 :
638 0 : if (fNumberOfLVdataPoints==0) {
639 0 : fLVDataPoints[fNumberOfLVdataPoints++] = object;
640 0 : return 0;
641 : }
642 :
643 0 : for (Int_t index=0; index<fNumberOfLVdataPoints; index++) {
644 0 : if (object->GetTime()==fLVDataPoints[index]->GetTime()) {
645 0 : fLVDataPoints[index]->Update(object);
646 0 : return 0;
647 : }
648 : }
649 :
650 0 : Int_t ii = FindLVdpIndex(object->GetTime());
651 0 : memmove(fLVDataPoints+ii+1 ,fLVDataPoints+ii,(fNumberOfLVdataPoints-ii)*sizeof(AliTOFDCSmaps*));
652 0 : fLVDataPoints[ii] = object;
653 0 : fNumberOfLVdataPoints++;
654 :
655 : return 0;
656 :
657 0 : }
658 :
659 : //_________________________________________________________________________
660 : Int_t AliTOFLvHvDataPoints::FindLVdpIndex(Int_t z) const {
661 : //
662 : // This function returns the index of the nearest LV DP in time
663 : //
664 :
665 0 : if (fNumberOfLVdataPoints==0) return 0;
666 0 : if (z <= fLVDataPoints[0]->GetTime()) return 0;
667 0 : if (z > fLVDataPoints[fNumberOfLVdataPoints-1]->GetTime()) return fNumberOfLVdataPoints;
668 0 : Int_t b = 0, e = fNumberOfLVdataPoints-1, m = (b+e)/2;
669 0 : for (; b<e; m=(b+e)/2) {
670 0 : if (z > fLVDataPoints[m]->GetTime()) b=m+1;
671 : else e=m;
672 : }
673 :
674 : return m;
675 :
676 0 : }
677 :
678 : //---------------------------------------------------------------
679 : void AliTOFLvHvDataPoints::Init(){
680 : //
681 : // Initialize aliases and DCS data
682 : //
683 :
684 0 : TString sindex;
685 0 : for(int i=0;i<kNsectors;i++)
686 0 : for(int j=0;j<kNplates;j++) {
687 0 : fAliasNamesXHVmap[i][j] = "TOF_HVSTATUS_";
688 0 : sindex.Form("SM%02dMOD%1d",i,j);
689 0 : fAliasNamesXHVmap[i][j] += sindex;
690 : }
691 :
692 :
693 0 : for(int i=0;i<kNddl;i++) {
694 0 : fAliasNamesXLVmap[i] = "TOF_FEACSTATUS_";
695 0 : sindex.Form("%02d",i);
696 0 : fAliasNamesXLVmap[i] += sindex;
697 : }
698 :
699 0 : fStartingLVmap->SetTime(0);
700 0 : for (Int_t iPad=0; iPad<kNpads; iPad++)
701 0 : fStartingLVmap->SetCellValue(iPad,1);
702 :
703 0 : fStartingHVmap->SetTime(0);
704 0 : for (Int_t iPad=0; iPad<kNpads; iPad++) {
705 0 : Int_t vol[5] = {-1,-1,-1,-1,-1};
706 0 : AliTOFGeometry::GetVolumeIndices(iPad,vol);
707 0 : if ( (vol[0]==13 || vol[0]==14 || vol[0]==15) &&
708 0 : vol[1]==2)
709 0 : fStartingHVmap->SetCellValue(iPad,0);
710 : else
711 0 : fStartingHVmap->SetCellValue(iPad,1);
712 0 : }
713 :
714 0 : }
715 :
716 : //---------------------------------------------------------------
717 : void AliTOFLvHvDataPoints::FillHVarrayPerDataPoint(Int_t sector, Int_t plate, UInt_t baseWord, Short_t *array) const
718 : {
719 : //
720 : // Set the status of the TOF pads connected to the HV dp
721 : // labelled by sector and plate numbers
722 : //
723 :
724 0 : Int_t det[5] = {sector, plate, -1, -1, -1};
725 : UInt_t checkBit = 0;
726 :
727 : Int_t channel = -1;
728 :
729 0 : for (Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(plate); iStrip++) {
730 0 : checkBit = AliBitPacking::UnpackWord(baseWord,iStrip,iStrip);
731 0 : for (Int_t iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++)
732 0 : for (Int_t iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
733 0 : det[2] = iStrip;
734 0 : det[3] = iPadZ;
735 0 : det[4] = iPadX;
736 0 : channel = AliTOFGeometry::GetIndex(det);
737 0 : array[channel]=checkBit;
738 : }
739 : }
740 :
741 :
742 0 : }
743 :
744 : //---------------------------------------------------------------
745 : void AliTOFLvHvDataPoints::FillLVarrayPerDataPoint(Int_t nDDL, UInt_t baseWord, Short_t *array) const
746 : {
747 : //
748 : // Set the status of the TOF pads connected to the LV dp
749 : // labelled by TOF crate number
750 : //
751 :
752 0 : Int_t det[5] = {nDDL/4, -1, -1, -1, -1};
753 : UInt_t checkBit = 0;
754 :
755 0 : Int_t iStripXsm[6] = {-1,-1,-1,-1,-1,-1};
756 0 : Int_t firstPadX = -1;
757 0 : Int_t lastPadX = -1;
758 0 : Int_t plate = -1;
759 0 : Int_t strip = -1;
760 :
761 : Int_t channel = -1;
762 :
763 0 : for (Int_t nFEAC=0; nFEAC<8; nFEAC++) {
764 0 : checkBit = AliBitPacking::UnpackWord(baseWord,nFEAC,nFEAC);
765 0 : firstPadX = -1;
766 0 : lastPadX = -1;
767 0 : GetStripsConnectedToFEAC(nDDL, nFEAC, iStripXsm, firstPadX,lastPadX);
768 0 : for (Int_t index=0; index<6; index++) {
769 0 : if (iStripXsm[index]==-1) continue;
770 :
771 0 : for (Int_t iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++)
772 0 : for (Int_t iPadX=firstPadX; iPadX<=lastPadX; iPadX++) {
773 0 : AliTOFGeometry::GetStripAndModule(iStripXsm[index],plate,strip);
774 0 : det[1] = plate;
775 0 : det[2] = strip;
776 0 : det[3] = iPadZ;
777 0 : det[4] = iPadX;
778 0 : channel = AliTOFGeometry::GetIndex(det);
779 0 : array[channel]=checkBit;
780 : }
781 0 : }
782 : }
783 :
784 :
785 0 : }
786 :
787 : //---------------------------------------------------------------
788 : void AliTOFLvHvDataPoints::GetStripsConnectedToFEAC(Int_t nDDL, Int_t nFEAC, Int_t *iStrip, Int_t &firstPadX, Int_t &lastPadX) const
789 : {
790 : //
791 : // FEAC-strip mapping:
792 : // return the strips and first PadX numbers
793 : // connected to the FEAC number nFEAC in the crate number nDDL
794 : //
795 :
796 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=-1;
797 :
798 0 : if (nDDL<0 || nDDL>=kNddl || nFEAC<0 || nFEAC>=8) return;
799 :
800 0 : switch (nDDL%4) {
801 : case 0:
802 0 : firstPadX = 0;
803 0 : lastPadX = AliTOFGeometry::NpadX()/2-1;
804 :
805 0 : if (nFEAC<=2)
806 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC;
807 0 : else if (nFEAC==3)
808 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC;
809 0 : else if (nFEAC==4)
810 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
811 0 : else if (nFEAC==5)
812 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1;
813 0 : else if (nFEAC==6)
814 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2;
815 0 : else if (nFEAC==7)
816 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-2;
817 :
818 : break;
819 : case 1:
820 0 : firstPadX = AliTOFGeometry::NpadX()/2;
821 0 : lastPadX = AliTOFGeometry::NpadX()-1;
822 :
823 0 : if (nFEAC<=2)
824 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC;
825 0 : else if (nFEAC==3)
826 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC;
827 0 : else if (nFEAC==4)
828 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
829 0 : else if (nFEAC==5)
830 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
831 0 : else if (nFEAC==6)
832 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1;
833 0 : else if (nFEAC==7)
834 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2;
835 :
836 : break;
837 : case 2:
838 0 : firstPadX = AliTOFGeometry::NpadX()/2;
839 0 : lastPadX = AliTOFGeometry::NpadX()-1;
840 :
841 0 : if (nFEAC<=2)
842 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC);
843 0 : else if (nFEAC==3)
844 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC);
845 0 : else if (nFEAC==4)
846 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
847 0 : else if (nFEAC==5)
848 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
849 0 : else if (nFEAC==6)
850 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
851 0 : else if (nFEAC==7)
852 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
853 :
854 : break;
855 : case 3:
856 0 : firstPadX = 0;
857 0 : lastPadX = AliTOFGeometry::NpadX()/2-1;
858 :
859 0 : if (nFEAC<=2)
860 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC);
861 0 : else if (nFEAC==3)
862 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC);
863 0 : else if (nFEAC==4)
864 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
865 0 : else if (nFEAC==5)
866 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
867 0 : else if (nFEAC==6)
868 0 : for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
869 0 : else if (nFEAC==7)
870 0 : for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
871 :
872 : break;
873 : }
874 :
875 0 : }
876 :
877 : //---------------------------------------------------------------
878 : void AliTOFLvHvDataPoints::Draw(const Option_t* /*option*/)
879 : {
880 : //
881 : // Draw all histos and graphs
882 : //
883 :
884 0 : if(!fIsProcessed) return;
885 : /*
886 : TCanvas *ch;
887 : TString canvasHistoName="Histos";
888 : ch = new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
889 : ch->cd();
890 : */
891 : // to be implemented
892 :
893 0 : }
894 :
895 :
896 : //---------------------------------------------------------------
897 : void AliTOFLvHvDataPoints::DrawHVandLVMap(Int_t index)
898 : {
899 : //
900 : // Draw HV+LV map labelled as index
901 : //
902 :
903 : const Int_t kSize = 100;
904 :
905 0 : if(!fIsProcessed) return;
906 :
907 0 : if (index>=fNumberOfHVandLVmaps) return;
908 :
909 0 : AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVandLVmap(index);
910 :
911 0 : char title[kSize];
912 0 : if (index==0) snprintf(title,kSize,"HVandLV map at time %d (%dst map)",mappa->GetTime(),index+1);
913 0 : else if (index==1) snprintf(title,kSize,"HVandLV map at time %d (%dnd map)",mappa->GetTime(),index+1);
914 0 : else if (index==2) snprintf(title,kSize,"HVandLV map at time %d (%drd map)",mappa->GetTime(),index+1);
915 0 : else if (index>=3) snprintf(title,kSize,"HVandLV map at time %d (%dth map)",mappa->GetTime(),index+1);
916 0 : fHisto->Delete();
917 0 : fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
918 : //fHisto->Clear();
919 0 : fHisto->SetTitle(title);
920 :
921 0 : for (Int_t ii=0; ii<kNpads; ii++)
922 0 : fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
923 :
924 0 : fHisto->Draw();
925 :
926 0 : }
927 :
928 : //---------------------------------------------------------------
929 : void AliTOFLvHvDataPoints::DrawLVMap(Int_t index)
930 : {
931 : //
932 : // Draw LV map labelled as index
933 : //
934 :
935 : const Int_t kSize = 100;
936 :
937 0 : if(!fIsProcessed) return;
938 :
939 0 : if (index>=fNumberOfLVdataPoints) return;
940 :
941 0 : AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetLVmap(index);
942 :
943 0 : char title[kSize];
944 0 : if (index==0) snprintf(title,kSize,"LV map at time %d (%dst map)",mappa->GetTime(),index+1);
945 0 : else if (index==1) snprintf(title,kSize,"LV map at time %d (%dnd map)",mappa->GetTime(),index+1);
946 0 : else if (index==2) snprintf(title,kSize,"LV map at time %d (%drd map)",mappa->GetTime(),index+1);
947 0 : else if (index>=3) snprintf(title,kSize,"LV map at time %d (%dth map)",mappa->GetTime(),index+1);
948 0 : fHisto->Delete();
949 0 : fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
950 : //fHisto->Clear();
951 0 : fHisto->SetTitle(title);
952 :
953 0 : for (Int_t ii=0; ii<kNpads; ii++)
954 0 : fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
955 :
956 0 : fHisto->Draw();
957 :
958 0 : }
959 :
960 : //---------------------------------------------------------------
961 : void AliTOFLvHvDataPoints::DrawHVMap(Int_t index)
962 : {
963 : //
964 : // Draw HV map labelled as index
965 : //
966 :
967 : const Int_t kSize = 100;
968 :
969 0 : if(!fIsProcessed) return;
970 :
971 0 : if (index>=fNumberOfHVdataPoints) return;
972 :
973 0 : AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVmap(index);
974 :
975 0 : char title[kSize];
976 0 : if (index==0) snprintf(title,kSize,"HV map at time %d (%dst map)",mappa->GetTime(),index+1);
977 0 : else if (index==1) snprintf(title,kSize,"HV map at time %d (%dnd map)",mappa->GetTime(),index+1);
978 0 : else if (index==2) snprintf(title,kSize,"HV map at time %d (%drd map)",mappa->GetTime(),index+1);
979 0 : else if (index>=3) snprintf(title,kSize,"HV map at time %d (%dth map)",mappa->GetTime(),index+1);
980 0 : fHisto->Delete();
981 0 : fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
982 : //fHisto->Clear();
983 0 : fHisto->SetTitle(title);
984 :
985 0 : for (Int_t ii=0; ii<kNpads; ii++)
986 0 : fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
987 :
988 0 : fHisto->Draw();
989 :
990 0 : }
991 :
992 : //---------------------------------------------------------------
993 : AliTOFDCSmaps *AliTOFLvHvDataPoints::GetHVandLVmapAtEOR()
994 : {
995 : //
996 : // Returns HVandLV status map at EOR.
997 : // If the end-of-run has been caused by TOF self,
998 : // the second-last value of HVandLV status map
999 : // will be taken into account, i.e. the value immediately before
1000 : // the change that caused EOR.
1001 : // This last condition is true
1002 : // if the time interval between the last map value and the EOR
1003 : // is less than 60s.
1004 : // If the run ended correctly, last map value will be take into account.
1005 : // If nothing changed during the run, the SOR map will be take into account.
1006 : //
1007 :
1008 : AliTOFDCSmaps * lvANDhvMap = 0;
1009 :
1010 0 : if (fNumberOfHVandLVmaps==1) { // nothing changed during the run
1011 :
1012 0 : AliInfo(Form("Nothing changed in the TOF channels LV and HV status during the run number %d",fRun));
1013 :
1014 0 : lvANDhvMap = fMap[fNumberOfHVandLVmaps-1];
1015 :
1016 0 : }
1017 : else {
1018 :
1019 0 : if ( (fEndTimeDCSQuery-fMap[fNumberOfHVandLVmaps-1]->GetTime()<=fNSecondsBeforeEOR) ||
1020 0 : (fEndTime-fMap[fNumberOfHVandLVmaps-1]->GetTime()<=fNSecondsBeforeEOR) ) {
1021 0 : lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-2];
1022 0 : AliInfo(Form("Probably, TOF caused the EOR (EOR-t(last map))<%d).For run number %d the second-last HVandLV map will be take into account.",fNSecondsBeforeEOR,fRun));
1023 0 : }
1024 : else {
1025 0 : lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-1];
1026 0 : AliInfo(Form("The run number %d ended correctly. The last HVandLV map will be take into account.",fRun));
1027 : }
1028 :
1029 : }
1030 :
1031 0 : return lvANDhvMap;
1032 :
1033 : }
|