]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALHistoUtilities.cxx
Removed loading non-existing library
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALHistoUtilities.cxx
CommitLineData
315d1c64 1/**************************************************************************
2 * Copyright(c) 1998-2002, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
4800667c 18Revision 1.1 2006/02/28 21:55:11 jklay
19add histogram utilities class, correct package definitions
20
315d1c64 21*/
22
23//*-- Authors: J.L. Klay (LLNL) & Aleksei Pavlinov (WSU)
24
25//*
26
27#include <TBrowser.h>
28#include <TFile.h>
29#include <TList.h>
30#include <TH1.h>
31#include <TH2.h>
32#include <TROOT.h>
33#include <TString.h>
34
35#include "AliEMCALHistoUtilities.h"
36
37ClassImp(AliEMCALHistoUtilities)
38
39AliEMCALHistoUtilities::AliEMCALHistoUtilities(const char *name, const char *tit) : TNamed(name,tit)
40{
41 //constructor
42 fDebug = 0;
43 gROOT->cd();
44 fListHist = MoveHistsToList("Hist For AliEMCALHistoUtilities", kFALSE);
45}
46
47AliEMCALHistoUtilities::~AliEMCALHistoUtilities()
48{
49 //destructor
50}
51
4800667c 52void AliEMCALHistoUtilities::Browse(TBrowser* b)
315d1c64 53{
54 // Browse
55 if(fListHist) b->Add((TObject*)fListHist);
56 // TObject::Browse(b);
57}
58
59Bool_t AliEMCALHistoUtilities::IsFolder() const
60{
61 // Is folder
62 if(fListHist) return kTRUE;
63 else return kFALSE;
64}
65
66TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser)
67{
68 // Move HIST to list
69 gROOT->cd();
70 TIter nextHist(gDirectory->GetList());
71 TList *list = new TList;
72 list->SetName(name);
73 TObject *objHist;
74 while((objHist=nextHist())){
75 if (!objHist->InheritsFrom("TH1")) continue;
76 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
77 list->Add(objHist);
78 }
79 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);
80 return list;
81}
82
83void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w)
84{
85 static TH1* hid=0;
86 if(l == 0) return;
87 if(ind < l->GetSize()){
88 hid = (TH1*)l->At(ind);
89 hid->Fill(x,w);
90 }
91}
92
93void AliEMCALHistoUtilities::FillH2(TList *l, Int_t ind, Double_t x, Double_t y, Double_t w)
94{
95 static TH2* hid=0;
96 if(l == 0) return;
97 if(ind < l->GetSize()){
98 hid = (TH2*)l->At(ind);
99 hid->Fill(x,y,w);
100 }
101}
102
4800667c 103int AliEMCALHistoUtilities::SaveListOfHists(TList *mylist,const char* name,Bool_t kSingleKey,const char* opt)
315d1c64 104{
105 printf(" Name of out file |%s|\n", name);
106 int save = 0;
4800667c 107 if(mylist && mylist->GetSize() && strlen(name)){
315d1c64 108 TString nf(name);
109 if(nf.Contains(".root") == kFALSE) nf += ".root";
110 TFile file(nf.Data(),opt);
4800667c 111 TIter nextHist(mylist);
315d1c64 112 TObject* objHist=0;
113 int nh=0;
114 if(kSingleKey) {
115 file.cd();
4800667c 116 mylist->Write(mylist->GetName(),TObject::kSingleKey);
117 mylist->ls();
315d1c64 118 save = 1;
119 } else {
120 while((objHist=nextHist())) { // loop over list
121 if(objHist->InheritsFrom("TH1")) {
122 TH1* hid = (TH1*)objHist;
123 file.cd();
124 hid->Write();
125 nh++;
126 printf("Save hist. %s \n",hid ->GetName());
127 }
128 }
129 printf("%i hists. save to file -> %s\n", nh,file.GetName());
130 if(nh>0) save = 1;
131 }
132 file.Close();
133 } else {
134 printf("AliEMCALHistoUtilities::SaveListOfHists : N O S A V I N G \n");
315d1c64 135 }
136 return save;
137}