]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - OADB/AliOADBContainer.cxx
Eventplane information
[u/mrichter/AliRoot.git] / OADB / AliOADBContainer.cxx
index 95511105e97d430b4fc29db2e2ca4f2a3f08c0b5..30bf5b713ad8f4ae12065069dd8df51263d46a0d 100644 (file)
 #include <TArrayI.h>
 #include <TFile.h>
 #include <TList.h>
+#include "TBrowser.h"
 
 ClassImp(AliOADBContainer);
 
 //______________________________________________________________________________
 AliOADBContainer::AliOADBContainer() : 
   TNamed(),
-  fArray(new TObjArray(100)),
-  fDefaultList(new TList()),
+  fArray(0),
+  fDefaultList(0),
   fLowerLimits(),
   fUpperLimits(),
   fEntries(0)
@@ -110,7 +111,7 @@ void AliOADBContainer::AppendObject(TObject* obj, Int_t lower, Int_t upper)
   Int_t index = HasOverlap(lower, upper);
   
   if (index != -1) {
-    AliFatal(Form("Ambiguos validity range (%5d) !\n", index));
+    AliFatal(Form("Ambiguos validity range (%5d, %5.5d-%5.5d) !\n", index,lower,upper));
     return;
   }
   //
@@ -164,10 +165,13 @@ void AliOADBContainer::UpdateObject(Int_t idx, TObject* obj, Int_t lower, Int_t
       return;
     }
   //
+  // Remove the old object
+  RemoveObject(idx);
+
   // Check that there is no overlap with existing run ranges  
   Int_t index = HasOverlap(lower, upper);
   if (index != -1) {
-    AliFatal(Form("Ambiguos validity range (%5d) !\n", index));
+    AliFatal(Form("Ambiguos validity range (%5d, %5.5d-%5.5d) !\n", index,lower,upper));
     return;
   }
   //
@@ -178,7 +182,7 @@ void AliOADBContainer::UpdateObject(Int_t idx, TObject* obj, Int_t lower, Int_t
 }
     
  
-void  AliOADBContainer::AddDefaultObject(TNamed* obj)
+void  AliOADBContainer::AddDefaultObject(TObject* obj)
 {
   // Add a default object
   fDefaultList->Add(obj);
@@ -214,7 +218,7 @@ Int_t AliOADBContainer::GetIndexForRun(Int_t run) const
   return index;
 }
 
-TObject* AliOADBContainer::GetObject(Int_t run, char* def) const
+TObject* AliOADBContainer::GetObject(Int_t run, const char* def) const
 {
   // Return object for given run or default if not found
   TObject* obj = 0;
@@ -243,8 +247,9 @@ void AliOADBContainer::WriteToFile(char* fname) const
 {
   //
   // Write object to file
-  TFile* f = new TFile(fname, "recreate");
+  TFile* f = new TFile(fname, "update");
   Write();
+  f->Purge();
   f->Close();
 }
 
@@ -261,7 +266,10 @@ Int_t AliOADBContainer::InitFromFile(char* fname, char* key)
        AliError("Object not found in file \n");        
        return 1;
     }
-    
+
+    SetName(cont->GetName());
+    SetTitle(cont->GetTitle());
+
     fEntries = cont->GetNumberOfEntries();
     fLowerLimits.Set(fEntries);
     fUpperLimits.Set(fEntries);
@@ -270,7 +278,7 @@ Int_t AliOADBContainer::InitFromFile(char* fname, char* key)
        fUpperLimits[i] = cont->UpperLimit(i);
        fArray->AddAt(cont->GetObjectByIndex(i), i);
     }
-
+    if (!fDefaultList) fDefaultList = new TList(); 
     TIter next(cont->GetDefaultList());
     TObject* obj;
     while((obj = next())) fDefaultList->Add(obj);
@@ -294,7 +302,7 @@ void AliOADBContainer::List()
 
 }
 
-Int_t AliOADBContainer::HasOverlap(Int_t lower, Int_t upper)
+Int_t AliOADBContainer::HasOverlap(Int_t lower, Int_t upper) const
 {
   //
   // Checks for overlpapping validity regions
@@ -307,3 +315,24 @@ Int_t AliOADBContainer::HasOverlap(Int_t lower, Int_t upper)
   }
   return (-1);
 }
+
+void AliOADBContainer::Browse(TBrowser *b)
+{
+   // Browse this object.
+   // If b=0, there is no Browse call TObject::Browse(0) instead.
+   //         This means TObject::Inspect() will be invoked indirectly
+
+
+  if (b) {
+    for (Int_t i = 0; i < fEntries; i++) {
+      b->Add(fArray->At(i),Form("%9.9d - %9.9d", fLowerLimits[i], fUpperLimits[i]));
+    }
+    TIter next(fDefaultList);
+    TObject* obj;
+    while((obj = next())) b->Add(obj);
+        
+  }     
+   else
+      TObject::Browse(b);
+}
+