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