]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONCDB.cxx
From Michael Knichel: The THnSparses are not merged anymore, instead a set of 1D...
[u/mrichter/AliRoot.git] / MUON / AliMUONCDB.cxx
index 54e97ca9a08586db3da717eac9e9df85c6df0b01..910c10799f378c23f50cafd5ee82f87257fe0a0a 100644 (file)
 #include "AliMUONCalibParamND.h"
 #include "AliMUONCalibParamNF.h"
 #include "AliMUONCalibParamNI.h"
+#include "AliMUONCalibrationData.h"
 #include "AliMUONConstants.h"
+#include "AliMUONGlobalCrateConfig.h"
+#include "AliMUONPadStatusMaker.h"
+#include "AliMUONPadStatusMapMaker.h"
+#include "AliMUONRecoParam.h"
+#include "AliMUONRegionalTriggerConfig.h"
 #include "AliMUONRejectList.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"
@@ -1423,3 +1427,156 @@ AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
   WriteConfig(startRun,endRun);
 }
 
+//_____________________________________________________________________________
+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();
+  
+    statusMaker->SetLimits(*recoParam);
+  
+    delete recoParam;
+  
+    UInt_t mask = recoParam->PadGoodnessMask();
+  
+    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;  
+}