1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
23 #include <TIterator.h>
26 #include "AliHFEcollection.h"
31 ClassImp(AliHFEcollection)
33 //___________________________________________________________________
34 AliHFEcollection::AliHFEcollection():
39 // default constructor
44 AliError("Initialization of the list failed");
47 // list is owner of the objects. Once list is deleted, the objects
48 // it contains will be deleted too
49 fListE->SetOwner(kTRUE);
51 //Printf("%s:%d,%p",(char*)__FILE__,__LINE__,fInstance);
54 //___________________________________________________________________
55 AliHFEcollection::AliHFEcollection(char* name, char* title):
66 AliError("Initialization of the list failed");
69 // list is owner of the objects. Once list is deleted, the objects
70 // it contains will be deleted too
71 fListE->SetOwner(kTRUE);
74 //___________________________________________________________________
75 AliHFEcollection::AliHFEcollection(const AliHFEcollection &c) :
86 //___________________________________________________________________
87 AliHFEcollection &AliHFEcollection::operator=(const AliHFEcollection &ref)
90 // Assignment operator
98 //___________________________________________________________________
99 void AliHFEcollection::Copy(TObject &ref) const {
101 // Performs the copying of the object
103 AliHFEcollection &target = dynamic_cast<AliHFEcollection &>(ref);
105 target.fListE = fListE;
107 //___________________________________________________________________
108 AliHFEcollection::~AliHFEcollection(){
109 AliInfo("DESTRUCTOR");
111 //___________________________________________________________________
112 Bool_t AliHFEcollection::CreateTH1F(const char* _name, const char* _title, Int_t _nBin, Float_t _nMin, Float_t _nMax){
115 AliError("No TList pointer ! ");
119 fListE->Add(new TH1F(_name, _title, _nBin, _nMin, _nMax));
120 return CheckObject(_name);
123 //___________________________________________________________________
124 Bool_t AliHFEcollection::CreateTH2F(const char* _name, const char* _title, Int_t _nBinX, Float_t _nMinX, Float_t _nMaxX, Int_t _nBinY, Float_t _nMinY, Float_t _nMaxY){
127 AliError("No TList pointer ! ");
130 fListE->Add(new TH2F(_name, _title, _nBinX, _nMinX, _nMaxX, _nBinY, _nMinY, _nMaxY));
131 return CheckObject(_name);
133 //___________________________________________________________________
134 Bool_t AliHFEcollection::CreateTH1Fvector1(Int_t _X, const char* _name, const char* _title, Int_t _nBin, Float_t _nMin, Float_t _nMax){
136 // create a 1 dimensional array of size [_X]
139 AliError("No TList pointer ! ");
143 AliError("can not create array with negative or zero size ");
147 for(Int_t i=0; i<_X; ++i){
149 name.Append(Form("%s_[%d]", _name, i));
150 //cout<<" -D: name: "<<name.str().c_str()<<endl;
151 //cout<<" -D: nBin: "<<_nBin<<" ,Min: "<<_nMin<<" , Max: "<<_nMax<<endl;
152 CreateTH1F(name.Data(), _title, _nBin, _nMin, _nMax);
153 if(!CheckObject(name.Data())){
154 AliError(Form("Not possible to create object: ", name.Data()));
160 //___________________________________________________________________
161 Bool_t AliHFEcollection::CreateTH2Fvector1(Int_t _X, const char* _name, const char* _title, Int_t _nBinX, Float_t _nMinX, Float_t _nMaxX, Int_t _nBinY, Float_t _nMinY, Float_t _nMaxY){
163 // create a 1 dimensinal array of TH2F histograms with size [_X]
165 AliError("No TList pointer !");
169 AliError("can not create array with negative or zero size ");
173 for(Int_t i=0; i<_X; ++i){
175 name.Append(Form("%s_[%d]", _name, i));
176 //cout<<" -D: name: "<<name<<endl;
177 //cout<<" -D: nBin: "<<_nBin<<" ,Min: "<<_nMin<<" , Max: "<<_nMax<<endl;
178 CreateTH2F(name.Data(), _title, _nBinX, _nMinX, _nMaxX, _nBinY, _nMinY, _nMaxY);
179 if(!CheckObject(name.Data())){
180 AliError(Form("Not possible to create object: %s", name.Data()));
186 //___________________________________________________________________
187 Bool_t AliHFEcollection::CreateTH1Fvector2(Int_t _X, Int_t _Y, const char* _name, const char* _title, Int_t _nBin, Float_t _nMin, Float_t _nMax){
189 // create a 2 dimensional array of histograms of size [_X, _Y]
191 AliError("No TList pointer ! ");
194 if(_X <=0 || _Y <=0){
195 AliError("can not create array with negative or zero size ");
199 for(Int_t i=0; i<_X; ++i){
200 for(Int_t j=0; j<_Y; ++j){
202 name.Append(Form("%s_[%d][%d]", _name, i, j));
203 //cout<<" -D: name: "<<name.str().c_str()<<endl;
204 //cout<<" -D: nBin: "<<_nBin<<" ,Min: "<<_nMin<<" , Max: "<<_nMax<<endl;
205 CreateTH1F(name.Data(), _title, _nBin, _nMin, _nMax);
206 if(!CheckObject(name.Data())){
207 AliError(Form("Not possible to create object: %s", name.Data()));
216 //___________________________________________________________________
217 TObject* AliHFEcollection::Get(const char* _name, Int_t _X){
219 TString name = _name;
220 name.Append(Form("_[%d]", _X));
221 if(!CheckObject(name.Data())){
222 AliError("No such object found in the list");
226 return Get(name.Data());
229 //___________________________________________________________________
230 TObject* AliHFEcollection::Get(const char* _name, Int_t _X, Int_t _Y){
232 TString name = _name;
233 name.Append(Form("_[%d][%d]", _X, _Y));
234 if(!CheckObject(name.Data())){
235 AliError("No such object found in the list");
236 AliError(Form("name: %s", name.Data()));
240 return Get(name.Data());
243 //___________________________________________________________________
244 Bool_t AliHFEcollection::CheckObject(const char* _name){
246 // check wheter the creation of the histogram was succesfull
249 AliError("No TList pointer ! ");
253 if(!fListE->FindObject(_name)){
254 AliError("Creating or Finding the object failed");
259 //___________________________________________________________________
260 TObject* AliHFEcollection::Get(const char* _name){
261 return fListE->FindObject(_name);
263 //___________________________________________________________________
264 Long64_t AliHFEcollection::Merge(TCollection *list){
267 AliError("AliHFEcollection::Merge : No TList pointer ! ");
271 return fListE->Merge(list);
274 //____________________________________________________________________
275 void AliHFEcollection::Browse(TBrowser *b)
277 // Browse the content of the directory.
281 TIter nextin(fListE);
283 //Add objects that are only in memory
284 while ((obj = nextin())) {
285 b->Add(obj, obj->GetName());