]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- adding possibility to open an AliHLTOUTDigitReader for a specific digit file
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Apr 2010 06:57:51 +0000 (06:57 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Apr 2010 06:57:51 +0000 (06:57 +0000)
- some code cleanup, using AliHLTMisc to create intances

HLT/BASE/AliHLTOUT.cxx
HLT/BASE/AliHLTOUT.h
HLT/rec/AliHLTOUTDigitReader.cxx
HLT/rec/AliHLTOUTDigitReader.h

index 99fdc6fe80510e352cc352bcb05301495066c5c9..76943061af9de4fba6989028f4cebf0b27f51ce2 100644 (file)
@@ -26,6 +26,7 @@
 #include <cassert>
 #include "AliHLTOUT.h"
 #include "AliHLTMessage.h"
+#include "AliHLTMisc.h"
 #include "TSystem.h"
 #include "TClass.h"
 #include "TROOT.h"
@@ -559,7 +560,7 @@ AliHLTUInt32_t AliHLTOUT::ByteSwap32(AliHLTUInt32_t src)
 AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
 {
   // see header file for class documentation
-  AliHLTOUT* instance=New("AliHLTOUTRawReader");
+  AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTRawReader", "libHLTrec.so");
   if (instance) {
     instance->SetParam(pRawReader);
   }
@@ -569,40 +570,19 @@ AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
 AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
 {
   // see header file for class documentation
-  AliHLTOUT* instance=New("AliHLTOUTDigitReader");
+  AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
   if (instance) {
     instance->SetParam(pDigitTree, event);
   }
   return instance;
 }
 
-AliHLTOUT* AliHLTOUT::New(const char* classname)
+AliHLTOUT* AliHLTOUT::New(const char* filename, int event)
 {
   // see header file for class documentation
-  int iLibResult=0;
-  AliHLTOUT* instance=NULL;
-  AliHLTLogging log;
-  TClass* pCl=NULL;
-  ROOT::NewFunc_t pNewFunc=NULL;
-  do {
-    pCl=TClass::GetClass(classname);
-  } while (!pCl && (iLibResult=gSystem->Load("libHLTrec.so"))==0);
-  if (iLibResult>=0) {
-    if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
-      void* p=(*pNewFunc)(NULL);
-      if (p) {
-       instance=reinterpret_cast<AliHLTOUT*>(p);
-       if (!instance) {
-         log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "type cast to AliHLTOUT instance failed");
-       }
-      } else {
-       log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not create AliHLTOUT instance from class descriptor");
-      }
-    } else {
-      log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not find AliHLTOUT class descriptor");
-    }
-  } else {
-    log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not load libHLTrec library");
+  AliHLTOUT* instance=AliHLTMisc::LoadInstance((AliHLTOUT*)0, "AliHLTOUTDigitReader", "libHLTrec.so");
+  if (instance) {
+    instance->SetParam(filename, event);
   }
   return instance;
 }
@@ -648,6 +628,17 @@ void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
   fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
 }
 
+void AliHLTOUT::SetParam(const char* /*filename*/, int /*event*/)
+{
+  // see header file for class documentation
+  // default implementation, we should never get here
+  // this function can only be called from the class itsself and
+  // is intended to be used with the New functions. If we get into
+  // the default implementation there is a class mismatch.
+  assert(0);
+  fLog.LoggingVarargs(kHLTLogFatal, "AliHLTOUT", "SetParam" , __FILE__ , __LINE__ , "severe internal error: class mismatch");
+}
+
 int AliHLTOUT::SelectDataBlock()
 {
   // see header file for class documentation
index 07bd5d61c3fe57b20a8c3999cacc2d21ca7c20f3..747cfbad0e6c15e5cfc71c6e9ebe2645b21a3cae 100644 (file)
@@ -58,6 +58,13 @@ class AliHLTOUT {
    */
   static AliHLTOUT* New(TTree* pDigitTree, int event=-1);
 
+  /**
+   * Create an AliHLTOUTDigitReader instance
+   * Helper function to transparently access classes from the
+   * libHLTrec library.
+   */
+  static AliHLTOUT* New(const char* filename, int event=-1);
+
   /**
    * Get the global instance.
    * The global instance is set temporarily by the AliHLTOUTGlobalInstanceGuard
@@ -731,13 +738,6 @@ class AliHLTOUT {
    */
   const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
 
-  /**
-   * Internal New function for the external HLTOUT instances.
-   * Currently supported classes are AliHLTOUTRawReader and
-   * AliHLTOUTDigitReader, both implemented in libHLTrec.so.
-   */
-  static AliHLTOUT* New(const char* classname);
-
   /**
    * Set the RawReader as parameter.
    * The function is for internal use only in conjunction with the
@@ -752,6 +752,13 @@ class AliHLTOUT {
    */
   virtual void SetParam(TTree* pDigitTree, int event=-1);
 
+  /**
+   * Set name of the digit file as parameter
+   * The function is for internal use only in conjunction with the
+   * New() functions.
+   */
+  virtual void SetParam(const char* filename, int event=-1);
+
   /** data type for the current block search, set from @ref SelectFirstDataBlock */
   AliHLTComponentDataType fSearchDataType; //!transient
 
index f4e58f105093602f2b2539cb25deeb3757f467a0..49e24e62d414bd6a9a9c86fd185e7d599da1f893 100644 (file)
@@ -223,3 +223,15 @@ void AliHLTOUTDigitReader::SetParam(TTree* /*pDigitTree*/, int event)
   // framework.
   fEvent=event;
 }
+
+void AliHLTOUTDigitReader::SetParam(const char* filename, int event)
+{
+  // see header file for class documentation
+
+  if (filename && filename[0]!=0) {
+    fDigitFileName=filename;
+  } else {
+    HLTWarning("no valid digit file provided, using default file %s", fDigitFileName.Data());
+  }
+  fEvent=event;
+}
index 510e6e4559e8759f3e1fc91a44d1b41e6b296584..37363b97986669d33c10025fa7a55ddd41884564 100644 (file)
@@ -68,6 +68,12 @@ class AliHLTOUTDigitReader : public AliHLTOUTHomerCollection {
    */
   void SetParam(TTree* pDigitTree, int event=-1);
 
+  /**
+   * Set name of the digit file as parameter
+   * Overloaded from AliHLTOUT
+   */ 
+  void SetParam(const char* filename, int event=-1);
+
   /** name of the digit file */
   TString fDigitFileName; //! transient