AliPhysics  9fe175b (9fe175b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
THistManager.h
Go to the documentation of this file.
1 #ifndef THISTMANAGER_H
2 #define THISTMANAGER_H
3 /* Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 #include <THashList.h>
7 #include <TIterator.h>
8 #include <TNamed.h>
9 #include <iterator>
10 
11 class TArrayD;
12 class TAxis;
13 class TBinning;
14 class TList;
15 class TH1;
16 class TH2;
17 class TH3;
18 class THnSparse;
19 class TProfile;
20 
43 class THistManager : public TNamed {
44 public:
45 
59  class iterator : public std::iterator<std::bidirectional_iterator_tag,
60  TObject, std::ptrdiff_t,
61  TObject **, TObject *&>{
62  public:
75  };
76 
84  iterator(const THistManager *hmgr, Int_t currentpos, THMIDirection_t dir = kTHMIforward);
85 
91  iterator(const iterator &ref);
92 
96  ~iterator() { }
97 
104  iterator &operator=(const iterator &rhs);
105 
112  Bool_t operator!=(const iterator &aIter) const;
113 
120  iterator &operator++();
121 
128  iterator operator++(int);
129 
136  iterator &operator--();
137 
144  iterator operator--(int);
145 
153  TObject *operator*() const;
154 
155  private:
157  Int_t fCurrentPos;
158  Int_t fNext;
160 
161  iterator();
162  };
163 
167  THistManager();
168 
173  THistManager(const char *name);
174 
178  ~THistManager();
179 
180  void ReleaseOwner() { fIsOwner = kFALSE; };
181 
189  THashList* CreateHistoGroup(const char *groupname, const char *parent = "/");
190 
201  TH1* CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt = "");
202 
212  TH1* CreateTH1(const char *name, const char *title, int nbins, const double *xbins, Option_t *opt = "");
213 
222  TH1* CreateTH1(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "");
223 
232  TH1* CreateTH1(const char *name, const char *title, const TBinning &binning, Option_t *opt = "");
233 
246  TH2* CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt = "");
247 
260  TH2* CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, Option_t *opt = "");
261 
270  TH2* CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, Option_t *opt = "");
271 
280  TH2* CreateTH2(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, Option_t *opt = "");
281 
294  TH3* 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 = "");
295 
308  TH3* 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 = "");
309 
319  TH3* CreateTH3(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, const TArrayD &zbins, Option_t *opt = "");
320 
330  TH3* CreateTH3(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, const TBinning &zbins, Option_t *opt = "");
331 
342  THnSparse* CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt = "");
343 
352  THnSparse* CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes, Option_t *opt = "");
353 
364  void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt = "");
365 
375  void CreateTProfile(const char *name, const char *title, int nbinsX, const double *xbins, Option_t *opt = "");
376 
385  void CreateTProfile(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "");
386 
395  void CreateTProfile(const char *name, const char *title, const TBinning &xbins, Option_t *opt = "");
396 
401  void SetObject(TObject * const o, const char *group = "/");
402 
410  void FillTH1(const char *hname, double x, double weight = 1., Option_t *opt = "");
411 
412  void FillTH1(const char *name, const char *label, double weight = 1., Option_t *opt = "");
413 
422  void FillTH2(const char *hname, double x, double y, double weight = 1., Option_t *opt = "");
423 
431  void FillTH2(const char *hname, double *point, double weight = 1., Option_t *opt = "");
432 
442  void FillTH3(const char *hname, double x, double y, double z, double weight = 1., Option_t *opt = "");
443 
451  void FillTH3(const char *hname, const double *point, double weight = 1., Option_t *opt = "");
452 
460  void FillTHnSparse(const char *name, const double *x, double weight = 1., Option_t *opt = "");
461 
470  void FillProfile(const char *name, double x, double y, double weight = 1.);
471 
477  inline iterator begin() const;
478 
484  inline iterator end() const;
485 
491  inline iterator rbegin() const;
492 
498  inline iterator rend() const;
499 
504  THashList *GetListOfHistograms() const { return fHistos; }
505 
512  TObject *FindObject(const char *name) const;
513 
520  virtual TObject *FindObject(const TObject *obj) const;
521 
522 private:
523  THistManager(const THistManager &);
525 
526 
532  THashList *FindGroup(const char *dirname) const;
533 
540  void TokenizeFilename(const char *name, const char *delim, std::vector<std::string> &listoftokens) const;
541 
547  TString basename(const char *path) const;
548 
554  TString histname(const char *path) const;
555 
556  THashList *fHistos;
557  bool fIsOwner;
558 
560  ClassDef(THistManager, 1); // Container for histograms
562 };
563 
565  return iterator(this, 0, iterator::kTHMIforward);
566 }
567 
569  return iterator(this, fHistos->GetEntries()-1, iterator::kTHMIbackward);
570 }
571 
573  return iterator(this, fHistos->GetEntries(), iterator::kTHMIforward);
574 }
575 
577  return iterator(this, -1, iterator::kTHMIbackward);
578 }
579 #endif
iterator & operator=(const iterator &rhs)
const Double_t ymax
Definition: AddTaskCFDStar.C:7
const char * title
Definition: MakeQAPdf.C:26
bool fIsOwner
Set the ownership.
Definition: THistManager.h:557
Int_t nbinsy
THashList * FindGroup(const char *dirname) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
void TokenizeFilename(const char *name, const char *delim, std::vector< std::string > &listoftokens) const
const THistManager * fkArray
Definition: THistManager.h:156
void SetObject(TObject *const o, const char *group="/")
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
THMIDirection_t fDirection
Definition: THistManager.h:159
TString histname(const char *path) const
THashList * CreateHistoGroup(const char *groupname, const char *parent="/")
Bool_t operator!=(const iterator &aIter) const
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
TObject * FindObject(const char *name) const
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
THistManager & operator=(const THistManager &)
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
const Double_t zmin
void ReleaseOwner()
Definition: THistManager.h:180
void FillProfile(const char *name, double x, double y, double weight=1.)
THMIDirection_t
Direction for the iteration.
Definition: THistManager.h:72
TString basename(const char *path) const
stl-iterator for the histogram manager
Definition: THistManager.h:59
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
iterator rbegin() const
Definition: THistManager.h:568
Int_t nbinsx
iterator begin() const
Definition: THistManager.h:564
TObject * operator*() const
iterator end() const
Definition: THistManager.h:572
const Double_t ymin
Definition: AddTaskCFDStar.C:6
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
iterator rend() const
Definition: THistManager.h:576
const Double_t zmax
const Int_t nbins
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
THashList * fHistos
List of histograms.
Definition: THistManager.h:556
TH3 * 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="")