]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONCDB.cxx
Make the Scan method public
[u/mrichter/AliRoot.git] / MUON / AliMUONCDB.cxx
index a4205b470250a26d9e02828be036ebf43bfacfc8..69751988c6bef6289e655ca3ad90f7dd8761035e 100644 (file)
@@ -14,7 +14,7 @@
  **************************************************************************/
 
 /* $Id$ */
-
 //-----------------------------------------------------------------------------
 /// \namespace AliMUONCDB
 ///
@@ -28,7 +28,7 @@
 ///
 /// For more information, please see READMEcalib
 ///
-// \author Laurent Aphecetche
+/// \author Laurent Aphecetche
 //-----------------------------------------------------------------------------
 
 #include "AliMUONCDB.h"
 #include "AliMUONCalibParamND.h"
 #include "AliMUONCalibParamNF.h"
 #include "AliMUONCalibParamNI.h"
+#include "AliMUONCalibrationData.h"
 #include "AliMUONConstants.h"
+#include "AliMUONGlobalCrateConfig.h"
+#include "AliMUONLogger.h"
+#include "AliMUONPadStatusMaker.h"
+#include "AliMUONPadStatusMapMaker.h"
+#include "AliMUONRecoParam.h"
+#include "AliMUONRegionalTriggerConfig.h"
 #include "AliMUONRejectList.h"
+#include "AliMUONTrackerData.h"
 #include "AliMUONTrackerIO.h"
 #include "AliMUONTriggerEfficiencyCells.h"
 #include "AliMUONTriggerLut.h"
-#include "AliMUONVStore.h"
 #include "AliMUONVCalibParam.h"
 #include "AliMUONVCalibParam.h"
-#include "AliMUONGlobalCrateConfig.h"
-#include "AliMUONRegionalTriggerConfig.h"
-#include "AliMUONRecoParam.h"
+#include "AliMUONVStore.h"
 
 #include "AliMpCDB.h"
 #include "AliMpConstants.h"
 #include "AliGRPManager.h"
 #include "AliDCSValue.h"
 #include "AliLog.h"
+#include "AliMpBusPatch.h"
 
 #include <Riostream.h>
 #include <TArrayI.h>
 #include <TClass.h>
+#include <TFile.h>
 #include <TH1F.h>
 #include <TList.h>
 #include <TMap.h>
 #include <TSystem.h>
 #include <TMath.h>
 #include <TGeoGlobalMagField.h>
+#include <TClonesArray.h>
+#include <sstream>
+#include <set>
 
+using std::endl;
+using std::cout;
+using std::cerr;
+using std::ostringstream;
+using std::ifstream;
 
 namespace
 {
@@ -121,6 +136,8 @@ void getBoundaries(const AliMUONVStore& store, Int_t dim,
     const AliMpVSegmentation* seg = 
       AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
         
+    if (!seg) continue;
+    
     for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
     {
       AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
@@ -277,7 +294,7 @@ AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
   
   AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
   
-  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
+  if (!AliMUONCDB::CheckOCDB()) return 0x0;
   
   AliMUONRecoParam* recoParam = 0x0;
   AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
@@ -288,6 +305,7 @@ AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
     if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
       
       TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
+//      recoParamArray->SetOwner(kTRUE); // FIXME: this should be done, but is causing a problem at the end of the reco... investigate why...
       
       for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
        recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
@@ -305,6 +323,30 @@ AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
   
 }
 
+//_____________________________________________________________________________
+TClonesArray* AliMUONCDB::LoadAlignmentData()
+{
+  /// Load and return the array of alignment objects.
+  
+  AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB...");
+  
+  if (!AliMUONCDB::CheckOCDB()) return 0x0;
+  
+  TClonesArray* alignmentArray = 0x0;
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data");
+  
+  if (entry) {
+    // load alignement array
+    alignmentArray = dynamic_cast<TClonesArray*>(entry->GetObject());
+  }
+  
+  if (!alignmentArray) { 
+    AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB");
+  }  
+  
+  return alignmentArray;
+}
+
 //_____________________________________________________________________________
 AliMUONVStore* 
 AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, 
@@ -375,14 +417,14 @@ AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2,
 }
 
 //_____________________________________________________________________________
-void 
+TH1** 
 AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
 {
   /// Make histograms of each dimension of the AliMUONVCalibParam
   /// contained inside store.
   /// It produces histograms named name_0, name_1, etc...
   
-  if (!AliMUONCDB::CheckMapping(kTRUE)) return;
+  if (!AliMUONCDB::CheckMapping(kTRUE)) return 0x0;
   
   TIter next(store.CreateIterator());
   AliMUONVCalibParam* param;
@@ -409,6 +451,8 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
                             nbins,xmin[i],xmax[i]);
         AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
       }
+      delete [] xmin;
+      delete [] xmax;
     }
     
     Int_t detElemId = param->ID0();
@@ -418,6 +462,8 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
     const AliMpVSegmentation* seg = 
       AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
     
+    if (!seg) continue;
+    
     for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
     {
       AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
@@ -441,6 +487,8 @@ AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
   AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
   
   delete[] nPerStation;
+  
+  return h;
 }
 
 //_____________________________________________________________________________
@@ -528,7 +576,15 @@ AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
 
     TObjArray* valueSet = new TObjArray;
     valueSet->SetOwner(kTRUE);
+
     Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data());
+    if ( measureType < 0 ) {
+      AliErrorGeneralStream("AliMUONCDB") 
+        << "Failed to get DCS variable from an alias (trigger): "
+        << aliasName.Data() << endl;
+      return 0;
+    }
+        
     for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
     {
       Float_t value = 
@@ -1359,6 +1415,29 @@ AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
   WriteTriggerEfficiency(startRun,endRun);
 }
 
+//_____________________________________________________________________________
+void
+AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun)
+{
+  /// Write complete tracker configuration to OCDB
+  ostringstream lines;
+  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+  AliMpBusPatch* bp;
+  while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
+  {
+    for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu) 
+    {
+      lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl;
+    }
+  }
+  
+  AliMUON2DMap config(kTRUE);
+  
+  AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config);
+  
+  WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE);
+}
+
 //_____________________________________________________________________________
 void
 AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
@@ -1369,7 +1448,515 @@ AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
   WriteGains(defaultValues,startRun,endRun);
   WriteCapacitances(defaultValues,startRun,endRun);
   WriteNeighbours(startRun,endRun);
-  WriteOccupancyMap(startRun,endRun,defaultValues);
-  WriteRejectList(startRun,endRun,defaultValues);
+  WriteOccupancyMap(defaultValues,startRun,endRun);
+  WriteRejectList(defaultValues,startRun,endRun);
+  WriteConfig(startRun,endRun);
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONCDB::ShowCapacitances()
+{
+  /// Show briefly the number of capa values we have in the OCDB,
+  /// and the list of manu that are actually in the config and for which
+  /// we miss the capa (if any).
+  
+  if (!AliMUONCDB::CheckOCDB()) return;
+  
+  AliMUONCDB::LoadMapping();
+  
+  if (!AliMUONCDB::CheckMapping()) return;
+  
+  AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
+  
+  if (!e) return ;
+  
+  AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
+  
+  e = AliCDBManager::Instance()->Get("MUON/Calib/Capacitances");
+  
+  if (!e) return;
+  
+  AliMUONVStore* capacitances = static_cast<AliMUONVStore*>(e->GetObject());
+  
+  AliInfoGeneral("ShowCapacitances",Form("%d capacitances are in OCDB",capacitances->GetSize()));
+  
+  TIter nextManu(config->CreateIterator());
+  AliMUONVCalibParam* param;
+  
+  while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
+  {
+    Int_t detElemId = param->ID0();
+    Int_t manuId = param->ID1();
+    
+    Int_t serialNumber 
+    = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
+    
+    if (serialNumber<0)
+    {
+      AliErrorGeneral("ShowCapacitances",Form("Did not find serial for DE %04d MANUID %04d",detElemId,manuId));
+    }
+    else
+    {
+      AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capacitances->FindObject(serialNumber));
+      if (!capa)
+      {
+        AliErrorGeneral("ShowCapacitances",Form("Did not find capacitance for DE %04d MANUID %04d SERIAL %d",detElemId,manuId,serialNumber));
+      }
+    }
+  }
+  
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONCDB::ShowConfig(Bool_t withStatusMap)
+{  
+  /// Dumps the current tracker configuration, i.e. number and identity of missing buspatches
+  /// If statusMap is true, will also take into account the status map to report the number
+  /// of good channels
+  
+  if (!AliMUONCDB::CheckOCDB()) return;
+  
+  AliMUONCDB::LoadMapping();
+  
+  if (!AliMUONCDB::CheckMapping()) return;
+  
+  AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
+  
+  if (!e) return ;
+  
+  AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
+  
+  AliMUONPadStatusMapMaker* statusMapMaker(0x0);
+  AliMUONCalibrationData* cd(0x0);
+  AliMUONPadStatusMaker* statusMaker(0x0);
+
+  if ( withStatusMap ) 
+  {
+    cd = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
+  
+    statusMaker = new AliMUONPadStatusMaker(*cd);
+
+    AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
+  
+    if (!recoParam)
+    {
+      AliErrorGeneral("AliMUONCDB::ShowConfig","Cannot get recoParams from OCDB !");
+      return;
+    }
+    
+    statusMaker->SetLimits(*recoParam);
+  
+    UInt_t mask = recoParam->PadGoodnessMask();
+
+    delete recoParam;
+    
+    const Bool_t deferredInitialization = kFALSE;
+  
+    statusMapMaker = new AliMUONPadStatusMapMaker(*cd,mask,deferredInitialization);
+  }
+  
+  TIter nextManu(config->CreateIterator());
+  AliMUONVCalibParam* param;
+  
+  AliMpExMap buspatches;
+  
+  while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
+  {
+    Int_t detElemId = param->ID0();
+    Int_t manuId = param->ID1();
+    Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
+    if ( buspatches.GetValue(busPatchId) == 0x0 ) 
+    {      
+      buspatches.Add(busPatchId,new TObjString(Form("BP%04d",busPatchId)));
+    }
+  }
+
+  TArrayI removed(buspatches.GetSize());
+
+  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+  AliMpBusPatch* bp;
+  Int_t n(0);
+  Int_t nok(0);
+  Int_t nremoved(0);
+  
+  // accounting of bus patches first
+  
+  while ( ( bp = static_cast<AliMpBusPatch*>(next())))
+  {
+    if ( buspatches.GetValue(bp->GetId()) )
+    {
+      ++nok;
+    }
+    else
+    {
+      removed.SetAt(bp->GetId(),nremoved++);
+    }
+  }
+  
+  // accounting of channels
+  
+  AliMpManuIterator it;
+
+  Int_t totalNumberOfChannels(0);
+  Int_t removedChannels(0);
+  Int_t badChannels(0);
+  Int_t badAndRemovedChannels(0);
+  Int_t badOrRemovedChannels(0);
+  
+  Int_t detElemId, manuId;
+  
+  while ( it.Next(detElemId,manuId) )
+  {
+    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+    for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
+    {
+      Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
+      
+      if ( de->IsConnectedChannel(manuId,i) )
+      {
+        ++totalNumberOfChannels;
+        Bool_t badBusPatch = ( buspatches.GetValue(busPatchId) == 0x0 );
+        
+        if ( withStatusMap ) 
+        {
+          Bool_t badChannel = ( ( statusMapMaker->StatusMap(detElemId,manuId,i) & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0);
+          if ( badChannel ) ++badChannels;
+          if ( badBusPatch && badChannel ) ++badAndRemovedChannels;
+          if ( badBusPatch || badChannel ) ++badOrRemovedChannels;          
+        }
+      
+        if ( badBusPatch) ++removedChannels;
+      }
+    }
+  }
+  
+  
+  Int_t* indices = new Int_t[nremoved];
+  
+  TMath::Sort(nremoved,removed.GetArray(),indices,kFALSE);
+  
+  for ( Int_t i = 0; i < nremoved; ++i ) 
+  {
+    Int_t busPatchId = removed[indices[i]];
+    bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
+    bp->Print();
+  }
+  
+  delete[] indices;  
+  
+  cout << endl;
+  cout << Form("Bus patches n=%3d nok=%3d nremoved=%3d",n,nok,nremoved) << endl;
+
+  cout << Form("Channels n=%6d nremoved=%6d bad=%6d bad and removed=%6d bad or removed=%6d",
+               totalNumberOfChannels,removedChannels,badChannels,badAndRemovedChannels,badOrRemovedChannels) << endl;
+  
+  if (totalNumberOfChannels>0)
+  {
+    cout << Form("Percentage of readout channels %5.1f %%",removedChannels*100.0/totalNumberOfChannels) << endl;
+    if ( withStatusMap )
+    {
+      cout << Form("Percentage of non useable channels (bad or removed) %5.1f %%",
+                   badOrRemovedChannels*100.0/totalNumberOfChannels) << endl;
+    }
+  }
+  
+  
+  delete statusMapMaker;
+  delete cd;
+  delete statusMaker;  
 }
 
+//______________________________________________________________________________
+void AliMUONCDB::ReadIntegers(const char* filename, std::vector<int>& integers)
+{
+  /// Read integers from filename, where integers are either
+  /// separated by "," or by return carriage
+  ifstream in(gSystem->ExpandPathName(filename));
+  int i;
+  
+  std::set<int> runset;
+  
+  char line[10000];
+  
+  in.getline(line,10000,'\n');
+  
+  TString sline(line);
+  
+  if (sline.Contains(","))
+  {
+    TObjArray* a = sline.Tokenize(",");
+    TIter next(a);
+    TObjString* s;
+    while ( ( s = static_cast<TObjString*>(next()) ) )
+    {
+      runset.insert(s->String().Atoi());
+    }
+    delete a;
+  }
+  else
+  {
+    runset.insert(sline.Atoi());
+    
+    while ( in >> i )
+    {
+      runset.insert(i);
+    }
+  }
+  
+  for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it ) 
+  {
+    integers.push_back((*it)); 
+  }
+  
+  std::sort(integers.begin(),integers.end());
+}
+
+//______________________________________________________________________________
+void AliMUONCDB::ShowFaultyBusPatches(const char* runlist, double occLimit,
+                                      const char* outputBaseName,
+                                      const char* ocdbPath)
+{
+  /// Shows the list of bus patches above a given occupancy limit,
+  /// for each run in the runlist
+  
+  AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError);
+  
+  //  AliLog::SetPrintType(AliLog::kInfo,kFALSE);
+  //  AliLog::SetPrintType(AliLog::kWarning,kFALSE);
+  //  gErrorIgnoreLevel=kError; // to avoid all the TAlienFile::Open messages...
+  
+  AliCDBManager* man = AliCDBManager::Instance();
+  
+  man->SetDefaultStorage(ocdbPath);
+  
+  Bool_t first(kTRUE);
+  
+  std::vector<int> runnumbers;
+  
+  ReadIntegers(runlist,runnumbers);
+  
+  AliMUON2DMap bpValues(kFALSE);
+  
+  std::ofstream outfile(Form("%s.txt",outputBaseName));
+  
+  for ( unsigned int i = 0 ; i < runnumbers.size(); ++i )
+  {
+    int runNumber = runnumbers[i];
+    
+    man->SetRun(runNumber);
+    
+    if ( first ) 
+    {
+      AliMpCDB::LoadAll();  
+      first = kFALSE;
+    }
+    
+    AliCDBEntry* e = man->Get("MUON/Calib/OccupancyMap",runNumber);
+    
+    if (!e)
+    {
+      AliErrorGeneral("AliMUONCDB::ShowFaultyBusPatches",
+                      Form("Could not get OccupancyMap for run %09d",runNumber));
+      continue;
+    }
+    
+    AliMUONVStore* occmap = static_cast<AliMUONVStore*>(e->GetObject());
+    
+    AliMUONTrackerData td("occ","occ",*occmap);
+    
+    TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+    AliMpBusPatch* bp;
+    std::set<int> buspatches;
+    Double_t sumn = 1000.0;
+    
+    while ( ( bp = static_cast<AliMpBusPatch*>(nextBP()) ) )
+    {      
+      Double_t occ = td.BusPatch(bp->GetId(),2);
+      
+      if (occ>occLimit) 
+      {
+        buspatches.insert(bp->GetId());
+        
+        AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(bpValues.FindObject(bp->GetId()));
+        
+        if (!param)
+        {
+          param = new AliMUONCalibParamND(5, 1, bp->GetId(), 0);
+          bpValues.Add(param);
+          
+          Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId());
+          AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+          
+          Int_t nchannels(0);
+          
+          for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu ) 
+          {
+            Int_t manuId = bp->GetManuId(imanu);
+            nchannels += de->NofChannelsInManu(manuId);
+          }
+          
+          param->SetValueAsDouble(0,2,sumn);
+          param->SetValueAsDouble(0,3,nchannels);
+          param->SetValueAsDouble(0,4,1);          
+        }
+        
+        Double_t sumw = sumn*(param->ValueAsDouble(0)/sumn+1.0/runnumbers.size());
+        Double_t sumw2 = 0.0; //(sumn-1)*ey*ey+sumw*sumw/sumn;
+        
+        param->SetValueAsDouble(0,0,sumw);
+        param->SetValueAsDouble(0,1,sumw2);
+        
+      }
+    }
+    
+    outfile << Form("RUN %09d",runNumber);
+    
+    for ( std::set<int>::const_iterator bit = buspatches.begin(); bit != buspatches.end(); ++bit )
+    {
+      outfile << Form(" %4d",*bit);
+    }
+    outfile << endl;
+  }
+  
+  outfile.close();
+  
+  const char* name = "BPfailureRate";
+  
+  AliMUONTrackerData* mpData = new AliMUONTrackerData(name,name,bpValues,2);
+  mpData->SetDimensionName(0,name);
+  
+  TFile f(Form("%s.root",outputBaseName),"recreate");
+  mpData->Write();
+  f.Close();
+  
+  cout << Form("Results are in %s.txt and %s.root",outputBaseName,outputBaseName) << endl;
+  
+  gSystem->Exec(Form("cat %s.txt",outputBaseName));
+  
+}
+
+//______________________________________________________________________________
+void AliMUONCDB::CheckHV(Int_t runNumber, Int_t verbose)
+{
+  /// Check the HV values in OCDB for a given run
+  
+  TList messages;
+  messages.SetOwner(kTRUE);
+  
+  Bool_t patched(kTRUE);
+  
+  if (!AliCDBManager::Instance()->IsDefaultStorageSet())
+  {
+    AliCDBManager::Instance()->SetDefaultStorage("raw://");
+  }
+
+  AliCDBManager::Instance()->SetRun(runNumber);
+
+  LoadMapping();
+  
+  AliMUONCalibrationData::CreateHV(runNumber,0,patched,&messages);
+  
+  AliMUONCalibrationData cd(runNumber,true);
+  
+  AliMUONPadStatusMaker statusMaker(cd);
+  
+  AliMUONRecoParam* rp = AliMUONCDB::LoadRecoParam();
+  
+  if (!rp)
+  {
+    AliErrorGeneral("AliMUONCDB::CheckHV","Could not get RecoParam !!!");
+    return;
+  }
+  
+  statusMaker.SetLimits(*rp);
+  
+  TIter next(&messages);
+  TObjString* s;
+  AliMpDCSNamer hvNamer("TRACKER");
+  AliMUONLogger log;
+  
+  while ( ( s = static_cast<TObjString*>(next()) ) )
+  {
+    TObjArray* a = s->String().Tokenize(":");
+    
+    TString name(static_cast<TObjString*>(a->At(0))->String());
+    
+    if ( name.Contains("sw") || name.Contains("SUMMARY") ) continue;
+    
+    Int_t index = hvNamer.DCSIndexFromDCSAlias(name.Data());
+    
+    Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
+    
+    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+    
+    if (!de)
+    {
+      AliErrorGeneral("AliMUONCDB::CheckHV",Form("Could not get detElemId from dcsAlias %s",name.Data()));
+      continue;
+    }
+    
+    Int_t manuId;
+    
+    if ( index >= 0 )
+    {
+      const AliMpArrayI* array = de->ManusForHV(index);
+      manuId = array->GetValue(0);
+    }
+    else
+      
+    {
+      AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(de->GetBusPatchId(0));
+      
+      manuId = bp->GetManuId(0);
+    }
+    
+    Int_t status = statusMaker.HVStatus(detElemId,manuId);
+    
+    log.Log(AliMUONPadStatusMaker::AsString(status).Data());
+    
+    s->String() += Form(" (DE %4d) ",detElemId);
+    s->String() += AliMUONPadStatusMaker::AsString(status).Data();
+    
+    delete a;
+  }    
+  
+  TIter nextMessage(&messages);
+  TObjString* msg;
+  
+  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
+  {
+    if ( verbose > 0 || msg->String().Contains("SUMMARY") )
+    {
+      AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d HVchannel %s",runNumber,msg->String().Data()));
+    }
+  }
+  
+  TString lmsg;
+  Int_t occurance;
+  TString totalLog;
+  
+  while (log.Next(lmsg,occurance))
+  {
+    totalLog += Form("%s(%d)",lmsg.Data(),occurance);
+    totalLog += " | ";
+  }
+
+  AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d %s",runNumber,totalLog.Data()));
+
+  // one last loop to get the list of problematic HV channels
+  nextMessage.Reset();
+  
+  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
+  {
+    if ( msg->String().Contains("HV ") )
+    {
+      AliInfoGeneral("AliMUONCDB::CheckHV",Form("     Problem at %s",msg->String().Data()));      
+    }
+  }
+   
+  AliCDBManager::Instance()->ClearCache();
+}
+
+