]>
Commit | Line | Data |
---|---|---|
fe913d8f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
fe913d8f | 16 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
17 | // // | |
9e1ceb13 | 18 | // AliCDBLocal // |
19 | // access class to a DataBase in a local storage // | |
fe913d8f | 20 | // // |
21 | ///////////////////////////////////////////////////////////////////////////////////////////////// | |
22 | ||
fe913d8f | 23 | #include <TSystem.h> |
fe913d8f | 24 | #include <TObjString.h> |
25 | #include <TRegexp.h> | |
9e1ceb13 | 26 | #include <TFile.h> |
27 | #include <TKey.h> | |
fe913d8f | 28 | |
fe913d8f | 29 | #include "AliCDBLocal.h" |
9e1ceb13 | 30 | #include "AliCDBEntry.h" |
31 | #include "AliLog.h" | |
fe913d8f | 32 | |
33 | ClassImp(AliCDBLocal) | |
34 | ||
35 | //_____________________________________________________________________________ | |
9e1ceb13 | 36 | AliCDBLocal::AliCDBLocal(const char* baseDir): |
37 | fBaseDirectory(baseDir) | |
fe913d8f | 38 | { |
39 | // constructor | |
9e1ceb13 | 40 | |
41 | // check baseDire: trying to cd to baseDir; if it does not exist, create it | |
42 | void* dir = gSystem->OpenDirectory(baseDir); | |
43 | if (dir == NULL) { | |
44 | if (gSystem->mkdir(baseDir, kTRUE)) { | |
45 | AliError(Form("Can't open directory <%s>!", baseDir)); | |
46 | } | |
47 | ||
48 | } else { | |
49 | AliDebug(2,Form("Folder <%s> found",fBaseDirectory.Data())); | |
50 | gSystem->FreeDirectory(dir); | |
51 | } | |
62032124 | 52 | fType="local"; |
53 | fBaseFolder = fBaseDirectory; | |
fe913d8f | 54 | } |
55 | ||
56 | //_____________________________________________________________________________ | |
9e1ceb13 | 57 | AliCDBLocal::~AliCDBLocal() { |
58 | // destructor | |
fe913d8f | 59 | |
60 | } | |
61 | ||
9e1ceb13 | 62 | |
fe913d8f | 63 | //_____________________________________________________________________________ |
9e1ceb13 | 64 | Bool_t AliCDBLocal::FilenameToId(const char* filename, AliCDBRunRange& runRange, |
4b5e0dce | 65 | Int_t& version, Int_t& subVersion) { |
9e1ceb13 | 66 | // build AliCDBId from filename numbers |
67 | ||
9e1ceb13 | 68 | |
69 | Ssiz_t mSize; | |
fe913d8f | 70 | |
9e1ceb13 | 71 | // valid filename: Run#firstRun_#lastRun_v#version_s#subVersion.root |
72 | TRegexp keyPattern("^Run[0-9]+_[0-9]+_v[0-9]+_s[0-9]+.root$"); | |
73 | keyPattern.Index(filename, &mSize); | |
74 | if (!mSize) { | |
75 | AliDebug(2, Form("Bad filename <%s>.", filename)); | |
76 | return kFALSE; | |
77 | } | |
78 | ||
79 | TString idString(filename); | |
80 | idString.Resize(idString.Length() - sizeof(".root") + 1); | |
81 | ||
82 | TObjArray* strArray = (TObjArray*) idString.Tokenize("_"); | |
83 | ||
84 | TString firstRunString(((TObjString*) strArray->At(0))->GetString()); | |
85 | runRange.SetFirstRun(atoi(firstRunString.Data() + 3)); | |
86 | runRange.SetLastRun(atoi(((TObjString*) strArray->At(1))->GetString())); | |
87 | ||
88 | TString verString(((TObjString*) strArray->At(2))->GetString()); | |
89 | version = atoi(verString.Data() + 1); | |
90 | ||
91 | TString subVerString(((TObjString*) strArray->At(3))->GetString()); | |
92 | subVersion = atoi(subVerString.Data() + 1); | |
93 | ||
94 | delete strArray; | |
95 | ||
96 | return kTRUE; | |
fe913d8f | 97 | } |
98 | ||
9e1ceb13 | 99 | |
fe913d8f | 100 | //_____________________________________________________________________________ |
c3a7b59a | 101 | Bool_t AliCDBLocal::IdToFilename(const AliCDBId& id, TString& filename) const { |
9e1ceb13 | 102 | // build file name from AliCDBId data (run range, version, subVersion) |
103 | ||
c3a7b59a | 104 | if (!id.GetAliCDBRunRange().IsValid()) { |
b05400be | 105 | AliDebug(2,Form("Invalid run range <%d, %d>.", |
c3a7b59a | 106 | id.GetFirstRun(), id.GetLastRun())); |
9e1ceb13 | 107 | return kFALSE; |
108 | } | |
109 | ||
c3a7b59a | 110 | if (id.GetVersion() < 0) { |
111 | AliDebug(2,Form("Invalid version <%d>.", id.GetVersion())); | |
9e1ceb13 | 112 | return kFALSE; |
113 | } | |
fe913d8f | 114 | |
c3a7b59a | 115 | if (id.GetSubVersion() < 0) { |
116 | AliDebug(2,Form("Invalid subversion <%s>.", id.GetSubVersion())); | |
9e1ceb13 | 117 | return kFALSE; |
118 | } | |
119 | ||
c3a7b59a | 120 | filename = Form("Run%d_%d_v%d_s%d.root", id.GetFirstRun(), id.GetLastRun(), |
121 | id.GetVersion(), id.GetSubVersion()); | |
122 | ||
123 | filename.Prepend(fBaseDirectory +'/' + id.GetPath() + '/'); | |
9e1ceb13 | 124 | |
125 | return kTRUE; | |
fe913d8f | 126 | } |
127 | ||
128 | //_____________________________________________________________________________ | |
9e1ceb13 | 129 | Bool_t AliCDBLocal::PrepareId(AliCDBId& id) { |
130 | // prepare id (version, subVersion) of the object that will be stored (called by PutEntry) | |
131 | ||
c3a7b59a | 132 | TString dirName = Form("%s/%s", fBaseDirectory.Data(), id.GetPath().Data()); |
9e1ceb13 | 133 | |
134 | // go to the path; if directory does not exist, create it | |
135 | void* dirPtr = gSystem->OpenDirectory(dirName); | |
136 | if (!dirPtr) { | |
137 | gSystem->mkdir(dirName, kTRUE); | |
138 | dirPtr = gSystem->OpenDirectory(dirName); | |
139 | ||
140 | if (!dirPtr) { | |
141 | AliError(Form("Can't create directory <%s>!", | |
142 | dirName.Data())); | |
143 | return kFALSE; | |
144 | } | |
145 | } | |
fe913d8f | 146 | |
9e1ceb13 | 147 | const char* filename; |
4667c116 | 148 | AliCDBRunRange aRunRange; // the runRange got from filename |
9e1ceb13 | 149 | AliCDBRunRange lastRunRange(-1,-1); // highest runRange found |
150 | Int_t aVersion, aSubVersion; // the version subVersion got from filename | |
151 | Int_t lastVersion = 0, lastSubVersion = -1; // highest version and subVersion found | |
152 | ||
153 | if (!id.HasVersion()) { // version not specified: look for highest version & subVersion | |
154 | ||
155 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on the files | |
156 | ||
157 | TString aString(filename); | |
158 | if (aString == "." || aString == "..") continue; | |
159 | ||
160 | if (!FilenameToId(filename, aRunRange, aVersion, | |
161 | aSubVersion)) { | |
b05400be | 162 | AliDebug(2,Form( |
9e1ceb13 | 163 | "Bad filename <%s>! I'll skip it.", |
164 | filename)); | |
165 | continue; | |
166 | } | |
167 | ||
168 | if (!aRunRange.Overlaps(id.GetAliCDBRunRange())) continue; | |
169 | if(aVersion < lastVersion) continue; | |
170 | if(aVersion > lastVersion) lastSubVersion = -1; | |
171 | if(aSubVersion < lastSubVersion) continue; | |
172 | lastVersion = aVersion; | |
173 | lastSubVersion = aSubVersion; | |
174 | lastRunRange = aRunRange; | |
175 | } | |
176 | ||
177 | id.SetVersion(lastVersion); | |
178 | id.SetSubVersion(lastSubVersion + 1); | |
179 | ||
180 | } else { // version specified, look for highest subVersion only | |
181 | ||
182 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on the files | |
183 | ||
184 | TString aString(filename); | |
185 | if (aString == "." || aString == "..") { | |
186 | continue; | |
187 | } | |
188 | ||
189 | if (!FilenameToId(filename, aRunRange, aVersion, | |
190 | aSubVersion)) { | |
b05400be | 191 | AliDebug(2,Form( |
9e1ceb13 | 192 | "Bad filename <%s>!I'll skip it.", |
193 | filename)); | |
194 | continue; | |
195 | } | |
196 | ||
197 | if (aRunRange.Overlaps(id.GetAliCDBRunRange()) | |
198 | && aVersion == id.GetVersion() | |
199 | && aSubVersion > lastSubVersion) { | |
200 | lastSubVersion = aSubVersion; | |
201 | lastRunRange = aRunRange; | |
202 | } | |
203 | ||
204 | } | |
205 | ||
206 | id.SetSubVersion(lastSubVersion + 1); | |
207 | } | |
fe913d8f | 208 | |
9e1ceb13 | 209 | gSystem->FreeDirectory(dirPtr); |
fe913d8f | 210 | |
9e1ceb13 | 211 | TString lastStorage = id.GetLastStorage(); |
212 | if(lastStorage.Contains(TString("grid"), TString::kIgnoreCase) && | |
213 | id.GetSubVersion() > 0 ){ | |
214 | AliError(Form("Grid to Local Storage error! local object with version v%d_s%d found:",id.GetVersion(), id.GetSubVersion()-1)); | |
215 | AliError(Form("This object has been already transferred from Grid (check v%d_s0)!",id.GetVersion())); | |
216 | return kFALSE; | |
217 | } | |
218 | ||
219 | if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) && | |
220 | id.GetSubVersion() > 0 ){ | |
84090f85 | 221 | AliDebug(2, Form("A NEW object is being stored with version v%d_s%d", |
9e1ceb13 | 222 | id.GetVersion(),id.GetSubVersion())); |
84090f85 | 223 | AliDebug(2, Form("and it will hide previously stored object with v%d_s%d!", |
9e1ceb13 | 224 | id.GetVersion(),id.GetSubVersion()-1)); |
225 | } | |
226 | ||
227 | if(!lastRunRange.IsAnyRange() && !(lastRunRange.IsEqual(& id.GetAliCDBRunRange()))) | |
228 | AliWarning(Form("Run range modified w.r.t. previous version (Run%d_%d_v%d_s%d)", | |
229 | lastRunRange.GetFirstRun(), lastRunRange.GetLastRun(), | |
230 | id.GetVersion(), id.GetSubVersion()-1)); | |
231 | ||
232 | return kTRUE; | |
fe913d8f | 233 | } |
234 | ||
4667c116 | 235 | // //_____________________________________________________________________________ |
236 | // Bool_t AliCDBLocal::GetId(const AliCDBId& query, AliCDBId& result) { | |
237 | // // look for filename matching query (called by GetEntry) | |
238 | // | |
239 | // TString dirName = Form("%s/%s", fBaseDirectory.Data(), query.GetPath().Data()); | |
240 | // | |
241 | // void* dirPtr = gSystem->OpenDirectory(dirName); | |
242 | // if (!dirPtr) { | |
243 | // AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data())); | |
244 | // AliDebug(2,Form("in DB folder %s", fBaseDirectory.Data())); | |
245 | // return kFALSE; | |
246 | // } | |
247 | // | |
248 | // const char* filename; | |
249 | // | |
250 | // AliCDBRunRange aRunRange; // the runRange got from filename | |
251 | // Int_t aVersion, aSubVersion; // the version and subVersion got from filename | |
252 | // | |
253 | // if (!query.HasVersion()) { // neither version and subversion specified -> look for highest version and subVersion | |
254 | // | |
255 | // while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
256 | // | |
257 | // TString aString(filename); | |
258 | // if (aString == "." || aString == "..") continue; | |
259 | // | |
260 | // if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
261 | // // aRunRange, aVersion, aSubVersion filled from filename | |
262 | // | |
263 | // if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; | |
264 | // // aRunRange contains requested run! | |
265 | // | |
266 | // if (result.GetVersion() < aVersion) { | |
267 | // result.SetVersion(aVersion); | |
268 | // result.SetSubVersion(aSubVersion); | |
269 | // | |
270 | // result.SetFirstRun( | |
271 | // aRunRange.GetFirstRun()); | |
272 | // result.SetLastRun( | |
273 | // aRunRange.GetLastRun()); | |
274 | // | |
275 | // } else if (result.GetVersion() == aVersion | |
276 | // && result.GetSubVersion() | |
277 | // < aSubVersion) { | |
278 | // | |
279 | // result.SetSubVersion(aSubVersion); | |
280 | // | |
281 | // result.SetFirstRun( | |
282 | // aRunRange.GetFirstRun()); | |
283 | // result.SetLastRun( | |
284 | // aRunRange.GetLastRun()); | |
285 | // } else if (result.GetVersion() == aVersion | |
286 | // && result.GetSubVersion() == aSubVersion){ | |
287 | // AliDebug(2,Form("More than one object valid for run %d, version %d_%d!", | |
288 | // query.GetFirstRun(), aVersion, aSubVersion)); | |
289 | // gSystem->FreeDirectory(dirPtr); | |
290 | // return kFALSE; | |
291 | // } | |
292 | // } | |
293 | // | |
294 | // } else if (!query.HasSubVersion()) { // version specified but not subversion -> look for highest subVersion | |
295 | // | |
296 | // result.SetVersion(query.GetVersion()); | |
297 | // | |
298 | // while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
299 | // | |
300 | // TString aString(filename); | |
301 | // if (aString == "." || aString == "..") continue; | |
302 | // | |
303 | // if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
304 | // // aRunRange, aVersion, aSubVersion filled from filename | |
305 | // | |
306 | // if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; | |
307 | // // aRunRange contains requested run! | |
308 | // | |
309 | // if(query.GetVersion() != aVersion) continue; | |
310 | // // aVersion is requested version! | |
311 | // | |
312 | // if(result.GetSubVersion() == aSubVersion){ | |
313 | // AliDebug(2,Form("More than one object valid for run %d, version %d_%d!", | |
314 | // query.GetFirstRun(), aVersion, aSubVersion)); | |
315 | // gSystem->FreeDirectory(dirPtr); | |
316 | // return kFALSE; | |
317 | // } | |
318 | // if( result.GetSubVersion() < aSubVersion) { | |
319 | // | |
320 | // result.SetSubVersion(aSubVersion); | |
321 | // | |
322 | // result.SetFirstRun( | |
323 | // aRunRange.GetFirstRun()); | |
324 | // result.SetLastRun( | |
325 | // aRunRange.GetLastRun()); | |
326 | // } | |
327 | // } | |
328 | // | |
329 | // } else { // both version and subversion specified | |
330 | // | |
331 | // while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
332 | // | |
333 | // TString aString(filename); | |
334 | // if (aString == "." || aString == "..") continue; | |
335 | // | |
336 | // if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
337 | // // aRunRange, aVersion, aSubVersion filled from filename | |
338 | // | |
339 | // if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; | |
340 | // // aRunRange contains requested run! | |
341 | // | |
342 | // if(query.GetVersion() != aVersion || query.GetSubVersion() != aSubVersion) continue; | |
343 | // // aVersion and aSubVersion are requested version and subVersion! | |
344 | // | |
345 | // if(result.GetVersion() == aVersion && result.GetSubVersion() == aSubVersion){ | |
346 | // AliDebug(2,Form("More than one object valid for run %d, version %d_%d!", | |
347 | // query.GetFirstRun(), aVersion, aSubVersion)); | |
348 | // gSystem->FreeDirectory(dirPtr); | |
349 | // return kFALSE; | |
350 | // } | |
351 | // result.SetVersion(aVersion); | |
352 | // result.SetSubVersion(aSubVersion); | |
353 | // result.SetFirstRun(aRunRange.GetFirstRun()); | |
354 | // result.SetLastRun(aRunRange.GetLastRun()); | |
355 | // | |
356 | // } | |
357 | // } | |
358 | // | |
359 | // gSystem->FreeDirectory(dirPtr); | |
360 | // | |
361 | // return kTRUE; | |
362 | // } | |
363 | ||
9e1ceb13 | 364 | //_____________________________________________________________________________ |
4667c116 | 365 | AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) { |
366 | // look for filename matching query (called by GetEntryId) | |
9e1ceb13 | 367 | |
c3a7b59a | 368 | TString dirName = Form("%s/%s", fBaseDirectory.Data(), query.GetPath().Data()); |
9e1ceb13 | 369 | |
c3a7b59a | 370 | void* dirPtr = gSystem->OpenDirectory(dirName); |
9e1ceb13 | 371 | if (!dirPtr) { |
024cf675 | 372 | AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data())); |
373 | AliDebug(2,Form("in DB folder %s", fBaseDirectory.Data())); | |
4667c116 | 374 | return NULL; |
9e1ceb13 | 375 | } |
376 | ||
c3a7b59a | 377 | const char* filename; |
4667c116 | 378 | AliCDBId *result = new AliCDBId(); |
379 | result->SetPath(query.GetPath()); | |
c3a7b59a | 380 | |
9e1ceb13 | 381 | AliCDBRunRange aRunRange; // the runRange got from filename |
382 | Int_t aVersion, aSubVersion; // the version and subVersion got from filename | |
383 | ||
384 | if (!query.HasVersion()) { // neither version and subversion specified -> look for highest version and subVersion | |
c3a7b59a | 385 | |
9e1ceb13 | 386 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files |
c3a7b59a | 387 | |
9e1ceb13 | 388 | TString aString(filename); |
389 | if (aString == "." || aString == "..") continue; | |
390 | ||
391 | if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
392 | // aRunRange, aVersion, aSubVersion filled from filename | |
393 | ||
394 | if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; | |
395 | // aRunRange contains requested run! | |
c3a7b59a | 396 | |
4667c116 | 397 | if (result->GetVersion() < aVersion) { |
398 | result->SetVersion(aVersion); | |
399 | result->SetSubVersion(aSubVersion); | |
9e1ceb13 | 400 | |
4667c116 | 401 | result->SetFirstRun( |
9e1ceb13 | 402 | aRunRange.GetFirstRun()); |
4667c116 | 403 | result->SetLastRun( |
9e1ceb13 | 404 | aRunRange.GetLastRun()); |
405 | ||
4667c116 | 406 | } else if (result->GetVersion() == aVersion |
407 | && result->GetSubVersion() | |
9e1ceb13 | 408 | < aSubVersion) { |
409 | ||
4667c116 | 410 | result->SetSubVersion(aSubVersion); |
9e1ceb13 | 411 | |
4667c116 | 412 | result->SetFirstRun( |
9e1ceb13 | 413 | aRunRange.GetFirstRun()); |
4667c116 | 414 | result->SetLastRun( |
9e1ceb13 | 415 | aRunRange.GetLastRun()); |
4667c116 | 416 | } else if (result->GetVersion() == aVersion |
417 | && result->GetSubVersion() == aSubVersion){ | |
418 | AliError(Form("More than one object valid for run %d, version %d_%d!", | |
9e1ceb13 | 419 | query.GetFirstRun(), aVersion, aSubVersion)); |
4b5e0dce | 420 | gSystem->FreeDirectory(dirPtr); |
4667c116 | 421 | delete result; |
422 | return NULL; | |
9e1ceb13 | 423 | } |
424 | } | |
4667c116 | 425 | |
9e1ceb13 | 426 | } else if (!query.HasSubVersion()) { // version specified but not subversion -> look for highest subVersion |
427 | ||
4667c116 | 428 | result->SetVersion(query.GetVersion()); |
9e1ceb13 | 429 | |
430 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
431 | ||
432 | TString aString(filename); | |
433 | if (aString == "." || aString == "..") continue; | |
434 | ||
4667c116 | 435 | if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; |
9e1ceb13 | 436 | // aRunRange, aVersion, aSubVersion filled from filename |
437 | ||
438 | if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; | |
439 | // aRunRange contains requested run! | |
4667c116 | 440 | |
9e1ceb13 | 441 | if(query.GetVersion() != aVersion) continue; |
442 | // aVersion is requested version! | |
4667c116 | 443 | |
444 | if(result->GetSubVersion() == aSubVersion){ | |
445 | AliError(Form("More than one object valid for run %d, version %d_%d!", | |
9e1ceb13 | 446 | query.GetFirstRun(), aVersion, aSubVersion)); |
4b5e0dce | 447 | gSystem->FreeDirectory(dirPtr); |
4667c116 | 448 | delete result; |
449 | return NULL; | |
9e1ceb13 | 450 | } |
4667c116 | 451 | if( result->GetSubVersion() < aSubVersion) { |
9e1ceb13 | 452 | |
4667c116 | 453 | result->SetSubVersion(aSubVersion); |
9e1ceb13 | 454 | |
4667c116 | 455 | result->SetFirstRun( |
9e1ceb13 | 456 | aRunRange.GetFirstRun()); |
4667c116 | 457 | result->SetLastRun( |
9e1ceb13 | 458 | aRunRange.GetLastRun()); |
459 | } | |
460 | } | |
461 | ||
462 | } else { // both version and subversion specified | |
463 | ||
4667c116 | 464 | //AliCDBId dataId(queryId.GetAliCDBPath(), -1, -1, -1, -1); |
465 | //Bool_t result; | |
466 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
9e1ceb13 | 467 | |
468 | TString aString(filename); | |
469 | if (aString == "." || aString == "..") continue; | |
470 | ||
471 | if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
472 | // aRunRange, aVersion, aSubVersion filled from filename | |
4667c116 | 473 | |
9e1ceb13 | 474 | if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue; |
475 | // aRunRange contains requested run! | |
476 | ||
4667c116 | 477 | if(query.GetVersion() != aVersion || query.GetSubVersion() != aSubVersion) continue; |
9e1ceb13 | 478 | // aVersion and aSubVersion are requested version and subVersion! |
4667c116 | 479 | |
480 | if(result->GetVersion() == aVersion && result->GetSubVersion() == aSubVersion){ | |
481 | AliError(Form("More than one object valid for run %d, version %d_%d!", | |
9e1ceb13 | 482 | query.GetFirstRun(), aVersion, aSubVersion)); |
4b5e0dce | 483 | gSystem->FreeDirectory(dirPtr); |
4667c116 | 484 | delete result; |
485 | return NULL; | |
9e1ceb13 | 486 | } |
4667c116 | 487 | result->SetVersion(aVersion); |
488 | result->SetSubVersion(aSubVersion); | |
489 | result->SetFirstRun(aRunRange.GetFirstRun()); | |
490 | result->SetLastRun(aRunRange.GetLastRun()); | |
9e1ceb13 | 491 | |
492 | } | |
493 | } | |
494 | ||
495 | gSystem->FreeDirectory(dirPtr); | |
496 | ||
4667c116 | 497 | return result; |
9e1ceb13 | 498 | } |
fe913d8f | 499 | |
500 | //_____________________________________________________________________________ | |
9e1ceb13 | 501 | AliCDBEntry* AliCDBLocal::GetEntry(const AliCDBId& queryId) { |
502 | // get AliCDBEntry from the database | |
503 | ||
4667c116 | 504 | AliCDBId* dataId = GetEntryId(queryId); |
9e1ceb13 | 505 | |
4667c116 | 506 | if (!dataId || !dataId->IsSpecified()) return NULL; |
9e1ceb13 | 507 | |
508 | TString filename; | |
4667c116 | 509 | if (!IdToFilename(*dataId, filename)) { |
9e1ceb13 | 510 | |
024cf675 | 511 | AliDebug(2,Form("Bad data ID encountered! Subnormal error!")); |
4667c116 | 512 | delete dataId; |
513 | return NULL; | |
9e1ceb13 | 514 | } |
9e1ceb13 | 515 | |
516 | TFile file(filename, "READ"); // open file | |
517 | if (!file.IsOpen()) { | |
024cf675 | 518 | AliDebug(2,Form("Can't open file <%s>!", filename.Data())); |
4667c116 | 519 | delete dataId; |
520 | return NULL; | |
9e1ceb13 | 521 | } |
522 | ||
523 | // get the only AliCDBEntry object from the file | |
524 | // the object in the file is an AliCDBEntry entry named "AliCDBEntry" | |
4667c116 | 525 | |
62032124 | 526 | AliCDBEntry* anEntry = dynamic_cast<AliCDBEntry*> (file.Get("AliCDBEntry")); |
527 | if (!anEntry) { | |
528 | AliDebug(2,Form("Bad storage data: No AliCDBEntry in file!")); | |
529 | file.Close(); | |
4667c116 | 530 | delete dataId; |
9e1ceb13 | 531 | return NULL; |
532 | } | |
533 | ||
4667c116 | 534 | AliCDBId& entryId = anEntry->GetId(); |
ed343d5e | 535 | |
9e1ceb13 | 536 | // The object's Id are not reset during storage |
537 | // If object's Id runRange or version do not match with filename, | |
538 | // it means that someone renamed file by hand. In this case a warning msg is issued. | |
62032124 | 539 | |
540 | anEntry-> SetLastStorage("local"); | |
4667c116 | 541 | |
542 | if(!entryId.IsEqual(dataId)){ | |
b8ec52f6 | 543 | AliWarning(Form("Mismatch between file name and object's Id!")); |
4667c116 | 544 | AliWarning(Form("File name: %s", dataId->ToString().Data())); |
b8ec52f6 | 545 | AliWarning(Form("Object's Id: %s", entryId.ToString().Data())); |
9e1ceb13 | 546 | } |
b8ec52f6 | 547 | |
145f45a2 | 548 | // Check whether entry contains a TTree. In case load the tree in memory! |
549 | LoadTreeFromFile(anEntry); | |
550 | ||
9e1ceb13 | 551 | // close file, return retieved entry |
552 | file.Close(); | |
4667c116 | 553 | delete dataId; |
62032124 | 554 | return anEntry; |
9e1ceb13 | 555 | } |
fe913d8f | 556 | |
4667c116 | 557 | //_____________________________________________________________________________ |
558 | AliCDBId* AliCDBLocal::GetEntryId(const AliCDBId& queryId) { | |
559 | // get AliCDBId from the database | |
560 | ||
561 | AliCDBId* dataId = 0; | |
562 | ||
563 | // look for a filename matching query requests (path, runRange, version, subVersion) | |
564 | if (!queryId.HasVersion()) { | |
565 | // if version is not specified, first check the selection criteria list | |
566 | AliCDBId selectedId(queryId); | |
567 | GetSelection(&selectedId); | |
568 | dataId = GetId(selectedId); | |
569 | } else { | |
570 | dataId = GetId(queryId); | |
571 | } | |
572 | ||
573 | if (dataId && !dataId->IsSpecified()) { | |
574 | delete dataId; | |
575 | return NULL; | |
576 | } | |
577 | ||
578 | return dataId; | |
579 | } | |
580 | ||
9e1ceb13 | 581 | //_____________________________________________________________________________ |
582 | void AliCDBLocal::GetEntriesForLevel0(const char* level0, | |
583 | const AliCDBId& queryId, TList* result) { | |
584 | // multiple request (AliCDBStorage::GetAll) | |
585 | ||
c3a7b59a | 586 | TString level0Dir = Form("%s/%s", fBaseDirectory.Data(), level0); |
587 | ||
9e1ceb13 | 588 | void* level0DirPtr = gSystem->OpenDirectory(level0Dir); |
589 | if (!level0DirPtr) { | |
c3a7b59a | 590 | AliDebug(2,Form("Can't open level0 directory <%s>!", |
9e1ceb13 | 591 | level0Dir.Data())); |
592 | return; | |
c3a7b59a | 593 | } |
9e1ceb13 | 594 | |
595 | const char* level1; | |
e53c6949 | 596 | Long_t flag=0; |
9e1ceb13 | 597 | while ((level1 = gSystem->GetDirEntry(level0DirPtr))) { |
598 | ||
599 | TString level1Str(level1); | |
600 | if (level1Str == "." || level1Str == "..") { | |
601 | continue; | |
602 | } | |
e53c6949 | 603 | |
604 | TString fullPath = Form("%s/%s",level0Dir.Data(), level1); | |
9e1ceb13 | 605 | |
e53c6949 | 606 | Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0); |
607 | ||
608 | if(res){ | |
609 | AliDebug(2, Form("Error reading entry %s !",level1Str.Data())); | |
610 | continue; | |
611 | } | |
612 | if(!(flag&2)) continue; // bit 1 of flag = directory! | |
613 | ||
9e1ceb13 | 614 | if (queryId.GetAliCDBPath().Level1Comprises(level1)) { |
615 | GetEntriesForLevel1(level0, level1, queryId, result); | |
616 | } | |
617 | } | |
fe913d8f | 618 | |
9e1ceb13 | 619 | gSystem->FreeDirectory(level0DirPtr); |
fe913d8f | 620 | } |
621 | ||
9e1ceb13 | 622 | //_____________________________________________________________________________ |
623 | void AliCDBLocal::GetEntriesForLevel1(const char* level0, const char* level1, | |
624 | const AliCDBId& queryId, TList* result) { | |
625 | // multiple request (AliCDBStorage::GetAll) | |
626 | ||
c3a7b59a | 627 | TString level1Dir = Form("%s/%s/%s", fBaseDirectory.Data(), level0,level1); |
9e1ceb13 | 628 | |
629 | void* level1DirPtr = gSystem->OpenDirectory(level1Dir); | |
630 | if (!level1DirPtr) { | |
c3a7b59a | 631 | AliDebug(2,Form("Can't open level1 directory <%s>!", |
9e1ceb13 | 632 | level1Dir.Data())); |
633 | return; | |
634 | } | |
fe913d8f | 635 | |
9e1ceb13 | 636 | const char* level2; |
e53c6949 | 637 | Long_t flag=0; |
9e1ceb13 | 638 | while ((level2 = gSystem->GetDirEntry(level1DirPtr))) { |
639 | ||
640 | TString level2Str(level2); | |
641 | if (level2Str == "." || level2Str == "..") { | |
642 | continue; | |
643 | } | |
644 | ||
e53c6949 | 645 | TString fullPath = Form("%s/%s",level1Dir.Data(), level2); |
646 | ||
647 | Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0); | |
648 | ||
649 | if(res){ | |
650 | AliDebug(2, Form("Error reading entry %s !",level2Str.Data())); | |
651 | continue; | |
652 | } | |
653 | if(!(flag&2)) continue; // bit 1 of flag = directory! | |
654 | ||
9e1ceb13 | 655 | if (queryId.GetAliCDBPath().Level2Comprises(level2)) { |
62032124 | 656 | |
9e1ceb13 | 657 | AliCDBPath entryPath(level0, level1, level2); |
658 | AliCDBId entryId(entryPath, queryId.GetAliCDBRunRange(), | |
659 | queryId.GetVersion(), queryId.GetSubVersion()); | |
660 | ||
661 | AliCDBEntry* anEntry = GetEntry(entryId); | |
662 | if (anEntry) { | |
663 | result->Add(anEntry); | |
664 | } | |
665 | } | |
666 | } | |
fe913d8f | 667 | |
9e1ceb13 | 668 | gSystem->FreeDirectory(level1DirPtr); |
669 | } | |
fe913d8f | 670 | |
9e1ceb13 | 671 | //_____________________________________________________________________________ |
672 | TList* AliCDBLocal::GetEntries(const AliCDBId& queryId) { | |
673 | // multiple request (AliCDBStorage::GetAll) | |
e53c6949 | 674 | |
9e1ceb13 | 675 | void* storageDirPtr = gSystem->OpenDirectory(fBaseDirectory); |
676 | if (!storageDirPtr) { | |
024cf675 | 677 | AliDebug(2,Form("Can't open storage directory <%s>", |
9e1ceb13 | 678 | fBaseDirectory.Data())); |
679 | return NULL; | |
c3a7b59a | 680 | } |
9e1ceb13 | 681 | |
682 | TList* result = new TList(); | |
683 | result->SetOwner(); | |
684 | ||
685 | const char* level0; | |
e53c6949 | 686 | Long_t flag=0; |
9e1ceb13 | 687 | while ((level0 = gSystem->GetDirEntry(storageDirPtr))) { |
c3a7b59a | 688 | |
9e1ceb13 | 689 | TString level0Str(level0); |
690 | if (level0Str == "." || level0Str == "..") { | |
691 | continue; | |
692 | } | |
e53c6949 | 693 | |
694 | TString fullPath = Form("%s/%s",fBaseDirectory.Data(), level0); | |
695 | ||
696 | Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0); | |
697 | ||
698 | if(res){ | |
699 | AliDebug(2, Form("Error reading entry %s !",level0Str.Data())); | |
700 | continue; | |
701 | } | |
702 | ||
703 | if(!(flag&2)) continue; // bit 1 of flag = directory! | |
9e1ceb13 | 704 | |
705 | if (queryId.GetAliCDBPath().Level0Comprises(level0)) { | |
c3a7b59a | 706 | GetEntriesForLevel0(level0, queryId, result); |
9e1ceb13 | 707 | } |
c3a7b59a | 708 | } |
709 | ||
9e1ceb13 | 710 | gSystem->FreeDirectory(storageDirPtr); |
711 | ||
712 | return result; | |
fe913d8f | 713 | } |
714 | ||
715 | //_____________________________________________________________________________ | |
9e1ceb13 | 716 | Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry) { |
717 | // put an AliCDBEntry object into the database | |
718 | ||
719 | AliCDBId& id = entry->GetId(); | |
720 | ||
721 | // set version and subVersion for the entry to be stored | |
c3a7b59a | 722 | if (!PrepareId(id)) return kFALSE; |
9e1ceb13 | 723 | |
724 | ||
725 | // build filename from entry's id | |
62032124 | 726 | TString filename=""; |
c3a7b59a | 727 | if (!IdToFilename(id, filename)) { |
9e1ceb13 | 728 | |
024cf675 | 729 | AliDebug(2,Form("Bad ID encountered! Subnormal error!")); |
9e1ceb13 | 730 | return kFALSE; |
731 | } | |
c3a7b59a | 732 | |
9e1ceb13 | 733 | // open file |
734 | TFile file(filename, "CREATE"); | |
735 | if (!file.IsOpen()) { | |
736 | AliError(Form("Can't open file <%s>!", filename.Data())); | |
737 | return kFALSE; | |
738 | } | |
739 | ||
ed343d5e | 740 | //SetTreeToFile(entry, &file); |
145f45a2 | 741 | |
9e1ceb13 | 742 | entry->SetVersion(id.GetVersion()); |
743 | entry->SetSubVersion(id.GetSubVersion()); | |
0f678e35 | 744 | |
9e1ceb13 | 745 | // write object (key name: "AliCDBEntry") |
746 | Bool_t result = file.WriteTObject(entry, "AliCDBEntry"); | |
024cf675 | 747 | if (!result) AliDebug(2,Form("Can't write entry to file: %s", filename.Data())); |
9e1ceb13 | 748 | |
749 | file.Close(); | |
0f678e35 | 750 | if(result) { |
0f678e35 | 751 | if(!(id.GetPath().Contains("SHUTTLE/STATUS"))) |
752 | AliInfo(Form("CDB object stored into file %s",filename.Data())); | |
753 | } | |
b05400be | 754 | |
755 | return result; | |
756 | } | |
757 | ||
758 | //_____________________________________________________________________________ | |
759 | TList* AliCDBLocal::GetIdListFromFile(const char* fileName){ | |
760 | ||
761 | TString fullFileName(fileName); | |
762 | fullFileName.Prepend(fBaseDirectory+'/'); | |
763 | TFile *file = TFile::Open(fullFileName); | |
764 | if (!file) { | |
765 | AliError(Form("Can't open selection file <%s>!", fullFileName.Data())); | |
766 | return NULL; | |
767 | } | |
768 | file->cd(); | |
769 | ||
770 | TList *list = new TList(); | |
771 | list->SetOwner(); | |
772 | int i=0; | |
773 | TString keycycle; | |
774 | ||
775 | AliCDBId *id; | |
776 | while(1){ | |
777 | i++; | |
778 | keycycle = "AliCDBId;"; | |
779 | keycycle+=i; | |
780 | ||
781 | id = (AliCDBId*) file->Get(keycycle); | |
782 | if(!id) break; | |
783 | list->AddFirst(id); | |
784 | } | |
785 | file->Close(); delete file; file=0; | |
786 | return list; | |
787 | } | |
788 | ||
789 | //_____________________________________________________________________________ | |
790 | Bool_t AliCDBLocal::Contains(const char* path) const{ | |
791 | // check for path in storage's fBaseDirectory | |
792 | ||
c3a7b59a | 793 | TString dirName = Form("%s/%s", fBaseDirectory.Data(), path); |
b05400be | 794 | Bool_t result=kFALSE; |
795 | ||
796 | void* dirPtr = gSystem->OpenDirectory(dirName); | |
797 | if (dirPtr) result=kTRUE; | |
798 | gSystem->FreeDirectory(dirPtr); | |
9e1ceb13 | 799 | |
800 | return result; | |
fe913d8f | 801 | } |
802 | ||
62032124 | 803 | //_____________________________________________________________________________ |
804 | void AliCDBLocal::QueryValidFiles() | |
805 | { | |
c3a7b59a | 806 | // Query the CDB for files valid for AliCDBStorage::fRun |
807 | // fills list fValidFileIds with AliCDBId objects created from file name | |
808 | ||
809 | if(fVersion != -1) AliWarning ("Version parameter is not used by local storage query!"); | |
810 | if(fMetaDataFilter) { | |
811 | AliWarning ("CDB meta data parameters are not used by local storage query!"); | |
812 | delete fMetaDataFilter; fMetaDataFilter=0; | |
813 | } | |
814 | ||
815 | void* storageDirPtr = gSystem->OpenDirectory(fBaseDirectory); | |
816 | ||
817 | const char* level0; | |
818 | while ((level0 = gSystem->GetDirEntry(storageDirPtr))) { | |
819 | ||
820 | TString level0Str(level0); | |
821 | if (level0Str == "." || level0Str == "..") { | |
822 | continue; | |
823 | } | |
824 | ||
825 | if (fPathFilter.Level0Comprises(level0)) { | |
826 | TString level0Dir = Form("%s/%s",fBaseDirectory.Data(),level0); | |
827 | void* level0DirPtr = gSystem->OpenDirectory(level0Dir); | |
828 | const char* level1; | |
829 | while ((level1 = gSystem->GetDirEntry(level0DirPtr))) { | |
830 | ||
831 | TString level1Str(level1); | |
832 | if (level1Str == "." || level1Str == "..") { | |
833 | continue; | |
834 | } | |
835 | ||
836 | if (fPathFilter.Level1Comprises(level1)) { | |
837 | TString level1Dir = Form("%s/%s/%s", | |
838 | fBaseDirectory.Data(),level0,level1); | |
839 | ||
840 | void* level1DirPtr = gSystem->OpenDirectory(level1Dir); | |
841 | const char* level2; | |
842 | while ((level2 = gSystem->GetDirEntry(level1DirPtr))) { | |
843 | ||
844 | TString level2Str(level2); | |
845 | if (level2Str == "." || level2Str == "..") { | |
846 | continue; | |
847 | } | |
848 | ||
849 | if (fPathFilter.Level2Comprises(level2)) { | |
850 | TString dirName = Form("%s/%s/%s/%s", | |
851 | fBaseDirectory.Data(),level0,level1,level2); | |
852 | ||
853 | void* dirPtr = gSystem->OpenDirectory(dirName); | |
854 | ||
855 | const char* filename; | |
856 | ||
857 | AliCDBRunRange aRunRange; // the runRange got from filename | |
858 | Int_t aVersion, aSubVersion; // the version and subVersion got from filename | |
859 | ||
860 | while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files | |
861 | ||
862 | TString aString(filename); | |
863 | if (aString == "." || aString == "..") continue; | |
864 | ||
865 | if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue; | |
866 | AliCDBRunRange runrg(fRun,fRun); | |
867 | if (!aRunRange.Comprises(runrg)) continue; | |
868 | // aRunRange contains requested run! | |
869 | AliCDBPath validPath(level0,level1,level2); | |
870 | AliCDBId validId(validPath,aRunRange,aVersion,aSubVersion); | |
871 | fValidFileIds.AddLast(validId.Clone()); | |
872 | } | |
873 | gSystem->FreeDirectory(dirPtr); | |
874 | } | |
875 | } | |
876 | gSystem->FreeDirectory(level1DirPtr); | |
877 | } | |
878 | } | |
879 | gSystem->FreeDirectory(level0DirPtr); | |
880 | } | |
881 | } | |
882 | gSystem->FreeDirectory(storageDirPtr); | |
883 | ||
884 | } | |
885 | ||
886 | //_____________________________________________________________________________ | |
887 | Int_t AliCDBLocal::GetLatestVersion(const char* path, Int_t run){ | |
888 | // get last version found in the database valid for run and path | |
889 | ||
890 | AliCDBPath aCDBPath(path); | |
891 | if(!aCDBPath.IsValid() || aCDBPath.IsWildcard()) { | |
892 | AliError(Form("Invalid path in request: %s", path)); | |
893 | return -1; | |
894 | } | |
895 | ||
896 | AliCDBId query(path, run, run, -1, -1); | |
4667c116 | 897 | AliCDBId* dataId = GetId(query); |
898 | ||
899 | if(!dataId) return -1; | |
c3a7b59a | 900 | |
4667c116 | 901 | Int_t version = dataId->GetVersion(); |
902 | delete dataId; | |
c3a7b59a | 903 | |
4667c116 | 904 | return version; |
c3a7b59a | 905 | |
906 | } | |
907 | ||
908 | //_____________________________________________________________________________ | |
909 | Int_t AliCDBLocal::GetLatestSubVersion(const char* path, Int_t run, Int_t version){ | |
910 | // get last version found in the database valid for run and path | |
911 | ||
912 | AliCDBPath aCDBPath(path); | |
913 | if(!aCDBPath.IsValid() || aCDBPath.IsWildcard()) { | |
914 | AliError(Form("Invalid path in request: %s", path)); | |
915 | return -1; | |
916 | } | |
917 | ||
918 | AliCDBId query(path, run, run, version, -1); | |
4667c116 | 919 | AliCDBId *dataId = GetId(query); |
920 | ||
921 | if(!dataId) return -1; | |
c3a7b59a | 922 | |
4667c116 | 923 | Int_t subVersion = dataId->GetSubVersion(); |
c3a7b59a | 924 | |
4667c116 | 925 | delete dataId; |
926 | return subVersion; | |
62032124 | 927 | |
928 | } | |
929 | ||
9e1ceb13 | 930 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
931 | // // | |
932 | // AliCDBLocal factory // | |
933 | // // | |
934 | ///////////////////////////////////////////////////////////////////////////////////////////////// | |
935 | ||
936 | ClassImp(AliCDBLocalFactory) | |
937 | ||
938 | //_____________________________________________________________________________ | |
939 | Bool_t AliCDBLocalFactory::Validate(const char* dbString) { | |
940 | // check if the string is valid local URI | |
941 | ||
942 | TRegexp dbPattern("^local://.+$"); | |
943 | ||
944 | return TString(dbString).Contains(dbPattern); | |
fe913d8f | 945 | } |
946 | ||
9e1ceb13 | 947 | //_____________________________________________________________________________ |
948 | AliCDBParam* AliCDBLocalFactory::CreateParameter(const char* dbString) { | |
949 | // create AliCDBLocalParam class from the URI string | |
950 | ||
951 | if (!Validate(dbString)) { | |
952 | return NULL; | |
953 | } | |
954 | ||
955 | TString pathname(dbString + sizeof("local://") - 1); | |
956 | ||
957 | gSystem->ExpandPathName(pathname); | |
958 | ||
959 | if (pathname[0] != '/') { | |
960 | pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/'); | |
961 | } | |
962 | ||
4667c116 | 963 | return new AliCDBLocalParam(pathname); |
fe913d8f | 964 | } |
965 | ||
9e1ceb13 | 966 | //_____________________________________________________________________________ |
967 | AliCDBStorage* AliCDBLocalFactory::Create(const AliCDBParam* param) { | |
968 | // create AliCDBLocal storage instance from parameters | |
969 | ||
970 | if (AliCDBLocalParam::Class() == param->IsA()) { | |
971 | ||
972 | const AliCDBLocalParam* localParam = | |
973 | (const AliCDBLocalParam*) param; | |
974 | ||
975 | return new AliCDBLocal(localParam->GetPath()); | |
976 | } | |
fe913d8f | 977 | |
9e1ceb13 | 978 | return NULL; |
fe913d8f | 979 | } |
980 | ||
9e1ceb13 | 981 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
982 | // // | |
983 | // AliCDBLocal Parameter class // // | |
984 | // // | |
985 | ///////////////////////////////////////////////////////////////////////////////////////////////// | |
986 | ||
987 | ClassImp(AliCDBLocalParam) | |
988 | ||
fe913d8f | 989 | //_____________________________________________________________________________ |
62032124 | 990 | AliCDBLocalParam::AliCDBLocalParam(): |
991 | AliCDBParam(), | |
992 | fDBPath() | |
993 | { | |
9e1ceb13 | 994 | // default constructor |
fe913d8f | 995 | |
fe913d8f | 996 | } |
997 | ||
9e1ceb13 | 998 | //_____________________________________________________________________________ |
999 | AliCDBLocalParam::AliCDBLocalParam(const char* dbPath): | |
62032124 | 1000 | AliCDBParam(), |
1001 | fDBPath(dbPath) | |
1002 | { | |
9e1ceb13 | 1003 | // constructor |
1004 | ||
1005 | SetType("local"); | |
1006 | SetURI(TString("local://") + dbPath); | |
1007 | } | |
1008 | ||
1009 | //_____________________________________________________________________________ | |
1010 | AliCDBLocalParam::~AliCDBLocalParam() { | |
1011 | // destructor | |
1012 | ||
1013 | } | |
fe913d8f | 1014 | |
1015 | //_____________________________________________________________________________ | |
9e1ceb13 | 1016 | AliCDBParam* AliCDBLocalParam::CloneParam() const { |
1017 | // clone parameter | |
1018 | ||
1019 | return new AliCDBLocalParam(fDBPath); | |
fe913d8f | 1020 | } |
fe913d8f | 1021 | |
9e1ceb13 | 1022 | //_____________________________________________________________________________ |
1023 | ULong_t AliCDBLocalParam::Hash() const { | |
1024 | // return Hash function | |
1025 | ||
1026 | return fDBPath.Hash(); | |
fe913d8f | 1027 | } |
9e1ceb13 | 1028 | |
1029 | //_____________________________________________________________________________ | |
1030 | Bool_t AliCDBLocalParam::IsEqual(const TObject* obj) const { | |
1031 | // check if this object is equal to AliCDBParam obj | |
1032 | ||
1033 | if (this == obj) { | |
1034 | return kTRUE; | |
1035 | } | |
1036 | ||
1037 | if (AliCDBLocalParam::Class() != obj->IsA()) { | |
1038 | return kFALSE; | |
1039 | } | |
1040 | ||
1041 | AliCDBLocalParam* other = (AliCDBLocalParam*) obj; | |
1042 | ||
1043 | return fDBPath == other->fDBPath; | |
1044 | } | |
1045 |