LCOV - code coverage report
Current view: top level - MUON/MUONbase - AliMUONPadStatusMaker.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 269 321 83.8 %
Date: 2016-06-14 17:26:59 Functions: 26 27 96.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             : *                                                                        *
       4             : * Author: The ALICE Off-line Project.                                    *
       5             : * Contributors are mentioned in the code where appropriate.              *
       6             : *                                                                        *
       7             : * Permission to use, copy, modify and distribute this software and its   *
       8             : * documentation strictly for non-commercial purposes is hereby granted   *
       9             : * without fee, provided that the above copyright notice appears in all   *
      10             : * copies and that both the copyright notice and this permission notice   *
      11             : * appear in the supporting documentation. The authors make no claims     *
      12             : * about the suitability of this software for any purpose. It is          *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : // $Id$
      17             : 
      18             : //-----------------------------------------------------------------------------
      19             : /// \class AliMUONPadStatusMaker
      20             : ///
      21             : /// Make a 2DStore of pad statuses, using different sources of information,
      22             : /// like pedestal values, LV values, and HV values.
      23             : ///
      24             : /// \author Laurent Aphecetche
      25             : //-----------------------------------------------------------------------------
      26             : 
      27             : #include "AliMUONPadStatusMaker.h"
      28             : 
      29             : #include "AliMUON2DMap.h"
      30             : #include "AliMUON2DStoreValidator.h"
      31             : #include "AliMUONCalibParamNI.h"
      32             : #include "AliMUONCalibrationData.h"
      33             : #include "AliMUONLogger.h"
      34             : #include "AliMUONRecoParam.h"
      35             : #include "AliMUONStringIntMap.h"
      36             : #include "AliMUONTrackerData.h"
      37             : #include "AliMUONVCalibParam.h"
      38             : 
      39             : #include "AliMpArea.h"
      40             : #include "AliMpArrayI.h"
      41             : #include "AliMpBusPatch.h"
      42             : #include "AliMpCDB.h"
      43             : #include "AliMpConstants.h"
      44             : #include "AliMpDDLStore.h"
      45             : #include "AliMpDEManager.h"
      46             : #include "AliMpDetElement.h"
      47             : #include "AliMpDCSNamer.h"
      48             : #include "AliMpManuIterator.h"
      49             : #include "AliMpManuUID.h"
      50             : 
      51             : #include "AliCDBEntry.h"
      52             : #include "AliCDBManager.h"
      53             : #include "AliCodeTimer.h"
      54             : #include "AliDCSValue.h"
      55             : #include "AliLog.h"
      56             : 
      57             : #include <Riostream.h>
      58             : #include <TArrayI.h>
      59             : #include <TExMap.h>
      60             : #include <TFile.h>
      61             : #include <TKey.h>
      62             : #include <TMap.h>
      63             : #include <TROOT.h>
      64             : #include <TString.h>
      65             : #include <TSystem.h>
      66             : 
      67             : using std::cout;
      68             : using std::endl;
      69             : /// \cond CLASSIMP
      70          18 : ClassImp(AliMUONPadStatusMaker)
      71             : /// \endcond
      72             : 
      73             : //_____________________________________________________________________________
      74           2 : AliMUONPadStatusMaker::AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData)
      75           2 : : fkCalibrationData(calibData),
      76           2 : fPedMeanLimits(0,4095),
      77           2 : fPedSigmaLimits(0,4095),
      78           2 : fManuOccupancyLimits(0,1.0),
      79           2 : fBuspatchOccupancyLimits(0,1.0),
      80           2 : fDEOccupancyLimits(0,1.0),
      81           6 : fStatus(new AliMUON2DMap(true)),
      82           2 : fHV(0x0),
      83           4 : fPedestals(calibData.Pedestals()),
      84           2 : fTrackerData(0x0),
      85           4 : fConfig(calibData.Config())
      86          10 : {
      87             :   /// ctor
      88           4 :   if ( calibData.OccupancyMap() )
      89             :   {
      90             :     /// create a tracker data from the occupancy map
      91           8 :     fTrackerData = new AliMUONTrackerData("OCC","OCC",*(calibData.OccupancyMap()));
      92           2 :   }     
      93           4 :   if ( calibData.HV() )
      94             :   {
      95             :     /// Only create the fHV internal store if there are some HV values available
      96           6 :     fHV = new TExMap;
      97           2 :   }
      98             :   
      99           2 :   SetHVLimit(-1,0.0);
     100           4 : }
     101             : 
     102             : //_____________________________________________________________________________
     103             : AliMUONPadStatusMaker::~AliMUONPadStatusMaker()
     104          12 : {
     105             :   /// dtor.
     106             :  
     107           4 :   delete fStatus;
     108           4 :   delete fHV;
     109           4 :   delete fTrackerData;
     110           6 : }
     111             : 
     112             : //_____________________________________________________________________________
     113             : TString
     114             : AliMUONPadStatusMaker::AsString(Int_t status)
     115             : {
     116             :   /// return a human readable version of the integer status
     117             :   
     118           4 :   if ( status == 0 ) 
     119             :   {
     120           0 :     return "Brave New World";
     121             :   }
     122             :   
     123           2 :   Int_t pedStatus;
     124           2 :   Int_t lvStatus;
     125           2 :   Int_t hvStatus;
     126           2 :   Int_t occStatus;
     127             :   
     128           2 :   DecodeStatus(status,pedStatus,hvStatus,lvStatus,occStatus);
     129             :   
     130           2 :   TString s;
     131             :   
     132           2 :   if ( pedStatus & kPedMeanZero ) s += "& Ped Mean is Zero ";
     133           2 :   if ( pedStatus & kPedMeanTooLow ) s += "& Ped Mean Too Low ";
     134           2 :   if ( pedStatus & kPedMeanTooHigh ) s += "& Ped Mean Too High ";
     135           2 :   if ( pedStatus & kPedSigmaTooLow ) s += "& Ped Sigma Too Low ";
     136           2 :   if ( pedStatus & kPedSigmaTooHigh ) s += "& Ped Sigma Too High ";
     137           4 :   if ( pedStatus & kPedMissing ) s += "& Ped is missing ";
     138             :   
     139           2 :         if ( lvStatus & kLVTooLow ) s+="& LV is Too Low ";
     140           2 :         if ( lvStatus & kLVMissing ) s+="& LV is missing ";
     141             :         
     142           2 :         if ( hvStatus & kHVError ) s+="& HV is on error ";
     143           2 :         if ( hvStatus & kHVTooLow ) s+="& HV is Too Low ";
     144           2 :         if ( hvStatus & kHVTooHigh ) s+="& HV is Too High ";
     145           2 :         if ( hvStatus & kHVChannelOFF ) s+="& HV has channel OFF ";
     146           2 :         if ( hvStatus & kHVSwitchOFF ) s+="& HV has switch OFF ";
     147           4 :         if ( hvStatus & kHVMissing ) s+="& HV is missing ";
     148             : 
     149           2 :   if ( occStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high ";
     150           2 :   if ( occStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low ";
     151           2 :   if ( occStatus & kBusPatchOccupancyTooHigh ) s+="& bus patch occupancy too high ";
     152           2 :   if ( occStatus & kBusPatchOccupancyTooLow ) s+="& bus patch occupancy too low ";
     153           2 :   if ( occStatus & kDEOccupancyTooHigh ) s+="& DE occupancy too high ";
     154           2 :   if ( occStatus & kDEOccupancyTooLow ) s+="& DE occupancy too low ";
     155             :   
     156           2 :   if ( occStatus & kBusPatchRemovedByPAR ) s+="& BusPatch removed during PAR";
     157             :   
     158           8 :   if ( s[0] == '&' ) s[0] = ' ';
     159             :   
     160           2 :   return s;
     161           4 : }
     162             : 
     163             : //_____________________________________________________________________________
     164             : TString
     165             : AliMUONPadStatusMaker::AsCondition(Int_t mask)
     166             : {
     167             :   /// return a human readable version of the mask's equivalent condition
     168             :   
     169           4 :   TString s(AsString(mask));
     170             :   
     171           2 :   s.ReplaceAll("&","|");
     172             :   
     173             :   return s;
     174           4 : }
     175             : 
     176             : //_____________________________________________________________________________
     177             : Int_t
     178             : AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus, 
     179             :                                    Int_t hvStatus, 
     180             :                                    Int_t lvStatus,
     181             :                                    Int_t occStatus)
     182             : {
     183             :   /// Build a complete status from specific parts (ped,hv,lv)
     184             :   
     185     8615936 :   return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) | 
     186     4307968 :   ( ( lvStatus & 0xFF ) << 16 ) |
     187     2153984 :   ( ( occStatus & 0xFF ) << 24 ) ;
     188             : }
     189             : 
     190             : //_____________________________________________________________________________
     191             : Int_t AliMUONPadStatusMaker::CheckConfigConsistencyWithPedestalInformation(Int_t detElemId,
     192             :                                                                            Int_t manuId) const
     193             : {
     194             :   /// Check the consistency between the information from the MUON/Calib/Config and
     195             :   /// MUON/Calib/Pedestals objects.
     196             :   
     197       67312 :   AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId));
     198             : 
     199       33656 :   AliMUONVCalibParam* config = static_cast<AliMUONVCalibParam*>(fConfig->FindObject(detElemId,manuId));
     200             :   
     201       33656 :   if ( pedestals == 0 && config == 0 )
     202             :   {
     203             :     /// manu missing both in config and pedestal run : that is expected
     204           0 :     return 0;
     205             :   }
     206             : 
     207       33656 :   if ( config == 0 && pedestals )
     208             :   {
     209             :     // a manu present in the pedestal run disappeared in the configuration
     210             :     // that is happening if we removed a bus patch _during_ the run and then
     211             :     // issued a PAR (Pause And Reconfigure) to change the readout configuration
     212             :     //
     213             :     // So, that's normal if all the manus of the same buspatch are in the same case.
     214             :     // Let's check that...
     215           0 :     AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(detElemId,manuId);
     216           0 :     Int_t n = busPatch->GetNofManus();
     217             :     Int_t missing(0);
     218           0 :     for ( Int_t i = 0; i < n; ++i )
     219             :     {
     220           0 :       Int_t manu = busPatch->GetManuId(i);
     221           0 :       if ( fConfig->FindObject(detElemId,manuId) == 0x0 ) ++missing;
     222             :     }
     223           0 :     if ( missing != n )
     224             :     {
     225           0 :       AliError(Form("Got an inconsistent state between config and pedestal information for DE %4d MANU %4d BUSPATCH %4d : not all the manus from this bus patch are missing in the configuration ? ",detElemId,manuId,busPatch->GetId()));
     226           0 :       return -1;
     227             :     }
     228           0 :     return 1;
     229             :   }
     230             :   
     231       33656 :   if ( pedestals == 0 && config != 0 )
     232             :   {
     233           0 :     AliError(Form("Got an inconsistent state between config and pedestal information for DE %4d MANU %4d : got a configuration but no pedestal values ???",detElemId,manuId));
     234           0 :     return -2;
     235             :   }
     236             :   
     237       33656 :   return 0;
     238       33656 : }
     239             : 
     240             : //_____________________________________________________________________________
     241             : void
     242             : AliMUONPadStatusMaker::DecodeStatus(Int_t status, 
     243             :                                     Int_t& pedStatus, 
     244             :                                     Int_t& hvStatus, 
     245             :                                     Int_t& lvStatus,
     246             :                                     Int_t& occStatus)
     247             : {
     248             :   /// Decode complete status into specific parts (ped,hv,lv)
     249             :   
     250           4 :   occStatus = ( status & 0xFF000000 ) >> 24;
     251           2 :   lvStatus = ( status & 0xFF0000 ) >> 16;
     252           2 :   pedStatus = ( status & 0xFF00 ) >> 8;
     253           2 :   hvStatus = (status & 0xFF);
     254           2 : }
     255             : 
     256             : //_____________________________________________________________________________
     257             : Bool_t 
     258             : AliMUONPadStatusMaker::HVSt12Status(Int_t detElemId, Int_t sector,
     259             :                                     Bool_t& hvChannelTooLow,
     260             :                                     Bool_t& hvChannelTooHigh,
     261             :                                     Bool_t& hvChannelON) const
     262             : {
     263             :   /// Get HV status for one HV sector of St12
     264             :   
     265             :   /// For a given PCB in a given DE, get the HV status (both the channel
     266             :   /// and the switch).
     267             :   /// Returns false if hv switch changed during the run.
     268             :   
     269         192 :   AliCodeTimerAuto("",0)
     270             :   
     271          96 :   if (!fHV) return kFALSE;
     272             :   
     273             :   Bool_t error = kFALSE;
     274          96 :   hvChannelTooLow = kFALSE;
     275          96 :   hvChannelTooHigh = kFALSE;
     276          96 :   hvChannelON = kTRUE;
     277             : 
     278          96 :   Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
     279             :   
     280          96 :   AliMpDCSNamer hvNamer("TRACKER");
     281             :   
     282          96 :   TString hvChannel(hvNamer.DCSAliasName(detElemId,sector));
     283             :   
     284          96 :   TMap* hvMap = fkCalibrationData.HV();
     285         288 :   TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
     286          96 :   if (!hvPair)
     287             :   {
     288           0 :     AliError(Form("Did not find expected alias (%s) for DE %d",
     289             :                   hvChannel.Data(),detElemId));  
     290             :     error = kTRUE;
     291           0 :   }
     292             :   else
     293             :   {
     294          96 :     TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
     295          96 :     if (!values)
     296             :     {
     297           0 :       AliError(Form("Could not get values for alias %s",hvChannel.Data()));
     298             :       error = kTRUE;
     299           0 :     }
     300             :     else
     301             :     {
     302             :       // find out min value, and makes a cut
     303             :       Float_t hvMin(1E9);
     304          96 :       TIter next(values);
     305             :       AliDCSValue* val;
     306             :       
     307         576 :       while ( ( val = static_cast<AliDCSValue*>(next()) ) )
     308             :       {
     309          96 :         Float_t hv = val->GetFloat();
     310          96 :         hvMin = TMath::Min(hv,hvMin);
     311             :       }
     312             :       
     313          96 :       float lowThreshold = HVLimit(chamberId);
     314             :             
     315         192 :       if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
     316          96 :       if ( hvMin < hvNamer.TrackerHVOFF() ) hvChannelON = kFALSE;
     317          96 :     }
     318             :   }
     319             :   
     320          96 :   return error;
     321         192 : }
     322             : 
     323             : //_____________________________________________________________________________
     324             : Float_t
     325             : AliMUONPadStatusMaker::SwitchValue(const TObjArray& dcsArray)
     326             : {
     327             :   /// Loop over the dcs value for a single switch to decide whether
     328             :   /// we should consider it on or off
     329             :   
     330             :   // we'll count the number of ON/OFF for this pad, to insure
     331             :   // consistency (i.e. if status changed during the run, we should
     332             :   // at least notify this fact ;-) and hope it's not the norm)
     333             :   Int_t nTrue(0);
     334             :   Int_t nFalse(0);
     335        2400 :   TIter next(&dcsArray);
     336             :   AliDCSValue* val;
     337             :   
     338       10800 :   while ( ( val = static_cast<AliDCSValue*>(next()) ) )
     339             :   {
     340        7200 :     if ( val->GetBool() )
     341             :     {
     342        3600 :       ++nTrue;
     343        3600 :     }
     344             :     else
     345             :     {
     346           0 :       ++nFalse;
     347             :     }
     348             :   }
     349             :   
     350        1200 :   if ( (nTrue>0 && nFalse>0) )
     351             :   {
     352             :     // change of state during the run, consider it off
     353           0 :     return 0.0;
     354             :   }
     355             :   
     356        1200 :   if ( nFalse ) 
     357             :   {
     358             :     /// switch = FALSE means the HV was flowding up to the PCB.
     359             :     /// i.e. switch = FALSE = ON
     360           0 :     return 1.0;    
     361             :   }
     362             :   
     363        1200 :   return 0.0;
     364        1200 : }
     365             : 
     366             : //_____________________________________________________________________________
     367             : Bool_t 
     368             : AliMUONPadStatusMaker::HVSt345Status(Int_t detElemId, Int_t pcbIndex,
     369             :                                      Bool_t& hvChannelTooLow,
     370             :                                      Bool_t& hvChannelTooHigh,
     371             :                                      Bool_t& hvChannelON,
     372             :                                      Bool_t& hvSwitchON) const
     373             : {
     374             :   /// For a given PCB in a given DE, get the HV status (both the channel
     375             :   /// and the switch).
     376             :   /// Returns false if something goes wrong (in particular if 
     377             :   /// hv switch changed during the run).
     378             :   
     379        2400 :   AliCodeTimerAuto("",0)
     380             :   
     381        1200 :   if (!fHV) return kFALSE;
     382             :   
     383             :   Bool_t error = kFALSE;
     384        1200 :   hvChannelTooLow = kFALSE;
     385        1200 :   hvChannelTooHigh = kFALSE;
     386        1200 :   hvSwitchON = kTRUE;
     387        1200 :   hvChannelON = kTRUE;
     388             :   
     389        1200 :   AliMpDCSNamer hvNamer("TRACKER");
     390             :   
     391        1200 :   Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
     392             :   
     393        1200 :   TString hvChannel(hvNamer.DCSAliasName(detElemId));
     394             :   
     395        1200 :   TMap* hvMap = fkCalibrationData.HV();
     396             :   
     397        3600 :   TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
     398        1200 :   if (!hvPair)
     399             :   {
     400           0 :     AliError(Form("Did not find expected alias (%s) for DE %d",
     401             :                   hvChannel.Data(),detElemId));  
     402             :     error = kTRUE;
     403           0 :   }
     404             :   else
     405             :   {
     406        1200 :     TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
     407        1200 :     if (!values)
     408             :     {
     409           0 :       AliError(Form("Could not get values for alias %s",hvChannel.Data()));
     410             :       error = kTRUE;
     411           0 :     }
     412             :     else
     413             :     {
     414             :       // find out min value, and makes a cut
     415             :       Float_t hvMin(1E9);
     416        1200 :       TIter next(values);
     417             :       AliDCSValue* val;
     418             :       
     419        7200 :       while ( ( val = static_cast<AliDCSValue*>(next()) ) )
     420             :       {
     421        1200 :         Float_t hv = val->GetFloat();
     422        1200 :         hvMin = TMath::Min(hv,hvMin);
     423             :       }
     424             : 
     425        1200 :       float lowThreshold = HVLimit(chamberId);
     426             : 
     427        2400 :       if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
     428        1200 :       if ( hvMin < hvNamer.TrackerHVOFF() ) hvChannelON = kFALSE;
     429        1200 :     }
     430             :   }
     431             :   
     432        1200 :   TString hvSwitch(hvNamer.DCSSwitchAliasName(detElemId,pcbIndex));
     433        3600 :   TPair* switchPair = static_cast<TPair*>(hvMap->FindObject(hvSwitch.Data()));
     434        1200 :   if (!switchPair)
     435             :   {
     436           0 :     AliError(Form("Did not find expected alias (%s) for DE %d PCB %d",
     437             :                   hvSwitch.Data(),detElemId,pcbIndex));
     438             :     error = kTRUE;
     439           0 :   }
     440             :   else
     441             :   {
     442        1200 :     TObjArray* values = static_cast<TObjArray*>(switchPair->Value());
     443        1200 :     if (!values)
     444             :     {    
     445           0 :       AliError(Form("Could not get values for alias %s",hvSwitch.Data()));
     446             :       error = kTRUE;
     447           0 :     }
     448             :     else
     449             :     {
     450        1200 :       Float_t sv = SwitchValue(*values);
     451        2400 :       if ( sv < 0.99 ) hvSwitchON = kFALSE;
     452             :     }
     453             :   }
     454        1200 :   return error;
     455        2400 : }
     456             : 
     457             : //_____________________________________________________________________________
     458             : Int_t
     459             : AliMUONPadStatusMaker::HVStatus(Int_t detElemId, Int_t manuId) const
     460             : {
     461             :   /// Get HV status of one manu
     462             :   
     463       67312 :   AliCodeTimerAuto("",0)
     464             :   
     465       33656 :   if ( !fHV ) return kMissing;
     466             : 
     467       67312 :   Long_t lint = fHV->GetValue(AliMpManuUID::BuildUniqueID(detElemId,manuId));
     468             :   
     469       33656 :   if ( lint ) 
     470             :   {
     471       32360 :     return (Int_t)(lint - 1);
     472             :   }
     473             : 
     474             :   Int_t status(0);
     475             :   
     476        1296 :   AliMpDCSNamer hvNamer("TRACKER");
     477             :   
     478        2592 :   switch ( AliMpDEManager::GetStationType(detElemId) )
     479             :   {
     480             :     case AliMp::kStation12:
     481             :     {
     482          96 :       int sector = hvNamer.ManuId2Sector(detElemId,manuId);
     483          96 :       if ( sector >= 0 ) 
     484             :       {
     485          96 :         Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON;
     486         192 :         Bool_t error = HVSt12Status(detElemId,sector,
     487             :                                     hvChannelTooLow,
     488             :                                     hvChannelTooHigh,
     489             :                                     hvChannelON);
     490          96 :         if ( error ) status |= kHVError;
     491         192 :         if ( hvChannelTooLow ) status |= kHVTooLow;
     492          96 :         if ( hvChannelTooHigh ) status |= kHVTooHigh; 
     493          96 :         if ( !hvChannelON ) status |= kHVChannelOFF;
     494             :         // assign this status to all the other manus handled by the same HV channel
     495          96 :         SetHVStatus(detElemId,sector,status);
     496          96 :       }
     497             :     }
     498          96 :       break;
     499             :     case AliMp::kStation345:
     500             :     {
     501        1200 :       int pcbIndex = hvNamer.ManuId2PCBIndex(detElemId,manuId);
     502        1200 :       if ( pcbIndex >= 0 ) 
     503             :       {
     504        1200 :         Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON;
     505        2400 :         Bool_t error = HVSt345Status(detElemId,pcbIndex,
     506             :                                      hvChannelTooLow,hvChannelTooHigh,
     507             :                                      hvChannelON,hvSwitchON);
     508        1200 :         if ( error ) status |= kHVError;
     509        2400 :         if ( hvChannelTooLow ) status |= kHVTooLow;
     510        1200 :         if ( hvChannelTooHigh ) status |= kHVTooHigh; 
     511        2400 :         if ( !hvSwitchON ) status |= kHVSwitchOFF; 
     512        1200 :         if ( !hvChannelON) status |= kHVChannelOFF;
     513             :         // assign this status to all the other manus handled by the same HV channel
     514        1200 :         SetHVStatus(detElemId,pcbIndex,status);
     515        1200 :       }
     516             :     }
     517        1200 :       break;
     518             :     default:
     519             :       break;
     520             :   }
     521             :   
     522             :   return status;
     523       34952 : }
     524             : 
     525             : //_____________________________________________________________________________
     526             : Int_t AliMUONPadStatusMaker::LVStatus(Int_t detElemId) const
     527             : {
     528             :   /// Get LV status of one detection element
     529       67312 :   return kLVMissing;
     530             : }
     531             : 
     532             : //_____________________________________________________________________________
     533             : AliMUONVCalibParam* 
     534             : AliMUONPadStatusMaker::Neighbours(Int_t detElemId, Int_t manuId) const
     535             : {
     536             :   /// Get the neighbours parameters for a given manu
     537         848 :   AliMUONVStore* neighbourStore = fkCalibrationData.Neighbours();
     538         424 :   return static_cast<AliMUONVCalibParam*>(neighbourStore->FindObject(detElemId,manuId));
     539             : }
     540             : 
     541             : //_____________________________________________________________________________
     542             : AliMUONVStore* 
     543             : AliMUONPadStatusMaker::NeighboursStore() const
     544             : {
     545             :   /// Return the store containing all the neighbours
     546           0 :   return fkCalibrationData.Neighbours();
     547             : }
     548             : 
     549             : //_____________________________________________________________________________
     550             : AliMUONVCalibParam*
     551             : AliMUONPadStatusMaker::ComputeStatus(Int_t detElemId, Int_t manuId) const
     552             : {
     553             :   /// Compute the status of a given manu, using all available information,
     554             :   /// i.e. pedestals, LV, and HV
     555             :   
     556      100968 :   AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,-1);
     557       33656 :   fStatus->Add(param);
     558             : 
     559       33656 :   AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId));
     560             : 
     561       33656 :   Int_t hvStatus = HVStatus(detElemId,manuId);
     562       33656 :   Int_t lvStatus = LVStatus(detElemId);
     563             :   
     564       33656 :   Int_t occStatus = OccupancyStatus(detElemId,manuId);
     565             :   
     566     4375280 :   for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
     567             :   {
     568             :     Int_t pedStatus(0);
     569             :     
     570     2153984 :     if (pedestals) 
     571             :     {
     572     2153984 :       Float_t pedMean = pedestals->ValueAsFloatFast(manuChannel,0);
     573     2153984 :       Float_t pedSigma = pedestals->ValueAsFloatFast(manuChannel,1);
     574     4282000 :       if ( pedMean < fPedMeanLimits.X() ) pedStatus |= kPedMeanTooLow;
     575       51936 :       else if ( pedMean > fPedMeanLimits.Y() ) pedStatus |= kPedMeanTooHigh;
     576     2153984 :       if ( pedSigma < fPedSigmaLimits.X() ) pedStatus |= kPedSigmaTooLow;
     577     2179952 :       else if ( pedSigma > fPedSigmaLimits.Y() ) pedStatus |= kPedSigmaTooHigh;
     578     4282000 :       if ( pedMean == 0 ) pedStatus |= kPedMeanZero;
     579     2153984 :     }
     580             :     else
     581             :     {
     582             :       pedStatus = kPedMissing;
     583             :     }
     584             :     
     585     2153984 :     Int_t status = BuildStatus(pedStatus,hvStatus,lvStatus,occStatus);
     586             :       
     587     2153984 :     param->SetValueAsIntFast(manuChannel,0,status);
     588             :   }
     589             :   
     590       33656 :   return param;
     591           0 : }
     592             : 
     593             : //_____________________________________________________________________________
     594             : Int_t 
     595             : AliMUONPadStatusMaker::OccupancyStatus(Int_t detElemId, Int_t manuId) const
     596             : {
     597             :   /// Get the "other" status for a given manu
     598             :  
     599             :   Int_t rv(0);
     600             :   
     601       67312 :   if ( fTrackerData ) 
     602             :   {
     603             :     const Int_t occIndex = 2;
     604             :     
     605       33656 :     Double_t occ = fTrackerData->DetectionElement(detElemId,occIndex);
     606             :     
     607       33656 :     if ( occ <= fDEOccupancyLimits.X() )
     608             :     {
     609             :       rv |= kDEOccupancyTooLow;
     610           0 :     } 
     611       33656 :     else if ( occ > fDEOccupancyLimits.Y() )
     612             :     {
     613             :       rv |= kDEOccupancyTooHigh;
     614           0 :     }
     615             :     
     616       33656 :     Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
     617             :     
     618       33656 :     occ = fTrackerData->BusPatch(busPatchId,occIndex);
     619             : 
     620       33656 :     if ( occ <= fBuspatchOccupancyLimits.X() )
     621             :     {
     622       33656 :       rv |= kBusPatchOccupancyTooLow;
     623       33656 :     } 
     624           0 :     else if ( occ > fBuspatchOccupancyLimits.Y() )
     625             :     {
     626           0 :       rv |= kBusPatchOccupancyTooHigh;
     627           0 :     }
     628             :     
     629       33656 :     occ = fTrackerData->Manu(detElemId,manuId,occIndex);
     630             :     
     631       33656 :     if ( occ <= fManuOccupancyLimits.X() )
     632             :     {
     633           0 :       rv |= kManuOccupancyTooLow;
     634           0 :     } 
     635       33656 :     else if ( occ > fManuOccupancyLimits.Y() )
     636             :     {
     637           0 :       rv |= kManuOccupancyTooHigh;
     638           0 :     }
     639       33656 :   }
     640             :   
     641       33656 :   Int_t config = CheckConfigConsistencyWithPedestalInformation(detElemId,manuId);
     642             :   
     643       33656 :   if (config==1)
     644             :   {
     645           0 :     Int_t bpid = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
     646             : 
     647           0 :     AliWarning(Form("BusPatchRemovedByPAR : BP %4d",bpid));
     648           0 :     rv |= kBusPatchRemovedByPAR;
     649           0 :   }
     650             :   
     651       33656 :   return rv;
     652             : }
     653             : 
     654             : //_____________________________________________________________________________
     655             : AliMUONVCalibParam* 
     656             : AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId) const
     657             : {
     658             :   /// Get the status container for a given manu
     659             :   
     660         848 :   AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
     661         424 :   if (!param)
     662             :   {
     663             :     // not already there, so compute it now
     664         424 :     AliCodeTimerAuto("ComputeStatus",0);
     665         424 :     param = ComputeStatus(detElemId,manuId);
     666         424 :   }
     667         424 :   return param;
     668           0 : }
     669             : 
     670             : //_____________________________________________________________________________
     671             : Int_t 
     672             : AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
     673             : {
     674             :   /// Get the status for a given channel
     675             :   
     676     4256032 :   AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
     677     2128016 :   if (!param)
     678             :   {
     679             :     // not already there, so compute it now
     680       33232 :     param = ComputeStatus(detElemId,manuId);
     681       33232 :   }
     682     2128016 :   return param->ValueAsInt(manuChannel,0);
     683             : }
     684             : 
     685             : //_____________________________________________________________________________
     686             : void
     687             : AliMUONPadStatusMaker::SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const
     688             : {
     689             :   /// Assign status to all manus in a given HV "zone" (defined by index, meaning
     690             :   /// is different thing from St12 and St345)
     691             :   
     692        2592 :   AliCodeTimerAuto("",0)
     693             :   
     694        2592 :   AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     695             :   
     696        1296 :   const AliMpArrayI* manus = de->ManusForHV(index);
     697             :   
     698      104856 :   for ( Int_t i = 0; i < manus->GetSize(); ++ i ) 
     699             :   {
     700       33656 :     Int_t manuId = manus->GetValue(i);
     701       67312 :     fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1);
     702             :   }
     703        1296 : }
     704             : 
     705             : //_____________________________________________________________________________
     706             : Double_t
     707             : AliMUONPadStatusMaker::HVLimit(Int_t chamberId) const
     708             : {
     709             :   /// Get HV limit for a given chamber
     710        2592 :   if ( chamberId >=0 && chamberId < 10 ) 
     711             :   {
     712        1296 :     return fHVLimit[chamberId];
     713             :   }
     714           0 :   return 0.0;
     715        1296 : }
     716             : 
     717             : //_____________________________________________________________________________
     718             : void
     719             : AliMUONPadStatusMaker::SetHVLimit(Int_t chamberId, Double_t hv) 
     720             : {
     721             :   /// Set hv limit for a given chamber (or all if chamberId==-1)
     722             :   
     723          44 :   if ( chamberId == -1 ) 
     724             :   {
     725          44 :     for ( Int_t i = 0; i < 10; ++i ) 
     726             :     {
     727          20 :       fHVLimit[i] = hv;
     728             :     }
     729           2 :   }
     730          20 :   else if ( chamberId >= 0 && chamberId < 10 ) 
     731             :   {
     732          20 :     fHVLimit[chamberId]=hv;
     733          20 :   }
     734             :   else
     735             :   {
     736           0 :     AliError(Form("chamberId=%d is invalid",chamberId));
     737             :   }
     738          22 : }
     739             : 
     740             : //_____________________________________________________________________________
     741             : void
     742             : AliMUONPadStatusMaker::SetLimits(const AliMUONRecoParam& recoParams) 
     743             : {
     744             :   /// Set the limits from the recoparam
     745             :   
     746          46 :   for ( int i = 0; i < 10; ++i )
     747             :   {
     748          20 :     SetHVLimit(i,recoParams.HVLimit(i));
     749             :   }
     750             :   
     751           2 :   SetPedMeanLimits(recoParams.PedMeanLowLimit(),recoParams.PedMeanHighLimit());
     752           2 :   SetPedSigmaLimits(recoParams.PedSigmaLowLimit(),recoParams.PedSigmaHighLimit());
     753             :   
     754           2 :   SetManuOccupancyLimits(recoParams.ManuOccupancyLowLimit(),recoParams.ManuOccupancyHighLimit());
     755           2 :   SetBuspatchOccupancyLimits(recoParams.BuspatchOccupancyLowLimit(),recoParams.BuspatchOccupancyHighLimit());
     756           2 :   SetDEOccupancyLimits(recoParams.DEOccupancyLowLimit(),recoParams.DEOccupancyHighLimit());  
     757           2 : }
     758             : 
     759             : //_____________________________________________________________________________
     760             : void 
     761             : AliMUONPadStatusMaker::Report(UInt_t mask)
     762             : {
     763             :   /// Report the number of bad pads, according to the mask,
     764             :   /// and the various reasons why they are bad (with occurence rates)
     765             :   
     766           4 :   AliInfo("");
     767           2 :   AliCodeTimerAuto("",0);
     768             : 
     769           2 :   AliMUONLogger log(1064008);
     770             :   
     771             :   Int_t nBadPads(0);
     772             :   Int_t nPads(0);
     773             :   
     774           2 :   AliMpManuIterator it;
     775             :   
     776           2 :   Int_t detElemId, manuId;
     777             :   
     778      100974 :   while ( it.Next(detElemId,manuId) )
     779             :   {
     780       67312 :     AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     781             :     
     782     4375280 :     for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
     783             :     {
     784     4307968 :       if ( de->IsConnectedChannel(manuId,i) ) 
     785             :       {
     786     2128016 :         ++nPads;
     787             :         
     788     2128016 :         Int_t status = PadStatus(detElemId,manuId,i);          
     789             :         
     790     4256032 :         if ( mask && ( status & mask) ) // note that if mask == 0, all pads are good...
     791             :         {
     792           0 :           ++nBadPads;
     793           0 :           log.Log(AsString(status));
     794           0 :         }
     795     2128016 :       }
     796             :     }
     797             :   }
     798             :   
     799           2 :   if (!nPads) 
     800             :   {
     801           0 :     AliError("Got no pad from the iterator ?! That's not normal. Please check !");
     802           0 :     return;
     803             :   }
     804             :   
     805           2 :   TString msg;
     806           2 :   Int_t ntimes;
     807             :   
     808           4 :   cout << Form("According to mask %x (human readable form below) %6d pads are bad (over a total of %6d, i.e. %7.2f %%)",
     809           4 :                mask,nBadPads,nPads,nBadPads*100.0/nPads) << endl;
     810           8 :   cout << AliMUONPadStatusMaker::AsCondition(mask) << endl;
     811           4 :   cout << "--------" << endl;
     812             :   
     813           4 :   while ( log.Next(msg,ntimes) )
     814             :   {
     815           0 :     cout << Form("The message (%120s) occured %15d times (%7.4f %%)",msg.Data(),ntimes,ntimes*100.0/nPads) << endl;
     816             :   }
     817             :   
     818           2 :   TMap* hvMap = CalibrationData().HV();
     819             :   
     820           8 :   std::cout << "Map UniqueID = " << hvMap->GetUniqueID() << std::endl;
     821           4 : }
     822             : 

Generated by: LCOV version 1.11