X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliCDBStorage.cxx;h=16283e4d30cbf686df179803068731696334f882;hb=5aedd7092c557113d6b1c82670e49181d18b18f8;hp=a82c176d25cdc1da3bd2ed206f286b886377a1b2;hpb=620321242adc863f8edba964e55ab8ee5475abbd;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliCDBStorage.cxx b/STEER/AliCDBStorage.cxx index a82c176d25c..16283e4d30c 100644 --- a/STEER/AliCDBStorage.cxx +++ b/STEER/AliCDBStorage.cxx @@ -15,8 +15,11 @@ #include #include -#include "AliCDBManager.h" +#include +#include +#include #include "AliCDBStorage.h" +#include "AliCDBGrid.h" #include "AliCDBEntry.h" #include "AliLog.h" @@ -200,7 +203,7 @@ void AliCDBStorage::PrintSelectionList(){ //_____________________________________________________________________________ AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) { // get an AliCDBEntry object from the database - + // check if query's path and runRange are valid // query is invalid also if version is not specified and subversion is! if (!query.IsValid()) { @@ -208,9 +211,9 @@ AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) { return NULL; } - // query is not specified if path contains wildcard or runrange = [-1,-1] + // query is not specified if path contains wildcard or runrange = [-1,-1] if (!query.IsSpecified()) { - AliError(Form("Unspecified query: %s", + AliError(Form("Unspecified query: %s", query.ToString().Data())); return NULL; } @@ -227,12 +230,11 @@ AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) { if (entry) { // this is to make the SHUTTLE output lighter if(!(query.GetPath().Contains("SHUTTLE/STATUS"))) - AliInfo(Form("CDB object retrieved: %s", entry->GetId().ToString().Data())); + AliDebug(2, Form("CDB object retrieved: %s", entry->GetId().ToString().Data())); } else { // this is to make the SHUTTLE output lighter if(!(query.GetPath().Contains("SHUTTLE/STATUS"))) - AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d", - (query.GetPath()).Data(), query.GetFirstRun())); + AliInfo(Form("No valid CDB object found! request was: %s", query.ToString().Data())); } // if drain storage is set, drain entry into drain storage @@ -243,7 +245,7 @@ AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) { } //_____________________________________________________________________________ -AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, Int_t runNumber, +AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, Int_t runNumber, Int_t version, Int_t subVersion) { // get an AliCDBEntry object from the database @@ -251,7 +253,7 @@ AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, Int_t runNumber, } //_____________________________________________________________________________ -AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, +AliCDBEntry* AliCDBStorage::Get(const AliCDBPath& path, const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) { // get an AliCDBEntry object from the database @@ -285,18 +287,15 @@ TList* AliCDBStorage::GetAll(const AliCDBId& query) { TH1::AddDirectory(kTRUE); Int_t nEntries = result->GetEntries(); - if (nEntries) { - AliInfo(Form("%d objects retrieved.",nEntries)); - for(int i=0; iAt(i); - AliInfo(Form("%s",entry->GetId().ToString().Data())); - - } - } else { - AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d, version = %d", - (query.GetPath()).Data(), query.GetFirstRun(), query.GetVersion())); + + AliInfo(Form("%d objects retrieved. Request was: %s", + nEntries, query.ToString().Data())); + for(int i=0; iAt(i); + AliInfo(Form("%s",entry->GetId().ToString().Data())); } + // if drain storage is set, drain entries into drain storage if((AliCDBManager::Instance())->IsDrainSet()){ for(int i = 0; iGetEntries(); i++){ @@ -326,18 +325,57 @@ TList* AliCDBStorage::GetAll(const AliCDBPath& path, return GetAll(AliCDBId(path, runRange, version, subVersion)); } +//_____________________________________________________________________________ +AliCDBId* AliCDBStorage::GetId(const AliCDBId& query) { +// get the Id of the valid object from the database (does not open the file) + + // check if query's path and runRange are valid + // query is invalid also if version is not specified and subversion is! + if (!query.IsValid()) { + AliError(Form("Invalid query: %s", query.ToString().Data())); + return NULL; + } + + // query is not specified if path contains wildcard or runrange = [-1,-1] + if (!query.IsSpecified()) { + AliError(Form("Unspecified query: %s", + query.ToString().Data())); + return NULL; + } + + AliCDBId* id = GetEntryId(query); + + return id; +} + +//_____________________________________________________________________________ +AliCDBId* AliCDBStorage::GetId(const AliCDBPath& path, Int_t runNumber, + Int_t version, Int_t subVersion) { +// get the Id of the valid object from the database (does not open the file) + + return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion)); +} + +//_____________________________________________________________________________ +AliCDBId* AliCDBStorage::GetId(const AliCDBPath& path, + const AliCDBRunRange& runRange, Int_t version, + Int_t subVersion) { +// get the Id of the valid object from the database (does not open the file) + + return GetId(AliCDBId(path, runRange, version, subVersion)); +} //_____________________________________________________________________________ -Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData) { +Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, AliCDBManager::DataType type) { // store an AliCDBEntry object into the database AliCDBEntry anEntry(object, id, metaData); - return Put(&anEntry); -} + return Put(&anEntry, type); +} //_____________________________________________________________________________ -Bool_t AliCDBStorage::Put(AliCDBEntry* entry) { +Bool_t AliCDBStorage::Put(AliCDBEntry* entry, AliCDBManager::DataType type) { // store an AliCDBEntry object into the database if (!entry){ @@ -357,6 +395,15 @@ Bool_t AliCDBStorage::Put(AliCDBEntry* entry) { return kFALSE; } + AliCDBManager::DataType expectedType = GetDataType(); + + if(expectedType != AliCDBManager::kPrivate && type != expectedType) { + AliError(Form("It is forbidden to store %s data into a folder of type %s!", + AliCDBManager::GetDataTypeName(type), + AliCDBManager::GetDataTypeName(expectedType))); + return 0; + } + // set object's class name into metaData! entry->GetMetaData()->SetObjectClassName(entry->GetObject()->ClassName()); @@ -364,7 +411,7 @@ Bool_t AliCDBStorage::Put(AliCDBEntry* entry) { } //_____________________________________________________________________________ -void AliCDBStorage::QueryCDB(Long64_t run, const char* pathFilter, +void AliCDBStorage::QueryCDB(Int_t run, const char* pathFilter, Int_t version, AliCDBMetaData* md){ // query CDB for files valid for given run, and fill list fValidFileIds // Actual query is done in virtual function QueryValidFiles() @@ -380,6 +427,9 @@ void AliCDBStorage::QueryCDB(Long64_t run, const char* pathFilter, fVersion = version; + AliInfo(Form("Querying files valid for run %d and path \"%s\" into CDB storage \"%s://%s\"", + fRun, pathFilter, fType.Data(), fBaseFolder.Data())); + // Clear fValidFileIds list (it cannot be filled twice! AliDebug(2, "Clearing list of CDB Id's previously loaded"); fValidFileIds.Clear(); @@ -388,10 +438,9 @@ void AliCDBStorage::QueryCDB(Long64_t run, const char* pathFilter, if(md) fMetaDataFilter = dynamic_cast (md->Clone()); QueryValidFiles(); + AliCDBId queryId(pathFilter,run,run,version); - AliInfo(Form("%d files valid for run %ld, path %s and version %d found in CDB storage: \n %s://%s", - fValidFileIds.GetEntries(), (long) fRun, pathFilter, version, - fType.Data(), fBaseFolder.Data())); + AliInfo(Form("%d valid files found!", fValidFileIds.GetEntriesFast())); } @@ -399,22 +448,89 @@ void AliCDBStorage::QueryCDB(Long64_t run, const char* pathFilter, void AliCDBStorage::PrintQueryCDB(){ // print parameters used to load list of CDB Id's (fRun, fPathFilter, fVersion) - AliInfo(Form("QueryCDB Parameters: \n\tRun = %ld \n\tPath filter = %s \n\tVersion = %d", - (long) fRun, fPathFilter.GetPath().Data(), fVersion)); + AliCDBId paramId(fPathFilter, fRun, fRun, fVersion); + AliInfo(Form("**** QueryCDB Parameters **** \n\t<%s>\n", + paramId.ToString().Data())); - if(fMetaDataFilter) { - AliInfo("CDBMetaData Parameters: "); - } - fMetaDataFilter->PrintMetaData(); + if(fMetaDataFilter) fMetaDataFilter->PrintMetaData(); - AliInfo("Id's of valid objects found:"); + + TString message = "**** Id's of valid objects found *****\n"; TIter iter(&fValidFileIds); AliCDBId* anId=0; // loop on the list of selection criteria while ((anId = dynamic_cast(iter.Next()))) { - AliInfo(Form("%s", anId->ToString().Data())); + message += Form("\t%s\n", anId->ToString().Data()); + } + message += Form("\n\tTotal: %d objects found\n", fValidFileIds.GetEntriesFast()); + AliInfo(Form("%s", message.Data())); +} + +//_____________________________________________________________________________ +AliCDBManager::DataType AliCDBStorage::GetDataType() const { +// returns the type of the data that should be stored into this storage: +// kConditions: conditions data; kReference: reference data; kPrivate: private (user-defined) data type + + if(GetType() != "alien") return AliCDBManager::kPrivate; + + TString condFolder = ((AliCDBGridParam*) AliCDBManager::Instance()->GetCondParam())->GetDBFolder(); + TString refFolder = ((AliCDBGridParam*) AliCDBManager::Instance()->GetRefParam())->GetDBFolder(); + + if(GetBaseFolder().Contains(condFolder)) return AliCDBManager::kCondition; + if(GetBaseFolder().Contains(refFolder)) return AliCDBManager::kReference; + + return AliCDBManager::kPrivate; +} + +//_____________________________________________________________________________ +void AliCDBStorage::LoadTreeFromFile(AliCDBEntry *entry) const { +// Checks whether entry contains a TTree and in case loads it into memory + + TObject *obj = (TObject*) entry->GetObject(); + + if (!strcmp(obj->ClassName(),TTree::Class_Name())) { + + AliWarning("Entry contains a TTree! Loading baskets..."); + + TTree* tree = dynamic_cast (obj); + + if(!tree) return; + + tree->LoadBaskets(); + tree->SetDirectory(0); } + else if (!strcmp(obj->ClassName(),TNtuple::Class_Name())){ + + AliWarning("Entry contains a TNtuple! Loading baskets..."); + + TNtuple* ntu = dynamic_cast (obj); + + if(!ntu) return; + ntu->LoadBaskets(); + ntu->SetDirectory(0); + } + + return; } +// //_____________________________________________________________________________ +// void AliCDBStorage::SetTreeToFile(AliCDBEntry *entry, TFile* file) const { +// // Checks whether entry contains a TTree and in case assigns it to memory +// +// AliCDBMetaData *md = dynamic_cast (entry->GetMetaData()); +// if(!md) return; +// TString objStr = md->GetObjectClassName(); +// if(objStr != "TTree") return; +// AliWarning("Entry contains a TTree! Setting file..."); +// +// TTree* tree = dynamic_cast (entry->GetObject()); +// +// if(!tree) return; +// +// // tree->SetDirectory(file); +// tree->SetDirectory(0); +// +// return; +// }