1 /**************************************************************************
2 * Copyright(c) 1998-2002, 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 **************************************************************************/
20 //*-- Authors: J.L. Klay (LLNL) & Aleksei Pavlinov (WSU)
32 #include "AliEMCALHistoUtilities.h"
34 ClassImp(AliEMCALHistoUtilities)
36 AliEMCALHistoUtilities::AliEMCALHistoUtilities(const char *name, const char *tit) : TNamed(name,tit)
41 fListHist = MoveHistsToList("Hist For AliEMCALHistoUtilities", kFALSE);
44 AliEMCALHistoUtilities::~AliEMCALHistoUtilities()
49 void AliEMCALHistoUtilities::Browse(TBrowser* b) const
52 if(fListHist) b->Add((TObject*)fListHist);
53 // TObject::Browse(b);
56 Bool_t AliEMCALHistoUtilities::IsFolder() const
59 if(fListHist) return kTRUE;
63 TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser)
67 TIter nextHist(gDirectory->GetList());
68 TList *list = new TList;
71 while((objHist=nextHist())){
72 if (!objHist->InheritsFrom("TH1")) continue;
73 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
76 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);
80 void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w)
84 if(ind < l->GetSize()){
85 hid = (TH1*)l->At(ind);
90 void AliEMCALHistoUtilities::FillH2(TList *l, Int_t ind, Double_t x, Double_t y, Double_t w)
94 if(ind < l->GetSize()){
95 hid = (TH2*)l->At(ind);
100 int AliEMCALHistoUtilities::SaveListOfHists(TList *list,const char* name,Bool_t kSingleKey,const char* opt)
102 printf(" Name of out file |%s|\n", name);
104 if(list && list->GetSize() && strlen(name)){
106 if(nf.Contains(".root") == kFALSE) nf += ".root";
107 TFile file(nf.Data(),opt);
108 TIter nextHist(list);
113 list->Write(list->GetName(),TObject::kSingleKey);
117 while((objHist=nextHist())) { // loop over list
118 if(objHist->InheritsFrom("TH1")) {
119 TH1* hid = (TH1*)objHist;
123 printf("Save hist. %s \n",hid ->GetName());
126 printf("%i hists. save to file -> %s\n", nh,file.GetName());
131 printf("AliEMCALHistoUtilities::SaveListOfHists : N O S A V I N G \n");
132 if(list==0) printf("List of object 0 : %p \n", list);
133 else printf("Size of list %i \n", list->GetSize());