]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronHistos.h
- HF can take now all kind of histograms
[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   enum {kNoAutoFill=1000000000};
37
38   void UserProfile(const char* histClass,const char *name, const char* title,
39                    UInt_t valTypeP,
40                    Int_t nbinsX, Double_t xmin, Double_t xmax,
41                    UInt_t valTypeX=kNoAutoFill, Bool_t logBinX=kFALSE, TString option="");
42
43   void UserProfile(const char* histClass,const char *name, const char* title,
44                    UInt_t valTypeP,
45                    Int_t nbinsX, Double_t xmin, Double_t xmax,
46                    Int_t nbinsY, Double_t ymin, Double_t ymax,
47                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0,
48                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, TString option="");
49   
50   void UserProfile(const char* histClass,const char *name, const char* title,
51                    UInt_t valTypeP,
52                    Int_t nbinsX, Double_t xmin, Double_t xmax,
53                    Int_t nbinsY, Double_t ymin, Double_t ymax,
54                    Int_t nbinsZ, Double_t zmin, Double_t zmax,
55                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0,
56                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE, TString option="");
57   
58   void UserProfile(const char* histClass,const char *name, const char* title,
59                    UInt_t valTypeP,
60                    const char* binning, UInt_t valTypeX=kNoAutoFill, TString option="");
61   
62   void UserProfile(const char* histClass,const char *name, const char* title,
63                    UInt_t valTypeP,
64                    const TVectorD * const binsX, UInt_t valTypeX=kNoAutoFill, TString option="");
65   
66   void UserProfile(const char* histClass,const char *name, const char* title,
67                    UInt_t valTypeP,
68                    const TVectorD * const binsX, const TVectorD * const binsY,
69                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, TString option="");
70   
71   void UserProfile(const char* histClass,const char *name, const char* title,
72                    UInt_t valTypeP,
73                    const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
74                    UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0, TString option="");
75
76   void UserHistogram(const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars);
77   void UserSparse(   const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars);
78   void UserHistogram(const char* histClass, Int_t ndim, TObjArray *limits, UInt_t *vars);
79   void UserSparse(   const char* histClass, Int_t ndim, TObjArray *limits, UInt_t *vars);
80
81   void UserHistogram(const char* histClass,const char *name, const char* title,
82                      Int_t nbinsX, Double_t xmin, Double_t xmax, UInt_t valTypeX=kNoAutoFill, Bool_t logBinX=kFALSE)
83   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,valTypeX,logBinX); }
84
85   void UserHistogram(const char* histClass,const char *name, const char* title,
86                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
87                      UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE)
88   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,nbinsY,ymin,ymax,valTypeX,valTypeY,logBinX,logBinY); }
89
90   void UserHistogram(const char* histClass,const char *name, const char* title,
91                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
92                      Int_t nbinsZ, Double_t zmin, Double_t zmax, UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0,
93                      Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE)
94   { UserProfile(histClass,name,title,999,nbinsX,xmin,xmax,nbinsY,ymin,ymax,nbinsZ,zmin,zmax,valTypeX,valTypeY,valTypeZ,logBinX,logBinY,logBinZ); }
95
96   void UserHistogram(const char* histClass,const char *name, const char* title,
97                      const char* binning, UInt_t valTypeX=kNoAutoFill)
98   { UserProfile(histClass,name,title,999,binning,valTypeX); }
99
100   void UserHistogram(const char* histClass,const char *name, const char* title,
101                      const TVectorD * const binsX, UInt_t valTypeX=kNoAutoFill)
102   { UserProfile(histClass,name,title,999,binsX,valTypeX); }
103
104   void UserHistogram(const char* histClass,const char *name, const char* title,
105                      const TVectorD * const binsX, const TVectorD * const binsY, UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0)
106   { UserProfile(histClass,name,title,999,binsX,binsY,valTypeX,valTypeY); }
107
108   void UserHistogram(const char* histClass,const char *name, const char* title,
109                      const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
110                      UInt_t valTypeX=kNoAutoFill, UInt_t valTypeY=0, UInt_t valTypeZ=0)
111   { UserProfile(histClass,name,title,999,binsX,binsY,binsZ,valTypeX,valTypeY,valTypeZ); }
112
113   void UserHistogram(const char* histClass, TObject* hist, UInt_t valTypes=kNoAutoFill);
114
115   void Fill(const char* histClass, const char* name, Double_t xval);
116   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval);
117   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval, Double_t zval);
118   
119 //   void FillClass(const char* histClass, const TVectorD &vals);
120   void FillClass(const char* histClass, Int_t nValues, const Double_t *values);
121   
122   TObject* GetHist(const char* histClass, const char* name) const;
123   TH1* GetHistogram(const char* histClass, const char* name) const;
124   TObject* GetHist(const char* cutClass, const char* histClass, const char* name) const;
125   TH1* GetHistogram(const char* cutClass, const char* histClass, const char* name) const;
126
127   void SetHistogramList(THashList &list, Bool_t setOwner=kTRUE);
128   void ResetHistogramList(){fHistoList.Clear();}
129   const THashList* GetHistogramList() const {return &fHistoList;}
130
131   void SetList(TList * const list) { fList=list; }
132   TList *GetList() const { return fList; }
133
134   void AddClass(const char* histClass);
135
136   void DumpToFile(const char* file="histos.root");
137   void ReadFromFile(const char* file="histos.root");
138   
139   virtual void Print(const Option_t* option = "") const;
140   virtual void Draw(const Option_t* option = "");
141   virtual void DrawSame(const char* histName, const Option_t *opt="leg can");
142
143   void SetReservedWords(const char* words);
144
145 //   virtual void       Add(TObject *obj) {};
146 //   virtual void       Clear(Option_t *option="") {};
147 //   virtual void       Delete(Option_t *option="") {};
148 //   virtual TObject  **GetObjectRef(const TObject *obj) const { return 0; }
149 //   virtual TIterator *MakeIterator(Bool_t dir = kIterForward) const ;
150 //   virtual TObject   *Remove(TObject *obj) { return 0; }
151
152   Bool_t SetCutClass(const char* cutClass);
153   static void StoreVariables(TObject *obj, UInt_t valType[20]);
154   static void StoreVariables(TH1 *obj, UInt_t valType[20]);
155   static void StoreVariables(THnBase *obj, UInt_t valType[20]);
156   static void AdaptNameTitle(TH1 *hist, const char* histClass);
157   static Int_t GetPrecision(Double_t value);
158   static void FillValues(TObject *obj, const Double_t *values);
159   static void FillValues(TH1 *obj, const Double_t *values);
160   static void FillValues(THnBase *obj, const Double_t *values);
161
162 private:
163
164   void FillVarArray(TObject *obj, UInt_t *valType);
165
166   THashList fHistoList;             //-> list of histograms
167   TList    *fList;                  //! List of list of histograms
168
169   TString *fReservedWords;          //! list of reserved words
170   void UserHistogramReservedWords(const char* histClass, const TObject *hist, UInt_t valTypes);
171   void FillClass(THashTable *classTable, Int_t nValues, Double_t *values);
172   
173   void PrintPDF(Option_t* opt);
174   void PrintStructure() const;
175
176   Bool_t IsHistogramOk(const char* classTable, const char* name);
177   
178
179   AliDielectronHistos(const AliDielectronHistos &hist);
180   AliDielectronHistos& operator = (const AliDielectronHistos &hist);
181
182   ClassDef(AliDielectronHistos,2)
183 };
184
185 #endif
186