1 | #ifndef MARS_MBinning
|
---|
2 | #define MARS_MBinning
|
---|
3 |
|
---|
4 | #ifndef MARS_MParContainer
|
---|
5 | #include "MParContainer.h"
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifndef ROOT_TArrayD
|
---|
9 | #include "TArrayD.h"
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | class TH1;
|
---|
13 |
|
---|
14 | class MBinning : public MParContainer
|
---|
15 | {
|
---|
16 | private:
|
---|
17 | TArrayD fEdges;
|
---|
18 |
|
---|
19 | Byte_t fType;
|
---|
20 |
|
---|
21 | void StreamPrimitive(ofstream &out) const;
|
---|
22 |
|
---|
23 | enum {
|
---|
24 | kIsDefault,
|
---|
25 | kIsLinear,
|
---|
26 | kIsLogarithmic,
|
---|
27 | kIsCosinic,
|
---|
28 | kIsUserArray
|
---|
29 | };
|
---|
30 |
|
---|
31 | public:
|
---|
32 | MBinning(const char *name=NULL, const char *title=NULL);
|
---|
33 |
|
---|
34 | void SetEdges(const TArrayD &arr)
|
---|
35 | {
|
---|
36 | fEdges = arr;
|
---|
37 | fType = kIsUserArray;
|
---|
38 | }
|
---|
39 |
|
---|
40 | void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
|
---|
41 | void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
|
---|
42 | void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
|
---|
43 |
|
---|
44 | Int_t FindLoEdge(Double_t val) const
|
---|
45 | {
|
---|
46 | if (val<GetEdgeLo() || val>=GetEdgeHi())
|
---|
47 | return -1;
|
---|
48 |
|
---|
49 | for (int i=1; i<fEdges.GetSize()-1; i++)
|
---|
50 | {
|
---|
51 | if (((TArrayD)fEdges)[i] >= val)
|
---|
52 | return i-1;
|
---|
53 | }
|
---|
54 | return -1;
|
---|
55 | }
|
---|
56 | Int_t FindHiEdge(Double_t val) const
|
---|
57 | {
|
---|
58 | const Int_t i = FindLoEdge(val);
|
---|
59 | return i<0 ? -1 : i+1;
|
---|
60 | }
|
---|
61 |
|
---|
62 | // FIXME: ROOT workaround: "operator[] const" missing
|
---|
63 | Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
|
---|
64 | Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
|
---|
65 |
|
---|
66 | Int_t GetNumEdges() const { return fEdges.GetSize(); }
|
---|
67 | Int_t GetNumBins() const { return fEdges.GetSize()-1; }
|
---|
68 |
|
---|
69 | Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }
|
---|
70 |
|
---|
71 | Bool_t IsLinear() const { return fType==kIsLinear; }
|
---|
72 | Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
|
---|
73 | Bool_t IsCosinic() const { return fType==kIsCosinic; }
|
---|
74 | Bool_t IsDefault() const { return fType==kIsDefault; }
|
---|
75 | Bool_t IsUserArray() const { return fType==kIsUserArray; }
|
---|
76 |
|
---|
77 | void Apply(TH1 &);
|
---|
78 |
|
---|
79 | ClassDef(MBinning, 1) //Container to store the binning of a histogram
|
---|
80 | };
|
---|
81 |
|
---|
82 | #endif
|
---|
83 |
|
---|