]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTMisc.h
adding availability check for a list of OCDB objects, code cleanup and updated docume...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTMisc.h
CommitLineData
2b545cdd 1//-*- Mode: C++ -*-
2// $Id$
6634349e 3
4#ifndef ALIHLTMISC_H
5#define ALIHLTMISC_H
6//* This file is property of and copyright by the ALICE HLT Project *
7//* ALICE Experiment at CERN, All rights reserved. *
8//* See cxx source for full Copyright notice */
9
2b545cdd 10/// @file AliHLTMisc.h
11/// @author Matthias Richter
12/// @date
13/// @brief Definition of various glue functions implemented in dynamically
14/// loaded libraries
15
16#include "TObject.h"
5bc495ef 17#include "AliHLTStdIncludes.h"
73305a93 18#include "AliHLTDataTypes.h"
ce8105b2 19#include "AliHLTLogging.h"
20#include "TClass.h"
21#include "TSystem.h"
2b545cdd 22
23class AliCDBManager;
24class AliCDBEntry;
73305a93 25class AliRawReader;
5bc495ef 26class AliHLTComponentDataType;
95ea76b5 27class AliHLTGlobalTriggerDecision;
74c1905c 28class TMap;
2b545cdd 29
30class AliHLTMisc : public TObject {
31 public:
32 AliHLTMisc();
33 ~AliHLTMisc();
34
35 template<class T>
07d136de 36 static T* LoadInstance(const T* dummy, const char* classname, const char* library=NULL);
2b545cdd 37
38 static AliHLTMisc& Instance();
39
40 virtual int InitCDB(const char* cdbpath);
41
42 virtual int SetCDBRunNo(int runNo);
74c1905c 43 virtual int GetCDBRunNo() const;
2b545cdd 44
74c1905c 45 /// Load an OCDB object
46 virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1, int version = -1, int subVersion = -1) const;
2b545cdd 47
74c1905c 48 // Extract the TObject instance from the CDB object
49 virtual TObject* ExtractObject(AliCDBEntry* entry) const;
50
51 /// check the availability of the OCDB entry descriptions in the TMap
52 /// key : complete OCDB path of the entry
53 /// value : auxiliary object - short description
54 virtual int CheckOCDBEntries(const TMap* const pMap) const;
2b545cdd 55
cc484ed9 56 virtual int InitMagneticField() const;
57
73305a93 58 virtual AliHLTUInt64_t GetTriggerMask(AliRawReader* rawReader) const;
59
a5e775ec 60 virtual Double_t GetBz();
61 virtual Double_t GetBz(const Double_t *r);
62 virtual void GetBxByBz(const Double_t r[3], Double_t b[3]);
63
95ea76b5 64 virtual const TClass* IsAliESDHLTDecision() const;
65 virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const;
66
2b545cdd 67 private:
68 static AliHLTMisc* fgInstance;
69
70 ClassDef(AliHLTMisc, 0)
71};
6634349e 72
73#define ALIHLTMISC_LIBRARY "libHLTrec.so"
74#define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB"
75#define ALIHLTMISC_SET_CDB_RUNNO "AliHLTMiscSetCDBRunNo"
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
81 /**
82 * Init the CDB access for the running instance.
83 * The method is used from the C wrapper interface utilized by the on-line
84 * framework. The path of the (H)CDB is set to the specified path.<br>
85 * When running from AliRoot, the CDB path is set in the startup of the
703bcca6 86 * reconstruction.<br>
87 * If cdbpath is nil or empty and the CDB is not already initialized, the
162637e4 88 * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0.
6634349e 89 * @param cdbpath path to the CDB
90 * @return neg. error code if failed
91 * @note function implemented in libHLTrec
92 */
93 int AliHLTMiscInitCDB(const char* cdbpath);
94 typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath);
95
6634349e 96 /**
97 * Init the Run no for the CDB access.
7e914051 98 * @param runNo the run no
6634349e 99 * @return neg. error code if failed
100 * @note function implemented in libHLTrec
101 */
102 int AliHLTMiscSetCDBRunNo(int runNo);
103 typedef int (*AliHLTMiscSetCDBRunNo_t)(int runNo);
104
105#ifdef __cplusplus
106}
107#endif
5bc495ef 108
ce8105b2 109template<class T>
110T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
111{
112 // see header file for function documentation
113 int iLibResult=0;
114 T* pInstance=NULL;
115 AliHLTLogging log;
116 TClass* pCl=NULL;
117 ROOT::NewFunc_t pNewFunc=NULL;
118 do {
119 pCl=TClass::GetClass(classname);
07d136de 120 } while (!pCl && library!=NULL && (iLibResult=gSystem->Load(library))==0);
ce8105b2 121 if (iLibResult>=0) {
122 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
123 void* p=(*pNewFunc)(NULL);
124 if (p) {
125 pInstance=reinterpret_cast<T*>(p);
126 if (!pInstance) {
127 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "type cast (%s) to instance failed", classname);
128 }
129 } else {
130 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
131 }
132 } else {
07d136de 133 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find TClass descriptor %s", classname);
ce8105b2 134 }
135 } else {
136 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
137 }
138 return pInstance;
139}
140
5bc495ef 141// direct printout of data type struct
142ostream &operator<<(ostream &str, const AliHLTComponentDataType&);
143
6634349e 144#endif //ALIHLTMISC_H