]>
Commit | Line | Data |
---|---|---|
2b545cdd | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
6634349e | 3 | |
4 | #ifndef ALIHLTMISC_H | |
5 | #define ALIHLTMISC_H | |
aac26979 | 6 | //* This file is property of and copyright by the * |
6634349e | 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 | |
23 | class AliCDBManager; | |
24 | class AliCDBEntry; | |
73305a93 | 25 | class AliRawReader; |
b8313826 | 26 | struct AliHLTComponentDataType; |
95ea76b5 | 27 | class AliHLTGlobalTriggerDecision; |
74c1905c | 28 | class TMap; |
2b545cdd | 29 | |
aac26979 | 30 | /** |
31 | * @class AliHLTMisc | |
32 | * Abstract interface of various glue functions implemented in dynamically | |
33 | * loaded libraries. | |
34 | * | |
35 | * The HLT base library is independent from AliRoot and binds AliRoot | |
36 | * functionality via dynamic libraries. The provided methods can be used | |
37 | * from any module library without introducing additional dependencies. | |
38 | */ | |
2b545cdd | 39 | class AliHLTMisc : public TObject { |
40 | public: | |
41 | AliHLTMisc(); | |
42 | ~AliHLTMisc(); | |
43 | ||
aac26979 | 44 | /// dynamically load a class from a library |
2b545cdd | 45 | template<class T> |
07d136de | 46 | static T* LoadInstance(const T* dummy, const char* classname, const char* library=NULL); |
2b545cdd | 47 | |
aac26979 | 48 | /// the global instance of the interface implementation |
2b545cdd | 49 | static AliHLTMisc& Instance(); |
50 | ||
aac26979 | 51 | /// init the CDB patch |
2b545cdd | 52 | virtual int InitCDB(const char* cdbpath); |
53 | ||
aac26979 | 54 | /// init the CDB run number |
2b545cdd | 55 | virtual int SetCDBRunNo(int runNo); |
aac26979 | 56 | /// get the run number from CDB manager |
74c1905c | 57 | virtual int GetCDBRunNo() const; |
2b545cdd | 58 | |
74c1905c | 59 | /// Load an OCDB object |
5df320bf | 60 | virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1) const; |
2b545cdd | 61 | |
74c1905c | 62 | // Extract the TObject instance from the CDB object |
63 | virtual TObject* ExtractObject(AliCDBEntry* entry) const; | |
64 | ||
65 | /// check the availability of the OCDB entry descriptions in the TMap | |
66 | /// key : complete OCDB path of the entry | |
67 | /// value : auxiliary object - short description | |
68 | virtual int CheckOCDBEntries(const TMap* const pMap) const; | |
2b545cdd | 69 | |
aac26979 | 70 | /// init the global magnetic field |
cc484ed9 | 71 | virtual int InitMagneticField() const; |
72 | ||
02d72a84 | 73 | /// extract the triggermask from the rawreader |
74 | /// NOTE: not to be used in the online system | |
16e6f752 | 75 | virtual AliHLTTriggerMask_t GetTriggerMask(AliRawReader* rawReader) const; |
73305a93 | 76 | |
02d72a84 | 77 | /// extract the timestamp from the rawreader |
78 | /// NOTE: not to be used in the online system, use AliHLTComponent::GetTimeStamp() | |
21c25cf3 | 79 | virtual AliHLTUInt32_t GetTimeStamp(AliRawReader* rawReader) const; |
02d72a84 | 80 | |
81 | /// extract the event type from the rawreader | |
82 | /// NOTE: not to be used in the online system | |
21c25cf3 | 83 | virtual AliHLTUInt32_t GetEventType(AliRawReader* rawReader) const; |
84 | ||
a5e775ec | 85 | virtual Double_t GetBz(); |
86 | virtual Double_t GetBz(const Double_t *r); | |
87 | virtual void GetBxByBz(const Double_t r[3], Double_t b[3]); | |
88 | ||
95ea76b5 | 89 | virtual const TClass* IsAliESDHLTDecision() const; |
1563c476 | 90 | |
91 | using TObject::Copy; // Needed since the declaration of AliHLTMisc::Copy below is ambiguous to the compiler. | |
92 | ||
95ea76b5 | 93 | virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const; |
94 | ||
79c426cf | 95 | /// Init streamer info from ocdb entry |
96 | virtual int InitStreamerInfos(const char* ocdbEntry) const; | |
97 | ||
98 | /// Init streamer info for a collection of classes | |
99 | virtual int InitStreamerInfos(TObjArray* pSchemas) const; | |
100 | ||
aac26979 | 101 | /// merge streamer info entries from source array to target array |
102 | /// add all existing infos if not existing in the current one, or having | |
103 | /// different class version | |
104 | /// return 1 if target array has been changed | |
105 | virtual int MergeStreamerInfo(TObjArray* tgt, const TObjArray* src, int iVerbosity=0) const; | |
106 | ||
ee15809c | 107 | /// set the online mode flag of AliESDtrack |
108 | virtual void SetAliESDtrackOnlineModeFlag(bool mode) const; | |
109 | ||
110 | /// get status of the online mode flag of AliESDtrack | |
111 | virtual bool GetAliESDtrackOnlineModeFlag() const; | |
112 | ||
113 | /// guard class for switching offline software to online mode | |
114 | class AliOnlineGuard { | |
115 | public: | |
116 | AliOnlineGuard(bool mode=true); | |
117 | ~AliOnlineGuard(); | |
118 | ||
119 | private: | |
120 | bool fMode; //! old value to be restored | |
121 | }; | |
122 | ||
2b545cdd | 123 | private: |
5df320bf | 124 | static AliHLTMisc* fgInstance; //! global instance |
2b545cdd | 125 | |
126 | ClassDef(AliHLTMisc, 0) | |
127 | }; | |
6634349e | 128 | |
129 | #define ALIHLTMISC_LIBRARY "libHLTrec.so" | |
130 | #define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB" | |
131 | #define ALIHLTMISC_SET_CDB_RUNNO "AliHLTMiscSetCDBRunNo" | |
132 | ||
133 | #ifdef __cplusplus | |
134 | extern "C" { | |
135 | #endif | |
136 | ||
137 | /** | |
138 | * Init the CDB access for the running instance. | |
139 | * The method is used from the C wrapper interface utilized by the on-line | |
140 | * framework. The path of the (H)CDB is set to the specified path.<br> | |
141 | * When running from AliRoot, the CDB path is set in the startup of the | |
703bcca6 | 142 | * reconstruction.<br> |
143 | * If cdbpath is nil or empty and the CDB is not already initialized, the | |
162637e4 | 144 | * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0. |
6634349e | 145 | * @param cdbpath path to the CDB |
146 | * @return neg. error code if failed | |
147 | * @note function implemented in libHLTrec | |
148 | */ | |
149 | int AliHLTMiscInitCDB(const char* cdbpath); | |
150 | typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath); | |
151 | ||
6634349e | 152 | /** |
153 | * Init the Run no for the CDB access. | |
7e914051 | 154 | * @param runNo the run no |
6634349e | 155 | * @return neg. error code if failed |
156 | * @note function implemented in libHLTrec | |
157 | */ | |
158 | int AliHLTMiscSetCDBRunNo(int runNo); | |
159 | typedef int (*AliHLTMiscSetCDBRunNo_t)(int runNo); | |
160 | ||
161 | #ifdef __cplusplus | |
162 | } | |
163 | #endif | |
5bc495ef | 164 | |
ce8105b2 | 165 | template<class T> |
166 | T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library) | |
167 | { | |
aac26979 | 168 | /// dynamically load a class from a library |
ce8105b2 | 169 | int iLibResult=0; |
170 | T* pInstance=NULL; | |
171 | AliHLTLogging log; | |
172 | TClass* pCl=NULL; | |
173 | ROOT::NewFunc_t pNewFunc=NULL; | |
174 | do { | |
175 | pCl=TClass::GetClass(classname); | |
07d136de | 176 | } while (!pCl && library!=NULL && (iLibResult=gSystem->Load(library))==0); |
ce8105b2 | 177 | if (iLibResult>=0) { |
178 | if (pCl && (pNewFunc=pCl->GetNew())!=NULL) { | |
179 | void* p=(*pNewFunc)(NULL); | |
180 | if (p) { | |
181 | pInstance=reinterpret_cast<T*>(p); | |
ce8105b2 | 182 | } else { |
183 | log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname); | |
184 | } | |
185 | } else { | |
07d136de | 186 | log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find TClass descriptor %s", classname); |
ce8105b2 | 187 | } |
188 | } else { | |
189 | log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname); | |
190 | } | |
191 | return pInstance; | |
192 | } | |
193 | ||
5bc495ef | 194 | // direct printout of data type struct |
195 | ostream &operator<<(ostream &str, const AliHLTComponentDataType&); | |
196 | ||
6634349e | 197 | #endif //ALIHLTMISC_H |