]>
Commit | Line | Data |
---|---|---|
1 | // @(#) $Id$ | |
2 | ||
3 | #ifndef ALIL3HISTOGRAM_H | |
4 | #define ALIL3HISTOGRAM_H | |
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 | public: | |
16 | ||
17 | AliL3Histogram(); | |
18 | 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); | |
19 | virtual ~AliL3Histogram(); | |
20 | ||
21 | void Reset(); | |
22 | virtual void Fill(Double_t x,Double_t y,Int_t weight=1); | |
23 | virtual void Fill(Double_t x,Int_t ybin,Int_t weight=1); | |
24 | virtual void Fill(Int_t xbin,Double_t y,Int_t weight=1); | |
25 | virtual void Fill(Int_t xbin,Int_t ybin,Int_t weight=1); | |
26 | virtual Int_t FindBin(Double_t x,Double_t y) const; | |
27 | virtual Int_t FindLabelBin(Double_t x,Double_t y) const; | |
28 | virtual Int_t FindXbin(Double_t x) const; | |
29 | virtual Int_t FindYbin(Double_t y) const; | |
30 | Int_t GetBin(Int_t xbin,Int_t ybin) const; | |
31 | Int_t GetLabelBin(Int_t xbin,Int_t ybin) const; | |
32 | Int_t GetBinContent(Int_t bin) const; | |
33 | void SetBinContent(Int_t xbin,Int_t ybin,Int_t value); | |
34 | void SetBinContent(Int_t bin,Int_t value); | |
35 | void AddBinContent(Int_t xbin,Int_t ybin,Int_t weight); | |
36 | void AddBinContent(Int_t bin,Int_t weight); | |
37 | void Add(AliL3Histogram *h1,Double_t weight=1); | |
38 | void SetThreshold(Int_t i) {fThreshold = i;} | |
39 | void CreateRootHisto(); | |
40 | virtual void Draw(Char_t *option="hist"); | |
41 | virtual void Print() const {}; | |
42 | ||
43 | friend ofstream& operator<< (ofstream &o, const AliL3Histogram &h); | |
44 | ||
45 | #ifdef use_root | |
46 | TH2F *GetRootHisto(); | |
47 | #else | |
48 | void *GetRootHisto(); | |
49 | #endif | |
50 | ||
51 | Double_t GetXmin() const {return fXmin;} | |
52 | Double_t GetXmax() const {return fXmax;} | |
53 | Double_t GetYmin() const {return fYmin;} | |
54 | Double_t GetYmax() const {return fYmax;} | |
55 | virtual Double_t GetBinCenterX(Int_t xbin) const; | |
56 | virtual Double_t GetBinCenterY(Int_t ybin) const; | |
57 | Double_t GetPreciseBinCenterX(Float_t xbin) const; | |
58 | Double_t GetPreciseBinCenterY(Float_t ybin) const; | |
59 | Double_t GetBinWidthX() const {return fBinwidthX;} | |
60 | Double_t GetBinWidthY() const {return fBinwidthY;} | |
61 | Int_t GetFirstXbin() const {return fFirstXbin;} | |
62 | Int_t GetLastXbin() const {return fLastXbin;} | |
63 | Int_t GetFirstYbin() const {return fFirstYbin;} | |
64 | Int_t GetLastYbin() const {return fLastYbin;} | |
65 | Int_t GetNbinsX() const {return fNxbins;} | |
66 | Int_t GetNbinsY() const {return fNybins;} | |
67 | Int_t GetNEntries() const {return fEntries;} | |
68 | ||
69 | Int_t *fContent; //! | |
70 | Int_t *GetContentArray() const {return fContent;} | |
71 | ||
72 | protected: | |
73 | Char_t fName[100]; // Name of the histogram | |
74 | Int_t fNxbins; // Number of bins in the histogram | |
75 | Int_t fNybins; // Number of bins in the histogram | |
76 | Int_t fNcells; // Overall number of bins in the histogram | |
77 | Int_t fEntries; // Number of entries in the histogram | |
78 | Int_t fFirstXbin; // First active bin | |
79 | Int_t fFirstYbin; // First active bin | |
80 | Int_t fLastXbin; // Last active bin | |
81 | Int_t fLastYbin; // Last active bin | |
82 | Int_t fThreshold; // Bin content threshold | |
83 | ||
84 | Double_t fXmin; // Lower limit in X | |
85 | Double_t fYmin; // Lower limit in Y | |
86 | Double_t fXmax; // Upper limit in X | |
87 | Double_t fYmax; // Upper limit in Y | |
88 | ||
89 | #ifdef use_root | |
90 | TH2F *fRootHisto; // Corresponding ROOT histogram | |
91 | #endif | |
92 | ||
93 | private: | |
94 | Double_t fBinwidthX; // Bin width of the Hough space | |
95 | Double_t fBinwidthY; // Bin width of the Hough space | |
96 | ||
97 | ClassDef(AliL3Histogram,1) //2D histogram class | |
98 | ||
99 | }; | |
100 | ||
101 | #ifdef use_root | |
102 | inline TH2F *AliL3Histogram::GetRootHisto() | |
103 | { | |
104 | if(!fRootHisto) | |
105 | { | |
106 | STDCERR<<"AliL3Histogram::GetRootHisto() : You must first Draw histogram before accessing it"<<STDENDL; | |
107 | return 0; | |
108 | } | |
109 | else | |
110 | return fRootHisto; | |
111 | } | |
112 | #else | |
113 | inline void *AliL3Histogram::GetRootHisto() | |
114 | { | |
115 | STDCERR<<"AliL3Histogram::GetRootHisto() : You must compile with ROOT in order to interface the ROOT histogram"<<STDENDL; | |
116 | return 0; | |
117 | } | |
118 | #endif | |
119 | ||
120 | #endif |