]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPreprocessor.cxx
- Adding check and flagging for HG present
[u/mrichter/AliRoot.git] / MUON / AliMUONPreprocessor.cxx
index cb3a85493217947473c355d4c640040484599b0e..9265a1cc873e2adb57cd2ff6aebb267bef6c9533 100644 (file)
 
 #include "AliMUONPreprocessor.h"
 
-#include "AliMUONPedestalSubprocessor.h"
-#include "AliMUONHVSubprocessor.h"
+#include "AliCDBEntry.h"
+#include "AliLog.h"
 #include "AliMUONGMSSubprocessor.h"
-
-#include "AliMpSegmentation.h"
+#include "AliMUONHVSubprocessor.h"
+#include "AliMUONPedestalSubprocessor.h"
+#include "AliMpCDB.h"
 #include "AliMpDDLStore.h"
-
-#include "AliLog.h"
+#include "AliMpDataMap.h"
+#include "AliMpDataStreams.h"
+#include "AliMpSegmentation.h"
 #include "AliShuttleInterface.h"
 #include "Riostream.h"
 #include "TObjArray.h"
@@ -47,9 +49,10 @@ ClassImp(AliMUONPreprocessor)
 //_____________________________________________________________________________
 AliMUONPreprocessor::AliMUONPreprocessor(const char* detName, AliShuttleInterface* shuttle)
 : AliPreprocessor(detName, shuttle),
+  fIsValid(kFALSE),
+  fIsApplicable(kTRUE),
   fSubprocessors(new TObjArray()),
-  fProcessDCS(kFALSE),
-  fIsValid(kFALSE)
+  fProcessDCS(kFALSE)
 {
   /// ctor
 }
@@ -69,6 +72,7 @@ AliMUONPreprocessor::ClearSubprocessors()
   fSubprocessors->Clear();
   fProcessDCS = kFALSE;
   fIsValid = kFALSE;
+  fIsApplicable = kTRUE;
 }
 
 //_____________________________________________________________________________
@@ -87,35 +91,48 @@ AliMUONPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
   /// Load mapping and initialize subtasks  
 
   // Delete previous mapping
-  delete AliMpSegmentation::Instance(false);
-  delete AliMpDDLStore::Instance(false);
-  
-  // Load mapping from CDB for this run
+  AliMpCDB::UnloadAll();
   
-  fIsValid = kTRUE;
+  if ( ! IsApplicable() ) {
+    Log(Form("WARNING-RunType=%s is not one I should handle.",GetRunType()));
+    return;
+  }   
   
-  AliCDBEntry* e = GetFromOCDB("Calib", "Mapping");
-  if (!e)
+  // Load mapping from CDB for this run
+  AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "MappingData");
+  if (!cdbEntry)
   {
-    Log("Could not get Mapping from OCDB !");
+    Log("Could not get MappingData from OCDB !");
     fIsValid = kFALSE;
   }
-  
-  e = GetFromOCDB("Calib", "DDLStore");
-  if (!e)
+  else
   {
-    Log("Could not get DDLStore from OCDB");
-    fIsValid = kFALSE;
+    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 )
     {
-      Subprocessor(i)->Initialize(run,startTime,endTime);
+      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")));
 }
 
 //_____________________________________________________________________________
@@ -130,6 +147,12 @@ AliMUONPreprocessor::Process(TMap* dcsAliasMap)
     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 )