]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTModulePreprocessor.cxx
adding helper method to extract object from the DSC map
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModulePreprocessor.cxx
index ef5507a32042e86a89b41ecd9f22fb4703f0b463..d48e59cad79cc6ece81fddd6c3501ac1e61976b5 100644 (file)
 //* 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>
@@ -29,6 +28,9 @@
 #include "AliHLTShuttleInterface.h"
 #include "TObjString.h"
 #include "TString.h"
+#include "TMap.h"
+#include "TObject.h"
+#include "TObjArray.h"
 
 
 ClassImp(AliHLTModulePreprocessor)
@@ -50,6 +52,7 @@ 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] = 
@@ -274,3 +277,21 @@ const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
     }
   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;
+}