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.3 2006/03/29 18:15:06 pavlinov
19 Alignmnet staff and some clean up
21 Revision 1.2 2006/03/01 23:36:50 jklay
22 suppress compiler warnings by correcting some hidden virtual methods
24 Revision 1.1 2006/02/28 21:55:11 jklay
25 add histogram utilities class, correct package definitions
29 //_________________________________________________________________________
30 // This is a set of histogram
31 // utilities for the EMCAL
32 // to make some common
35 //*-- Authors: J.L. Klay (LLNL) & Aleksei Pavlinov (WSU)
37 #include "AliEMCALHistoUtilities.h"
45 #include <TObjString.h>
48 ClassImp(AliEMCALHistoUtilities)
50 AliEMCALHistoUtilities::AliEMCALHistoUtilities(const char *name, const char *tit) : TNamed(name,tit)
55 AliEMCALHistoUtilities::~AliEMCALHistoUtilities()
60 TList* AliEMCALHistoUtilities::MoveHistsToList(const char* name, Bool_t putToBrowser)
64 TIter nextHist(gDirectory->GetList());
65 TList *list = new TList;
68 while((objHist=nextHist())){
69 if (!objHist->InheritsFrom("TH1")) continue;
70 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
73 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);
77 void AliEMCALHistoUtilities::FillH1(TList *l, Int_t ind, Double_t x, Double_t w)
82 if(ind < l->GetSize()){
83 hid = (TH1*)l->At(ind);
88 void AliEMCALHistoUtilities::FillH2(TList *l, Int_t ind, Double_t x, Double_t y, Double_t w)
93 if(ind < l->GetSize()){
94 hid = (TH2*)l->At(ind);
99 int AliEMCALHistoUtilities::SaveListOfHists(TList *mylist,const char* name,Bool_t kSingleKey,const char* opt)
101 //write histograms to file
102 printf(" Name of out file |%s|\n", name);
104 if(mylist && mylist->GetSize() && strlen(name)){
106 if(nf.Contains(".root") == kFALSE) nf += ".root";
107 TFile file(nf.Data(),opt);
108 TIter nextHist(mylist);
113 mylist->Write(mylist->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");
136 int AliEMCALHistoUtilities::ParseString(const TString &topt, TObjArray &Opt)
138 // Moved from AliEMCALGeometry
140 Ssiz_t begin, index, end, end2;
141 begin = index = end = end2 = 0;
142 TRegexp separator("[^ ;,\\t\\s/]+");
143 while ( (begin < topt.Length()) && (index != kNPOS) ) {
144 // loop over given options
145 index = topt.Index(separator,&end,begin);
146 if (index >= 0 && end >= 1) {
147 TString substring(topt(index,end));
148 Opt.Add(new TObjString(substring.Data()));
152 return Opt.GetEntries();