]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/CDB/AliCDBManager.h
If reading from the CDB snapshot was not successful, AliReconstruction does not retur...
[u/mrichter/AliRoot.git] / STEER / CDB / AliCDBManager.h
CommitLineData
9e1ceb13 1#ifndef ALI_CDB_MANAGER_H
2#define ALI_CDB_MANAGER_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/////////////////////////////////////////////////////////////////////
8// //
9// class AliCDBManager //
10// //
11/////////////////////////////////////////////////////////////////////
12
13#include <TObject.h>
14#include <TList.h>
15#include <TMap.h>
27cac7e3 16#include <TSystem.h>
9e1ceb13 17
fdf65bb5 18class AliCDBEntry;
02c4845e 19class AliCDBId;
20class AliCDBPath;
21class AliCDBRunRange;
22class AliCDBMetaData;
9e1ceb13 23class AliCDBStorage;
24class AliCDBStorageFactory;
25class AliCDBParam;
26
27class AliCDBManager: public TObject {
28
29 public:
b8ec52f6 30 enum DataType {kCondition=0, kReference, kPrivate};
9e1ceb13 31
32 void RegisterFactory(AliCDBStorageFactory* factory);
33
fdf65bb5 34 Bool_t HasStorage(const char* dbString) const;
9e1ceb13 35
fdf65bb5 36 AliCDBParam* CreateParameter(const char* dbString) const;
b8ec52f6 37 AliCDBParam* GetCondParam() const {return fCondParam;}
38 AliCDBParam* GetRefParam() const {return fRefParam;}
39 static const char* GetDataTypeName(DataType type);
9e1ceb13 40
41 AliCDBStorage* GetStorage(const char* dbString);
42 AliCDBStorage* GetStorage(const AliCDBParam* param);
b8ec52f6 43
9e1ceb13 44 TList* GetActiveStorages();
45
b21e3194 46 const TMap* GetStorageMap() const {return fStorageMap;}
47 const TList* GetRetrievedIds() const {return fIds;}
48
9e1ceb13 49 void SetDefaultStorage(const char* dbString);
50 void SetDefaultStorage(const AliCDBParam* param);
51 void SetDefaultStorage(AliCDBStorage *storage);
7de84b33 52 void SetDefaultStorage(const char* runType, const char* simType);
53 void SetDefaultStorageFromRun(Int_t run);
4667c116 54
02c4845e 55 Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
fdf65bb5 56 AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
1f341624 57 void UnsetDefaultStorage();
4667c116 58
024cf675 59 void SetSpecificStorage(const char* calibType, const char* dbString);
647d2bb8 60 void SetSpecificStorage(const char* calibType, const AliCDBParam* param);
02c4845e 61
024cf675 62 AliCDBStorage* GetSpecificStorage(const char* calibType);
9e1ceb13 63
64 void SetDrain(const char* dbString);
65 void SetDrain(const AliCDBParam* param);
66 void SetDrain(AliCDBStorage *storage);
67
fdf65bb5 68 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
9e1ceb13 69
70 Bool_t Drain(AliCDBEntry* entry);
71
b05400be 72 void UnsetDrain(){fDrainStorage = 0x0;}
9e1ceb13 73
02c4845e 74 AliCDBEntry* Get(const AliCDBId& query);
62032124 75 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
02c4845e 76 Int_t version = -1, Int_t subVersion = -1);
77 AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
78 Int_t version = -1, Int_t subVersion = -1);
79
0f40a831 80 const char* GetURI(const char* path);
81
4667c116 82 AliCDBId* GetId(const AliCDBId& query);
83 AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1,
84 Int_t version = -1, Int_t subVersion = -1);
85 AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
86 Int_t version = -1, Int_t subVersion = -1);
87
02c4845e 88 TList* GetAll(const AliCDBId& query);
62032124 89 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
02c4845e 90 Int_t version = -1, Int_t subVersion = -1);
91 TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
92 Int_t version = -1, Int_t subVersion = -1);
93
647d2bb8 94 Bool_t Put(TObject* object, const AliCDBId& id,
27cac7e3 95 AliCDBMetaData* metaData, const DataType type=kPrivate);
b8ec52f6 96 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
97
4b5e0dce 98 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
e1e6896f 99 Bool_t GetCacheFlag() const {return fCache;}
1f341624 100
a6f59240 101 ULong_t SetLock(Bool_t lockFlag=kTRUE, ULong_t key=0);
1f341624 102 Bool_t GetLock() const {return fLock;}
4b5e0dce 103
7de84b33 104 void SetRaw(Bool_t rawFlag){fRaw=rawFlag;}
105 Bool_t GetRaw() const {return fRaw;}
106
c3a7b59a 107 void SetRun(Int_t run);
108 Int_t GetRun() const {return fRun;}
4b5e0dce 109
9e1ceb13 110 void DestroyActiveStorages();
111 void DestroyActiveStorage(AliCDBStorage* storage);
917a098b 112
62032124 113 void QueryCDB();
114
917a098b 115 void Print(Option_t* option="") const;
116
9e1ceb13 117 static void Destroy();
118 ~AliCDBManager();
119
8e245d15 120 void ClearCache();
4005d0b5 121 void UnloadFromCache(const char* path);
d1982b43 122 const TMap* GetEntryCache() const {return &fEntryCache;}
8e245d15 123
4667c116 124 Bool_t IsShortLived(const char* path);
125
d1982b43 126 static AliCDBManager* Instance(TMap *entryCache = NULL, Int_t run = -1);
9e1ceb13 127
b03591ab 128 void Init();
129 void InitFromCache(TMap *entryCache, Int_t run);
647d2bb8 130 Bool_t InitFromSnapshot(const char* snapshotFileName);
7ec0d3df 131 void DumpToSnapshotFile(const char* snapshotFileName);
b03591ab 132
133protected:
b8ec52f6 134
135 static TString fgkCondUri; // URI of the Conditions data base folder
136 static TString fgkRefUri; // URI of the Reference data base folder
7de84b33 137 static TString fgkMCIdealStorage; // URI of the MC-Ideal Conditions data base folder form MC data
138 static TString fgkMCFullStorage; // URI of the MC-Full Conditions data base folder form MC data
139 static TString fgkMCResidualStorage; // URI of the MC-Residual Conditions data base folder form MC data
140 static TString fgkOCDBFolderXMLfile; // alien path of the XML file for OCDB folder <--> Run range correspondance
b8ec52f6 141
b03591ab 142 AliCDBManager() ;
fe12e09c 143 AliCDBManager(const AliCDBManager & source);
144 AliCDBManager & operator=(const AliCDBManager & source);
145
fdf65bb5 146 static AliCDBManager* fgInstance; // AliCDBManager instance
9e1ceb13 147
148 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
149 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
917a098b 150
4b5e0dce 151 void CacheEntry(const char* path, AliCDBEntry* entry);
8e245d15 152
024cf675 153 AliCDBParam* SelectSpecificStorage(const TString& path);
154
9e1ceb13 155
b03591ab 156// void Init();
4667c116 157 void InitShortLived();
b03591ab 158// void InitFromCache(TMap *entryCache, Int_t run);
4667c116 159
160
b05400be 161 TList fFactories; //! list of registered storage factories
162 TMap fActiveStorages; //! list of active storages
02c4845e 163 TMap fSpecificStorages; //! list of detector-specific storages
b21e3194 164 TMap fEntryCache; //! cache of the retrieved objects
165
166 TList* fIds; //! List of the retrieved object Id's (to be streamed to file)
167 TMap* fStorageMap; //! list of storages (to be streamed to file)
168 TList* fShortLived; //! List of short lived objects
4b5e0dce 169
b05400be 170 AliCDBStorage *fDefaultStorage; //! pointer to default storage
171 AliCDBStorage *fDrainStorage; //! pointer to drain storage
9e1ceb13 172
b21e3194 173 AliCDBParam* fCondParam; // Conditions data storage parameters
174 AliCDBParam* fRefParam; // Reference data storage parameters
4b5e0dce 175
b21e3194 176 Int_t fRun; //! The run number
4b5e0dce 177 Bool_t fCache; //! The cache flag
1f341624 178 Bool_t fLock; //! Lock flag, if ON default storage and run number cannot be reset
4b5e0dce 179
7de84b33 180 Bool_t fRaw; // flag to say whether we are in the raw case
181 Int_t fStartRunLHCPeriod; // 1st run of the LHC period set
182 Int_t fEndRunLHCPeriod; // last run of the LHC period set
183 TString fLHCPeriod; // LHC period alien folder
184
a6f59240 185private:
186 ULong_t fKey; //! Key for locking/unlocking
187
4667c116 188
9e1ceb13 189 ClassDef(AliCDBManager, 0);
190};
191
192
193/////////////////////////////////////////////////////////////////////
194// //
195// class AliCDBStorageFactory //
196// //
197/////////////////////////////////////////////////////////////////////
198
199class AliCDBParam;
200class AliCDBStorageFactory: public TObject {
201 friend class AliCDBManager;
202
203public:
e1e6896f 204 virtual ~AliCDBStorageFactory(){}
9e1ceb13 205 virtual Bool_t Validate(const char* dbString) = 0;
b05400be 206 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
9e1ceb13 207
208protected:
209 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
210
211 ClassDef(AliCDBStorageFactory, 0);
212};
213
214/////////////////////////////////////////////////////////////////////
215// //
216// class AliCDBParam //
217// //
218/////////////////////////////////////////////////////////////////////
219
220class AliCDBParam: public TObject {
221
222public:
223
224 AliCDBParam();
225 virtual ~AliCDBParam();
226
227 const TString& GetType() const {return fType;};
228 const TString& GetURI() const {return fURI;};
229
230 virtual AliCDBParam* CloneParam() const = 0;
231
232protected:
233
234 void SetType(const char* type) {fType = type;};
235 void SetURI(const char* uri) {fURI = uri;};
236
237private:
238
917a098b 239 TString fType; //! CDB type
240 TString fURI; //! CDB URI
9e1ceb13 241
242 ClassDef(AliCDBParam, 0);
243};
244
245#endif