]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliL3Histogram.h
Moved to the latest version of the HLT code in Bergen.
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Histogram.h
1 // @(#) $Id$
2
3 #ifndef ALIL3_HISTOGRAM
4 #define ALIL3_HISTOGRAM
5
6 #include "AliL3RootTypes.h"
7
8 #ifdef use_root
9 #include <TH2.h>
10 #endif
11
12 class ostream;
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 Int_t FindBin(Double_t x,Double_t y) const;
51   virtual Int_t FindXbin(Double_t x) const;
52   virtual Int_t FindYbin(Double_t y) const;
53   Int_t GetBin(Int_t xbin,Int_t ybin) const;
54   Int_t GetBinContent(Int_t bin) const;
55   void SetBinContent(Int_t xbin,Int_t ybin,Int_t value);
56   void SetBinContent(Int_t bin,Int_t value);
57   void AddBinContent(Int_t xbin,Int_t ybin,Int_t weight);
58   void AddBinContent(Int_t bin,Int_t weight);
59   void Add(AliL3Histogram *h1,Double_t weight=1);
60   void SetThreshold(Int_t i) {fThreshold = i;}
61   void CreateRootHisto();
62   virtual void Draw(Char_t *option="hist");
63   virtual void Print() {};
64
65   friend ostream& operator<< (ostream &o, const AliL3Histogram &h);
66
67 #ifdef use_root
68   TH2F *GetRootHisto();
69 #else
70   void *GetRootHisto();
71 #endif
72     
73   Double_t GetXmin() const {return fXmin;}
74   Double_t GetXmax() const {return fXmax;}
75   Double_t GetYmin() const {return fYmin;}
76   Double_t GetYmax() const {return fYmax;}
77   virtual Double_t GetBinCenterX(Int_t xbin) const;
78   virtual Double_t GetBinCenterY(Int_t ybin) const;
79   Double_t GetBinWidthX() const {return fBinwidthX;}
80   Double_t GetBinWidthY() const {return fBinwidthY;}
81   Int_t GetFirstXbin() const {return fFirstXbin;}
82   Int_t GetLastXbin() const {return fLastXbin;}
83   Int_t GetFirstYbin() const {return fFirstYbin;}
84   Int_t GetLastYbin() const {return fLastYbin;}
85   Int_t GetNbinsX() const {return fNxbins;}
86   Int_t GetNbinsY() const {return fNybins;}
87   Int_t GetNEntries() const {return fEntries;}
88   
89   ClassDef(AliL3Histogram,1) //2D histogram class
90     
91 };
92
93 #ifdef use_root
94 inline TH2F *AliL3Histogram::GetRootHisto()
95 {
96   if(!fRootHisto)
97     {
98       STDCERR<<"AliL3Histogram::GetRootHisto() : You must first Draw histogram before accessing it"<<STDENDL;
99       return 0;
100     }
101   else
102     return fRootHisto;
103 }
104 #else
105 inline void *AliL3Histogram::GetRootHisto()
106 {
107   STDCERR<<"AliL3Histogram::GetRootHisto() : You must compile with ROOT in order to interface the ROOT histogram"<<STDENDL;
108   return 0;
109 }
110 #endif
111
112 #endif