]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTModulePreprocessor.cxx
reverting r45444 to disentangle modules and make porting possible
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModulePreprocessor.cxx
index 77baa836b0f375bd037508bbd9c39290c4333dd8..8ae3812e7303fd1591705fde8538d5de5e1fc8da 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: AliHLTModulePreprocessor.cxx 23039 2007-12-13 20:53:02Z richterm $
+// $Id$
 
 //**************************************************************************
 //* This file is property of and copyright by the ALICE HLT Project        * 
 //* provided "as is" without express or implied warranty.                  *
 //**************************************************************************
 
-/**
- * @file   AliHLTModulePreprocessor.cxx
- * @author Matthias Richter
- * @date   2008-01-22
- * @brief  Base class for HLT module preprocessors
- */
+// @file   AliHLTModulePreprocessor.cxx
+// @author Matthias Richter
+// @date   2008-01-22
+// @brief  Base class for HLT module preprocessors
+// 
 
+#include <cstdlib>
 #include <cassert>
 #include "AliHLTModulePreprocessor.h"
 #include "AliHLTShuttleInterface.h"
+#include "TObjString.h"
+#include "TString.h"
+#include "TMap.h"
+#include "TObject.h"
+#include "TObjArray.h"
+
 
 ClassImp(AliHLTModulePreprocessor)
 
 AliHLTModulePreprocessor::AliHLTModulePreprocessor() 
   :
-  fpInterface(NULL)
+  fpInterface(NULL),
+  fActiveDetectors(0)
 {
   // see header file for class documentation
   // or
@@ -45,13 +52,41 @@ AliHLTModulePreprocessor::~AliHLTModulePreprocessor()
   // see header file for function documentation
 }
 
+// TODO: map this constants to AliHLTDAQ class
+const Int_t AliHLTModulePreprocessor::kNDetectors = 21;
+
+const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] = 
+{
+  "ITSSPD",
+  "ITSSDD",
+  "ITSSSD",
+  "TPC",
+  "TRD",
+  "TOF",
+  "HMPID",
+  "PHOS",
+  "CPV",
+  "PMD",
+  "MUONTRK",
+  "MUONTRG",
+  "FMD",
+  "T0",
+  "VZERO", // Name to be changed to V0 ?
+  "ZDC",
+  "ACORDE",
+  "TRG",
+  "EMCAL",
+  "DAQ_TEST",
+  "HLT"
+};
+
 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
 {
   assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
   fpInterface=pInterface;
 }
 
-Int_t AliHLTModulePreprocessor::GetRun()
+Int_t AliHLTModulePreprocessor::GetRun() const
 {
   // see header file for function documentation
 
@@ -60,7 +95,7 @@ Int_t AliHLTModulePreprocessor::GetRun()
   return fpInterface->PreprocessorGetRun();
 }
 
-UInt_t AliHLTModulePreprocessor::GetStartTime()
+UInt_t AliHLTModulePreprocessor::GetStartTime() const
 {
   // see header file for function documentation
 
@@ -69,7 +104,7 @@ UInt_t AliHLTModulePreprocessor::GetStartTime()
   return fpInterface->PreprocessorGetStartTime();
 }
 
-UInt_t AliHLTModulePreprocessor::GetEndTime()
+UInt_t AliHLTModulePreprocessor::GetEndTime() const
 {
   // see header file for function documentation
 
@@ -178,3 +213,85 @@ void AliHLTModulePreprocessor::Log(const char* message)
   if (!fpInterface) return;
   fpInterface->PreprocessorLog(message);
 }
+
+Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
+{
+  // Return the detector index
+  // corresponding to a given
+  // detector name
+  TString detStr = detectorName;
+
+  Int_t iDet;
+  for(iDet = 0; iDet < kNDetectors; iDet++) {
+    if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
+      break;
+  }
+  if (iDet == kNDetectors) 
+    {
+      TString errormessage;
+      errormessage.Form("Invalid detector name: %s !",detectorName);
+      Log(errormessage.Data());
+      return -1;
+    }
+
+  Int_t detectorbitmask = 0;
+  if(iDet > 32)
+    {
+      TString errormessage2;
+      errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
+      Log(errormessage2.Data());
+      return -1;
+    }
+  
+  detectorbitmask = (1 << iDet);
+  return detectorbitmask;
+}
+
+Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
+{
+  // see header file for function documentation
+  // retrieve list of active detectors from previous run.
+  fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
+  if((fActiveDetectors & detectorbitmask) != 0)
+    {
+      return 1;
+    }
+  else
+    {
+      return 0;
+    }
+}
+
+// function copied from AliDAQ.cxx
+const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
+{
+  // Returns the name of particular
+  // detector identified by its index
+  if (detectorID < 0 || detectorID >= kNDetectors) 
+    {
+      TString errormessage;
+      errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
+      Log(errormessage.Data());
+      return "";
+    }
+  return fgkDetectorName[detectorID];
+}
+
+TObject* AliHLTModulePreprocessor::GetFromMap(TMap* dcsAliasMap, const char* stringId) const
+{
+  /// extract object from the alias map
+  /// return the last object from the value set
+  TObject* object=dcsAliasMap->FindObject(stringId);
+  if (!object) return NULL;
+  TPair* pair = dynamic_cast<TPair*>(object);
+  if (pair && pair->Value()) {
+    TObjArray* valueSet = dynamic_cast<TObjArray*>(pair->Value());
+    if (!valueSet) return NULL;
+    Int_t nentriesDCS = valueSet->GetEntriesFast() - 1;
+    if(nentriesDCS>=0 && valueSet->At(nentriesDCS)){
+      return valueSet->At(nentriesDCS);
+    }
+  }
+  return NULL;
+}