]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronHistos.h
-sync with gsi repository
[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 //   Julian Book   <Julian.Book@cern.ch>                                                 //
14 //                                                                                       //
15 ///////////////////////////////////////////////////////////////////////////////////////////
16
17 #include <Rtypes.h>
18
19 #include <TNamed.h>
20 // #include <TCollection.h>
21 #include <THashList.h>
22 #include <TVectorDfwd.h>
23 #include <THnBase.h>
24
25 class TH1;
26 class TString;
27 class TList;
28 // class TVectorT<double>;
29
30 class AliDielectronHistos : public TNamed {
31 public:
32
33   AliDielectronHistos();
34   AliDielectronHistos(const char* name, const char* title);
35   virtual ~AliDielectronHistos();
36
37   enum {kNoAutoFill=1000000000, kNoProfile=999, kNoWeights=998};
38
39   void UserProfile(const char* histClass,const char *name, const char* title,
40                    UInt_t valTypeP,
41                    Int_t nbinsX, Double_t xmin, Double_t xmax,
42                    UInt_t valTypeX, Bool_t logBinX=kFALSE, TString option="",
43                    UInt_t valTypeW=kNoWeights);
44
45   void UserProfile(const char* histClass,const char *name, const char* title,
46                    UInt_t valTypeP,
47                    Int_t nbinsX, Double_t xmin, Double_t xmax,
48                    Int_t nbinsY, Double_t ymin, Double_t ymax,
49                    UInt_t valTypeX, UInt_t valTypeY,
50                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, TString option="",
51                    UInt_t valTypeW=kNoWeights);
52   
53   void UserProfile(const char* histClass,const char *name, const char* title,
54                    UInt_t valTypeP,
55                    Int_t nbinsX, Double_t xmin, Double_t xmax,
56                    Int_t nbinsY, Double_t ymin, Double_t ymax,
57                    Int_t nbinsZ, Double_t zmin, Double_t zmax,
58                    UInt_t valTypeX, UInt_t valTypeY, UInt_t valTypeZ,
59                    Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE, TString option="",
60                    UInt_t valTypeW=kNoWeights);
61   
62   void UserProfile(const char* histClass,const char *name, const char* title,
63                    UInt_t valTypeP,
64                    const char* binning, UInt_t valTypeX, TString option="",
65                    UInt_t valTypeW=kNoWeights);
66   
67   void UserProfile(const char* histClass,const char *name, const char* title,
68                    UInt_t valTypeP,
69                    const TVectorD * const binsX, UInt_t valTypeX, TString option="",
70                    UInt_t valTypeW=kNoWeights);
71   
72   void UserProfile(const char* histClass,const char *name, const char* title,
73                    UInt_t valTypeP,
74                    const TVectorD * const binsX, const TVectorD * const binsY,
75                    UInt_t valTypeX, UInt_t valTypeY, TString option="",
76                    UInt_t valTypeW=kNoWeights);
77   
78   void UserProfile(const char* histClass,const char *name, const char* title,
79                    UInt_t valTypeP,
80                    const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
81                    UInt_t valTypeX, UInt_t valTypeY, UInt_t valTypeZ, TString option="",
82                    UInt_t valTypeW=kNoWeights);
83
84   void UserHistogram(const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars, UInt_t valTypeW=kNoWeights);
85   void UserSparse(   const char* histClass, Int_t ndim, Int_t *bins, Double_t *mins, Double_t *maxs, UInt_t *vars, UInt_t valTypeW=kNoWeights);
86   void UserHistogram(const char* histClass, Int_t ndim, TObjArray *limits, UInt_t *vars, UInt_t valTypeW=kNoWeights);
87   void UserSparse(   const char* histClass, Int_t ndim, TObjArray *limits, UInt_t *vars, UInt_t valTypeW=kNoWeights);
88
89   void UserHistogram(const char* histClass,const char *name, const char* title,
90                      Int_t nbinsX, Double_t xmin, Double_t xmax, UInt_t valTypeX, Bool_t logBinX=kFALSE)
91   { UserProfile(histClass,name,title,kNoProfile,nbinsX,xmin,xmax,valTypeX,logBinX); }
92
93   void UserHistogram(const char* histClass,const char *name, const char* title,
94                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
95                      UInt_t valTypeX, UInt_t valTypeY, Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE,
96                      UInt_t valTypeW=kNoWeights)
97   { UserProfile(histClass,name,title,kNoProfile,nbinsX,xmin,xmax,nbinsY,ymin,ymax,valTypeX,valTypeY,logBinX,logBinY,valTypeW); }
98
99   void UserHistogram(const char* histClass,const char *name, const char* title,
100                      Int_t nbinsX, Double_t xmin, Double_t xmax, Int_t nbinsY, Double_t ymin, Double_t ymax,
101                      Int_t nbinsZ, Double_t zmin, Double_t zmax, UInt_t valTypeX, UInt_t valTypeY, UInt_t valTypeZ,
102                      Bool_t logBinX=kFALSE, Bool_t logBinY=kFALSE, Bool_t logBinZ=kFALSE,
103                      UInt_t valTypeW=kNoWeights)
104   { UserProfile(histClass,name,title,kNoProfile,nbinsX,xmin,xmax,nbinsY,ymin,ymax,nbinsZ,zmin,zmax,valTypeX,valTypeY,valTypeZ,logBinX,logBinY,logBinZ,valTypeW); }
105
106   void UserHistogram(const char* histClass,const char *name, const char* title,
107                      const char* binning, UInt_t valTypeX)
108   { UserProfile(histClass,name,title,kNoProfile,binning,valTypeX); }
109
110   void UserHistogram(const char* histClass,const char *name, const char* title,
111                      const TVectorD * const binsX, UInt_t valTypeX)
112   { UserProfile(histClass,name,title,kNoProfile,binsX,valTypeX); }
113
114   void UserHistogram(const char* histClass,const char *name, const char* title,
115                      const TVectorD * const binsX, UInt_t valTypeX, UInt_t valTypeW)
116   { UserProfile(histClass,name,title,kNoProfile,binsX,valTypeX,valTypeW); }
117
118   void UserHistogram(const char* histClass,const char *name, const char* title,
119                      const TVectorD * const binsX, const TVectorD * const binsY, UInt_t valTypeX, UInt_t valTypeY,
120                      UInt_t valTypeW=kNoWeights)
121   { UserProfile(histClass,name,title,kNoProfile,binsX,binsY,valTypeX,valTypeY,valTypeW); }
122
123   void UserHistogram(const char* histClass,const char *name, const char* title,
124                      const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ,
125                      UInt_t valTypeX, UInt_t valTypeY, UInt_t valTypeZ,
126                      UInt_t valTypeW=kNoWeights)
127   { UserProfile(histClass,name,title,kNoProfile,binsX,binsY,binsZ,valTypeX,valTypeY,valTypeZ,valTypeW); }
128
129   void UserHistogram(const char* histClass, TObject* hist, UInt_t valTypes=kNoAutoFill);
130
131   // some functions needed to garantuee backward compatibility
132   void UserHistogram(const char* histClass,const char *name, const char* title,
133                      Int_t nbinsX, Double_t xmin, Double_t xmax)
134   { UserProfile(histClass,name,title,kNoProfile,nbinsX,xmin,xmax,kNoAutoFill); }
135   void UserHistogram(const char* histClass,const char *name, const char* title,
136                      Int_t nbinsX, Double_t xmin, Double_t xmax,
137                      Int_t nbinsY, Double_t ymin, Double_t ymax)
138   { UserProfile(histClass,name,title,kNoProfile,nbinsX,xmin,xmax,nbinsY,ymin,ymax,kNoAutoFill,kNoAutoFill); }
139
140
141   void Fill(const char* histClass, const char* name, Double_t xval);
142   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval);
143   void Fill(const char* histClass, const char* name, Double_t xval, Double_t yval, Double_t zval);
144   
145 //   void FillClass(const char* histClass, const TVectorD &vals);
146   void FillClass(const char* histClass, Int_t nValues, const Double_t *values);
147   
148   TObject* GetHist(const char* histClass, const char* name) const;
149   TH1* GetHistogram(const char* histClass, const char* name) const;
150   TObject* GetHist(const char* cutClass, const char* histClass, const char* name) const;
151   TH1* GetHistogram(const char* cutClass, const char* histClass, const char* name) const;
152
153   void SetHistogramList(THashList &list, Bool_t setOwner=kTRUE);
154   void ResetHistogramList(){fHistoList.Clear();}
155   const THashList* GetHistogramList() const {return &fHistoList;}
156
157   void SetList(TList * const list) { fList=list; }
158   TList *GetList() const { return fList; }
159
160   void AddClass(const char* histClass);
161
162   void DumpToFile(const char* file="histos.root");
163   void ReadFromFile(const char* file="histos.root");
164   
165   virtual void Print(const Option_t* option = "") const;
166   virtual void Draw(const Option_t* option = "");
167   virtual void DrawSame(const char* histName, const Option_t *opt="leg can");
168
169   void SetReservedWords(const char* words);
170
171 //   virtual void       Add(TObject *obj) {};
172 //   virtual void       Clear(Option_t *option="") {};
173 //   virtual void       Delete(Option_t *option="") {};
174 //   virtual TObject  **GetObjectRef(const TObject *obj) const { return 0; }
175 //   virtual TIterator *MakeIterator(Bool_t dir = kIterForward) const ;
176 //   virtual TObject   *Remove(TObject *obj) { return 0; }
177
178   Bool_t SetCutClass(const char* cutClass);
179   static void StoreVariables(TObject *obj, UInt_t valType[20]);
180   static void StoreVariables(TH1 *obj, UInt_t valType[20]);
181   static void StoreVariables(THnBase *obj, UInt_t valType[20]);
182   static void AdaptNameTitle(TH1 *hist, const char* histClass);
183   static Int_t GetPrecision(Double_t value);
184   static void FillValues(TObject *obj, const Double_t *values);
185   static void FillValues(TH1 *obj, const Double_t *values);
186   static void FillValues(THnBase *obj, const Double_t *values);
187
188 private:
189
190   void FillVarArray(TObject *obj, UInt_t *valType);
191
192   THashList fHistoList;             //-> list of histograms
193   TList    *fList;                  //! List of list of histograms
194
195   TString *fReservedWords;          //! list of reserved words
196   void UserHistogramReservedWords(const char* histClass, const TObject *hist, UInt_t valTypes);
197   void FillClass(THashTable *classTable, Int_t nValues, Double_t *values);
198   
199   void PrintPDF(Option_t* opt);
200   void PrintStructure() const;
201
202   Bool_t IsHistogramOk(const char* classTable, const char* name);
203   
204
205   AliDielectronHistos(const AliDielectronHistos &hist);
206   AliDielectronHistos& operator = (const AliDielectronHistos &hist);
207
208   ClassDef(AliDielectronHistos,2)
209 };
210
211 #endif
212