]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/Tools/THistManager.h
Replace c-string by stl string in order to fix coverity defects
[u/mrichter/AliRoot.git] / PWG / Tools / THistManager.h
1 #ifndef THISTMANAGER_H
2 #define THISTMANAGER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 // Author: Markus Fasel
7
8 #include <TNamed.h>
9
10 class TArrayD;
11 class TAxis;
12 class TList;
13 class THashList;
14
15 class THistManager : public TNamed {
16 public:
17         THistManager();
18         THistManager(const char *name);
19         ~THistManager();
20         void ReleaseOwner() { fIsOwner = kFALSE; };
21
22         void CreateHistoGroup(const char *groupname, const char *parent = "/");
23
24         void CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax);
25         void CreateTH1(const char *name, const char *title, int nbins, const double *xbins);
26         void CreateTH1(const char *name, const char *title, const TArrayD &xbins);
27         void CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax);
28         void CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins);
29         void CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins);
30         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);
31         void CreateTH3(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, int nbinsz, const double *zbins);
32         void CreateTH3(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, const TArrayD &zbins);
33         void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max);
34         void CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes);
35         void SetObject(TObject * const o, const char *group = "/");
36         void FillTH1(const char *hname, double x, double weight = 1.);
37         void FillTH2(const char *hname, double x, double y, double weight = 1.);
38         void FillTH2(const char *hname, double *point, double weight = 1.);
39         void FillTH3(const char *hname, double x, double y, double z, double weight = 1.);
40         void FillTH3(const char *hname, const double *point, double weight = 1.);
41         void FillTHnSparse(const char *name, const double *x, double weight = 1.);
42
43         THashList *GetListOfHistograms() { return fHistos; }
44         TObject *FindObject(const char *name) const;
45         virtual TObject *FindObject(const TObject *obj) const;
46
47 private:
48         THistManager(const THistManager &);
49         THistManager &operator=(const THistManager &);
50         THashList *FindGroup(const char *dirname) const;
51         void TokenizeFilename(const char *name, const char *delim, std::vector<std::string> &listoftokens) const;
52         const char *basename(const char *path) const;
53         const char *histname(const char *path) const;
54
55         THashList *fHistos;                   // List of histograms
56         bool fIsOwner;                        // Set the ownership
57
58         ClassDef(THistManager, 1);  // Container for histograms
59 };
60
61 #endif