6 //* This file is property of and copyright by the *
7 //* ALICE Experiment at CERN, All rights reserved. *
8 //* See cxx source for full Copyright notice */
10 /// @file AliHLTMisc.h
11 /// @author Matthias Richter
13 /// @brief Definition of various glue functions implemented in dynamically
17 #include "AliHLTStdIncludes.h"
18 #include "AliHLTDataTypes.h"
19 #include "AliHLTLogging.h"
26 struct AliHLTComponentDataType;
27 class AliHLTGlobalTriggerDecision;
32 * Abstract interface of various glue functions implemented in dynamically
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.
39 class AliHLTMisc : public TObject {
44 /// dynamically load a class from a library
46 static T* LoadInstance(const T* dummy, const char* classname, const char* library=NULL);
48 /// the global instance of the interface implementation
49 static AliHLTMisc& Instance();
51 /// init the CDB patch
52 virtual int InitCDB(const char* cdbpath);
54 /// init the CDB run number
55 virtual int SetCDBRunNo(int runNo);
56 /// get the run number from CDB manager
57 virtual int GetCDBRunNo() const;
59 /// Load an OCDB object
60 virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1) const;
62 // Extract the TObject instance from the CDB object
63 virtual TObject* ExtractObject(AliCDBEntry* entry) const;
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;
70 /// init the global magnetic field
71 virtual int InitMagneticField() const;
73 /// extract the triggermask from the rawreader
74 /// NOTE: not to be used in the online system
75 virtual AliHLTTriggerMask_t GetTriggerMask(AliRawReader* rawReader) const;
77 /// extract the timestamp from the rawreader
78 /// NOTE: not to be used in the online system, use AliHLTComponent::GetTimeStamp()
79 virtual AliHLTUInt32_t GetTimeStamp(AliRawReader* rawReader) const;
81 /// extract the event type from the rawreader
82 /// NOTE: not to be used in the online system
83 virtual AliHLTUInt32_t GetEventType(AliRawReader* rawReader) const;
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]);
89 virtual const TClass* IsAliESDHLTDecision() const;
91 using TObject::Copy; // Needed since the declaration of AliHLTMisc::Copy below is ambiguous to the compiler.
93 virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const;
95 /// Init streamer info from ocdb entry
96 virtual int InitStreamerInfos(const char* ocdbEntry) const;
98 /// Init streamer info for a collection of classes
99 virtual int InitStreamerInfos(TObjArray* pSchemas) const;
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;
107 /// set the online mode flag of AliESDtrack
108 virtual void SetAliESDtrackOnlineModeFlag(bool mode) const;
110 /// get status of the online mode flag of AliESDtrack
111 virtual bool GetAliESDtrackOnlineModeFlag() const;
113 /// guard class for switching offline software to online mode
114 class AliOnlineGuard {
116 AliOnlineGuard(bool mode=true);
120 bool fMode; //! old value to be restored
124 static AliHLTMisc* fgInstance; //! global instance
126 ClassDef(AliHLTMisc, 0)
129 #define ALIHLTMISC_LIBRARY "libHLTrec.so"
130 #define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB"
131 #define ALIHLTMISC_SET_CDB_RUNNO "AliHLTMiscSetCDBRunNo"
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
142 * reconstruction.<br>
143 * If cdbpath is nil or empty and the CDB is not already initialized, the
144 * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0.
145 * @param cdbpath path to the CDB
146 * @return neg. error code if failed
147 * @note function implemented in libHLTrec
149 int AliHLTMiscInitCDB(const char* cdbpath);
150 typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath);
153 * Init the Run no for the CDB access.
154 * @param runNo the run no
155 * @return neg. error code if failed
156 * @note function implemented in libHLTrec
158 int AliHLTMiscSetCDBRunNo(int runNo);
159 typedef int (*AliHLTMiscSetCDBRunNo_t)(int runNo);
166 T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
168 /// dynamically load a class from a library
173 ROOT::NewFunc_t pNewFunc=NULL;
175 pCl=TClass::GetClass(classname);
176 } while (!pCl && library!=NULL && (iLibResult=gSystem->Load(library))==0);
178 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
179 void* p=(*pNewFunc)(NULL);
181 pInstance=reinterpret_cast<T*>(p);
183 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
186 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find TClass descriptor %s", classname);
189 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
194 // direct printout of data type struct
195 ostream &operator<<(ostream &str, const AliHLTComponentDataType&);
197 #endif //ALIHLTMISC_H