]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPadStatusMaker.cxx
Bug fix for loading the LUT for chambers 1 to 6. (Indra)
[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
29#include "AliMUON2DMap.h"
9044498f 30#include "AliMUON2DStoreValidator.h"
31#include "AliMUONCalibParamNI.h"
2c780493 32#include "AliMUONCalibrationData.h"
411a502a 33#include "AliMUONLogger.h"
34#include "AliMUONRecoParam.h"
49e396d9 35#include "AliMUONStringIntMap.h"
7eafe398 36#include "AliMUONTrackerData.h"
411a502a 37#include "AliMUONVCalibParam.h"
2ce1c72b 38
2c780493 39#include "AliMpArea.h"
49e396d9 40#include "AliMpArrayI.h"
411a502a 41#include "AliMpCDB.h"
8d8e920c 42#include "AliMpConstants.h"
49e396d9 43#include "AliMpDDLStore.h"
2c780493 44#include "AliMpDEManager.h"
49e396d9 45#include "AliMpDetElement.h"
49e110ec 46#include "AliMpDCSNamer.h"
411a502a 47#include "AliMpManuIterator.h"
49e396d9 48#include "AliMpManuUID.h"
2ce1c72b 49
50#include "AliCDBEntry.h"
51#include "AliCDBManager.h"
52#include "AliCodeTimer.h"
53#include "AliDCSValue.h"
54#include "AliLog.h"
55
9044498f 56#include <Riostream.h>
49e396d9 57#include <TArrayI.h>
58#include <TExMap.h>
004a9ccd 59#include <TFile.h>
60#include <TKey.h>
9044498f 61#include <TMap.h>
004a9ccd 62#include <TROOT.h>
9044498f 63#include <TString.h>
004a9ccd 64#include <TSystem.h>
2c780493 65
78649106 66/// \cond CLASSIMP
2c780493 67ClassImp(AliMUONPadStatusMaker)
78649106 68/// \endcond
2c780493 69
70//_____________________________________________________________________________
71AliMUONPadStatusMaker::AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData)
72dae9ff 72: fkCalibrationData(calibData),
004a9ccd 73fGainA1Limits(0,1E30),
74fGainA2Limits(-1E-30,1E30),
75fGainThresLimits(0,4095),
76fHVSt12Limits(0,5000),
77fHVSt345Limits(0,5000),
78fPedMeanLimits(0,4095),
79fPedSigmaLimits(0,4095),
7eafe398 80fManuOccupancyLimits(0,1.0),
411a502a 81fBuspatchOccupancyLimits(0,1.0),
7eafe398 82fDEOccupancyLimits(0,1.0),
004a9ccd 83fStatus(new AliMUON2DMap(true)),
00977a64 84fHV(0x0),
004a9ccd 85fPedestals(calibData.Pedestals()),
86fGains(calibData.Gains()),
7eafe398 87fTrackerData(0x0)
2c780493 88{
004a9ccd 89 /// ctor
7eafe398 90 if ( calibData.OccupancyMap() )
004a9ccd 91 {
7eafe398 92 /// create a tracker data from the occupancy map
93 fTrackerData = new AliMUONTrackerData("OCC","OCC",*(calibData.OccupancyMap()));
411a502a 94 }
00977a64 95 if ( calibData.HV() )
96 {
97 /// Only create the fHV internal store if there are some HV values available
98 fHV = new TExMap;
99 }
2c780493 100}
101
102//_____________________________________________________________________________
103AliMUONPadStatusMaker::~AliMUONPadStatusMaker()
104{
71a2d3aa 105 /// dtor.
411a502a 106
49e396d9 107 delete fStatus;
108 delete fHV;
7eafe398 109 delete fTrackerData;
2c780493 110}
111
112//_____________________________________________________________________________
49e396d9 113TString
114AliMUONPadStatusMaker::AsString(Int_t status)
2c780493 115{
49e396d9 116 /// return a human readable version of the integer status
004a9ccd 117
49e396d9 118 Int_t pedStatus;
119 Int_t gainStatus;
120 Int_t hvStatus;
7eafe398 121 Int_t occStatus;
004a9ccd 122
7eafe398 123 DecodeStatus(status,pedStatus,hvStatus,gainStatus,occStatus);
004a9ccd 124
125 TString s;
126
127 if ( pedStatus & kPedMeanZero ) s += "& Ped Mean is Zero ";
128 if ( pedStatus & kPedMeanTooLow ) s += "& Ped Mean Too Low ";
129 if ( pedStatus & kPedMeanTooHigh ) s += "& Ped Mean Too High ";
130 if ( pedStatus & kPedSigmaTooLow ) s += "& Ped Sigma Too Low ";
131 if ( pedStatus & kPedSigmaTooHigh ) s += "& Ped Sigma Too High ";
132 if ( pedStatus & kPedMissing ) s += "& Ped is missing ";
133
134 if ( gainStatus & kGainA1TooLow ) s+="& Gain A1 is Too Low ";
135 if ( gainStatus & kGainA1TooHigh ) s+="& Gain A1 is Too High ";
136 if ( gainStatus & kGainA2TooLow ) s+="& Gain A2 is Too Low ";
137 if ( gainStatus & kGainA2TooHigh ) s+="& Gain A2 is Too High ";
138 if ( gainStatus & kGainThresTooLow ) s+="& Gain Thres is Too Low ";
139 if ( gainStatus & kGainThresTooHigh ) s+="& Gain Thres is Too High ";
140 if ( gainStatus & kGainMissing ) s+="& Gain is missing ";
141
142 if ( hvStatus & kHVError ) s+="& HV is on error ";
143 if ( hvStatus & kHVTooLow ) s+="& HV is Too Low ";
144 if ( hvStatus & kHVTooHigh ) s+="& HV is Too High ";
145 if ( hvStatus & kHVChannelOFF ) s+="& HV has channel OFF ";
146 if ( hvStatus & kHVSwitchOFF ) s+="& HV has switch OFF ";
147 if ( hvStatus & kHVMissing ) s+="& HV is missing ";
148
7eafe398 149 if ( occStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high ";
150 if ( occStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low ";
151 if ( occStatus & kBusPatchOccupancyTooHigh ) s+="& bus patch occupancy too high ";
152 if ( occStatus & kBusPatchOccupancyTooLow ) s+="& bus patch occupancy too low ";
153 if ( occStatus & kDEOccupancyTooHigh ) s+="& DE occupancy too high ";
154 if ( occStatus & kDEOccupancyTooLow ) s+="& DE occupancy too low ";
49e396d9 155
004a9ccd 156 if ( s[0] == '&' ) s[0] = ' ';
157
158 return s;
159}
49e396d9 160
004a9ccd 161//_____________________________________________________________________________
162TString
163AliMUONPadStatusMaker::AsCondition(Int_t mask)
164{
165 /// return a human readable version of the mask's equivalent condition
166
167 TString s(AsString(mask));
168
169 s.ReplaceAll("&","|");
170
49e396d9 171 return s;
2c780493 172}
173
96199305 174//_____________________________________________________________________________
49e396d9 175Int_t
176AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus,
177 Int_t hvStatus,
004a9ccd 178 Int_t gainStatus,
7eafe398 179 Int_t occStatus)
96199305 180{
49e396d9 181 /// Build a complete status from specific parts (ped,hv,gain)
8d8e920c 182
49e396d9 183 return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) |
004a9ccd 184 ( ( gainStatus & 0xFF ) << 16 ) |
7eafe398 185 ( ( occStatus & 0xFF ) << 24 ) ;
49e396d9 186}
187
188//_____________________________________________________________________________
189void
190AliMUONPadStatusMaker::DecodeStatus(Int_t status,
191 Int_t& pedStatus,
192 Int_t& hvStatus,
004a9ccd 193 Int_t& gainStatus,
7eafe398 194 Int_t& occStatus)
49e396d9 195{
196 /// Decode complete status into specific parts (ped,hv,gain)
96199305 197
7eafe398 198 occStatus = ( status & 0xFF000000 ) >> 24;
49e396d9 199 gainStatus = ( status & 0xFF0000 ) >> 16;
200 pedStatus = ( status & 0xFF00 ) >> 8;
201 hvStatus = (status & 0xFF);
96199305 202}
203
2c780493 204//_____________________________________________________________________________
205Bool_t
49e396d9 206AliMUONPadStatusMaker::HVSt12Status(Int_t detElemId, Int_t sector,
207 Bool_t& hvChannelTooLow,
208 Bool_t& hvChannelTooHigh,
209 Bool_t& hvChannelON) const
2c780493 210{
211 /// Get HV status for one HV sector of St12
212
213 /// For a given PCB in a given DE, get the HV status (both the channel
214 /// and the switch).
215 /// Returns false if hv switch changed during the run.
216
99c136e1 217 AliCodeTimerAuto("",0)
49e396d9 218
00977a64 219 if (!fHV) return kFALSE;
220
2c780493 221 Bool_t error = kFALSE;
222 hvChannelTooLow = kFALSE;
223 hvChannelTooHigh = kFALSE;
224 hvChannelON = kTRUE;
49e396d9 225
49e110ec 226 AliMpDCSNamer hvNamer("TRACKER");
2c780493 227
49e110ec 228 TString hvChannel(hvNamer.DCSChannelName(detElemId,sector));
2c780493 229
72dae9ff 230 TMap* hvMap = fkCalibrationData.HV();
49e396d9 231 TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
2c780493 232 if (!hvPair)
233 {
234 AliError(Form("Did not find expected alias (%s) for DE %d",
235 hvChannel.Data(),detElemId));
236 error = kTRUE;
237 }
238 else
239 {
240 TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
241 if (!values)
242 {
243 AliError(Form("Could not get values for alias %s",hvChannel.Data()));
244 error = kTRUE;
245 }
246 else
247 {
248 // find out min and max value, and makes a cut
249 Float_t hvMin(1E9);
250 Float_t hvMax(0);
251 TIter next(values);
252 AliDCSValue* val;
253
254 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
255 {
256 Float_t hv = val->GetFloat();
257 hvMin = TMath::Min(hv,hvMin);
258 hvMax = TMath::Max(hv,hvMax);
259 }
260
261 float lowThreshold = fHVSt12Limits.X();
262 float highThreshold = fHVSt12Limits.Y();
263
264 if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
265 if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
266 if ( hvMin < 1 ) hvChannelON = kFALSE;
267 }
268 }
269
270 return error;
271}
272
ca913045 273//_____________________________________________________________________________
274Float_t
275AliMUONPadStatusMaker::SwitchValue(const TObjArray& dcsArray)
276{
277 /// Loop over the dcs value for a single switch to decide whether
278 /// we should consider it on or off
279
280 // we'll count the number of ON/OFF for this pad, to insure
281 // consistency (i.e. if status changed during the run, we should
282 // at least notify this fact ;-) and hope it's not the norm)
283 Int_t nTrue(0);
284 Int_t nFalse(0);
285 TIter next(&dcsArray);
286 AliDCSValue* val;
287
288 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
289 {
290 if ( val->GetBool() )
291 {
292 ++nTrue;
293 }
294 else
295 {
296 ++nFalse;
297 }
298 }
299
300 if ( (nTrue>0 && nFalse>0) )
301 {
302 // change of state during the run, consider it off
303 return 0.0;
304 }
305
306 if ( nFalse )
307 {
308 /// switch = FALSE means the HV was flowding up to the PCB.
309 /// i.e. switch = FALSE = ON
310 return 1.0;
311 }
312
313 return 0.0;
314}
315
2c780493 316//_____________________________________________________________________________
317Bool_t
49e396d9 318AliMUONPadStatusMaker::HVSt345Status(Int_t detElemId, Int_t pcbIndex,
319 Bool_t& hvChannelTooLow,
320 Bool_t& hvChannelTooHigh,
321 Bool_t& hvChannelON,
322 Bool_t& hvSwitchON) const
2c780493 323{
324 /// For a given PCB in a given DE, get the HV status (both the channel
325 /// and the switch).
326 /// Returns false if something goes wrong (in particular if
327 /// hv switch changed during the run).
328
99c136e1 329 AliCodeTimerAuto("",0)
49e396d9 330
00977a64 331 if (!fHV) return kFALSE;
332
2c780493 333 Bool_t error = kFALSE;
334 hvChannelTooLow = kFALSE;
335 hvChannelTooHigh = kFALSE;
336 hvSwitchON = kTRUE;
337 hvChannelON = kTRUE;
338
49e110ec 339 AliMpDCSNamer hvNamer("TRACKER");
2c780493 340
49e110ec 341 TString hvChannel(hvNamer.DCSChannelName(detElemId));
2c780493 342
72dae9ff 343 TMap* hvMap = fkCalibrationData.HV();
49e396d9 344
345 TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
2c780493 346 if (!hvPair)
347 {
348 AliError(Form("Did not find expected alias (%s) for DE %d",
349 hvChannel.Data(),detElemId));
350 error = kTRUE;
351 }
352 else
353 {
354 TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
355 if (!values)
356 {
357 AliError(Form("Could not get values for alias %s",hvChannel.Data()));
358 error = kTRUE;
359 }
360 else
361 {
362 // find out min and max value, and makes a cut
363 Float_t hvMin(1E9);
364 Float_t hvMax(0);
365 TIter next(values);
366 AliDCSValue* val;
367
368 while ( ( val = static_cast<AliDCSValue*>(next()) ) )
369 {
370 Float_t hv = val->GetFloat();
371 hvMin = TMath::Min(hv,hvMin);
372 hvMax = TMath::Max(hv,hvMax);
373 }
374
375 float lowThreshold = fHVSt345Limits.X();
376 float highThreshold = fHVSt345Limits.Y();
377
378 if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
49e396d9 379 else if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
2c780493 380 if ( hvMin < 1 ) hvChannelON = kFALSE;
381 }
382 }
383
49e110ec 384 TString hvSwitch(hvNamer.DCSSwitchName(detElemId,pcbIndex));
49e396d9 385 TPair* switchPair = static_cast<TPair*>(hvMap->FindObject(hvSwitch.Data()));
2c780493 386 if (!switchPair)
387 {
388 AliError(Form("Did not find expected alias (%s) for DE %d PCB %d",
389 hvSwitch.Data(),detElemId,pcbIndex));
390 error = kTRUE;
391 }
392 else
393 {
394 TObjArray* values = static_cast<TObjArray*>(switchPair->Value());
395 if (!values)
396 {
397 AliError(Form("Could not get values for alias %s",hvSwitch.Data()));
398 error = kTRUE;
399 }
400 else
401 {
ca913045 402 Float_t sv = SwitchValue(*values);
403 if ( sv < 0.99 ) hvSwitchON = kFALSE;
2c780493 404 }
405 }
406 return error;
407}
408
409//_____________________________________________________________________________
49e396d9 410Int_t
411AliMUONPadStatusMaker::HVStatus(Int_t detElemId, Int_t manuId) const
2c780493 412{
49e396d9 413 /// Get HV status of one manu
2c780493 414
99c136e1 415 AliCodeTimerAuto("",0)
2c780493 416
00977a64 417 if ( !fHV ) return kMissing;
49e396d9 418
419 Long_t lint = fHV->GetValue(AliMpManuUID::BuildUniqueID(detElemId,manuId));
2c780493 420
49e396d9 421 if ( lint )
422 {
423 return (Int_t)(lint - 1);
424 }
425
426 Int_t status(0);
2c780493 427
49e110ec 428 AliMpDCSNamer hvNamer("TRACKER");
2c780493 429
49e396d9 430 switch ( AliMpDEManager::GetStationType(detElemId) )
2c780493 431 {
4e51cfd2 432 case AliMp::kStation12:
2c780493 433 {
49e396d9 434 int sector = hvNamer.ManuId2Sector(detElemId,manuId);
435 if ( sector >= 0 )
2c780493 436 {
49e396d9 437 Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON;
438 Bool_t error = HVSt12Status(detElemId,sector,
439 hvChannelTooLow,
440 hvChannelTooHigh,
441 hvChannelON);
442 if ( error ) status |= kHVError;
443 if ( hvChannelTooLow ) status |= kHVTooLow;
444 if ( hvChannelTooHigh ) status |= kHVTooHigh;
445 if ( !hvChannelON ) status |= kHVChannelOFF;
446 // assign this status to all the other manus handled by the same HV channel
447 SetHVStatus(detElemId,sector,status);
448 }
449 }
450 break;
451 case AliMp::kStation345:
452 {
453 int pcbIndex = hvNamer.ManuId2PCBIndex(detElemId,manuId);
454 if ( pcbIndex >= 0 )
455 {
456 Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON;
457 Bool_t error = HVSt345Status(detElemId,pcbIndex,
458 hvChannelTooLow,hvChannelTooHigh,
459 hvChannelON,hvSwitchON);
460 if ( error ) status |= kHVError;
461 if ( hvChannelTooLow ) status |= kHVTooLow;
462 if ( hvChannelTooHigh ) status |= kHVTooHigh;
463 if ( !hvSwitchON ) status |= kHVSwitchOFF;
464 if ( !hvChannelON) status |= kHVChannelOFF;
465 // assign this status to all the other manus handled by the same HV channel
466 SetHVStatus(detElemId,pcbIndex,status);
2c780493 467 }
2c780493 468 }
49e396d9 469 break;
470 default:
471 break;
2c780493 472 }
473
49e396d9 474 return status;
475}
476
477//_____________________________________________________________________________
478AliMUONVCalibParam*
479AliMUONPadStatusMaker::Neighbours(Int_t detElemId, Int_t manuId) const
480{
481 /// Get the neighbours parameters for a given manu
72dae9ff 482 AliMUONVStore* neighbourStore = fkCalibrationData.Neighbours();
49e396d9 483 return static_cast<AliMUONVCalibParam*>(neighbourStore->FindObject(detElemId,manuId));
2c780493 484}
485
486//_____________________________________________________________________________
8d8e920c 487AliMUONVStore*
49e396d9 488AliMUONPadStatusMaker::NeighboursStore() const
2c780493 489{
49e396d9 490 /// Return the store containing all the neighbours
72dae9ff 491 return fkCalibrationData.Neighbours();
49e396d9 492}
493
494//_____________________________________________________________________________
495AliMUONVCalibParam*
496AliMUONPadStatusMaker::ComputeStatus(Int_t detElemId, Int_t manuId) const
497{
498 /// Compute the status of a given manu, using all available information,
499 /// i.e. pedestals, gains, and HV
2c780493 500
49e396d9 501 AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,-1);
502 fStatus->Add(param);
004a9ccd 503
49e396d9 504 AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId));
505
506 AliMUONVCalibParam* gains = static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemId,manuId));
2c780493 507
49e396d9 508 Int_t hvStatus = HVStatus(detElemId,manuId);
509
7eafe398 510 Int_t occStatus = OccupancyStatus(detElemId,manuId);
2c780493 511
49e396d9 512 for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
2c780493 513 {
49e396d9 514 Int_t pedStatus(0);
515
516 if (pedestals)
2c780493 517 {
49e396d9 518 Float_t pedMean = pedestals->ValueAsFloatFast(manuChannel,0);
519 Float_t pedSigma = pedestals->ValueAsFloatFast(manuChannel,1);
520 if ( pedMean < fPedMeanLimits.X() ) pedStatus |= kPedMeanTooLow;
521 else if ( pedMean > fPedMeanLimits.Y() ) pedStatus |= kPedMeanTooHigh;
522 if ( pedSigma < fPedSigmaLimits.X() ) pedStatus |= kPedSigmaTooLow;
523 else if ( pedSigma > fPedSigmaLimits.Y() ) pedStatus |= kPedSigmaTooHigh;
524 if ( pedMean == 0 ) pedStatus |= kPedMeanZero;
525 }
526 else
527 {
528 pedStatus = kPedMissing;
529 }
530
531 Int_t gainStatus(0);
532
533 if ( gains )
534 {
535 Float_t a0 = gains->ValueAsFloatFast(manuChannel,0);
536 Float_t a1 = gains->ValueAsFloatFast(manuChannel,1);
537 Float_t thres = gains->ValueAsFloatFast(manuChannel,2);
538
004a9ccd 539 if ( a0 < fGainA1Limits.X() ) gainStatus |= kGainA1TooLow;
540 else if ( a0 > fGainA1Limits.Y() ) gainStatus |= kGainA1TooHigh;
541 if ( a1 < fGainA2Limits.X() ) gainStatus |= kGainA2TooLow;
542 else if ( a1 > fGainA2Limits.Y() ) gainStatus |= kGainA2TooHigh;
49e396d9 543 if ( thres < fGainThresLimits.X() ) gainStatus |= kGainThresTooLow;
544 else if ( thres > fGainThresLimits.Y() ) gainStatus |= kGainThresTooHigh;
2c780493 545 }
49e396d9 546 else
547 {
548 gainStatus = kGainMissing;
549 }
2b8a1212 550
7eafe398 551 Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus,occStatus);
49e396d9 552
553 param->SetValueAsIntFast(manuChannel,0,status);
2c780493 554 }
555
49e396d9 556 return param;
2c780493 557}
558
004a9ccd 559//_____________________________________________________________________________
560Int_t
7eafe398 561AliMUONPadStatusMaker::OccupancyStatus(Int_t detElemId, Int_t manuId) const
004a9ccd 562{
563 /// Get the "other" status for a given manu
7eafe398 564
565 Int_t rv(0);
566
004a9ccd 567 if ( fTrackerData )
568 {
7eafe398 569 const Int_t occIndex = 2;
570
571 Double_t occ = fTrackerData->DetectionElement(detElemId,occIndex);
572
573 if ( occ <= fDEOccupancyLimits.X() )
574 {
575 rv |= kDEOccupancyTooLow;
576 }
577 else if ( occ > fDEOccupancyLimits.Y() )
004a9ccd 578 {
7eafe398 579 rv |= kDEOccupancyTooHigh;
004a9ccd 580 }
7eafe398 581
582 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
583
584 occ = fTrackerData->BusPatch(busPatchId,occIndex);
585
411a502a 586 if ( occ <= fBuspatchOccupancyLimits.X() )
7eafe398 587 {
588 rv |= kBusPatchOccupancyTooLow;
589 }
411a502a 590 else if ( occ > fBuspatchOccupancyLimits.Y() )
7eafe398 591 {
592 rv |= kBusPatchOccupancyTooHigh;
593 }
594
595 occ = fTrackerData->Manu(detElemId,manuId,occIndex);
596
597 if ( occ <= fManuOccupancyLimits.X() )
598 {
599 rv |= kManuOccupancyTooLow;
600 }
601 else if ( occ > fManuOccupancyLimits.Y() )
004a9ccd 602 {
7eafe398 603 rv |= kManuOccupancyTooHigh;
004a9ccd 604 }
605 }
7eafe398 606 return rv;
004a9ccd 607}
608
2c780493 609//_____________________________________________________________________________
49e396d9 610AliMUONVCalibParam*
611AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId) const
2c780493 612{
004a9ccd 613 /// Get the status container for a given manu
2c780493 614
49e396d9 615 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
616 if (!param)
96199305 617 {
49e396d9 618 // not already there, so compute it now
99c136e1 619 AliCodeTimerAuto("ComputeStatus",0);
49e396d9 620 param = ComputeStatus(detElemId,manuId);
96199305 621 }
49e396d9 622 return param;
2c780493 623}
624
625//_____________________________________________________________________________
49e396d9 626Int_t
627AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
2c780493 628{
49e396d9 629 /// Get the status for a given channel
2c780493 630
49e396d9 631 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
632 if (!param)
2c780493 633 {
49e396d9 634 // not already there, so compute it now
635 param = ComputeStatus(detElemId,manuId);
636 }
637 return param->ValueAsInt(manuChannel,0);
2c780493 638}
639
640//_____________________________________________________________________________
641void
49e396d9 642AliMUONPadStatusMaker::SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const
2c780493 643{
49e396d9 644 /// Assign status to all manus in a given HV "zone" (defined by index, meaning
645 /// is different thing from St12 and St345)
646
99c136e1 647 AliCodeTimerAuto("",0)
49e396d9 648
649 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
2c780493 650
49e396d9 651 const AliMpArrayI* manus = de->ManusForHV(index);
2c780493 652
49e396d9 653 for ( Int_t i = 0; i < manus->GetSize(); ++ i )
2c780493 654 {
49e396d9 655 Int_t manuId = manus->GetValue(i);
656 fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1);
2c780493 657 }
658}
411a502a 659
660//_____________________________________________________________________________
661void
662AliMUONPadStatusMaker::SetLimits(const AliMUONRecoParam& recoParams)
663{
664 /// Set the limits from the recoparam
665
666 SetHVSt12Limits(recoParams.HVSt12LowLimit(),recoParams.HVSt12HighLimit());
667 SetHVSt345Limits(recoParams.HVSt345LowLimit(),recoParams.HVSt345HighLimit());
668
669 SetPedMeanLimits(recoParams.PedMeanLowLimit(),recoParams.PedMeanHighLimit());
670 SetPedSigmaLimits(recoParams.PedSigmaLowLimit(),recoParams.PedSigmaHighLimit());
671
672 SetGainA1Limits(recoParams.GainA1LowLimit(),recoParams.GainA1HighLimit());
673 SetGainA2Limits(recoParams.GainA2LowLimit(),recoParams.GainA2HighLimit());
674 SetGainThresLimits(recoParams.GainThresLowLimit(),recoParams.GainThresHighLimit());
675
676 SetManuOccupancyLimits(recoParams.ManuOccupancyLowLimit(),recoParams.ManuOccupancyHighLimit());
677 SetBuspatchOccupancyLimits(recoParams.BuspatchOccupancyLowLimit(),recoParams.BuspatchOccupancyHighLimit());
678 SetDEOccupancyLimits(recoParams.DEOccupancyLowLimit(),recoParams.DEOccupancyHighLimit());
679}
680
681//_____________________________________________________________________________
682void
683AliMUONPadStatusMaker::Report(UInt_t mask)
684{
685 /// Report the number of bad pads, according to the mask,
686 /// and the various reasons why they are bad (with occurence rates)
687
688 AliInfo("");
99c136e1 689 AliCodeTimerAuto("",0);
411a502a 690
691 AliMUONLogger log(1064008);
692
693 Int_t nBadPads(0);
694 Int_t nPads(0);
695
696 AliMpManuIterator it;
697
698 Int_t detElemId, manuId;
699
700 while ( it.Next(detElemId,manuId) )
701 {
702 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
703
704 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
705 {
706 if ( de->IsConnectedChannel(manuId,i) )
707 {
708 ++nPads;
709
710 Int_t status = PadStatus(detElemId,manuId,i);
711
712 if ( ( status & mask) || (!mask && status) )
713 {
714 ++nBadPads;
715 log.Log(AsString(status));
716 }
717 }
718 }
719 }
720
721 TString msg;
722 Int_t ntimes;
723
724 cout << Form("According to mask %x (human readable form below) %6d pads are bad (over a total of %6d, i.e. %7.2f %%)",
725 mask,nBadPads,nPads,nPads ? nBadPads*100.0/nPads : 0.0) << endl;
726 cout << AliMUONPadStatusMaker::AsCondition(mask) << endl;
727 cout << "--------" << endl;
728
729 while ( log.Next(msg,ntimes) )
730 {
731 cout << Form("The message (%120s) occured %15d times (%7.4f %%)",msg.Data(),ntimes,ntimes*100.0/nPads) << endl;
732 }
733
734}
735