1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 $Log: AliTOFLvHvDataPoints.cxx,v $
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
27 #include "TTimeStamp.h"
32 #include "AliDCSValue.h"
34 #include "AliBitPacking.h"
36 #include "AliTOFGeometry.h"
37 #include "AliTOFDCSmaps.h"
38 #include "AliTOFLvHvDataPoints.h"
43 ClassImp(AliTOFLvHvDataPoints)
45 //---------------------------------------------------------------
46 AliTOFLvHvDataPoints::AliTOFLvHvDataPoints():
51 fStartTimeDCSQuery(0),
55 fNumberOfLVdataPoints(0),
56 fNumberOfHVdataPoints(0),
57 fNumberOfHVandLVmaps(0),
61 fNSecondsBeforeEOR(60)
65 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= 0x0;
66 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= 0x0;
67 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= 0x0;
71 //---------------------------------------------------------------
72 AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery):
75 fStartTime(startTime),
77 fStartTimeDCSQuery(startTimeDCSQuery),
78 fEndTimeDCSQuery(endTimeDCSQuery),
81 fNumberOfLVdataPoints(0),
82 fNumberOfHVdataPoints(0),
83 fNumberOfHVandLVmaps(0),
84 fStartingLVmap(new AliTOFDCSmaps()),
85 fStartingHVmap(new AliTOFDCSmaps()),
86 fHisto(new TH1C("histo","",kNpads,-0.5,kNpads-0.5)),
87 fNSecondsBeforeEOR(60)
90 // constructor with arguments
92 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fLVDataPoints[ii]= 0x0;
93 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fHVDataPoints[ii]= 0x0;
94 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) fMap[ii]= 0x0;
96 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()));
106 //---------------------------------------------------------------
108 AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(const AliTOFLvHvDataPoints & data):
111 fStartTime(data.fStartTime),
112 fEndTime(data.fEndTime),
113 fStartTimeDCSQuery(data.fStartTimeDCSQuery),
114 fEndTimeDCSQuery(data.fEndTimeDCSQuery),
115 fIsProcessed(data.fIsProcessed),
117 fNumberOfLVdataPoints(data.fNumberOfLVdataPoints),
118 fNumberOfHVdataPoints(data.fNumberOfHVdataPoints),
119 fNumberOfHVandLVmaps(data.fNumberOfHVandLVmaps),
120 fStartingLVmap(data.fStartingLVmap),
121 fStartingHVmap(data.fStartingHVmap),
123 fNSecondsBeforeEOR(data.fNSecondsBeforeEOR)
128 for(int i=0;i<kNddl;i++)
129 fAliasNamesXLVmap[i]=data.fAliasNamesXLVmap[i];
131 for(int i=0;i<kNsectors;i++)
132 for(int j=0;j<kNplates;j++)
133 fAliasNamesXHVmap[i][j]=data.fAliasNamesXHVmap[i][j];
137 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) if (fLVDataPoints[ii]) fLVDataPoints[ii]->Delete();
139 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) if (fHVDataPoints[ii]) fHVDataPoints[ii]->Delete();
141 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) if (fMap[ii]) fMap[ii]->Delete();
145 //---------------------------------------------------------------
147 AliTOFLvHvDataPoints& AliTOFLvHvDataPoints:: operator=(const AliTOFLvHvDataPoints & data) {
149 // assignment operator
154 TObject::operator=(data);
156 fStartTime=data.GetStartTime();
157 fEndTime=data.GetEndTime();
158 fStartTimeDCSQuery=data.GetStartTimeDCSQuery();
159 fEndTimeDCSQuery=data.GetEndTimeDCSQuery();
161 fNumberOfLVdataPoints=data.fNumberOfLVdataPoints;
162 fNumberOfHVdataPoints=data.fNumberOfHVdataPoints;
163 fNumberOfHVandLVmaps=data.fNumberOfHVandLVmaps;
165 fStartingLVmap=data.fStartingLVmap;
166 fStartingHVmap=data.fStartingHVmap;
168 for(int i=0;i<kNddl;i++)
169 fAliasNamesXLVmap[i]=data.fAliasNamesXLVmap[i];
171 for(int i=0;i<kNsectors;i++)
172 for(int j=0;j<kNplates;j++)
173 fAliasNamesXHVmap[i][j]=data.fAliasNamesXHVmap[i][j];
177 fNSecondsBeforeEOR=data.fNSecondsBeforeEOR;
181 //---------------------------------------------------------------
182 AliTOFLvHvDataPoints::~AliTOFLvHvDataPoints() {
186 delete fStartingLVmap;
187 delete fStartingHVmap;
191 //---------------------------------------------------------------
192 Bool_t AliTOFLvHvDataPoints::ProcessData(TMap& aliasMap) {
194 // method to process the data
197 if(!(fAliasNamesXHVmap[0][0]) || !(fAliasNamesXLVmap[0])) Init();
199 AliInfo(Form(" Start Time = %i",fStartTime));
200 AliInfo(Form(" End Time = %i",fEndTime));
201 AliInfo(Form(" Start Time DCS Query= %i",fStartTimeDCSQuery));
202 AliInfo(Form(" End Time DCS Query= %i",fEndTimeDCSQuery));
204 if (fEndTime==fStartTime){
205 AliError(Form(" Run with null time length: start time = %d = end time = %d",fStartTime,fEndTime));
210 if (!ReadLVDataPoints(aliasMap)) return kFALSE;
211 AliDebug(1,Form(" Number of LV dp value changes = %d",fNumberOfLVdataPoints));
213 if (!ReadHVDataPoints(aliasMap)) return kFALSE;
214 AliDebug(1,Form(" Number of HV dp value changes = %d",fNumberOfHVdataPoints));
216 if (!MergeLVmap()) return kFALSE;
218 if (!MergeHVmap()) return kFALSE;
220 if (!MergeMaps()) return kFALSE;
228 //---------------------------------------------------------------
229 Bool_t AliTOFLvHvDataPoints::MergeMaps() {
231 // Merge together LV and HV maps
234 Int_t timeMaps[kNmaxDataPoints];
235 for (Int_t ii=0; ii<kNmaxDataPoints; ii++) timeMaps[ii]=0;
237 for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++) {
238 AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d, LV=%d) - time=%d",fNumberOfHVandLVmaps,fNumberOfHVdataPoints,fNumberOfLVdataPoints,timeMaps[fNumberOfHVandLVmaps]));
239 timeMaps[fNumberOfHVandLVmaps++]=fHVDataPoints[ii]->GetTime();
242 AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d) ",fNumberOfHVandLVmaps,fNumberOfHVdataPoints));
244 Bool_t check = kTRUE;
245 for (Int_t jj=0; jj<fNumberOfLVdataPoints; jj++) {
247 for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++)
248 check=check&&(fLVDataPoints[jj]->GetTime()!=timeMaps[ii]);
251 AliDebug(1,Form(" fNumberOfHVandLVmaps = %d (HV=%d, LV=%d) - time=%d",fNumberOfHVandLVmaps,fNumberOfHVdataPoints,fNumberOfLVdataPoints,timeMaps[fNumberOfHVandLVmaps]));
252 timeMaps[fNumberOfHVandLVmaps++]=fLVDataPoints[jj]->GetTime();
256 AliInfo(Form(" TOF HV dps = %d; TOF LV dps = %d; TOF HVandLV dps %d",
257 fNumberOfHVdataPoints, fNumberOfLVdataPoints, fNumberOfHVandLVmaps));
260 Int_t *controller = new Int_t[fNumberOfHVandLVmaps];
261 for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++) controller[ii]=-1;
262 TMath::Sort(fNumberOfHVandLVmaps,timeMaps,controller,kFALSE); // increasing order
264 for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++)
265 AliDebug(1, Form(" Time Order - time[controller[%d]] = %d", ii, timeMaps[controller[ii]]));
267 Short_t array[kNpads];
268 for (Int_t iPad=0; iPad<kNpads; iPad++) array[iPad]=-1;
271 // HVandLV status map during run
272 for (Int_t index=0; index<fNumberOfHVandLVmaps; index++) {
273 time = timeMaps[controller[index]];
275 AliDebug(2, Form(" Time Order - time[controller[%d]] = %d", index, timeMaps[controller[index]]));
277 for (Int_t ii=0; ii<fNumberOfHVdataPoints; ii++)
278 for (Int_t jj=0; jj<fNumberOfLVdataPoints; jj++) {
280 AliDebug(2,Form(" time=%d --- HVdp_time[%d]=%d, LVdp_time[%d]=%d",
282 ii,fHVDataPoints[ii]->GetTime(),
283 jj,fLVDataPoints[jj]->GetTime()));
285 if ( (fHVDataPoints[ii]->GetTime()==time && fLVDataPoints[jj]->GetTime()<=time) ||
286 (fLVDataPoints[jj]->GetTime()==time && fHVDataPoints[ii]->GetTime()<=time) ) {
288 AliDebug(2,Form(" HVdp_time[%d]=%d, LVdp_time[%d]=%d",
289 ii,fHVDataPoints[ii]->GetTime(),
290 jj,fLVDataPoints[jj]->GetTime()));
291 for (Int_t iPad=0; iPad<kNpads; iPad++)
292 array[iPad] = fHVDataPoints[ii]->GetCellValue(iPad)*fLVDataPoints[jj]->GetCellValue(iPad);
293 AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
298 else if ( fHVDataPoints[ii]->GetTime()==time && fLVDataPoints[jj]->GetTime()>time ) {
300 AliDebug(2,Form(" HVdp_time[%d]=%d, (no LVdp)",ii,fHVDataPoints[ii]->GetTime()));
301 for (Int_t iPad=0; iPad<kNpads; iPad++)
302 array[iPad] = fHVDataPoints[ii]->GetCellValue(iPad);
303 AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
307 } else if ( fLVDataPoints[jj]->GetTime()==time && fHVDataPoints[ii]->GetTime()>time ) {
309 AliDebug(2,Form(" LVdp_time[%d]=%d, (no HVdp)",jj,fLVDataPoints[jj]->GetTime()));
310 for (Int_t iPad=0; iPad<kNpads; iPad++)
311 array[iPad] = fLVDataPoints[jj]->GetCellValue(iPad);
312 AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array);
322 delete [] controller;
324 for (Int_t ii=0; ii<fNumberOfHVandLVmaps; ii++)
325 AliDebug(1,Form(" fMap[%d]->GetTime() = %d ",ii,fMap[ii]->GetTime()));
331 //---------------------------------------------------------------
332 Bool_t AliTOFLvHvDataPoints::MergeHVmap() {
334 // Create HV maps from HV dps
337 Bool_t check= kFALSE;
339 if (fNumberOfHVdataPoints==0)
343 // first map construction
344 for (Int_t iPad=0; iPad<kNpads; iPad++) {
345 if (fHVDataPoints[0]->GetCellValue(iPad)==-1)
346 fHVDataPoints[0]->SetCellValue(iPad,fStartingHVmap->GetCellValue(iPad));
348 //fHVDataPoints[0]->SetCellValue(iPad,fHVDataPoints[0]->GetCellValue(iPad)*fStartingHVmap->GetCellValue(iPad));
351 AliDebug(2,Form("HVdp0: channel=%6d -> %1d",iPad,fHVDataPoints[0]->GetCellValue(iPad)));
354 // other maps construction
355 for (Int_t ii=1; ii<fNumberOfHVdataPoints; ii++) {
356 for (Int_t iPad=0; iPad<kNpads; iPad++) {
357 if (fHVDataPoints[ii]->GetCellValue(iPad)==-1)
358 fHVDataPoints[ii]->SetCellValue(iPad,fHVDataPoints[ii-1]->GetCellValue(iPad));
361 AliDebug(2,Form("HVdp%d: channel=%6d -> %1d",ii,iPad,fHVDataPoints[ii]->GetCellValue(iPad)));
372 //---------------------------------------------------------------
373 Bool_t AliTOFLvHvDataPoints::MergeLVmap() {
375 // Create LV maps from LV dps
378 Bool_t check= kFALSE;
380 if (fNumberOfLVdataPoints==0)
384 // first map construction
385 for (Int_t iPad=0; iPad<kNpads; iPad++) {
386 if (fLVDataPoints[0]->GetCellValue(iPad)==-1)
387 fLVDataPoints[0]->SetCellValue(iPad,fStartingLVmap->GetCellValue(iPad));
389 //fLVDataPoints[0]->SetCellValue(iPad,fLVDataPoints[0]->GetCellValue(iPad)*fStartingLVmap->GetCellValue(iPad));
392 AliDebug(2,Form("LVdp0: channel=%6d -> %1d",iPad,fLVDataPoints[0]->GetCellValue(iPad)));
395 // other maps construction
396 for (Int_t ii=1; ii<fNumberOfLVdataPoints; ii++) {
397 for (Int_t iPad=0; iPad<kNpads; iPad++) {
398 if (fLVDataPoints[ii]->GetCellValue(iPad)==-1)
399 fLVDataPoints[ii]->SetCellValue(iPad,fLVDataPoints[ii-1]->GetCellValue(iPad));
402 AliDebug(2,Form("LVdp%d: channel=%6d -> %1d",ii,iPad,fLVDataPoints[ii]->GetCellValue(iPad)));
413 //---------------------------------------------------------------
414 Bool_t AliTOFLvHvDataPoints::ReadHVDataPoints(TMap& aliasMap) {
421 AliDCSValue* aValuePrev;
426 Short_t dummy[kNpads];
428 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
429 // starting loop on aliases
430 for (int i=0; i<kNsectors; i++)
431 for (int j=0; j<kNplates; j++) {
432 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNamesXHVmap[i][j].Data());
434 AliError(Form("Alias %s not found!", fAliasNamesXHVmap[i][j].Data()));
436 return kFALSE; // returning only in case we are not in a FDR run
441 nEntries = aliasArr->GetEntries();
443 if (nEntries<2) AliDebug(1, Form(" NB: number of values for dp %s %d (less than 2)",fAliasNamesXHVmap[i][j].Data(),nEntries));
446 AliError(Form("Alias %s has no entries! Nothing will be stored",
447 fAliasNamesXHVmap[i][j].Data()));
452 // read the first value
453 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
454 aValue = (AliDCSValue*) aliasArr->At(0);
455 val = aValue->GetInt();
456 time = aValue->GetTimeStamp();
457 AliDebug(1, Form(" at t=%d, 1st value for dp %s = %d", time, fAliasNamesXHVmap[i][j].Data(), val));
458 FillHVarrayPerDataPoint(i,j,val,dummy);
459 AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,dummy);
460 if (InsertHVDataPoint(object0)!=0) return kTRUE; // to be verified
462 // read the values from the second one
463 for (Int_t iEntry=1; iEntry<nEntries; iEntry++) {
464 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
465 aValue = (AliDCSValue*) aliasArr->At(iEntry);
466 val = aValue->GetInt();
467 time = aValue->GetTimeStamp();
468 AliDebug(2, Form(" at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXHVmap[i][j].Data(), val));
469 aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1);
470 if (aValuePrev->GetInt()!=val) {
471 AliDebug(1, Form(" CHANGE - at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXHVmap[i][j].Data(), val));
472 FillHVarrayPerDataPoint(i,j,val,dummy);
473 AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy);
474 if (InsertHVDataPoint(object)!=0) return kTRUE; // to be verified
481 if (fNumberOfHVdataPoints==0) {
482 AliInfo("Valid HV dps not found. By default all HV TOF channels (except the ones in the PHOS holes) switched ON, at SOR.");
483 if (InsertHVDataPoint(fStartingHVmap)!=0) return kTRUE; // to be verified
490 //---------------------------------------------------------------
491 Bool_t AliTOFLvHvDataPoints::ReadLVDataPoints(TMap& aliasMap) {
498 AliDCSValue* aValuePrev;
503 Short_t dummy[kNpads];
505 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
506 // starting loop on aliases
507 for (int i=0; i<kNddl; i++) {
508 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNamesXLVmap[i].Data());
510 AliError(Form("Alias %s not found!", fAliasNamesXLVmap[i].Data()));
512 return kFALSE; // returning only in case we are not in a FDR run
517 nEntries = aliasArr->GetEntries();
519 if (nEntries<2) AliDebug(1, Form(" NB: number of values for dp %s %d (less than 2)",fAliasNamesXLVmap[i].Data(),nEntries));
522 AliError(Form("Alias %s has no entries! Nothing will be stored",
523 fAliasNamesXLVmap[i].Data()));
528 // read the first value
529 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
530 aValue = (AliDCSValue*) aliasArr->At(0);
531 val = aValue->GetInt();
532 time = aValue->GetTimeStamp();
533 AliDebug(1, Form(" at t=%d, 1st value for dp %s = %d", time, fAliasNamesXLVmap[i].Data(), val));
534 FillLVarrayPerDataPoint(i,val,dummy);
535 AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,dummy);
536 if (InsertLVDataPoint(object0)!=0) return kTRUE; // to be verified
538 // read the values from the second one
539 for (Int_t iEntry=1; iEntry<nEntries; iEntry++) {
540 for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
541 aValue = (AliDCSValue*) aliasArr->At(iEntry);
542 val = aValue->GetInt();
543 time = aValue->GetTimeStamp();
544 AliDebug(2, Form(" at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXLVmap[i].Data(), val));
545 aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1);
546 if (aValuePrev->GetInt()!=val) {
547 AliDebug(1, Form(" CHANGE - at t=%d, %dth value for dp %s = %d", time, iEntry+1, fAliasNamesXLVmap[i].Data(), val));
548 FillLVarrayPerDataPoint(i,val,dummy);
549 AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy);
550 if (InsertLVDataPoint(object)!=0) return kTRUE; // to be verified
557 if (fNumberOfLVdataPoints==0) {
558 AliInfo("Valid LV dps not found. By default all LV TOF channels switched ON, at SOR.");
559 if (InsertLVDataPoint(fStartingLVmap)!=0) return kTRUE; // to be verified
566 //---------------------------------------------------------------
567 Int_t AliTOFLvHvDataPoints::InsertHVDataPoint(AliTOFDCSmaps *object)
570 // Insert HV dp in the HV dps array.
571 // The HV dps array is sorted according to increasing dp timeStamp value
574 if (fNumberOfHVdataPoints==kNmaxDataPoints) {
575 AliError("Too many HV data points!");
579 if (fNumberOfHVdataPoints==0) {
580 fHVDataPoints[fNumberOfHVdataPoints++] = object;
584 for (Int_t index=0; index<fNumberOfHVdataPoints; index++) {
585 if (object->GetTime()==fHVDataPoints[index]->GetTime()) {
586 fHVDataPoints[index]->Update(object);
591 Int_t ii = FindHVdpIndex(object->GetTime());
592 memmove(fHVDataPoints+ii+1 ,fHVDataPoints+ii,(fNumberOfHVdataPoints-ii)*sizeof(AliTOFDCSmaps*));
593 fHVDataPoints[ii] = object;
594 fNumberOfHVdataPoints++;
600 //_________________________________________________________________________
601 Int_t AliTOFLvHvDataPoints::FindHVdpIndex(Int_t z) const {
603 // This function returns the index of the nearest HV DP in time
606 if (fNumberOfHVdataPoints==0) return 0;
607 if (z <= fHVDataPoints[0]->GetTime()) return 0;
608 if (z > fHVDataPoints[fNumberOfHVdataPoints-1]->GetTime()) return fNumberOfHVdataPoints;
609 Int_t b = 0, e = fNumberOfHVdataPoints-1, m = (b+e)/2;
610 for (; b<e; m=(b+e)/2) {
611 if (z > fHVDataPoints[m]->GetTime()) b=m+1;
619 //---------------------------------------------------------------
620 Int_t AliTOFLvHvDataPoints::InsertLVDataPoint(AliTOFDCSmaps *object)
623 // Insert LV dp in the LV dps array.
624 // The LV dps array is sorted according to increasing dp timeStamp value
627 if (fNumberOfLVdataPoints==kNmaxDataPoints) {
628 AliError("Too many LV data points!");
632 if (fNumberOfLVdataPoints==0) {
633 fLVDataPoints[fNumberOfLVdataPoints++] = object;
637 for (Int_t index=0; index<fNumberOfLVdataPoints; index++) {
638 if (object->GetTime()==fLVDataPoints[index]->GetTime()) {
639 fLVDataPoints[index]->Update(object);
644 Int_t ii = FindLVdpIndex(object->GetTime());
645 memmove(fLVDataPoints+ii+1 ,fLVDataPoints+ii,(fNumberOfLVdataPoints-ii)*sizeof(AliTOFDCSmaps*));
646 fLVDataPoints[ii] = object;
647 fNumberOfLVdataPoints++;
653 //_________________________________________________________________________
654 Int_t AliTOFLvHvDataPoints::FindLVdpIndex(Int_t z) const {
656 // This function returns the index of the nearest LV DP in time
659 if (fNumberOfLVdataPoints==0) return 0;
660 if (z <= fLVDataPoints[0]->GetTime()) return 0;
661 if (z > fLVDataPoints[fNumberOfLVdataPoints-1]->GetTime()) return fNumberOfLVdataPoints;
662 Int_t b = 0, e = fNumberOfLVdataPoints-1, m = (b+e)/2;
663 for (; b<e; m=(b+e)/2) {
664 if (z > fLVDataPoints[m]->GetTime()) b=m+1;
672 //---------------------------------------------------------------
673 void AliTOFLvHvDataPoints::Init(){
675 // Initialize aliases and DCS data
679 for(int i=0;i<kNsectors;i++)
680 for(int j=0;j<kNplates;j++) {
681 fAliasNamesXHVmap[i][j] = "TOF_HVSTATUS_";
682 sindex.Form("SM%02dMOD%1d",i,j);
683 fAliasNamesXHVmap[i][j] += sindex;
687 for(int i=0;i<kNddl;i++) {
688 fAliasNamesXLVmap[i] = "TOF_FEACSTATUS_";
689 sindex.Form("%02d",i);
690 fAliasNamesXLVmap[i] += sindex;
693 fStartingLVmap->SetTime(0);
694 for (Int_t iPad=0; iPad<kNpads; iPad++)
695 fStartingLVmap->SetCellValue(iPad,1);
697 fStartingHVmap->SetTime(0);
698 for (Int_t iPad=0; iPad<kNpads; iPad++) {
699 Int_t vol[5] = {-1,-1,-1,-1,-1};
700 AliTOFGeometry::GetVolumeIndices(iPad,vol);
701 if ( (vol[0]==13 || vol[0]==14 || vol[0]==15) &&
703 fStartingHVmap->SetCellValue(iPad,0);
705 fStartingHVmap->SetCellValue(iPad,1);
710 //---------------------------------------------------------------
711 void AliTOFLvHvDataPoints::FillHVarrayPerDataPoint(Int_t sector, Int_t plate, UInt_t baseWord, Short_t *array) const
714 // Set the status of the TOF pads connected to the HV dp
715 // labelled by sector and plate numbers
718 Int_t det[5] = {sector, plate, -1, -1, -1};
723 for (Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(plate); iStrip++) {
724 checkBit = AliBitPacking::UnpackWord(baseWord,iStrip,iStrip);
725 for (Int_t iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++)
726 for (Int_t iPadX=0; iPadX<AliTOFGeometry::NpadX(); iPadX++) {
730 channel = AliTOFGeometry::GetIndex(det);
731 array[channel]=checkBit;
738 //---------------------------------------------------------------
739 void AliTOFLvHvDataPoints::FillLVarrayPerDataPoint(Int_t nDDL, UInt_t baseWord, Short_t *array) const
742 // Set the status of the TOF pads connected to the LV dp
743 // labelled by TOF crate number
746 Int_t det[5] = {nDDL/4, -1, -1, -1, -1};
749 Int_t iStripXsm[6] = {-1,-1,-1,-1,-1,-1};
750 Int_t firstPadX = -1;
757 for (Int_t nFEAC=0; nFEAC<8; nFEAC++) {
758 checkBit = AliBitPacking::UnpackWord(baseWord,nFEAC,nFEAC);
761 GetStripsConnectedToFEAC(nDDL, nFEAC, iStripXsm, firstPadX,lastPadX);
762 for (Int_t index=0; index<6; index++) {
763 if (iStripXsm[index]==-1) continue;
765 for (Int_t iPadZ=0; iPadZ<AliTOFGeometry::NpadZ(); iPadZ++)
766 for (Int_t iPadX=firstPadX; iPadX<=lastPadX; iPadX++) {
767 AliTOFGeometry::GetStripAndModule(iStripXsm[index],plate,strip);
772 channel = AliTOFGeometry::GetIndex(det);
773 array[channel]=checkBit;
781 //---------------------------------------------------------------
782 void AliTOFLvHvDataPoints::GetStripsConnectedToFEAC(Int_t nDDL, Int_t nFEAC, Int_t *iStrip, Int_t &firstPadX, Int_t &lastPadX) const
785 // FEAC-strip mapping:
786 // return the strips and first PadX numbers
787 // connected to the FEAC number nFEAC in the crate number nDDL
790 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=-1;
792 if (nDDL<0 || nDDL>=kNddl || nFEAC<0 || nFEAC>=8) return;
797 lastPadX = AliTOFGeometry::NpadX()/2-1;
800 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC;
802 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC;
804 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
806 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1;
808 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2;
810 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-2;
814 firstPadX = AliTOFGeometry::NpadX()/2;
815 lastPadX = AliTOFGeometry::NpadX()-1;
818 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC;
820 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC;
822 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
824 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1;
826 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1;
828 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2;
832 firstPadX = AliTOFGeometry::NpadX()/2;
833 lastPadX = AliTOFGeometry::NpadX()-1;
836 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC);
838 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC);
840 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
842 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
844 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
846 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
851 lastPadX = AliTOFGeometry::NpadX()/2-1;
854 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC);
856 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC);
858 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
860 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
862 for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1);
864 for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2);
871 //---------------------------------------------------------------
872 void AliTOFLvHvDataPoints::Draw(const Option_t* /*option*/)
875 // Draw all histos and graphs
878 if(!fIsProcessed) return;
881 TString canvasHistoName="Histos";
882 ch = new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
890 //---------------------------------------------------------------
891 void AliTOFLvHvDataPoints::DrawHVandLVMap(Int_t index)
894 // Draw HV+LV map labelled as index
897 const Int_t kSize = 100;
899 if(!fIsProcessed) return;
901 if (index>=fNumberOfHVandLVmaps) return;
903 AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVandLVmap(index);
906 if (index==0) snprintf(title,kSize,"HVandLV map at time %d (%dst map)",mappa->GetTime(),index+1);
907 else if (index==1) snprintf(title,kSize,"HVandLV map at time %d (%dnd map)",mappa->GetTime(),index+1);
908 else if (index==2) snprintf(title,kSize,"HVandLV map at time %d (%drd map)",mappa->GetTime(),index+1);
909 else if (index>=3) snprintf(title,kSize,"HVandLV map at time %d (%dth map)",mappa->GetTime(),index+1);
911 fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
913 fHisto->SetTitle(title);
915 for (Int_t ii=0; ii<kNpads; ii++)
916 fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
922 //---------------------------------------------------------------
923 void AliTOFLvHvDataPoints::DrawLVMap(Int_t index)
926 // Draw LV map labelled as index
929 const Int_t kSize = 100;
931 if(!fIsProcessed) return;
933 if (index>=fNumberOfLVdataPoints) return;
935 AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetLVmap(index);
938 if (index==0) snprintf(title,kSize,"LV map at time %d (%dst map)",mappa->GetTime(),index+1);
939 else if (index==1) snprintf(title,kSize,"LV map at time %d (%dnd map)",mappa->GetTime(),index+1);
940 else if (index==2) snprintf(title,kSize,"LV map at time %d (%drd map)",mappa->GetTime(),index+1);
941 else if (index>=3) snprintf(title,kSize,"LV map at time %d (%dth map)",mappa->GetTime(),index+1);
943 fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
945 fHisto->SetTitle(title);
947 for (Int_t ii=0; ii<kNpads; ii++)
948 fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
954 //---------------------------------------------------------------
955 void AliTOFLvHvDataPoints::DrawHVMap(Int_t index)
958 // Draw HV map labelled as index
961 const Int_t kSize = 100;
963 if(!fIsProcessed) return;
965 if (index>=fNumberOfHVdataPoints) return;
967 AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVmap(index);
970 if (index==0) snprintf(title,kSize,"HV map at time %d (%dst map)",mappa->GetTime(),index+1);
971 else if (index==1) snprintf(title,kSize,"HV map at time %d (%dnd map)",mappa->GetTime(),index+1);
972 else if (index==2) snprintf(title,kSize,"HV map at time %d (%drd map)",mappa->GetTime(),index+1);
973 else if (index>=3) snprintf(title,kSize,"HV map at time %d (%dth map)",mappa->GetTime(),index+1);
975 fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5);
977 fHisto->SetTitle(title);
979 for (Int_t ii=0; ii<kNpads; ii++)
980 fHisto->SetBinContent(ii+1,mappa->GetCellValue(ii));
986 //---------------------------------------------------------------
987 AliTOFDCSmaps *AliTOFLvHvDataPoints::GetHVandLVmapAtEOR()
990 // Returns HVandLV status map at EOR.
991 // If the end-of-run has been caused by TOF self,
992 // the second-last value of HVandLV status map
993 // will be taken into account, i.e. the value immediately before
994 // the change that caused EOR.
995 // This last condition is true
996 // if the time interval between the last map value and the EOR
998 // If the run ended correctly, last map value will be take into account.
999 // If nothing changed during the run, the SOR map will be take into account.
1002 AliTOFDCSmaps * lvANDhvMap = 0;
1004 if (fNumberOfHVandLVmaps==1) { // nothing changed during the run
1006 AliInfo(Form("Nothing changed in the TOF channels LV and HV status during the run number %d",fRun));
1008 lvANDhvMap = fMap[fNumberOfHVandLVmaps-1];
1013 if ( (fEndTimeDCSQuery-fMap[fNumberOfHVandLVmaps-1]->GetTime()<=fNSecondsBeforeEOR) ||
1014 (fEndTime-fMap[fNumberOfHVandLVmaps-1]->GetTime()<=fNSecondsBeforeEOR) ) {
1015 lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-2];
1016 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));
1019 lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-1];
1020 AliInfo(Form("The run number %d ended correctly. The last HVandLV map will be take into account.",fRun));