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