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