]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliL3Histogram.h
Also add the number of entries when adding 2 histograms.
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Histogram.h
1 #ifndef ALIL3_HISTOGRAM
2 #define ALIL3_HISTOGRAM
3
4 #include <stream.h>
5 #include "AliL3RootTypes.h"
6
7 #ifdef use_root
8 #include <TH2.h>
9 #endif
10
11 class AliL3Histogram {
12   
13  private:
14   
15   Int_t *fContent; //!
16   Char_t fName[100];
17   Int_t fNxbins;
18   Int_t fNybins;
19   Int_t fNcells;
20   Int_t fEntries;
21   Int_t fFirstXbin;
22   Int_t fFirstYbin;
23   Int_t fLastXbin;
24   Int_t fLastYbin;
25   Int_t fThreshold;
26
27   Double_t fXmin;
28   Double_t fYmin;
29   Double_t fXmax;
30   Double_t fYmax;
31
32 #ifdef use_root
33   TH2F *fRootHisto;
34 #endif  
35
36  public:
37   AliL3Histogram();
38   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);
39   virtual ~AliL3Histogram();
40   
41   void Reset();
42   void Fill(Double_t x,Double_t y,Int_t weight=1);
43   Int_t FindBin(Double_t x,Double_t y);
44   Int_t FindXbin(Double_t x);
45   Int_t FindYbin(Double_t y);
46   Int_t GetBin(Int_t xbin,Int_t ybin);
47   Int_t GetBinContent(Int_t bin);
48   void SetBinContent(Int_t xbin,Int_t ybin,Int_t value);
49   void SetBinContent(Int_t bin,Int_t value);
50   void AddBinContent(Int_t xbin,Int_t ybin,Int_t weight);
51   void AddBinContent(Int_t bin,Int_t weight);
52   void Add(AliL3Histogram *h1,Double_t weight=1);
53   void SetThreshold(Int_t i) {fThreshold = i;}
54   void Draw(Char_t *option="hist");
55   void CreateRootHisto();
56
57 #ifdef use_root
58   TH2F *GetRootHisto();
59 #else
60   void *GetRootHisto();
61 #endif
62     
63   Double_t GetXmin() {return fXmin;}
64   Double_t GetXmax() {return fXmax;}
65   Double_t GetYmin() {return fYmin;}
66   Double_t GetYmax() {return fYmax;}
67   Double_t GetBinCenterX(Int_t xbin);
68   Double_t GetBinCenterY(Int_t ybin);
69   Int_t GetFirstXbin() {return fFirstXbin;}
70   Int_t GetLastXbin() {return fLastXbin;}
71   Int_t GetFirstYbin() {return fFirstYbin;}
72   Int_t GetLastYbin() {return fLastYbin;}
73   Int_t GetNbinsX() {return fNxbins;}
74   Int_t GetNbinsY() {return fNybins;}
75   Int_t GetNEntries() {return fEntries;}
76   
77   
78   ClassDef(AliL3Histogram,1) //2D histogram class
79     
80 };
81
82 #ifdef use_root
83 inline TH2F *AliL3Histogram::GetRootHisto()
84 {
85   if(!fRootHisto)
86     {
87       cerr<<"AliL3Histogram::GetRootHisto() : You must first Draw histogram before accessing it"<<endl;
88       return 0;
89     }
90   else
91     return fRootHisto;
92 }
93 #else
94 inline void *AliL3Histogram::GetRootHisto()
95 {
96   cerr<<"AliL3Histogram::GetRootHisto() : You must compile with ROOT in order to interface the ROOT histogram"<<endl;
97   return 0;
98 }
99 #endif
100
101 #endif