1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Offline Analysis Database Container and Service Class
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
26 #include "AliOADBContainer.h"
28 #include <TObjArray.h>
32 ClassImp(AliOADBContainer);
34 //______________________________________________________________________________
35 AliOADBContainer::AliOADBContainer() :
37 fArray(new TObjArray(100)),
44 AliOADBContainer::AliOADBContainer(char* name) :
45 TNamed(name, "OADBContainer"),
46 fArray(new TObjArray(100)),
54 //______________________________________________________________________________
55 AliOADBContainer::~AliOADBContainer()
60 //______________________________________________________________________________
61 AliOADBContainer::AliOADBContainer(const AliOADBContainer& cont) :
64 fLowerLimits(cont.fLowerLimits),
65 fUpperLimits(cont.fUpperLimits),
66 fEntries(cont.fEntries)
71 //______________________________________________________________________________
72 AliOADBContainer& AliOADBContainer::operator=(const AliOADBContainer& cont)
74 // Assignment operator
76 TNamed::operator=(cont);
81 void AliOADBContainer::AppendObject(TObject* obj, Int_t lower, Int_t upper)
83 // Append a new object to the list
85 fLowerLimits.Set(fEntries);
86 fUpperLimits.Set(fEntries);
88 fLowerLimits[fEntries - 1] = lower;
89 fUpperLimits[fEntries - 1] = upper;
94 void AliOADBContainer::RemoveObject(Int_t idx)
96 // Remove object from the list
97 if (idx < 0 || idx >= fEntries)
99 AliError(Form("Index out of Range %5d >= %5d", idx, fEntries));
103 TObject* obj = fArray->RemoveAt(idx);
106 for (Int_t i = idx; i < (fEntries-1); i++) {
107 fLowerLimits[i] = fLowerLimits[i + 1];
108 fUpperLimits[i] = fUpperLimits[i + 1];
109 fArray->AddAt(fArray->At(i+1), i);
111 fArray->RemoveAt(fEntries - 1);
115 void AliOADBContainer::UpdateObject(Int_t idx, TObject* obj, Int_t lower, Int_t upper)
117 // Append a new object to the list
118 if (idx < 0 || idx >= fEntries)
120 AliError(Form("Index out of Range %5d >= %5d", idx, fEntries));
124 fLowerLimits[idx] = lower;
125 fUpperLimits[idx] = upper;
126 fArray->AddAt(obj, idx);
129 Int_t AliOADBContainer::GetIndexForRun(Int_t run)
131 // Find the index for a given run
134 for (Int_t i = 0; i < fEntries; i++)
136 if (run >= fLowerLimits[i] && run <= fUpperLimits[i])
145 void AliOADBContainer::WriteToFile(char* fname)
147 // Write object to file
148 TFile* f = new TFile(fname, "recreate");
153 void AliOADBContainer::List()
156 for (Int_t i = 0; i < fEntries; i++) {
157 printf("Lower %5d Upper %5d \n", fLowerLimits[i], fUpperLimits[i]);
158 (fArray->At(i))->Dump();