AliPhysics  251aa1e (251aa1e)
 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:
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);
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 
539  TString basename(const TString &path) const;
540 
546  TString histname(const TString &path) const;
547 
548  THashList *fHistos;
549  bool fIsOwner;
550 
552  ClassDef(THistManager, 1); // Container for histograms
554 };
555 
557  return iterator(this, 0, iterator::kTHMIforward);
558 }
559 
561  return iterator(this, fHistos->GetEntries()-1, iterator::kTHMIbackward);
562 }
563 
565  return iterator(this, fHistos->GetEntries(), iterator::kTHMIforward);
566 }
567 
569  return iterator(this, -1, iterator::kTHMIbackward);
570 }
571 
577 namespace TestTHistManager {
578 
593 public:
594 
599 
604 
620 
639 
658 
674 };
675 
681 int TestRunAll();
682 
688 int TestRunBuildSimple();
689 
695 int TestRunBuildGrouped();
696 
702 int TestRunFillSimple();
703 
709 int TestRunFillGrouped();
710 
711 }
712 #endif
iterator & operator=(const iterator &rhs)
THashList * CreateHistoGroup(const char *groupname)
const Double_t ymax
Definition: AddTaskCFDStar.C:7
const char * title
Definition: MakeQAPdf.C:26
Definition: External.C:244
bool fIsOwner
Set the ownership.
Definition: THistManager.h:549
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="")
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
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
int Int_t
Definition: External.C:63
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
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:560
Int_t nbinsx
iterator begin() const
Definition: THistManager.h:556
TString basename(const TString &path) const
Collection of tests for the THistManager.
Definition: THistManager.h:592
TString histname(const TString &path) const
Definition: External.C:220
TObject * operator*() const
iterator end() const
Definition: THistManager.h:564
const Double_t ymin
Definition: AddTaskCFDStar.C:6
Container class for histograms.
Definition: THistManager.h:43
iterator rend() const
Definition: THistManager.h:568
const char Option_t
Definition: External.C:48
const Double_t zmax
const Int_t nbins
bool Bool_t
Definition: External.C:53
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:548
Definition: External.C:196
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="")