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 **************************************************************************/
18 Revision 1.2 2006/03/01 23:36:50 jklay
19 suppress compiler warnings by correcting some hidden virtual methods
21 Revision 1.1 2006/02/28 21:55:11 jklay
22 add histogram utilities class, correct package definitions
26 //_________________________________________________________________________
27 // This is just set of static methods for common using
29 //*-- Authors: J.L. Klay (LLNL) & Aleksei Pavlinov (WSU)
31 #include "AliEMCALHistoUtilities.h"
39 #include <TObjString.h>
42 ClassImp(AliEMCALHistoUtilities)
44 AliEMCALHistoUtilities::AliEMCALHistoUtilities(const char *name, const char *tit) : TNamed(name,tit)
49 AliEMCALHistoUtilities::~AliEMCALHistoUtilities()
54 TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser)
58 TIter nextHist(gDirectory->GetList());
59 TList *list = new TList;
62 while((objHist=nextHist())){
63 if (!objHist->InheritsFrom("TH1")) continue;
64 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
67 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);
71 void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w)
75 if(ind < l->GetSize()){
76 hid = (TH1*)l->At(ind);
81 void AliEMCALHistoUtilities::FillH2(TList *l, Int_t ind, Double_t x, Double_t y, Double_t w)
85 if(ind < l->GetSize()){
86 hid = (TH2*)l->At(ind);
91 int AliEMCALHistoUtilities::SaveListOfHists(TList *mylist,const char* name,Bool_t kSingleKey,const char* opt)
93 printf(" Name of out file |%s|\n", name);
95 if(mylist && mylist->GetSize() && strlen(name)){
97 if(nf.Contains(".root") == kFALSE) nf += ".root";
98 TFile file(nf.Data(),opt);
99 TIter nextHist(mylist);
104 mylist->Write(mylist->GetName(),TObject::kSingleKey);
108 while((objHist=nextHist())) { // loop over list
109 if(objHist->InheritsFrom("TH1")) {
110 TH1* hid = (TH1*)objHist;
114 printf("Save hist. %s \n",hid ->GetName());
117 printf("%i hists. save to file -> %s\n", nh,file.GetName());
122 printf("AliEMCALHistoUtilities::SaveListOfHists : N O S A V I N G \n");
127 // Moved from AliEMCALGeometry
128 int AliEMCALHistoUtilities::ParseString(const TString &topt, TObjArray &Opt)
130 Ssiz_t begin, index, end, end2;
131 begin = index = end = end2 = 0;
132 TRegexp separator("[^ ;,\\t\\s/]+");
133 while ( (begin < topt.Length()) && (index != kNPOS) ) {
134 // loop over given options
135 index = topt.Index(separator,&end,begin);
136 if (index >= 0 && end >= 1) {
137 TString substring(topt(index,end));
138 Opt.Add(new TObjString(substring.Data()));
142 return Opt.GetEntries();