]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliL3Histogram.h
Merged Bergen, mergen Cvetan TransformerRow and
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Histogram.h
1 // @(#) $Id$
2
3 #ifndef ALIL3_HISTOGRAM
4 #define ALIL3_HISTOGRAM
5
6 #include "AliL3StandardIncludes.h"
7 #include "AliL3RootTypes.h"
8 #include "AliL3StandardIncludes.h"
9
10 #ifdef use_root
11 #include <TH2.h>
12 #endif
13
14 class AliL3Histogram {
15   
16  private:
17   Double_t fBinwidthX;
18   Double_t fBinwidthY;
19   
20  protected:
21   Int_t *fContent; //!
22   Char_t fName[100];
23   Int_t fNxbins;
24   Int_t fNybins;
25   Int_t fNcells;
26   Int_t fEntries;
27   Int_t fFirstXbin;
28   Int_t fFirstYbin;
29   Int_t fLastXbin;
30   Int_t fLastYbin;
31   Int_t fThreshold;
32
33   Double_t fXmin;
34   Double_t fYmin;
35   Double_t fXmax;
36   Double_t fYmax;
37
38 #ifdef use_root
39   TH2F *fRootHisto;
40 #endif  
41   
42  public:
43
44   AliL3Histogram();
45   AliL3Histogram(Char_t *name,Char_t *id,Int_t nxbin,Double_t xmin,Double_t xmax,Int_t nybin,Double_t ymin,Double_t ymax);
46   virtual ~AliL3Histogram();
47   
48   void Reset();
49   virtual void Fill(Double_t x,Double_t y,Int_t weight=1);
50   virtual void Fill(Double_t x,Int_t ybin,Int_t weight=1);
51   virtual void Fill(Int_t xbin,Double_t y,Int_t weight=1);
52   virtual void Fill(Int_t xbin,Int_t ybin,Int_t weight=1);
53   virtual Int_t FindBin(Double_t x,Double_t y) const;
54   virtual Int_t FindXbin(Double_t x) const;
55   virtual Int_t FindYbin(Double_t y) const;
56   Int_t GetBin(Int_t xbin,Int_t ybin) const;
57   Int_t GetBinContent(Int_t bin) const;
58   void SetBinContent(Int_t xbin,Int_t ybin,Int_t value);
59   void SetBinContent(Int_t bin,Int_t value);
60   void AddBinContent(Int_t xbin,Int_t ybin,Int_t weight);
61   void AddBinContent(Int_t bin,Int_t weight);
62   void Add(AliL3Histogram *h1,Double_t weight=1);
63   void SetThreshold(Int_t i) {fThreshold = i;}
64   void CreateRootHisto();
65   virtual void Draw(Char_t *option="hist");
66   virtual void Print() {};
67
68   friend ofstream& operator<< (ofstream &o, const AliL3Histogram &h);
69
70 #ifdef use_root
71   TH2F *GetRootHisto();
72 #else
73   void *GetRootHisto();
74 #endif
75     
76   Double_t GetXmin() const {return fXmin;}
77   Double_t GetXmax() const {return fXmax;}
78   Double_t GetYmin() const {return fYmin;}
79   Double_t GetYmax() const {return fYmax;}
80   virtual Double_t GetBinCenterX(Int_t xbin) const;
81   virtual Double_t GetBinCenterY(Int_t ybin) const;
82   Double_t GetPreciseBinCenterX(Float_t xbin) const;
83   Double_t GetPreciseBinCenterY(Float_t ybin) const;
84   Double_t GetBinWidthX() const {return fBinwidthX;}
85   Double_t GetBinWidthY() const {return fBinwidthY;}
86   Int_t GetFirstXbin() const {return fFirstXbin;}
87   Int_t GetLastXbin() const {return fLastXbin;}
88   Int_t GetFirstYbin() const {return fFirstYbin;}
89   Int_t GetLastYbin() const {return fLastYbin;}
90   Int_t GetNbinsX() const {return fNxbins;}
91   Int_t GetNbinsY() const {return fNybins;}
92   Int_t GetNEntries() const {return fEntries;}
93   
94   ClassDef(AliL3Histogram,1) //2D histogram class
95     
96 };
97
98 #ifdef use_root
99 inline TH2F *AliL3Histogram::GetRootHisto()
100 {
101   if(!fRootHisto)
102     {
103       STDCERR<<"AliL3Histogram::GetRootHisto() : You must first Draw histogram before accessing it"<<STDENDL;
104       return 0;
105     }
106   else
107     return fRootHisto;
108 }
109 #else
110 inline void *AliL3Histogram::GetRootHisto()
111 {
112   STDCERR<<"AliL3Histogram::GetRootHisto() : You must compile with ROOT in order to interface the ROOT histogram"<<STDENDL;
113   return 0;
114 }
115 #endif
116
117 #endif