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