]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTMisc.h
Patch from Matthias Richter:
[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;
2b545cdd 28
29class AliHLTMisc : public TObject {
30 public:
31 AliHLTMisc();
32 ~AliHLTMisc();
33
34 template<class T>
35 static T* LoadInstance(const T* dummy, const char* classname, const char* library);
36
37 static AliHLTMisc& Instance();
38
39 virtual int InitCDB(const char* cdbpath);
40
41 virtual int SetCDBRunNo(int runNo);
42
43 virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1, int version = -1, int subVersion = -1);
44
45 virtual TObject* ExtractObject(AliCDBEntry* entry);
46
cc484ed9 47 virtual int InitMagneticField() const;
48
73305a93 49 virtual AliHLTUInt64_t GetTriggerMask(AliRawReader* rawReader) const;
50
a5e775ec 51 virtual Double_t GetBz();
52 virtual Double_t GetBz(const Double_t *r);
53 virtual void GetBxByBz(const Double_t r[3], Double_t b[3]);
54
95ea76b5 55 virtual const TClass* IsAliESDHLTDecision() const;
56 virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const;
57
2b545cdd 58 private:
59 static AliHLTMisc* fgInstance;
60
61 ClassDef(AliHLTMisc, 0)
62};
6634349e 63
64#define ALIHLTMISC_LIBRARY "libHLTrec.so"
65#define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB"
66#define ALIHLTMISC_SET_CDB_RUNNO "AliHLTMiscSetCDBRunNo"
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72 /**
73 * Init the CDB access for the running instance.
74 * The method is used from the C wrapper interface utilized by the on-line
75 * framework. The path of the (H)CDB is set to the specified path.<br>
76 * When running from AliRoot, the CDB path is set in the startup of the
703bcca6 77 * reconstruction.<br>
78 * If cdbpath is nil or empty and the CDB is not already initialized, the
162637e4 79 * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0.
6634349e 80 * @param cdbpath path to the CDB
81 * @return neg. error code if failed
82 * @note function implemented in libHLTrec
83 */
84 int AliHLTMiscInitCDB(const char* cdbpath);
85 typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath);
86
6634349e 87 /**
88 * Init the Run no for the CDB access.
7e914051 89 * @param runNo the run no
6634349e 90 * @return neg. error code if failed
91 * @note function implemented in libHLTrec
92 */
93 int AliHLTMiscSetCDBRunNo(int runNo);
94 typedef int (*AliHLTMiscSetCDBRunNo_t)(int runNo);
95
96#ifdef __cplusplus
97}
98#endif
5bc495ef 99
ce8105b2 100template<class T>
101T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
102{
103 // see header file for function documentation
104 int iLibResult=0;
105 T* pInstance=NULL;
106 AliHLTLogging log;
107 TClass* pCl=NULL;
108 ROOT::NewFunc_t pNewFunc=NULL;
109 do {
110 pCl=TClass::GetClass(classname);
111 } while (!pCl && (iLibResult=gSystem->Load(library))==0);
112 if (iLibResult>=0) {
113 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
114 void* p=(*pNewFunc)(NULL);
115 if (p) {
116 pInstance=reinterpret_cast<T*>(p);
117 if (!pInstance) {
118 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "type cast (%s) to instance failed", classname);
119 }
120 } else {
121 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
122 }
123 } else {
124 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find class descriptor %s", classname);
125 }
126 } else {
127 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
128 }
129 return pInstance;
130}
131
5bc495ef 132// direct printout of data type struct
133ostream &operator<<(ostream &str, const AliHLTComponentDataType&);
134
6634349e 135#endif //ALIHLTMISC_H