We should not delete what we do not own...
[u/mrichter/AliRoot.git] / MUON / AliMUONPadStatusMaker.cxx
CommitLineData
2c780493 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// $Id$
78649106 17
3d1463c8 18//-----------------------------------------------------------------------------
2c780493 19/// \class AliMUONPadStatusMaker
20///
21/// Make a 2DStore of pad statuses, using different sources of information,
22/// like pedestal values, gain values, and HV values.
23///
78649106 24/// \author Laurent Aphecetche
3d1463c8 25//-----------------------------------------------------------------------------
2c780493 26
27#include "AliMUONPadStatusMaker.h"
28
4e25ac79 29#include "AliQAv1.h"
004a9ccd 30
2c780493 31#include "AliMUON2DMap.h"
9044498f 32#include "AliMUON2DStoreValidator.h"
33#include "AliMUONCalibParamNI.h"
2c780493 34#include "AliMUONCalibrationData.h"
49e396d9 35#include "AliMUONStringIntMap.h"
2c780493 36#include "AliMUONVCalibParam.h"
004a9ccd 37#include "AliMUONVTrackerData.h"
2ce1c72b 38
2c780493 39#include "AliMpArea.h"
49e396d9 40#include "AliMpArrayI.h"
8d8e920c 41#include "AliMpConstants.h"
49e396d9 42#include "AliMpDDLStore.h"
2c780493 43#include "AliMpDEManager.h"
49e396d9 44#include "AliMpDetElement.h"
49e110ec 45#include "AliMpDCSNamer.h"
49e396d9 46#include "AliMpManuUID.h"
2ce1c72b 47
48#include "AliCDBEntry.h"
49#include "AliCDBManager.h"
50#include "AliCodeTimer.h"
51#include "AliDCSValue.h"
52#include "AliLog.h"
53
9044498f 54#include <Riostream.h>
49e396d9 55#include <TArrayI.h>
56#include <TExMap.h>
004a9ccd 57#include <TFile.h>
58#include <TKey.h>
9044498f 59#include <TMap.h>
004a9ccd 60#include <TROOT.h>
9044498f 61#include <TString.h>
004a9ccd 62#include <TSystem.h>
2c780493 63
78649106 64/// \cond CLASSIMP
2c780493 65ClassImp(AliMUONPadStatusMaker)
78649106 66/// \endcond
2c780493 67
68//_____________________________________________________________________________
69AliMUONPadStatusMaker::AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData)
72dae9ff 70: fkCalibrationData(calibData),
004a9ccd 71fGainA1Limits(0,1E30),
72fGainA2Limits(-1E-30,1E30),
73fGainThresLimits(0,4095),
74fHVSt12Limits(0,5000),
75fHVSt345Limits(0,5000),
76fPedMeanLimits(0,4095),
77fPedSigmaLimits(0,4095),
78fManuOccupancyLimits(0,0.1),
79fStatus(new AliMUON2DMap(true)),
80fHV(new TExMap),
81fPedestals(calibData.Pedestals()),
82fGains(calibData.Gains()),
2b8a1212 83fTrackerData(0x0),
84fKillMap(calibData.KillMap())
2c780493 85{
004a9ccd 86 /// ctor
87 AliDebug(1,Form("ped store %s gain store %s",
88 fPedestals->ClassName(),
89 fGains->ClassName()));
90
4e25ac79 91 TString qaFileName(AliQAv1::GetQADataFileName("MUON",calibData.RunNumber()));
004a9ccd 92
93 // search the QA file in memory first.
94 TFile* f = static_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(qaFileName.Data()));
95
96 if (!f)
97 {
98 // then tries to open it
99 if ( gSystem->AccessPathName(qaFileName.Data()) == kFALSE )
100 {
101 f = TFile::Open(qaFileName.Data());
102 if ( f )
103 {
104 AliDebug(1,Form("Got %s from disk",qaFileName.Data()));
105 }
106 }
107 }
108 else
109 {
110 AliDebug(1,Form("Got %s from memory",qaFileName.Data()));
111 }
112
113 if (f)
114 {
115 TDirectory* d = gDirectory;
116
117 f->cd("MUON/Raws");
118
119 TIter next(gDirectory->GetListOfKeys());
120 TKey* key;
121
122 while ( ( key = static_cast<TKey*>(next()) ) && !fTrackerData )
123 {
124 TString name(key->GetName());
125
126 if ( name.Contains("CALZ") )
127 {
128 fTrackerData = dynamic_cast<AliMUONVTrackerData*>(key->ReadObj());
129 }
130
131 }
132
133 gDirectory = d;
134
135 if ( fTrackerData )
136 {
137 AliInfo(Form("Will make a cut on MANU occupancy from TrackerData=%s",fTrackerData->GetName()));
138 }
139 else
140 {
141 AliWarning(Form("Found a QA file = %s, but could not get the expected TrackerData in there... (probably not a serious problem though)",
142 f->GetName()));
143 }
144 }
145 else
146 {
147 AliWarning("Did not find QA file, so will not use manu occupancy as a criteria");
148 }
2c780493 149}
150
151//_____________________________________________________________________________
152AliMUONPadStatusMaker::~AliMUONPadStatusMaker()
153{
71a2d3aa 154 /// dtor.
49e396d9 155 delete fStatus;
156 delete fHV;
2c780493 157}
158
159//_____________________________________________________________________________
49e396d9 160TString
161AliMUONPadStatusMaker::AsString(Int_t status)
2c780493 162{
49e396d9 163 /// return a human readable version of the integer status
004a9ccd 164
49e396d9 165 Int_t pedStatus;
166 Int_t gainStatus;
167 Int_t hvStatus;
004a9ccd 168 Int_t otherStatus;
169
170 DecodeStatus(status,pedStatus,hvStatus,gainStatus,otherStatus);
171
172 TString s;
173
174 if ( pedStatus & kPedMeanZero ) s += "& Ped Mean is Zero ";
175 if ( pedStatus & kPedMeanTooLow ) s += "& Ped Mean Too Low ";
176 if ( pedStatus & kPedMeanTooHigh ) s += "& Ped Mean Too High ";
177 if ( pedStatus & kPedSigmaTooLow ) s += "& Ped Sigma Too Low ";
178 if ( pedStatus & kPedSigmaTooHigh ) s += "& Ped Sigma Too High ";
179 if ( pedStatus & kPedMissing ) s += "& Ped is missing ";
180
181 if ( gainStatus & kGainA1TooLow ) s+="& Gain A1 is Too Low ";
182 if ( gainStatus & kGainA1TooHigh ) s+="& Gain A1 is Too High ";
183 if ( gainStatus & kGainA2TooLow ) s+="& Gain A2 is Too Low ";
184 if ( gainStatus & kGainA2TooHigh ) s+="& Gain A2 is Too High ";
185 if ( gainStatus & kGainThresTooLow ) s+="& Gain Thres is Too Low ";
186 if ( gainStatus & kGainThresTooHigh ) s+="& Gain Thres is Too High ";
187 if ( gainStatus & kGainMissing ) s+="& Gain is missing ";
188
189 if ( hvStatus & kHVError ) s+="& HV is on error ";
190 if ( hvStatus & kHVTooLow ) s+="& HV is Too Low ";
191 if ( hvStatus & kHVTooHigh ) s+="& HV is Too High ";
192 if ( hvStatus & kHVChannelOFF ) s+="& HV has channel OFF ";
193 if ( hvStatus & kHVSwitchOFF ) s+="& HV has switch OFF ";
194 if ( hvStatus & kHVMissing ) s+="& HV is missing ";
195
196 if ( otherStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high ";
197 if ( otherStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low ";
2b8a1212 198 if ( otherStatus & kKilled ) s+="& killed";
49e396d9 199
004a9ccd 200 if ( s[0] == '&' ) s[0] = ' ';
201
202 return s;
203}
49e396d9 204
004a9ccd 205//_____________________________________________________________________________
206TString
207AliMUONPadStatusMaker::AsCondition(Int_t mask)
208{
209 /// return a human readable version of the mask's equivalent condition
210
211 TString s(AsString(mask));
212
213 s.ReplaceAll("&","|");
214
49e396d9 215 return s;
2c780493 216}
217
218//_____________________________________________________________________________
49e396d9 219Int_t
220AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus,
221 Int_t hvStatus,
004a9ccd 222 Int_t gainStatus,
223 Int_t otherStatus)
96199305 224{
49e396d9 225 /// Build a complete status from specific parts (ped,hv,gain)
8d8e920c 226
49e396d9 227 return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) |
004a9ccd 228 ( ( gainStatus & 0xFF ) << 16 ) |
229 ( ( otherStatus & 0xFF ) << 24 ) ;
49e396d9 230}
231
232//_____________________________________________________________________________
233void
234AliMUONPadStatusMaker::DecodeStatus(Int_t status,
235 Int_t& pedStatus,
236 Int_t& hvStatus,
004a9ccd 237 Int_t& gainStatus,
238 Int_t& otherStatus)
49e396d9 239{
240 /// Decode complete status into specific parts (ped,hv,gain)
96199305 241
004a9ccd 242 otherStatus = ( status & 0xFF000000 ) >> 24;
49e396d9 243 gainStatus = ( status & 0xFF0000 ) >> 16;
244 pedStatus = ( status & 0xFF00 ) >> 8;
245 hvStatus = (status & 0xFF);
96199305 246}
247
248//_____________________________________________________________________________
2c780493 249Bool_t
49e396d9 250AliMUONPadStatusMaker::HVSt12Status(Int_t detElemId, Int_t sector,
251 Bool_t& hvChannelTooLow,
252 Bool_t& hvChannelTooHigh,
253 Bool_t& hvChannelON) const
2c780493 254{
255 /// Get HV status for one HV sector of St12
256
257 /// For a given PCB in a given DE, get the HV status (both the channel
258 /// and the switch).
259 /// Returns false if hv switch changed during the run.
260
49e396d9 261 AliCodeTimerAuto("")
262
2c780493 263 Bool_t error = kFALSE;
264 hvChannelTooLow = kFALSE;
265 hvChannelTooHigh = kFALSE;
266 hvChannelON = kTRUE;
49e396d9 267
49e110ec 268 AliMpDCSNamer hvNamer("TRACKER");
2c780493 269
49e110ec 270 TString hvChannel(hvNamer.DCSChannelName(detElemId,sector));
2c780493 271
72dae9ff 272 TMap* hvMap = fkCalibrationData.HV();
49e396d9 273 TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
2c780493 274 if (!hvPair)
275 {
276 AliError(Form("Did not find expected alias (%s) for DE %d",
277 hvChannel.Data(),detElemId));
278 error = kTRUE;
279 }
280 else
281 {
282 TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
283 if (!values)
284 {
285 AliError(Form("Could not get values for alias %s",hvChannel.Data()));
286 error = kTRUE;
287 }
288 else
289 {
290 // find out min and max value, and makes a cut
291 Float_t hvMin(1E9);
292 Float_t hvMax(0);
293 TIter next(values);
294 AliDCSValue* val;
295
296 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
297 {
298 Float_t hv = val->GetFloat();
299 hvMin = TMath::Min(hv,hvMin);
300 hvMax = TMath::Max(hv,hvMax);
301 }
302
303 float lowThreshold = fHVSt12Limits.X();
304 float highThreshold = fHVSt12Limits.Y();
305
306 if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
307 if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
308 if ( hvMin < 1 ) hvChannelON = kFALSE;
309 }
310 }
311
312 return error;
313}
314
315//_____________________________________________________________________________
316Bool_t
49e396d9 317AliMUONPadStatusMaker::HVSt345Status(Int_t detElemId, Int_t pcbIndex,
318 Bool_t& hvChannelTooLow,
319 Bool_t& hvChannelTooHigh,
320 Bool_t& hvChannelON,
321 Bool_t& hvSwitchON) const
2c780493 322{
323 /// For a given PCB in a given DE, get the HV status (both the channel
324 /// and the switch).
325 /// Returns false if something goes wrong (in particular if
326 /// hv switch changed during the run).
327
49e396d9 328 AliCodeTimerAuto("")
329
2c780493 330 Bool_t error = kFALSE;
331 hvChannelTooLow = kFALSE;
332 hvChannelTooHigh = kFALSE;
333 hvSwitchON = kTRUE;
334 hvChannelON = kTRUE;
335
49e110ec 336 AliMpDCSNamer hvNamer("TRACKER");
2c780493 337
49e110ec 338 TString hvChannel(hvNamer.DCSChannelName(detElemId));
2c780493 339
72dae9ff 340 TMap* hvMap = fkCalibrationData.HV();
49e396d9 341
342 TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
2c780493 343 if (!hvPair)
344 {
345 AliError(Form("Did not find expected alias (%s) for DE %d",
346 hvChannel.Data(),detElemId));
347 error = kTRUE;
348 }
349 else
350 {
351 TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
352 if (!values)
353 {
354 AliError(Form("Could not get values for alias %s",hvChannel.Data()));
355 error = kTRUE;
356 }
357 else
358 {
359 // find out min and max value, and makes a cut
360 Float_t hvMin(1E9);
361 Float_t hvMax(0);
362 TIter next(values);
363 AliDCSValue* val;
364
365 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
366 {
367 Float_t hv = val->GetFloat();
368 hvMin = TMath::Min(hv,hvMin);
369 hvMax = TMath::Max(hv,hvMax);
370 }
371
372 float lowThreshold = fHVSt345Limits.X();
373 float highThreshold = fHVSt345Limits.Y();
374
375 if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
49e396d9 376 else if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
2c780493 377 if ( hvMin < 1 ) hvChannelON = kFALSE;
378 }
379 }
380
49e110ec 381 TString hvSwitch(hvNamer.DCSSwitchName(detElemId,pcbIndex));
49e396d9 382 TPair* switchPair = static_cast<TPair*>(hvMap->FindObject(hvSwitch.Data()));
2c780493 383 if (!switchPair)
384 {
385 AliError(Form("Did not find expected alias (%s) for DE %d PCB %d",
386 hvSwitch.Data(),detElemId,pcbIndex));
387 error = kTRUE;
388 }
389 else
390 {
391 TObjArray* values = static_cast<TObjArray*>(switchPair->Value());
392 if (!values)
393 {
394 AliError(Form("Could not get values for alias %s",hvSwitch.Data()));
395 error = kTRUE;
396 }
397 else
398 {
399 // we'll count the number of ON/OFF for this pad, to insure
400 // consistency (i.e. if status changed during the run, we should
401 // at least notify this fact ;-) and hope it's not the norm)
402 Int_t nTrue(0);
403 Int_t nFalse(0);
404 TIter next(values);
405 AliDCSValue* val;
406
407 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
408 {
409 if ( val->GetBool() )
410 {
411 ++nTrue;
412 }
413 else
414 {
415 ++nFalse;
416 }
417 }
418
419 if ( (nTrue>0 && nFalse>0) )
420 {
421 AliWarning(Form("Status of HV Switch %s changed during this run nTrue=%d nFalse=%d! Will consider it OFF",
422 hvSwitch.Data(),nTrue,nFalse));
423 error = kTRUE;
424 }
425
426 if ( nFalse ) hvSwitchON = kFALSE;
427 }
428 }
429 return error;
430}
431
432//_____________________________________________________________________________
49e396d9 433Int_t
434AliMUONPadStatusMaker::HVStatus(Int_t detElemId, Int_t manuId) const
2c780493 435{
49e396d9 436 /// Get HV status of one manu
2c780493 437
49e396d9 438 AliCodeTimerAuto("")
2c780493 439
72dae9ff 440 if ( !fkCalibrationData.HV() ) return kMissing;
49e396d9 441
442 Long_t lint = fHV->GetValue(AliMpManuUID::BuildUniqueID(detElemId,manuId));
2c780493 443
49e396d9 444 if ( lint )
445 {
446 return (Int_t)(lint - 1);
447 }
448
449 Int_t status(0);
2c780493 450
49e110ec 451 AliMpDCSNamer hvNamer("TRACKER");
2c780493 452
49e396d9 453 switch ( AliMpDEManager::GetStationType(detElemId) )
2c780493 454 {
4e51cfd2 455 case AliMp::kStation12:
2c780493 456 {
49e396d9 457 int sector = hvNamer.ManuId2Sector(detElemId,manuId);
458 if ( sector >= 0 )
2c780493 459 {
49e396d9 460 Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON;
461 Bool_t error = HVSt12Status(detElemId,sector,
462 hvChannelTooLow,
463 hvChannelTooHigh,
464 hvChannelON);
465 if ( error ) status |= kHVError;
466 if ( hvChannelTooLow ) status |= kHVTooLow;
467 if ( hvChannelTooHigh ) status |= kHVTooHigh;
468 if ( !hvChannelON ) status |= kHVChannelOFF;
469 // assign this status to all the other manus handled by the same HV channel
470 SetHVStatus(detElemId,sector,status);
471 }
472 }
473 break;
474 case AliMp::kStation345:
475 {
476 int pcbIndex = hvNamer.ManuId2PCBIndex(detElemId,manuId);
477 if ( pcbIndex >= 0 )
478 {
479 Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON;
480 Bool_t error = HVSt345Status(detElemId,pcbIndex,
481 hvChannelTooLow,hvChannelTooHigh,
482 hvChannelON,hvSwitchON);
483 if ( error ) status |= kHVError;
484 if ( hvChannelTooLow ) status |= kHVTooLow;
485 if ( hvChannelTooHigh ) status |= kHVTooHigh;
486 if ( !hvSwitchON ) status |= kHVSwitchOFF;
487 if ( !hvChannelON) status |= kHVChannelOFF;
488 // assign this status to all the other manus handled by the same HV channel
489 SetHVStatus(detElemId,pcbIndex,status);
2c780493 490 }
2c780493 491 }
49e396d9 492 break;
493 default:
494 break;
2c780493 495 }
496
49e396d9 497 return status;
498}
499
500//_____________________________________________________________________________
501AliMUONVCalibParam*
502AliMUONPadStatusMaker::Neighbours(Int_t detElemId, Int_t manuId) const
503{
504 /// Get the neighbours parameters for a given manu
72dae9ff 505 AliMUONVStore* neighbourStore = fkCalibrationData.Neighbours();
49e396d9 506 return static_cast<AliMUONVCalibParam*>(neighbourStore->FindObject(detElemId,manuId));
2c780493 507}
508
509//_____________________________________________________________________________
8d8e920c 510AliMUONVStore*
49e396d9 511AliMUONPadStatusMaker::NeighboursStore() const
2c780493 512{
49e396d9 513 /// Return the store containing all the neighbours
72dae9ff 514 return fkCalibrationData.Neighbours();
49e396d9 515}
516
517//_____________________________________________________________________________
518AliMUONVCalibParam*
519AliMUONPadStatusMaker::ComputeStatus(Int_t detElemId, Int_t manuId) const
520{
521 /// Compute the status of a given manu, using all available information,
522 /// i.e. pedestals, gains, and HV
2c780493 523
49e396d9 524 AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,-1);
525 fStatus->Add(param);
004a9ccd 526
49e396d9 527 AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId));
528
529 AliMUONVCalibParam* gains = static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemId,manuId));
2c780493 530
2b8a1212 531 AliMUONVCalibParam* kill(0x0);
532
533 if ( fKillMap )
534 {
535 kill = static_cast<AliMUONVCalibParam*>(fKillMap->FindObject(detElemId,manuId));
536 }
537
49e396d9 538 Int_t hvStatus = HVStatus(detElemId,manuId);
539
004a9ccd 540 Int_t otherStatus = OtherStatus(detElemId,manuId);
2c780493 541
49e396d9 542 for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
2c780493 543 {
49e396d9 544 Int_t pedStatus(0);
545
546 if (pedestals)
2c780493 547 {
49e396d9 548 Float_t pedMean = pedestals->ValueAsFloatFast(manuChannel,0);
549 Float_t pedSigma = pedestals->ValueAsFloatFast(manuChannel,1);
550 if ( pedMean < fPedMeanLimits.X() ) pedStatus |= kPedMeanTooLow;
551 else if ( pedMean > fPedMeanLimits.Y() ) pedStatus |= kPedMeanTooHigh;
552 if ( pedSigma < fPedSigmaLimits.X() ) pedStatus |= kPedSigmaTooLow;
553 else if ( pedSigma > fPedSigmaLimits.Y() ) pedStatus |= kPedSigmaTooHigh;
554 if ( pedMean == 0 ) pedStatus |= kPedMeanZero;
555 }
556 else
557 {
558 pedStatus = kPedMissing;
559 }
560
561 Int_t gainStatus(0);
562
563 if ( gains )
564 {
565 Float_t a0 = gains->ValueAsFloatFast(manuChannel,0);
566 Float_t a1 = gains->ValueAsFloatFast(manuChannel,1);
567 Float_t thres = gains->ValueAsFloatFast(manuChannel,2);
568
004a9ccd 569 if ( a0 < fGainA1Limits.X() ) gainStatus |= kGainA1TooLow;
570 else if ( a0 > fGainA1Limits.Y() ) gainStatus |= kGainA1TooHigh;
571 if ( a1 < fGainA2Limits.X() ) gainStatus |= kGainA2TooLow;
572 else if ( a1 > fGainA2Limits.Y() ) gainStatus |= kGainA2TooHigh;
49e396d9 573 if ( thres < fGainThresLimits.X() ) gainStatus |= kGainThresTooLow;
574 else if ( thres > fGainThresLimits.Y() ) gainStatus |= kGainThresTooHigh;
2c780493 575 }
49e396d9 576 else
577 {
578 gainStatus = kGainMissing;
579 }
2b8a1212 580
581 if ( kill && (kill->ValueAsInt(manuChannel,0) > 0) )
582 {
583 otherStatus |= kKilled;
584 }
49e396d9 585
004a9ccd 586 Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus,otherStatus);
49e396d9 587
588 param->SetValueAsIntFast(manuChannel,0,status);
2c780493 589 }
590
49e396d9 591 return param;
2c780493 592}
593
594//_____________________________________________________________________________
004a9ccd 595Int_t
596AliMUONPadStatusMaker::OtherStatus(Int_t detElemId, Int_t manuId) const
597{
598 /// Get the "other" status for a given manu
599 if ( fTrackerData )
600 {
601 Double_t occ = fTrackerData->Manu(detElemId,manuId,2);
602 if ( occ < fManuOccupancyLimits.X() )
603 {
604 return kManuOccupancyTooLow;
605 }
606 if ( occ > fManuOccupancyLimits.Y() )
607 {
608 return kManuOccupancyTooHigh;
609 }
610 }
611 return 0;
612}
613
614//_____________________________________________________________________________
49e396d9 615AliMUONVCalibParam*
616AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId) const
2c780493 617{
004a9ccd 618 /// Get the status container for a given manu
2c780493 619
49e396d9 620 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
621 if (!param)
96199305 622 {
49e396d9 623 // not already there, so compute it now
624 AliCodeTimerAuto("ComputeStatus");
625 param = ComputeStatus(detElemId,manuId);
96199305 626 }
49e396d9 627 return param;
2c780493 628}
629
630//_____________________________________________________________________________
49e396d9 631Int_t
632AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
2c780493 633{
49e396d9 634 /// Get the status for a given channel
2c780493 635
49e396d9 636 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
637 if (!param)
2c780493 638 {
49e396d9 639 // not already there, so compute it now
640 param = ComputeStatus(detElemId,manuId);
641 }
642 return param->ValueAsInt(manuChannel,0);
2c780493 643}
644
645//_____________________________________________________________________________
646void
49e396d9 647AliMUONPadStatusMaker::SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const
2c780493 648{
49e396d9 649 /// Assign status to all manus in a given HV "zone" (defined by index, meaning
650 /// is different thing from St12 and St345)
651
652 AliCodeTimerAuto("")
653
654 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
2c780493 655
49e396d9 656 const AliMpArrayI* manus = de->ManusForHV(index);
2c780493 657
49e396d9 658 for ( Int_t i = 0; i < manus->GetSize(); ++ i )
2c780493 659 {
49e396d9 660 Int_t manuId = manus->GetValue(i);
661 fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1);
2c780493 662 }
663}