1 #ifndef ALIEMCALHISTOCONTAINER_H
2 #define ALIEMCALHISTOCONTAINER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 // Author: Markus Fasel
19 namespace EMCalTriggerPtAnalysis {
21 class HistoContainerContentException : public std::exception {
23 * Error handling class for the histogram container
26 enum ExceptionType_t {
27 kHistNotFoundException = 0,
29 kHistDuplicationException = 2,
33 HistoContainerContentException(const char *histname, const char *hgroup, ExceptionType_t etype):
39 if(histname) fHistname = histname;
40 if(hgroup) fGroup = hgroup;
44 virtual ~HistoContainerContentException() throw() {}
46 virtual const char *what() const throw() {
47 return fErrorMessage.c_str();
50 const char * GetErrorHistogramName() const { return fHistname.c_str(); }
51 ExceptionType_t GetExceptionType() const { return fExceptionType; }
54 void CreateErrorMessage(){
56 * Create error message with the histogram name, the histogram group, and the error type
58 std::stringstream msgbuilder;
59 switch(fExceptionType) {
60 case kHistNotFoundException:
61 msgbuilder << "Histogram " << fHistname << " not found in";
62 if(strlen(fGroup.c_str())) msgbuilder << " group " << fGroup;
63 else msgbuilder << " the list of histograms.";
66 msgbuilder << "Object " << fHistname << " is of wrong type.";
68 case kHistDuplicationException:
69 msgbuilder << "Histogram " << fHistname << " already exists in";
70 if(strlen(fGroup.c_str())) msgbuilder << " group " << fGroup;
71 else msgbuilder << " the list of histograms.";
74 msgbuilder << "Group " << fGroup << " not found.";
77 fErrorMessage = msgbuilder.str();
80 std::string fHistname; // Name of the histogram producing the exception
81 std::string fGroup; // Group of objects producing the exception
82 std::string fErrorMessage; // container for the error message produced in the what function
83 ExceptionType_t fExceptionType; // type of the exception
87 class AliEMCalHistoContainer : public TNamed {
89 AliEMCalHistoContainer();
90 AliEMCalHistoContainer(const char *name);
91 ~AliEMCalHistoContainer();
92 void ReleaseOwner() { fIsOwner = kFALSE; };
94 void CreateHistoGroup(const char *groupname, const char *parent = "/") throw(HistoContainerContentException);
96 void CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt = "") throw(HistoContainerContentException);
97 void CreateTH1(const char *name, const char *title, int nbins, const double *xbins, Option_t *opt = "") throw(HistoContainerContentException);
98 void CreateTH1(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "") throw(HistoContainerContentException);
99 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);
100 void CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, Option_t *opt = "") throw(HistoContainerContentException);
101 void CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, Option_t *opt = "") throw(HistoContainerContentException);
102 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);
103 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);
104 void CreateTH3(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, const TArrayD &zbins, Option_t *opt = "") throw(HistoContainerContentException);
105 void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt = "") throw(HistoContainerContentException);
106 void CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes, Option_t *opt = "") throw(HistoContainerContentException);
107 void SetObject(TObject * const o, const char *group = "/") throw(HistoContainerContentException);
108 void FillTH1(const char *hname, double x, double weight = 1.) throw(HistoContainerContentException);
109 void FillTH2(const char *hname, double x, double y, double weight = 1.) throw(HistoContainerContentException);
110 void FillTH2(const char *hname, double *point, double weight = 1.) throw(HistoContainerContentException);
111 void FillTH3(const char *hname, double x, double y, double z, double weight = 1.) throw(HistoContainerContentException);
112 void FillTH3(const char *hname, const double *point, double weight = 1.) throw(HistoContainerContentException);
113 void FillTHnSparse(const char *name, const double *x, double weight = 1.) throw(HistoContainerContentException);
115 THashList *GetListOfHistograms() { return fHistos; }
116 virtual TObject *FindObject(const char *name) const;
117 virtual TObject *FindObject(const TObject *obj) const;
120 AliEMCalHistoContainer(const AliEMCalHistoContainer &);
121 AliEMCalHistoContainer &operator=(const AliEMCalHistoContainer &);
122 THashList *FindGroup(const char *dirname) const;
123 void TokenizeFilename(const char *name, const char *delim, std::vector<std::string> &listoftokens) const;
124 const char *basename(const char *path) const;
125 const char *histname(const char *path) const;
127 THashList *fHistos; // List of histograms
128 bool fIsOwner; // Set the ownership
130 ClassDef(AliEMCalHistoContainer, 1); // Container for histograms