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