removing deprecated option to query specific (sub)version of OCDB entry
[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
5df320bf 46 virtual AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-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
02d72a84 58 /// extract the triggermask from the rawreader
59 /// NOTE: not to be used in the online system
73305a93 60 virtual AliHLTUInt64_t GetTriggerMask(AliRawReader* rawReader) const;
61
02d72a84 62 /// extract the timestamp from the rawreader
63 /// NOTE: not to be used in the online system, use AliHLTComponent::GetTimeStamp()
21c25cf3 64 virtual AliHLTUInt32_t GetTimeStamp(AliRawReader* rawReader) const;
02d72a84 65
66 /// extract the event type from the rawreader
67 /// NOTE: not to be used in the online system
21c25cf3 68 virtual AliHLTUInt32_t GetEventType(AliRawReader* rawReader) const;
69
a5e775ec 70 virtual Double_t GetBz();
71 virtual Double_t GetBz(const Double_t *r);
72 virtual void GetBxByBz(const Double_t r[3], Double_t b[3]);
73
95ea76b5 74 virtual const TClass* IsAliESDHLTDecision() const;
1563c476 75
76 using TObject::Copy; // Needed since the declaration of AliHLTMisc::Copy below is ambiguous to the compiler.
77
95ea76b5 78 virtual int Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* pESDHLTDecision) const;
79
79c426cf 80 /// Init streamer info from ocdb entry
81 virtual int InitStreamerInfos(const char* ocdbEntry) const;
82
83 /// Init streamer info for a collection of classes
84 virtual int InitStreamerInfos(TObjArray* pSchemas) const;
85
ee15809c 86 /// set the online mode flag of AliESDtrack
87 virtual void SetAliESDtrackOnlineModeFlag(bool mode) const;
88
89 /// get status of the online mode flag of AliESDtrack
90 virtual bool GetAliESDtrackOnlineModeFlag() const;
91
92 /// guard class for switching offline software to online mode
93 class AliOnlineGuard {
94 public:
95 AliOnlineGuard(bool mode=true);
96 ~AliOnlineGuard();
97
98 private:
99 bool fMode; //! old value to be restored
100 };
101
2b545cdd 102 private:
5df320bf 103 static AliHLTMisc* fgInstance; //! global instance
2b545cdd 104
105 ClassDef(AliHLTMisc, 0)
106};
6634349e 107
108#define ALIHLTMISC_LIBRARY "libHLTrec.so"
109#define ALIHLTMISC_INIT_CDB "AliHLTMiscInitCDB"
110#define ALIHLTMISC_SET_CDB_RUNNO "AliHLTMiscSetCDBRunNo"
111
112#ifdef __cplusplus
113extern "C" {
114#endif
115
116 /**
117 * Init the CDB access for the running instance.
118 * The method is used from the C wrapper interface utilized by the on-line
119 * framework. The path of the (H)CDB is set to the specified path.<br>
120 * When running from AliRoot, the CDB path is set in the startup of the
703bcca6 121 * reconstruction.<br>
122 * If cdbpath is nil or empty and the CDB is not already initialized, the
162637e4 123 * CDB storage is set to local://$ALICE_ROOT/OCDB and the run no to 0.
6634349e 124 * @param cdbpath path to the CDB
125 * @return neg. error code if failed
126 * @note function implemented in libHLTrec
127 */
128 int AliHLTMiscInitCDB(const char* cdbpath);
129 typedef int (*AliHLTMiscInitCDB_t)(const char* cdbpath);
130
6634349e 131 /**
132 * Init the Run no for the CDB access.
7e914051 133 * @param runNo the run no
6634349e 134 * @return neg. error code if failed
135 * @note function implemented in libHLTrec
136 */
137 int AliHLTMiscSetCDBRunNo(int runNo);
138 typedef int (*AliHLTMiscSetCDBRunNo_t)(int runNo);
139
140#ifdef __cplusplus
141}
142#endif
5bc495ef 143
ce8105b2 144template<class T>
145T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
146{
147 // see header file for function documentation
148 int iLibResult=0;
149 T* pInstance=NULL;
150 AliHLTLogging log;
151 TClass* pCl=NULL;
152 ROOT::NewFunc_t pNewFunc=NULL;
153 do {
154 pCl=TClass::GetClass(classname);
07d136de 155 } while (!pCl && library!=NULL && (iLibResult=gSystem->Load(library))==0);
ce8105b2 156 if (iLibResult>=0) {
157 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
158 void* p=(*pNewFunc)(NULL);
159 if (p) {
160 pInstance=reinterpret_cast<T*>(p);
ce8105b2 161 } else {
162 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
163 }
164 } else {
07d136de 165 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find TClass descriptor %s", classname);
ce8105b2 166 }
167 } else {
168 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
169 }
170 return pInstance;
171}
172
5bc495ef 173// direct printout of data type struct
174ostream &operator<<(ostream &str, const AliHLTComponentDataType&);
175
6634349e 176#endif //ALIHLTMISC_H