]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCDBStorage.cxx
POI's and RP's for LeeYang Zeroes eventplane
[u/mrichter/AliRoot.git] / STEER / AliCDBStorage.cxx
index 7fcebf01e4b07419052bf775f1f2aee6b1233936..d7dc53b062351ccf7f6a3f403f8eaad4065a1efc 100644 (file)
@@ -16,6 +16,7 @@
 #include <TKey.h>
 #include <TH1.h>
 #include <TTree.h>
+#include <TNtuple.h>
 #include <TFile.h>
 #include "AliCDBStorage.h"
 #include "AliCDBGrid.h"
@@ -202,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()) {
@@ -210,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;
        }
@@ -244,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
 
@@ -252,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
@@ -324,11 +325,55 @@ 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, AliCDBManager::DataType type) {
 // store an AliCDBEntry object into the database
        
+       if (object==0x0) {
+               AliError("Null Entry! No storage will be done!");
+               return kFALSE;
+       } 
+
        AliCDBEntry anEntry(object, id, metaData);
 
        return Put(&anEntry, type);
@@ -343,6 +388,11 @@ Bool_t AliCDBStorage::Put(AliCDBEntry* entry, AliCDBManager::DataType type) {
                return kFALSE;
        }
        
+       if (entry->GetObject()==0x0){
+               AliError("No valid object in CDB entry!");
+               return kFALSE;
+       }
+
        if (!entry->GetId().IsValid()) {
                AliError(Form("Invalid entry ID: %s",
                        entry->GetId().ToString().Data()));
@@ -447,37 +497,55 @@ AliCDBManager::DataType AliCDBStorage::GetDataType() const {
 void AliCDBStorage::LoadTreeFromFile(AliCDBEntry *entry) const {
 // Checks whether entry contains a TTree and in case loads it into memory
 
-       AliCDBMetaData *md = dynamic_cast<AliCDBMetaData*> (entry->GetMetaData());
-       if(!md) return;
-       TString objStr = md->GetObjectClassName();
-       if(objStr != "TTree") return;
-       AliWarning("Entry contains a TTree! Loading baskets...");
+       TObject *obj = (TObject*) entry->GetObject();
+       if (!obj) {
+         AliError("Cannot retrieve the object:");
+         entry->PrintMetaData();
+         return;
+       }
 
-       TTree* tree = dynamic_cast<TTree*> (entry->GetObject());
+       if (!strcmp(obj->ClassName(),TTree::Class_Name())) {
 
-       if(!tree) return;
+               AliWarning("Entry contains a TTree! Loading baskets...");
 
-       tree->LoadBaskets();
-       tree->SetDirectory(0);
+               TTree* tree = dynamic_cast<TTree*> (obj);
 
-       return;
-}
+               if(!tree) return;
 
-//_____________________________________________________________________________
-void AliCDBStorage::SetTreeToFile(AliCDBEntry *entry, TFile* file) const {
-// Checks whether entry contains a TTree and in case assigns it to memory
+               tree->LoadBaskets();
+               tree->SetDirectory(0);
+       }
+       else if (!strcmp(obj->ClassName(),TNtuple::Class_Name())){
 
-       AliCDBMetaData *md = dynamic_cast<AliCDBMetaData*> (entry->GetMetaData());
-       if(!md) return;
-       TString objStr = md->GetObjectClassName();
-       if(objStr != "TTree") return;
-       AliWarning("Entry contains a TTree! Setting file...");
+               AliWarning("Entry contains a TNtuple! Loading baskets...");
 
-       TTree* tree = dynamic_cast<TTree*> (entry->GetObject());
+               TNtuple* ntu = dynamic_cast<TNtuple*> (obj);
 
-       if(!tree) return;
+               if(!ntu) return;
 
-       tree->SetDirectory(file);
+               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<AliCDBMetaData*> (entry->GetMetaData());
+//     if(!md) return;
+//     TString objStr = md->GetObjectClassName();
+//     if(objStr != "TTree") return;
+//     AliWarning("Entry contains a TTree! Setting file...");
+// 
+//     TTree* tree = dynamic_cast<TTree*> (entry->GetObject());
+// 
+//     if(!tree) return;
+// 
+// //  tree->SetDirectory(file);
+//     tree->SetDirectory(0);
+// 
+//     return;
+// }