]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronHistos.h
- use base class for multidimensional objects
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronHistos.h
1 #ifndef ALIDIELECTRONHISTOS_H
2 #define ALIDIELECTRONHISTOS_H
3 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 ///////////////////////////////////////////////////////////////////////////////////////////
7 //                                                                                       //
8 // Generic Histogram container with support for groups and filling of groups by passing  //
9 // a vector of data                                                                      //
10 //                                                                                       //
11 // Authors:                                                                              //
12 //   Jens Wiechula <Jens.Wiechula@cern.ch>                                               //
13 //                                                                                       //
14 ///////////////////////////////////////////////////////////////////////////////////////////
15
16 #include <Rtypes.h>
17
18 #include <TNamed.h>
19 // #include <TCollection.h>
20 #include <THashList.h>
21 #include <TVectorDfwd.h>
22 #include <THnBase.h>
23
24 class TH1;
25 class TString;
26 class TList;
27 // class TVectorT<double>;
28
29 class AliDielectronHistos : public TNamed {
30 public:
31
32   AliDielectronHistos();
33   AliDielectronHistos(const char* name, const char* title);
34   virtual ~AliDielectronHistos();
35
36   
37   void UserProfile(const char* histClass,const char *name, const char* title,
38                    UInt_t valTypeP,
39                    Int_t nbinsX, Double_t xmin, Double_t xmax,
40                    UInt_t valTypeX=kNoAutoFill, Bool_t logBinX=kFALSE, TString option="");
41
42   void UserProfile(const char* histClass,const char *name, const char* title,
43                    UInt_t valTypeP,
44                    Int_t nbinsX, Double_t xmin, Double_t xmax,
45                    Int_t nbinsY, Double_t ymin, Double_t ymax,
46                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0,
47                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, TString option="");
48   
49   void UserProfile(const char* histClass,const char *name, const char* title,
50                    UInt_t valTypeP,
51                    Int_t nbinsX, Double_t xmin, Double_t xmax,
52                    Int_t nbinsY, Double_t ymin, Double_t ymax,
53                    Int_t nbinsZ, Double_t zmin, Double_t zmax,
54                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0,
55                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE, TString option="");
56   
57   void UserProfile(const char* histClass,const char *name, const char* title,
58                    UInt_t valTypeP,
59                    const char* binning, UInt_t valTypeX=kNoAutoFill, TString option="");
60   
61   void UserProfile(const char* histClass,const char *name, const char* title,
62                    UInt_t valTypeP,
63                    const TVectorD * const binsX, UInt_t valTypeX=kNoAutoFill, TString option="");
64   
65   void UserProfile(const char* histClass,const char *name, const char* title,
66                    UInt_t valTypeP,
67                    const TVectorD * const binsX, const TVectorD * const binsY,
68                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, TString option="");
69   
70   void UserProfile(const char* histClass,const char *name, const char* title,
71                    UInt_t valTypeP,
72                    const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
73                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0, TString option="");
74
75   void UserHistogram(const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars);
76   void UserSparse(const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars);
77
78   void UserHistogram(const char* histClass,const char *name, const char* title,
79                      Int_t nbinsX, Double_t xmin, Double_t xmax, UInt_t valTypeX=kNoAutoFill, Bool_t logBinX=kFALSE)
80   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,valTypeX,logBinX); }
81
82   void UserHistogram(const char* histClass,const char *name, const char* title,
83                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
84                      UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE)
85   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,nbinsY,ymin,ymax,valTypeX,valTypeY,logBinX,logBinY); }
86
87   void UserHistogram(const char* histClass,const char *name, const char* title,
88                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
89                      Int_t nbinsZ, Double_t zmin, Double_t zmax, UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0,
90                      Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE)
91   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,nbinsY,ymin,ymax,nbinsZ,zmin,zmax,valTypeX,valTypeY,valTypeZ,logBinX,logBinY,logBinZ); }
92
93   void UserHistogram(const char* histClass,const char *name, const char* title,
94                      const char* binning, UInt_t valTypeX=kNoAutoFill)
95   { UserProfile(histClass,name,title,999,binning,valTypeX); }
96
97   void UserHistogram(const char* histClass,const char *name, const char* title,
98                      const TVectorD * const binsX, UInt_t valTypeX=kNoAutoFill)
99   { UserProfile(histClass,name,title,999,binsX,valTypeX); }
100
101   void UserHistogram(const char* histClass,const char *name, const char* title,
102                      const TVectorD * const binsX, const TVectorD * const binsY, UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0)
103   { UserProfile(histClass,name,title,999,binsX,binsY,valTypeX,valTypeY); }
104
105   void UserHistogram(const char* histClass,const char *name, const char* title,
106                      const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
107                      UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0)
108   { UserProfile(histClass,name,title,999,binsX,binsY,binsZ,valTypeX,valTypeY,valTypeZ); }
109   
110   void UserHistogram(const char* histClass, TObject* hist, UInt_t valTypes=kNoAutoFill);
111
112   void Fill(const char* histClass, const char* name, Double_t xval);
113   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval);
114   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval, Double_t zval);
115   
116 //   void FillClass(const char* histClass, const TVectorD &vals);
117   void FillClass(const char* histClass, Int_t nValues, const Double_t *values);
118   
119   void StoreVariables(TObject *obj, UInt_t valType[20]);
120   void StoreVariables(TH1 *obj, UInt_t valType[20]);
121   void StoreVariables(THnBase *obj, UInt_t valType[20]);
122   void AdaptNameTitle(TH1 *hist, const char* histClass);
123   Int_t GetPrecision(Double_t value);
124   void FillVarArray(TObject *obj, UInt_t *valType);
125   void FillValues(TObject *obj, const Double_t *values);
126   void FillValues(TH1 *obj, const Double_t *values);
127   void FillValues(THnBase *obj, const Double_t *values);
128
129   TObject* GetHist(const char* histClass, const char* name) const;
130   TH1* GetHistogram(const char* histClass, const char* name) const;
131   TObject* GetHist(const char* cutClass, const char* histClass, const char* name) const;
132   TH1* GetHistogram(const char* cutClass, const char* histClass, const char* name) const;
133
134   void SetHistogramList(THashList &list, Bool_t setOwner=kTRUE);
135   void ResetHistogramList(){fHistoList.Clear();}
136   const THashList* GetHistogramList() const {return &fHistoList;}
137
138   void SetList(TList * const list) { fList=list; }
139   TList *GetList() const { return fList; }
140
141   void AddClass(const char* histClass);
142
143   void DumpToFile(const char* file="histos.root");
144   void ReadFromFile(const char* file="histos.root");
145   
146   virtual void Print(const Option_t* option = "") const;
147   virtual void Draw(const Option_t* option = "");
148   virtual void DrawSame(const char* histName, const Option_t *opt="leg can");
149
150   void SetReservedWords(const char* words);
151   //  void StoreVarForProfile(TObject *obj, UInt_t valType);
152 //   virtual void       Add(TObject *obj) {};
153 //   virtual void       Clear(Option_t *option="") {};
154 //   virtual void       Delete(Option_t *option="") {};
155 //   virtual TObject  **GetObjectRef(const TObject *obj) const { return 0; }
156 //   virtual TIterator *MakeIterator(Bool_t dir = kIterForward) const ;
157 //   virtual TObject   *Remove(TObject *obj) { return 0; }
158
159   Bool_t SetCutClass(const char* cutClass);
160   
161 private:
162   THashList fHistoList;             //-> list of histograms
163   TList    *fList;                  //! List of list of histograms
164
165   TString *fReservedWords;          //! list of reserved words
166   void UserHistogramReservedWords(const char* histClass, const TObject *hist, UInt_t valTypes);
167   void FillClass(THashTable *classTable, Int_t nValues, Double_t *values);
168   
169   void PrintPDF(Option_t* opt);
170   void PrintStructure() const;
171
172   Bool_t IsHistogramOk(const char* classTable, const char* name);
173   
174   enum {kNoAutoFill=1000000000};
175
176   AliDielectronHistos(const AliDielectronHistos &hist);
177   AliDielectronHistos& operator = (const AliDielectronHistos &hist);
178
179   ClassDef(AliDielectronHistos,2)
180 };
181
182 #endif
183