]>
Commit | Line | Data |
---|---|---|
2c8628dd | 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 | ||
b05400be | 16 | #include <TKey.h> |
02c4845e | 17 | #include <TH1.h> |
145f45a2 | 18 | #include <TTree.h> |
ed343d5e | 19 | #include <TNtuple.h> |
145f45a2 | 20 | #include <TFile.h> |
fe913d8f | 21 | #include "AliCDBStorage.h" |
b8ec52f6 | 22 | #include "AliCDBGrid.h" |
2c8628dd | 23 | |
9e1ceb13 | 24 | #include "AliCDBEntry.h" |
25 | #include "AliLog.h" | |
2c8628dd | 26 | |
fe913d8f | 27 | ClassImp(AliCDBStorage) |
2c8628dd | 28 | |
9e1ceb13 | 29 | //_____________________________________________________________________________ |
62032124 | 30 | AliCDBStorage::AliCDBStorage(): |
31 | fValidFileIds(), | |
32 | fRun(-1), | |
33 | fPathFilter(), | |
34 | fVersion(-1), | |
35 | fMetaDataFilter(0), | |
36 | fSelections(), | |
37 | fURI(), | |
38 | fType(), | |
89004e35 | 39 | fBaseFolder(), |
40 | fNretry(0), | |
5bfe3965 | 41 | fInitRetrySeconds(0) |
62032124 | 42 | { |
9e1ceb13 | 43 | // constructor |
44 | ||
62032124 | 45 | fValidFileIds.SetOwner(1); |
9e1ceb13 | 46 | fSelections.SetOwner(1); |
47 | } | |
2c8628dd | 48 | |
9e1ceb13 | 49 | //_____________________________________________________________________________ |
50 | AliCDBStorage::~AliCDBStorage() { | |
51 | // destructor | |
2c8628dd | 52 | |
62032124 | 53 | RemoveAllSelections(); |
54 | fValidFileIds.Clear(); | |
55 | delete fMetaDataFilter; | |
56 | ||
9e1ceb13 | 57 | } |
2c8628dd | 58 | |
59 | //_____________________________________________________________________________ | |
4b5e0dce | 60 | void AliCDBStorage::GetSelection(/*const*/ AliCDBId* id) { |
0f678e35 | 61 | // return required version and subversion from the list of selection criteria |
9e1ceb13 | 62 | |
63 | TIter iter(&fSelections); | |
64 | AliCDBId* aSelection; | |
65 | ||
66 | // loop on the list of selection criteria | |
67 | while ((aSelection = (AliCDBId*) iter.Next())) { | |
68 | // check if selection element contains id's path and run (range) | |
4b5e0dce | 69 | if (aSelection->Comprises(*id)) { |
b05400be | 70 | AliDebug(2,Form("Using selection criterion: %s ", aSelection->ToString().Data())); |
9e1ceb13 | 71 | // return required version and subversion |
4b5e0dce | 72 | |
73 | id->SetVersion(aSelection->GetVersion()); | |
74 | id->SetSubVersion(aSelection->GetSubVersion()); | |
75 | return; | |
9e1ceb13 | 76 | } |
77 | } | |
78 | ||
79 | // no valid element is found in the list of selection criteria -> return | |
b05400be | 80 | AliDebug(2,"Looking for objects with most recent version"); |
4b5e0dce | 81 | return; |
2c8628dd | 82 | } |
83 | ||
b05400be | 84 | //_____________________________________________________________________________ |
85 | void AliCDBStorage::ReadSelectionFromFile(const char *fileName){ | |
86 | // read selection criteria list from file | |
87 | ||
88 | RemoveAllSelections(); | |
89 | ||
90 | TList *list = GetIdListFromFile(fileName); | |
91 | if(!list) return; | |
92 | ||
93 | list->SetOwner(); | |
94 | Int_t nId = list->GetEntries(); | |
95 | AliCDBId *id; | |
96 | TKey *key; | |
97 | ||
98 | for(int i=nId-1;i>=0;i--){ | |
99 | key = (TKey*) list->At(i); | |
100 | id = (AliCDBId*) key->ReadObj(); | |
101 | if(id) AddSelection(*id); | |
102 | } | |
103 | delete list; | |
104 | AliInfo(Form("Selection criteria list filled with %d entries",fSelections.GetEntries())); | |
105 | PrintSelectionList(); | |
106 | ||
107 | } | |
108 | ||
2c8628dd | 109 | //_____________________________________________________________________________ |
9e1ceb13 | 110 | void AliCDBStorage::AddSelection(const AliCDBId& selection) { |
111 | // add a selection criterion | |
112 | ||
113 | AliCDBPath path = selection.GetPath(); | |
114 | if(!path.IsValid()) return; | |
115 | ||
116 | TIter iter(&fSelections); | |
117 | const AliCDBId *anId; | |
118 | while((anId = (AliCDBId*) iter.Next())){ | |
119 | if(selection.Comprises(*anId)){ | |
120 | AliWarning("This selection is more general than a previous one and will hide it!"); | |
121 | AliWarning(Form("%s", (anId->ToString()).Data())); | |
122 | fSelections.AddBefore(anId, new AliCDBId(selection)); | |
123 | return; | |
124 | } | |
125 | ||
126 | } | |
127 | fSelections.AddFirst(new AliCDBId(selection)); | |
128 | } | |
2c8628dd | 129 | |
130 | //_____________________________________________________________________________ | |
62032124 | 131 | void AliCDBStorage::AddSelection(const AliCDBPath& path, |
9e1ceb13 | 132 | const AliCDBRunRange& runRange, Int_t version, Int_t subVersion){ |
133 | // add a selection criterion | |
2c8628dd | 134 | |
9e1ceb13 | 135 | AddSelection(AliCDBId(path, runRange, version, subVersion)); |
2c8628dd | 136 | } |
137 | ||
9e1ceb13 | 138 | //_____________________________________________________________________________ |
139 | void AliCDBStorage::AddSelection(const AliCDBPath& path, | |
140 | Int_t firstRun, Int_t lastRun, Int_t version, Int_t subVersion){ | |
141 | // add a selection criterion | |
142 | ||
143 | AddSelection(AliCDBId(path, firstRun, lastRun, version, subVersion)); | |
144 | } | |
2c8628dd | 145 | |
9e1ceb13 | 146 | //_____________________________________________________________________________ |
147 | void AliCDBStorage::RemoveSelection(const AliCDBId& selection) { | |
148 | // remove a selection criterion | |
2c8628dd | 149 | |
9e1ceb13 | 150 | TIter iter(&fSelections); |
151 | AliCDBId* aSelection; | |
2c8628dd | 152 | |
9e1ceb13 | 153 | while ((aSelection = (AliCDBId*) iter.Next())) { |
154 | if (selection.Comprises(*aSelection)) { | |
155 | fSelections.Remove(aSelection); | |
156 | } | |
157 | } | |
158 | } | |
2c8628dd | 159 | |
9e1ceb13 | 160 | //_____________________________________________________________________________ |
161 | void AliCDBStorage::RemoveSelection(const AliCDBPath& path, | |
162 | const AliCDBRunRange& runRange){ | |
163 | // remove a selection criterion | |
2c8628dd | 164 | |
9e1ceb13 | 165 | RemoveSelection(AliCDBId(path, runRange, -1, -1)); |
166 | } | |
f05209ee | 167 | |
9e1ceb13 | 168 | //_____________________________________________________________________________ |
169 | void AliCDBStorage::RemoveSelection(const AliCDBPath& path, | |
170 | Int_t firstRun, Int_t lastRun){ | |
171 | // remove a selection criterion | |
f05209ee | 172 | |
9e1ceb13 | 173 | RemoveSelection(AliCDBId(path, firstRun, lastRun, -1, -1)); |
174 | } | |
f05209ee | 175 | |
9e1ceb13 | 176 | //_____________________________________________________________________________ |
eb0b1051 | 177 | void AliCDBStorage::RemoveSelection(int position){ |
9e1ceb13 | 178 | // remove a selection criterion from its position in the list |
2c8628dd | 179 | |
62032124 | 180 | delete fSelections.RemoveAt(position); |
2c8628dd | 181 | } |
182 | ||
2c8628dd | 183 | //_____________________________________________________________________________ |
9e1ceb13 | 184 | void AliCDBStorage::RemoveAllSelections(){ |
185 | // remove all selection criteria | |
2c8628dd | 186 | |
62032124 | 187 | fSelections.Clear(); |
9e1ceb13 | 188 | } |
fe913d8f | 189 | |
9e1ceb13 | 190 | //_____________________________________________________________________________ |
191 | void AliCDBStorage::PrintSelectionList(){ | |
192 | // prints the list of selection criteria | |
193 | ||
194 | TIter iter(&fSelections); | |
195 | AliCDBId* aSelection; | |
62032124 | 196 | |
9e1ceb13 | 197 | // loop on the list of selection criteria |
198 | int index=0; | |
199 | while ((aSelection = (AliCDBId*) iter.Next())) { | |
200 | AliInfo(Form("index %d -> selection: %s",index++, aSelection->ToString().Data())); | |
201 | } | |
fe913d8f | 202 | |
9e1ceb13 | 203 | } |
fe913d8f | 204 | |
9e1ceb13 | 205 | //_____________________________________________________________________________ |
0f678e35 | 206 | AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) { |
9e1ceb13 | 207 | // get an AliCDBEntry object from the database |
4667c116 | 208 | |
9e1ceb13 | 209 | // check if query's path and runRange are valid |
210 | // query is invalid also if version is not specified and subversion is! | |
211 | if (!query.IsValid()) { | |
212 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
213 | return NULL; | |
214 | } | |
215 | ||
4667c116 | 216 | // query is not specified if path contains wildcard or runrange = [-1,-1] |
9e1ceb13 | 217 | if (!query.IsSpecified()) { |
4667c116 | 218 | AliError(Form("Unspecified query: %s", |
9e1ceb13 | 219 | query.ToString().Data())); |
220 | return NULL; | |
221 | } | |
62032124 | 222 | |
02c4845e | 223 | // This is needed otherwise TH1 objects (histos, TTree's) are lost when file is closed! |
224 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
225 | TH1::AddDirectory(kFALSE); | |
9e1ceb13 | 226 | |
227 | AliCDBEntry* entry = GetEntry(query); | |
02c4845e | 228 | |
229 | if (oldStatus != kFALSE) | |
230 | TH1::AddDirectory(kTRUE); | |
0f678e35 | 231 | |
9e1ceb13 | 232 | if (entry) { |
62032124 | 233 | // this is to make the SHUTTLE output lighter |
234 | if(!(query.GetPath().Contains("SHUTTLE/STATUS"))) | |
b8ec52f6 | 235 | AliDebug(2, Form("CDB object retrieved: %s", entry->GetId().ToString().Data())); |
9e1ceb13 | 236 | } else { |
62032124 | 237 | // this is to make the SHUTTLE output lighter |
f6c857dc | 238 | if(!(query.GetPath().Contains("SHUTTLE/STATUS"))){ |
239 | ||
240 | if(!(query.GetPath().Contains("SHUTTLE"))){ | |
241 | AliFatal(Form("No valid CDB object found! request was: %s", query.ToString().Data())); | |
242 | } | |
243 | else { | |
244 | AliInfo(Form("No valid CDB object found! request was: %s", query.ToString().Data())); | |
245 | } | |
b6102d21 | 246 | } |
9e1ceb13 | 247 | } |
0f678e35 | 248 | |
9e1ceb13 | 249 | // if drain storage is set, drain entry into drain storage |
250 | if(entry && (AliCDBManager::Instance())->IsDrainSet()) | |
251 | AliCDBManager::Instance()->Drain(entry); | |
0f678e35 | 252 | |
9e1ceb13 | 253 | return entry; |
2c8628dd | 254 | } |
255 | ||
256 | //_____________________________________________________________________________ | |
4667c116 | 257 | AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, Int_t runNumber, |
9e1ceb13 | 258 | Int_t version, Int_t subVersion) { |
259 | // get an AliCDBEntry object from the database | |
2c8628dd | 260 | |
9e1ceb13 | 261 | return Get(AliCDBId(path, runNumber, runNumber, version, subVersion)); |
2c8628dd | 262 | } |
263 | ||
2c8628dd | 264 | //_____________________________________________________________________________ |
4667c116 | 265 | AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, |
9e1ceb13 | 266 | const AliCDBRunRange& runRange, Int_t version, |
267 | Int_t subVersion) { | |
268 | // get an AliCDBEntry object from the database | |
2c8628dd | 269 | |
9e1ceb13 | 270 | return Get(AliCDBId(path, runRange, version, subVersion)); |
2c8628dd | 271 | } |
272 | ||
2c8628dd | 273 | //_____________________________________________________________________________ |
9e1ceb13 | 274 | TList* AliCDBStorage::GetAll(const AliCDBId& query) { |
275 | // get multiple AliCDBEntry objects from the database | |
276 | ||
277 | ||
278 | if (!query.IsValid()) { | |
279 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
280 | return NULL; | |
281 | } | |
282 | ||
283 | if (query.IsAnyRange()) { | |
284 | AliError(Form("Unspecified run or runrange: %s", | |
285 | query.ToString().Data())); | |
286 | return NULL; | |
287 | } | |
288 | ||
02c4845e | 289 | // This is needed otherwise TH1 objects (histos, TTree's) are lost when file is closed! |
290 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
291 | TH1::AddDirectory(kFALSE); | |
292 | ||
9e1ceb13 | 293 | TList *result = GetEntries(query); |
294 | ||
02c4845e | 295 | if (oldStatus != kFALSE) |
296 | TH1::AddDirectory(kTRUE); | |
297 | ||
9e1ceb13 | 298 | Int_t nEntries = result->GetEntries(); |
b8ec52f6 | 299 | |
300 | AliInfo(Form("%d objects retrieved. Request was: %s", | |
301 | nEntries, query.ToString().Data())); | |
302 | for(int i=0; i<nEntries;i++){ | |
303 | AliCDBEntry *entry = (AliCDBEntry*) result->At(i); | |
304 | AliInfo(Form("%s",entry->GetId().ToString().Data())); | |
9e1ceb13 | 305 | } |
306 | ||
b8ec52f6 | 307 | |
9e1ceb13 | 308 | // if drain storage is set, drain entries into drain storage |
309 | if((AliCDBManager::Instance())->IsDrainSet()){ | |
310 | for(int i = 0; i<result->GetEntries(); i++){ | |
311 | AliCDBEntry* entry = (AliCDBEntry*) result->At(i); | |
312 | AliCDBManager::Instance()->Drain(entry); | |
313 | } | |
314 | } | |
315 | ||
316 | ||
317 | return result; | |
318 | } | |
2c8628dd | 319 | |
9e1ceb13 | 320 | //_____________________________________________________________________________ |
321 | TList* AliCDBStorage::GetAll(const AliCDBPath& path, Int_t runNumber, | |
322 | Int_t version, Int_t subVersion) { | |
323 | // get multiple AliCDBEntry objects from the database | |
2c8628dd | 324 | |
9e1ceb13 | 325 | return GetAll(AliCDBId(path, runNumber, runNumber, version, |
326 | subVersion)); | |
2c8628dd | 327 | } |
328 | ||
2c8628dd | 329 | //_____________________________________________________________________________ |
9e1ceb13 | 330 | TList* AliCDBStorage::GetAll(const AliCDBPath& path, |
331 | const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) { | |
332 | // get multiple AliCDBEntry objects from the database | |
2c8628dd | 333 | |
9e1ceb13 | 334 | return GetAll(AliCDBId(path, runRange, version, subVersion)); |
2c8628dd | 335 | } |
f05209ee | 336 | |
4667c116 | 337 | //_____________________________________________________________________________ |
338 | AliCDBId* AliCDBStorage::GetId(const AliCDBId& query) { | |
339 | // get the Id of the valid object from the database (does not open the file) | |
340 | ||
341 | // check if query's path and runRange are valid | |
342 | // query is invalid also if version is not specified and subversion is! | |
343 | if (!query.IsValid()) { | |
344 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
345 | return NULL; | |
346 | } | |
347 | ||
348 | // query is not specified if path contains wildcard or runrange = [-1,-1] | |
349 | if (!query.IsSpecified()) { | |
350 | AliError(Form("Unspecified query: %s", | |
351 | query.ToString().Data())); | |
352 | return NULL; | |
353 | } | |
354 | ||
355 | AliCDBId* id = GetEntryId(query); | |
356 | ||
357 | return id; | |
358 | } | |
359 | ||
360 | //_____________________________________________________________________________ | |
361 | AliCDBId* AliCDBStorage::GetId(const AliCDBPath& path, Int_t runNumber, | |
362 | Int_t version, Int_t subVersion) { | |
363 | // get the Id of the valid object from the database (does not open the file) | |
364 | ||
365 | return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion)); | |
366 | } | |
367 | ||
368 | //_____________________________________________________________________________ | |
369 | AliCDBId* AliCDBStorage::GetId(const AliCDBPath& path, | |
370 | const AliCDBRunRange& runRange, Int_t version, | |
371 | Int_t subVersion) { | |
372 | // get the Id of the valid object from the database (does not open the file) | |
373 | ||
374 | return GetId(AliCDBId(path, runRange, version, subVersion)); | |
375 | } | |
f05209ee | 376 | |
377 | //_____________________________________________________________________________ | |
c5941d67 | 378 | Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, const char* mirrors, AliCDBManager::DataType type) { |
02c4845e | 379 | // store an AliCDBEntry object into the database |
9e1ceb13 | 380 | |
968cfa08 | 381 | if (object==0x0) { |
382 | AliError("Null Entry! No storage will be done!"); | |
383 | return kFALSE; | |
384 | } | |
385 | ||
9e1ceb13 | 386 | AliCDBEntry anEntry(object, id, metaData); |
f05209ee | 387 | |
c5941d67 | 388 | return Put(&anEntry, mirrors, type); |
b8ec52f6 | 389 | } |
f05209ee | 390 | |
9e1ceb13 | 391 | //_____________________________________________________________________________ |
06eeadea | 392 | Bool_t AliCDBStorage::Put(AliCDBEntry* entry, const char* mirrors, AliCDBManager::DataType type) { |
02c4845e | 393 | // store an AliCDBEntry object into the database |
9e1ceb13 | 394 | |
02c4845e | 395 | if (!entry){ |
396 | AliError("No entry!"); | |
397 | return kFALSE; | |
398 | } | |
399 | ||
968cfa08 | 400 | if (entry->GetObject()==0x0){ |
401 | AliError("No valid object in CDB entry!"); | |
402 | return kFALSE; | |
403 | } | |
404 | ||
9e1ceb13 | 405 | if (!entry->GetId().IsValid()) { |
62032124 | 406 | AliError(Form("Invalid entry ID: %s", |
9e1ceb13 | 407 | entry->GetId().ToString().Data())); |
408 | return kFALSE; | |
409 | } | |
410 | ||
411 | if (!entry->GetId().IsSpecified()) { | |
62032124 | 412 | AliError(Form("Unspecified entry ID: %s", |
9e1ceb13 | 413 | entry->GetId().ToString().Data())); |
414 | return kFALSE; | |
415 | } | |
416 | ||
b8ec52f6 | 417 | AliCDBManager::DataType expectedType = GetDataType(); |
418 | ||
419 | if(expectedType != AliCDBManager::kPrivate && type != expectedType) { | |
420 | AliError(Form("It is forbidden to store %s data into a folder of type %s!", | |
421 | AliCDBManager::GetDataTypeName(type), | |
422 | AliCDBManager::GetDataTypeName(expectedType))); | |
423 | return 0; | |
424 | } | |
425 | ||
c5941d67 | 426 | |
427 | TString strMirrors(mirrors); | |
428 | if(!strMirrors.IsNull() && !strMirrors.IsWhitespace()) | |
429 | return PutEntry(entry, mirrors); | |
430 | else | |
431 | return PutEntry(entry); | |
f05209ee | 432 | } |
fe913d8f | 433 | |
62032124 | 434 | //_____________________________________________________________________________ |
c3a7b59a | 435 | void AliCDBStorage::QueryCDB(Int_t run, const char* pathFilter, |
62032124 | 436 | Int_t version, AliCDBMetaData* md){ |
437 | // query CDB for files valid for given run, and fill list fValidFileIds | |
438 | // Actual query is done in virtual function QueryValidFiles() | |
439 | ||
440 | fRun = run; | |
441 | ||
442 | fPathFilter = pathFilter; | |
443 | if(!fPathFilter.IsValid()) { | |
444 | AliError(Form("Filter not valid: %s", pathFilter)); | |
445 | fPathFilter = "*"; | |
446 | return; | |
447 | } | |
448 | ||
449 | fVersion = version; | |
450 | ||
6dc56e97 | 451 | AliInfo(Form("Querying files valid for run %d and path \"%s\" into CDB storage \"%s://%s\"", |
452 | fRun, pathFilter, fType.Data(), fBaseFolder.Data())); | |
453 | ||
62032124 | 454 | // Clear fValidFileIds list (it cannot be filled twice! |
455 | AliDebug(2, "Clearing list of CDB Id's previously loaded"); | |
456 | fValidFileIds.Clear(); | |
457 | ||
458 | if(fMetaDataFilter) {delete fMetaDataFilter; fMetaDataFilter=0;} | |
459 | if(md) fMetaDataFilter = dynamic_cast<AliCDBMetaData*> (md->Clone()); | |
460 | ||
461 | QueryValidFiles(); | |
462 | ||
6dc56e97 | 463 | AliInfo(Form("%d valid files found!", fValidFileIds.GetEntriesFast())); |
62032124 | 464 | |
465 | } | |
466 | ||
467 | //_____________________________________________________________________________ | |
468 | void AliCDBStorage::PrintQueryCDB(){ | |
469 | // print parameters used to load list of CDB Id's (fRun, fPathFilter, fVersion) | |
470 | ||
c3a7b59a | 471 | AliCDBId paramId(fPathFilter, fRun, fRun, fVersion); |
472 | AliInfo(Form("**** QueryCDB Parameters **** \n\t<%s>\n", | |
473 | paramId.ToString().Data())); | |
474 | ||
475 | if(fMetaDataFilter) fMetaDataFilter->PrintMetaData(); | |
62032124 | 476 | |
62032124 | 477 | |
c3a7b59a | 478 | TString message = "**** Id's of valid objects found *****\n"; |
62032124 | 479 | TIter iter(&fValidFileIds); |
480 | AliCDBId* anId=0; | |
481 | ||
482 | // loop on the list of selection criteria | |
483 | while ((anId = dynamic_cast<AliCDBId*>(iter.Next()))) { | |
c3a7b59a | 484 | message += Form("\t%s\n", anId->ToString().Data()); |
62032124 | 485 | } |
6dc56e97 | 486 | message += Form("\n\tTotal: %d objects found\n", fValidFileIds.GetEntriesFast()); |
c3a7b59a | 487 | AliInfo(Form("%s", message.Data())); |
62032124 | 488 | } |
489 | ||
b8ec52f6 | 490 | //_____________________________________________________________________________ |
491 | AliCDBManager::DataType AliCDBStorage::GetDataType() const { | |
492 | // returns the type of the data that should be stored into this storage: | |
493 | // kConditions: conditions data; kReference: reference data; kPrivate: private (user-defined) data type | |
494 | ||
495 | if(GetType() != "alien") return AliCDBManager::kPrivate; | |
496 | ||
497 | TString condFolder = ((AliCDBGridParam*) AliCDBManager::Instance()->GetCondParam())->GetDBFolder(); | |
498 | TString refFolder = ((AliCDBGridParam*) AliCDBManager::Instance()->GetRefParam())->GetDBFolder(); | |
499 | ||
500 | if(GetBaseFolder().Contains(condFolder)) return AliCDBManager::kCondition; | |
501 | if(GetBaseFolder().Contains(refFolder)) return AliCDBManager::kReference; | |
502 | ||
503 | return AliCDBManager::kPrivate; | |
504 | } | |
145f45a2 | 505 | |
c5941d67 | 506 | //_____________________________________________________________________________ |
507 | void AliCDBStorage::SetMirrorSEs(const char* mirrors) { | |
508 | // if the current storage is not of "alien" type, just issue a warning | |
509 | // AliCDBGrid implements its own SetMirrorSEs method | |
510 | ||
511 | TString storageType = GetType(); | |
512 | if(storageType != "alien"){ | |
513 | AliWarning(Form("The current storage is of type \"%s\" and cannot handle SEs. Setting skipped!",storageType.Data())); | |
514 | return; | |
515 | } | |
516 | AliError("We should never get here!! AliCDBGrid must have masked this virtual method!"); | |
517 | return; | |
518 | } | |
519 | ||
520 | //_____________________________________________________________________________ | |
521 | const char* AliCDBStorage::GetMirrorSEs() const { | |
522 | // if the current storage is not of "alien" type, just issue a warning | |
523 | // AliCDBGrid implements its own GetMirrorSEs method | |
524 | ||
525 | TString storageType = GetType(); | |
526 | if(storageType != "alien"){ | |
527 | AliWarning(Form("The current storage is of type \"%s\" and cannot handle SEs. Returning empty string!",storageType.Data())); | |
528 | return ""; | |
529 | } | |
530 | AliError("We should never get here!! AliCDBGrid must have masked this virtual method!"); | |
531 | return ""; | |
532 | } | |
533 | ||
145f45a2 | 534 | //_____________________________________________________________________________ |
535 | void AliCDBStorage::LoadTreeFromFile(AliCDBEntry *entry) const { | |
536 | // Checks whether entry contains a TTree and in case loads it into memory | |
537 | ||
ed343d5e | 538 | TObject *obj = (TObject*) entry->GetObject(); |
0a9e4cc8 | 539 | if (!obj) { |
540 | AliError("Cannot retrieve the object:"); | |
541 | entry->PrintMetaData(); | |
542 | return; | |
543 | } | |
145f45a2 | 544 | |
ed343d5e | 545 | if (!strcmp(obj->ClassName(),TTree::Class_Name())) { |
145f45a2 | 546 | |
ed343d5e | 547 | AliWarning("Entry contains a TTree! Loading baskets..."); |
145f45a2 | 548 | |
ed343d5e | 549 | TTree* tree = dynamic_cast<TTree*> (obj); |
145f45a2 | 550 | |
ed343d5e | 551 | if(!tree) return; |
145f45a2 | 552 | |
ed343d5e | 553 | tree->LoadBaskets(); |
554 | tree->SetDirectory(0); | |
555 | } | |
556 | else if (!strcmp(obj->ClassName(),TNtuple::Class_Name())){ | |
145f45a2 | 557 | |
ed343d5e | 558 | AliWarning("Entry contains a TNtuple! Loading baskets..."); |
145f45a2 | 559 | |
ed343d5e | 560 | TNtuple* ntu = dynamic_cast<TNtuple*> (obj); |
145f45a2 | 561 | |
ed343d5e | 562 | if(!ntu) return; |
145f45a2 | 563 | |
ed343d5e | 564 | ntu->LoadBaskets(); |
565 | ntu->SetDirectory(0); | |
566 | } | |
145f45a2 | 567 | |
568 | return; | |
569 | } | |
ed343d5e | 570 | |
571 | // //_____________________________________________________________________________ | |
572 | // void AliCDBStorage::SetTreeToFile(AliCDBEntry *entry, TFile* file) const { | |
573 | // // Checks whether entry contains a TTree and in case assigns it to memory | |
574 | // | |
575 | // AliCDBMetaData *md = dynamic_cast<AliCDBMetaData*> (entry->GetMetaData()); | |
576 | // if(!md) return; | |
577 | // TString objStr = md->GetObjectClassName(); | |
578 | // if(objStr != "TTree") return; | |
579 | // AliWarning("Entry contains a TTree! Setting file..."); | |
580 | // | |
581 | // TTree* tree = dynamic_cast<TTree*> (entry->GetObject()); | |
582 | // | |
583 | // if(!tree) return; | |
584 | // | |
585 | // // tree->SetDirectory(file); | |
586 | // tree->SetDirectory(0); | |
587 | // | |
588 | // return; | |
589 | // } |