]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPreprocessor.cxx
dEdxSSDAQA added to PilotAnalysis
[u/mrichter/AliRoot.git] / MUON / AliMUONPreprocessor.cxx
index 51b50d9e0ab0191e1ca034ade96228e2ebc0ce0e..9265a1cc873e2adb57cd2ff6aebb267bef6c9533 100644 (file)
 
 #include "AliMUONPreprocessor.h"
 
-#include "AliMUONPedestalSubprocessor.h"
-#include "AliMUONHVSubprocessor.h"
-#include "AliMUONGMSSubprocessor.h"
-
+#include "AliCDBEntry.h"
 #include "AliLog.h"
+#include "AliMUONGMSSubprocessor.h"
+#include "AliMUONHVSubprocessor.h"
+#include "AliMUONPedestalSubprocessor.h"
+#include "AliMpCDB.h"
+#include "AliMpDDLStore.h"
+#include "AliMpDataMap.h"
+#include "AliMpDataStreams.h"
+#include "AliMpSegmentation.h"
 #include "AliShuttleInterface.h"
 #include "Riostream.h"
 #include "TObjArray.h"
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONPreprocessor
 ///
 /// Shuttle preprocessor for MUON subsystems (TRK and TRG)
@@ -34,6 +40,7 @@
 /// (of type AliMUONVSubprocessor).
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMUONPreprocessor)
@@ -42,6 +49,8 @@ ClassImp(AliMUONPreprocessor)
 //_____________________________________________________________________________
 AliMUONPreprocessor::AliMUONPreprocessor(const char* detName, AliShuttleInterface* shuttle)
 : AliPreprocessor(detName, shuttle),
+  fIsValid(kFALSE),
+  fIsApplicable(kTRUE),
   fSubprocessors(new TObjArray()),
   fProcessDCS(kFALSE)
 {
@@ -62,6 +71,8 @@ AliMUONPreprocessor::ClearSubprocessors()
   /// Empty our subprocessor list
   fSubprocessors->Clear();
   fProcessDCS = kFALSE;
+  fIsValid = kFALSE;
+  fIsApplicable = kTRUE;
 }
 
 //_____________________________________________________________________________
@@ -77,11 +88,51 @@ AliMUONPreprocessor::Add(AliMUONVSubprocessor* sub, Bool_t processDCS)
 void
 AliMUONPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
 {
-  /// loop over subtasks and initialize them
-  for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
+  /// Load mapping and initialize subtasks  
+
+  // Delete previous mapping
+  AliMpCDB::UnloadAll();
+  
+  if ( ! IsApplicable() ) {
+    Log(Form("WARNING-RunType=%s is not one I should handle.",GetRunType()));
+    return;
+  }   
+  
+  // Load mapping from CDB for this run
+  AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "MappingData");
+  if (!cdbEntry)
+  {
+    Log("Could not get MappingData from OCDB !");
+    fIsValid = kFALSE;
+  }
+  else
   {
-    Subprocessor(i)->Initialize(run,startTime,endTime);
+    AliMpDataMap* dataMap = dynamic_cast<AliMpDataMap*>(cdbEntry->GetObject());
+    if (!dataMap)
+    {
+      Log("DataMap is not of the expected type. That is bad...");
+      fIsValid = kFALSE;
+    }
+    else
+    {
+      AliMpDataStreams dataStreams(dataMap);
+      AliMpDDLStore::ReadData(dataStreams);
+    }
   }
+  
+  Int_t nok(0);
+
+  if (IsValid())
+  {
+    // loop over subtasks and initialize them
+    for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
+    {
+      Bool_t ok = Subprocessor(i)->Initialize(run,startTime,endTime);
+      if (ok) ++nok;
+    }
+    if (nok !=  fSubprocessors->GetLast()+1) fIsValid = kFALSE;
+  }
+  Log(Form("Initialize was %s",( IsValid() ? "fine" : "NOT OK")));
 }
 
 //_____________________________________________________________________________
@@ -89,12 +140,26 @@ UInt_t
 AliMUONPreprocessor::Process(TMap* dcsAliasMap)
 {
   /// loop over subtasks to make them work
+  
+  if (!IsValid())
+  {
+    Log("Will not run as not properly initialized");
+    return 99;
+  }
+  
+  if (!IsApplicable())
+  {
+    Log("Nothing to do for me");
+    return 0;
+  }
+  
   UInt_t rv(0);
   
   for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
   {
     rv += Subprocessor(i)->Process(dcsAliasMap);
   }
+  
   return rv;
 }