AliPhysics  b81c3d2 (b81c3d2)
 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 
99 class THistManager : public TNamed {
100 public:
101 
115  class iterator : public std::iterator<std::bidirectional_iterator_tag,
116  TObject, std::ptrdiff_t,
117  TObject **, TObject *&>{
118  public:
131  };
132 
142  iterator(const THistManager *hmgr, Int_t currentpos, THMIDirection_t dir = kTHMIforward);
143 
150  iterator(const iterator &ref);
151 
155  ~iterator() { }
156 
163  iterator &operator=(const iterator &rhs);
164 
173  Bool_t operator!=(const iterator &aIter) const;
174 
182  iterator &operator++();
183 
192  iterator operator++(int);
193 
201  iterator &operator--();
202 
211  iterator operator--(int);
212 
221  TObject *operator*() const;
222 
223  private:
228 
229  iterator();
230  };
231 
237  THistManager();
238 
245  THistManager(const char *name);
246 
252  ~THistManager();
253 
254  void ReleaseOwner() { fIsOwner = kFALSE; };
255 
266  THashList* CreateHistoGroup(const char *groupname);
267 
280  TH1* CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt = "");
281 
293  TH1* CreateTH1(const char *name, const char *title, int nbins, const double *xbins, Option_t *opt = "");
294 
305  TH1* CreateTH1(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "");
306 
317  TH1* CreateTH1(const char *name, const char *title, const TBinning &binning, Option_t *opt = "");
318 
333  TH2* CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt = "");
334 
349  TH2* CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, Option_t *opt = "");
350 
361  TH2* CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, Option_t *opt = "");
362 
373  TH2* CreateTH2(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, Option_t *opt = "");
374 
389  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 = "");
390 
405  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 = "");
406 
418  TH3* CreateTH3(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, const TArrayD &zbins, Option_t *opt = "");
419 
431  TH3* CreateTH3(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, const TBinning &zbins, Option_t *opt = "");
432 
445  THnSparse* CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt = "");
446 
457  THnSparse* CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes, Option_t *opt = "");
458 
469  THnSparse* CreateTHnSparse(const char *name, const char *title, int ndim, const TBinning **axes, Option_t *opt = "");
470 
471 
484  void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt = "");
485 
497  void CreateTProfile(const char *name, const char *title, int nbinsX, const double *xbins, Option_t *opt = "");
498 
509  void CreateTProfile(const char *name, const char *title, const TArrayD &xbins, Option_t *opt = "");
510 
521  void CreateTProfile(const char *name, const char *title, const TBinning &xbins, Option_t *opt = "");
522 
527  void SetObject(TObject * const o, const char *group = "/");
528 
539  void FillTH1(const char *hname, double x, double weight = 1., Option_t *opt = "");
540 
552  void FillTH1(const char *name, const char *label, double weight = 1., Option_t *opt = "");
553 
565  void FillTH2(const char *hname, double x, double y, double weight = 1., Option_t *opt = "");
566 
577  void FillTH2(const char *hname, double *point, double weight = 1., Option_t *opt = "");
578 
591  void FillTH3(const char *hname, double x, double y, double z, double weight = 1., Option_t *opt = "");
592 
601  void FillTH3(const char *hname, const double *point, double weight = 1., Option_t *opt = "");
602 
611  void FillTHnSparse(const char *name, const double *x, double weight = 1., Option_t *opt = "");
612 
622  void FillProfile(const char *name, double x, double y, double weight = 1.);
623 
629  inline iterator begin() const;
630 
636  inline iterator end() const;
637 
644  inline iterator rbegin() const;
645 
652  inline iterator rend() const;
653 
658  THashList *GetListOfHistograms() const { return fHistos; }
659 
668  TObject *FindObject(const char *name) const;
669 
679  virtual TObject *FindObject(const TObject *obj) const;
680 
681 private:
682  THistManager(const THistManager &);
684 
685 
693  THashList *FindGroup(const char *dirname) const;
694 
700  TString basename(const TString &path) const;
701 
707  TString histname(const TString &path) const;
708 
709  THashList *fHistos;
710  bool fIsOwner;
711 
713  ClassDef(THistManager, 1); // Container for histograms
715 };
716 
718  return iterator(this, 0, iterator::kTHMIforward);
719 }
720 
722  return iterator(this, fHistos->GetEntries()-1, iterator::kTHMIbackward);
723 }
724 
726  return iterator(this, fHistos->GetEntries(), iterator::kTHMIforward);
727 }
728 
730  return iterator(this, -1, iterator::kTHMIbackward);
731 }
732 
738 namespace TestTHistManager {
739 
754 public:
755 
760 
765 
781 
800 
819 
835 };
836 
842 int TestRunAll();
843 
849 int TestRunBuildSimple();
850 
856 int TestRunBuildGrouped();
857 
863 int TestRunFillSimple();
864 
870 int TestRunFillGrouped();
871 
872 }
873 #endif
Int_t fNext
Next position in the histmanager.
Definition: THistManager.h:226
iterator & operator=(const iterator &rhs)
THashList * CreateHistoGroup(const char *groupname)
Create a new group of histograms within a parent group.
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:710
Int_t nbinsy
THistManager()
Default constructor.
THashList * FindGroup(const char *dirname) const
Find histogram group.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
Fill a 3D histogram within the container.
const THistManager * fkArray
Underlying histmanager to iterate over.
Definition: THistManager.h:224
void SetObject(TObject *const o, const char *group="/")
Set a new group into the container into the parent group.
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
THMIDirection_t fDirection
Direction of the iterator.
Definition: THistManager.h:227
Bool_t operator!=(const iterator &aIter) const
Comparison operator for unequalness.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
~THistManager()
Destructor.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
TObject * FindObject(const char *name) const
Find an object inside the container.
int Int_t
Definition: External.C:63
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
Create a new TProfile within the container.
THistManager & operator=(const THistManager &)
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:658
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
const Double_t zmin
void ReleaseOwner()
Definition: THistManager.h:254
void FillProfile(const char *name, double x, double y, double weight=1.)
THMIDirection_t
Direction for the iteration.
Definition: THistManager.h:128
stl-iterator for the histogram manager
Definition: THistManager.h:115
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
iterator rbegin() const
Create backward iterator starting behind the end of the container.
Definition: THistManager.h:721
iterator & operator++()
Prefix increment operator.
Int_t nbinsx
iterator begin() const
Create forward iterator starting at the beginning of the container.
Definition: THistManager.h:717
TString basename(const TString &path) const
Extracting the basename from a given histogram path.
Collection of tests for the THistManager.
Definition: THistManager.h:753
iterator & operator--()
Prefix decrement operator.
TString histname(const TString &path) const
Extracting the histogram name from a given histogram path.
Definition: External.C:220
TObject * operator*() const
Dereferncing operator.
iterator end() const
Create forward iterator starting at the end of the container.
Definition: THistManager.h:725
const Double_t ymin
Definition: AddTaskCFDStar.C:6
Container class for histograms.
Definition: THistManager.h:99
iterator rend() const
Create backward iterator starting before the beginning of the container.
Definition: THistManager.h:729
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="")
Create a new THnSparse within the container.
THashList * fHistos
List of histograms.
Definition: THistManager.h:709
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="")
Create a new TH2 within the container.
Int_t fCurrentPos
Current position of the iterator in the histmanager.
Definition: THistManager.h:225