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