* provided "as is" without express or implied warranty. *
**************************************************************************/
+#include <TKey.h>
+#include <TH1.h>
#include "AliCDBManager.h"
#include "AliCDBStorage.h"
}
//_____________________________________________________________________________
-AliCDBId AliCDBStorage::GetSelection(const AliCDBId& id) {
+void AliCDBStorage::GetSelection(/*const*/ AliCDBId* id) {
// return required version and subversion from the list of selection criteria
TIter iter(&fSelections);
// loop on the list of selection criteria
while ((aSelection = (AliCDBId*) iter.Next())) {
// check if selection element contains id's path and run (range)
- if (aSelection->Comprises(id)) {
- AliInfo(Form("Using selection criterion: %s ", aSelection->ToString().Data()));
+ if (aSelection->Comprises(*id)) {
+ AliDebug(2,Form("Using selection criterion: %s ", aSelection->ToString().Data()));
// return required version and subversion
- return AliCDBId(id.GetAliCDBPath(),
- id.GetAliCDBRunRange(),
- aSelection->GetVersion(),
- aSelection->GetSubVersion());
+
+ id->SetVersion(aSelection->GetVersion());
+ id->SetSubVersion(aSelection->GetSubVersion());
+ return;
}
}
// no valid element is found in the list of selection criteria -> return
- AliInfo("No matching selection criteria: highest version will be seeked!");
- return AliCDBId(id.GetAliCDBPath(), id.GetAliCDBRunRange());
+ AliDebug(2,"Looking for objects with most recent version");
+ return;
+}
+
+//_____________________________________________________________________________
+void AliCDBStorage::ReadSelectionFromFile(const char *fileName){
+// read selection criteria list from file
+
+ RemoveAllSelections();
+
+ TList *list = GetIdListFromFile(fileName);
+ if(!list) return;
+
+ list->SetOwner();
+ Int_t nId = list->GetEntries();
+ AliCDBId *id;
+ TKey *key;
+
+ for(int i=nId-1;i>=0;i--){
+ key = (TKey*) list->At(i);
+ id = (AliCDBId*) key->ReadObj();
+ if(id) AddSelection(*id);
+ }
+ delete list;
+ AliInfo(Form("Selection criteria list filled with %d entries",fSelections.GetEntries()));
+ PrintSelectionList();
+
}
//_____________________________________________________________________________
query.ToString().Data()));
return NULL;
}
+
+ // This is needed otherwise TH1 objects (histos, TTree's) are lost when file is closed!
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
AliCDBEntry* entry = GetEntry(query);
+
+ if (oldStatus != kFALSE)
+ TH1::AddDirectory(kTRUE);
if (entry) {
- AliInfo(Form("Valid AliCDBEntry object found! %s", entry->GetId().ToString().Data()));
+ AliInfo(Form("CDB object retrieved: %s", entry->GetId().ToString().Data()));
} else {
- AliInfo(Form("Sorry, found no object valid for: name = <%s>, run = %d",
+ AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d",
(query.GetPath()).Data(), query.GetFirstRun()));
}
return NULL;
}
+ // This is needed otherwise TH1 objects (histos, TTree's) are lost when file is closed!
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
TList *result = GetEntries(query);
+ if (oldStatus != kFALSE)
+ TH1::AddDirectory(kTRUE);
+
Int_t nEntries = result->GetEntries();
if (nEntries) {
- AliInfo(Form("%d AliCDBEntry objects found!",nEntries));
+ AliInfo(Form("%d AliCDBEntry objects retrieved.",nEntries));
for(int i=0; i<nEntries;i++){
AliCDBEntry *entry = (AliCDBEntry*) result->At(i);
AliInfo(Form("%s",entry->GetId().ToString().Data()));
}
} else {
- AliInfo(Form("Sorry, found no object valid for: name = <%s>, run = %d",
- (query.GetPath()).Data(), query.GetFirstRun()));
+ AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d, version = %d",
+ (query.GetPath()).Data(), query.GetFirstRun(), query.GetVersion()));
}
// if drain storage is set, drain entries into drain storage
//_____________________________________________________________________________
Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData) {
-// put an AliCDBEntry object from the database
+// store an AliCDBEntry object into the database
AliCDBEntry anEntry(object, id, metaData);
//_____________________________________________________________________________
Bool_t AliCDBStorage::Put(AliCDBEntry* entry) {
-// put an AliCDBEntry object from the database
+// store an AliCDBEntry object into the database
+ if (!entry){
+ AliError("No entry!");
+ return kFALSE;
+ }
+
if (!entry->GetId().IsValid()) {
- AliWarning(Form("Invalid entry ID: %s",
+ AliError(Form("Invalid entry ID: %s",
entry->GetId().ToString().Data()));
return kFALSE;
}
return kFALSE;
}
+ // set object's class name into metaData!
+ entry->GetMetaData()->SetObjectClassName(entry->GetObject()->ClassName());
+
return PutEntry(entry);
}