AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliEMCalHistoContainer.h
Go to the documentation of this file.
1 
12 #ifndef ALIEMCALHISTOCONTAINER_H
13 #define ALIEMCALHISTOCONTAINER_H
14 /* Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
15  * See cxx source for full Copyright notice */
16 
17 #include <cstring>
18 #include <exception>
19 #include <string>
20 #include <sstream>
21 #include <TNamed.h>
22 
23 class TArrayD;
24 class TAxis;
25 class TList;
26 class THashList;
27 
35 namespace EMCalTriggerPtAnalysis {
36 
51 class HistoContainerContentException : public std::exception {
52 public:
64  };
65 
72  HistoContainerContentException(const char *histname, const char *hgroup, ExceptionType_t etype):
73  fHistname(),
74  fGroup(),
75  fErrorMessage(),
76  fExceptionType(etype)
77  {
78  if(histname) fHistname = histname;
79  if(hgroup) fGroup = hgroup;
80 
82  }
83 
87  virtual ~HistoContainerContentException() throw() {}
88 
93  virtual const char *what() const throw() {
94  return fErrorMessage.c_str();
95  }
96 
101  const char * GetErrorHistogramName() const { return fHistname.c_str(); }
107 
108 private:
113  std::stringstream msgbuilder;
114  switch(fExceptionType) {
116  msgbuilder << "Histogram " << fHistname << " not found in";
117  if(strlen(fGroup.c_str())) msgbuilder << " group " << fGroup;
118  else msgbuilder << " the list of histograms.";
119  break;
120  case kTypeException:
121  msgbuilder << "Object " << fHistname << " is of wrong type.";
122  break;
124  msgbuilder << "Histogram " << fHistname << " already exists in";
125  if(strlen(fGroup.c_str())) msgbuilder << " group " << fGroup;
126  else msgbuilder << " the list of histograms.";
127  break;
128  case kGroupException:
129  msgbuilder << "Group " << fGroup << " not found.";
130  break;
131  };
132  fErrorMessage = msgbuilder.str();
133  }
134 
135  std::string fHistname;
136  std::string fGroup;
137  std::string fErrorMessage;
139 
140 };
141 
156 class AliEMCalHistoContainer : public TNamed {
157 public:
159  AliEMCalHistoContainer(const char *name);
160  virtual ~AliEMCalHistoContainer();
161  void ReleaseOwner() { fIsOwner = kFALSE; };
162 
163  void CreateHistoGroup(const char *groupname, const char *parent = "/") throw(HistoContainerContentException);
164 
165  void CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt = "") throw(HistoContainerContentException);
166  void CreateTH1(const char *name, const char *title, int nbins, const double *xbins, Option_t *opt = "") throw(HistoContainerContentException);
167  void CreateTH1(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "") throw(HistoContainerContentException);
168  void CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt = "") throw(HistoContainerContentException);
169  void CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, Option_t *opt = "") throw(HistoContainerContentException);
170  void CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, Option_t *opt = "") throw(HistoContainerContentException);
171  void CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt = "") throw (HistoContainerContentException);
172  void CreateTH3(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, int nbinsz, const double *zbins, Option_t *opt = "") throw (HistoContainerContentException);
173  void CreateTH3(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, const TArrayD &zbins, Option_t *opt = "") throw(HistoContainerContentException);
174  void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt = "") throw(HistoContainerContentException);
175  void CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes, Option_t *opt = "") throw(HistoContainerContentException);
176  void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt = "") throw(HistoContainerContentException);
177  void CreateTProfile(const char *name, const char *title, int nbinsX, const double *xbins, Option_t *opt = "") throw(HistoContainerContentException);
178  void CreateTProfile(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "") throw(HistoContainerContentException);
179  void SetObject(TObject * const o, const char *group = "/") throw(HistoContainerContentException);
180  void FillTH1(const char *hname, double x, double weight = 1.) throw(HistoContainerContentException);
181  void FillTH2(const char *hname, double x, double y, double weight = 1.) throw(HistoContainerContentException);
182  void FillTH2(const char *hname, double *point, double weight = 1.) throw(HistoContainerContentException);
183  void FillTH3(const char *hname, double x, double y, double z, double weight = 1.) throw(HistoContainerContentException);
184  void FillTH3(const char *hname, const double *point, double weight = 1.) throw(HistoContainerContentException);
185  void FillTHnSparse(const char *name, const double *x, double weight = 1.) throw(HistoContainerContentException);
186  void FillProfile(const char *name, double x, double y, double weight = 1.) throw(HistoContainerContentException);
187 
192  THashList *GetListOfHistograms() { return fHistos; }
193  virtual TObject *FindObject(const char *name) const;
194  virtual TObject *FindObject(const TObject *obj) const;
195 
196 private:
199  THashList *FindGroup(const char *dirname) const;
200  void TokenizeFilename(const char *name, const char *delim, std::vector<std::string> &listoftokens) const;
201  const char *basename(const char *path) const;
202  const char *histname(const char *path) const;
203 
204  THashList *fHistos;
205  bool fIsOwner;
206 
208  ClassDef(AliEMCalHistoContainer, 1); // Container for histograms
210 };
211 
212 }
213 #endif
AliEMCalHistoContainer & operator=(const AliEMCalHistoContainer &)
const Double_t ymax
Definition: AddTaskCFDStar.C:7
std::string fHistname
Name of the histogram producing the exception.
void FillTH2(const char *hname, double x, double y, double weight=1.)
const char * title
Definition: MakeQAPdf.C:26
ExceptionType_t
Definition of exception types thrown by the histogram container.
Int_t nbinsy
void CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt="")
void SetObject(TObject *const o, const char *group="/")
void CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Container class for histograms for the high- charged particle analysis.
void FillTHnSparse(const char *name, const double *x, double weight=1.)
void FillTH3(const char *hname, double x, double y, double z, double weight=1.)
std::string fErrorMessage
container for the error message produced in the what function
Exception thrown by the histogram container in case of problems.
virtual TObject * FindObject(const char *name) const
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
const Double_t zmin
std::string fGroup
Group of objects producing the exception.
void CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
const char * basename(const char *path) const
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
Int_t nbinsx
void TokenizeFilename(const char *name, const char *delim, std::vector< std::string > &listoftokens) const
const char * histname(const char *path) const
const Double_t ymin
Definition: AddTaskCFDStar.C:6
THashList * FindGroup(const char *dirname) const
void FillTH1(const char *hname, double x, double weight=1.)
const Double_t zmax
void CreateHistoGroup(const char *groupname, const char *parent="/")
const Int_t nbins
HistoContainerContentException(const char *histname, const char *hgroup, ExceptionType_t etype)
void FillProfile(const char *name, double x, double y, double weight=1.)