]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTMisc.h
removing deprecated option to query specific (sub)version of OCDB entry
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTMisc.h
index 2c259799bed4868468073ee04acac583d3c2dd3e..ab761586bb0d1d5f664ad3cc07329fc17b2bef95 100644 (file)
@@ -1,4 +1,5 @@
-// @(#) $Id: AliHLTMisc.h 23396 2008-01-18 12:45:35Z richterm $
+//-*- Mode: C++ -*-
+// $Id$
 
 #ifndef ALIHLTMISC_H
 #define ALIHLTMISC_H
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //* See cxx source for full Copyright notice                               */
 
-/** @file   AliHLTMisc.h
-    @author Matthias Richter
-    @date   
-    @brief  Definition of various glue functions implemented in dynamically
-            loaded libraries
-*/
+/// @file   AliHLTMisc.h
+/// @author Matthias Richter
+/// @date   
+/// @brief  Definition of various glue functions implemented in dynamically
+///         loaded libraries
+
+#include "TObject.h"
+#include "AliHLTStdIncludes.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTLogging.h"
+#include "TClass.h"
+#include "TSystem.h"
+
+class AliCDBManager;
+class AliCDBEntry;
+class AliRawReader;
+class AliHLTComponentDataType;
+class AliHLTGlobalTriggerDecision;
+class TMap;
+
+class AliHLTMisc : public TObject {
+ public:
+  AliHLTMisc();
+  ~AliHLTMisc();
+
+  template<class T>
+  static T* LoadInstance(const T* dummy, const char* classname, const char* library=NULL);
+
+  static AliHLTMisc& Instance();
+
+  virtual int InitCDB(const char* cdbpath);
+
+  virtual int SetCDBRunNo(int runNo);
+  virtual int GetCDBRunNo() const;
+
+  /// Load an OCDB object
+  virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1) const;
+
+  // Extract the TObject instance from the CDB object
+  virtual TObject* ExtractObject(AliCDBEntry* entry) const;
+
+  /// check the availability of the OCDB entry descriptions in the TMap
+  ///  key : complete OCDB path of the entry
+  ///  value : auxiliary object - short description
+  virtual int CheckOCDBEntries(const TMap* const pMap) const;
+
+  virtual int InitMagneticField() const;
+
+  /// extract the triggermask from the rawreader
+  /// NOTE: not to be used in the online system
+  virtual AliHLTUInt64_t GetTriggerMask(AliRawReader* rawReader) const;
+
+  /// extract the timestamp from the rawreader
+  /// NOTE: not to be used in the online system, use AliHLTComponent::GetTimeStamp()
+  virtual AliHLTUInt32_t GetTimeStamp(AliRawReader* rawReader) const;
+
+  /// extract the event type from the rawreader
+  /// NOTE: not to be used in the online system
+  virtual AliHLTUInt32_t GetEventType(AliRawReader* rawReader) const;
+
+  virtual Double_t GetBz();
+  virtual Double_t GetBz(const Double_t *r);
+  virtual void GetBxByBz(const Double_t r[3], Double_t b[3]);
+
+  virtual const TClass* IsAliESDHLTDecision() const;
+  
+  using TObject::Copy;  // Needed since the declaration of AliHLTMisc::Copy below is ambiguous to the compiler.
+  
+  virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const;
+
+  /// Init streamer info from ocdb entry
+  virtual int InitStreamerInfos(const char* ocdbEntry) const;
+
+  /// Init streamer info for a collection of classes
+  virtual int InitStreamerInfos(TObjArray* pSchemas) const;
+
+  /// set the online mode flag of AliESDtrack
+  virtual void SetAliESDtrackOnlineModeFlag(bool mode) const;
+
+  /// get status of the online mode flag of AliESDtrack
+  virtual bool GetAliESDtrackOnlineModeFlag() const;
+
+  /// guard class for switching offline software to online mode
+  class AliOnlineGuard {
+  public:
+    AliOnlineGuard(bool mode=true);
+    ~AliOnlineGuard();
+
+  private:
+    bool fMode; //! old value to be restored
+  };
+
+ private:
+  static AliHLTMisc* fgInstance; //! global instance
+
+  ClassDef(AliHLTMisc, 0)
+};
 
 #define ALIHLTMISC_LIBRARY "libHLTrec.so"
 #define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB"
@@ -26,7 +118,9 @@ extern "C" {
    * The method is used from the C wrapper interface utilized by the  on-line
    * framework. The path of the (H)CDB is set to the specified path.<br>
    * When running from AliRoot, the CDB path is set in the startup of the
-   * reconstruction.
+   * reconstruction.<br>
+   * If cdbpath is nil or empty and the CDB is not already initialized, the
+   * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0.
    * @param cdbpath     path to the CDB
    * @return neg. error code if failed
    * @note function implemented in libHLTrec
@@ -34,7 +128,6 @@ extern "C" {
   int AliHLTMiscInitCDB(const char* cdbpath);
   typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath);
 
-
   /**
    * Init the Run no for the CDB access.
    * @param runNo       the run no
@@ -47,4 +140,37 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
+
+template<class T>
+T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
+{
+  // see header file for function documentation
+  int iLibResult=0;
+  T* pInstance=NULL;
+  AliHLTLogging log;
+  TClass* pCl=NULL;
+  ROOT::NewFunc_t pNewFunc=NULL;
+  do {
+    pCl=TClass::GetClass(classname);
+  } while (!pCl && library!=NULL && (iLibResult=gSystem->Load(library))==0);
+  if (iLibResult>=0) {
+    if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
+      void* p=(*pNewFunc)(NULL);
+      if (p) {
+       pInstance=reinterpret_cast<T*>(p);
+      } else {
+       log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
+      }
+    } else {
+      log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find TClass descriptor %s", classname);
+    }
+  } else {
+    log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
+  }
+  return pInstance;
+}
+
+// direct printout of data type struct
+ostream  &operator<<(ostream &str, const AliHLTComponentDataType&);
+
 #endif //ALIHLTMISC_H