1 | #ifndef MARS_MH3
|
---|
2 | #define MARS_MH3
|
---|
3 |
|
---|
4 | #ifndef ROOT_TH1
|
---|
5 | #include <TH1.h>
|
---|
6 | #endif
|
---|
7 | #ifndef MARS_MH
|
---|
8 | #include "MH.h"
|
---|
9 | #endif
|
---|
10 | #ifndef MARS_MObjLookup
|
---|
11 | #include "MObjLookup.h"
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | class TH1;
|
---|
15 | class MData;
|
---|
16 | class MBinning;
|
---|
17 | class TFormula;
|
---|
18 |
|
---|
19 | class MH3 : public MH
|
---|
20 | {
|
---|
21 | public:
|
---|
22 | enum Labels_t {
|
---|
23 | kNoLabels = 0,
|
---|
24 | kLabelsX = BIT(0),
|
---|
25 | kLabelsY = BIT(1),
|
---|
26 | kLabelsZ = BIT(2),
|
---|
27 | kLabelsXY = kLabelsX|kLabelsY,
|
---|
28 | kLabelsXZ = kLabelsX|kLabelsZ,
|
---|
29 | kLabelsYZ = kLabelsY|kLabelsZ,
|
---|
30 | kLabelsXYZ = kLabelsX|kLabelsY|kLabelsZ,
|
---|
31 | };
|
---|
32 |
|
---|
33 | private:
|
---|
34 | static const TString gsDefName;
|
---|
35 | static const TString gsDefTitle;
|
---|
36 |
|
---|
37 | // Helper for constructor
|
---|
38 | void Init();
|
---|
39 |
|
---|
40 | // Helper for dealing with labeled histograms
|
---|
41 | MObjLookup *GetLabels(char axe);
|
---|
42 | void InitLabels(TAxis &x) const;
|
---|
43 | void DeflateLabels() const;
|
---|
44 | Labels_t GetLabels() const;
|
---|
45 | const char *GetLabel(Int_t axe, Double_t val) const;
|
---|
46 |
|
---|
47 | MObjLookup fLabels[3]; //! Lookup table to conflate and name labels
|
---|
48 |
|
---|
49 | protected:
|
---|
50 | // Could be const but root < 3.02/06 doesn't like this...
|
---|
51 | Int_t fDimension; // Number of dimensions of histogram
|
---|
52 | TH1 *fHist; // Histogram to fill
|
---|
53 | MData *fData[4]; // Object from which the data is filled (+additional weight)
|
---|
54 | MBinning *fBins[3]; // Binning set omitting the parlist access
|
---|
55 | Double_t fScale[3]; // Scale for the three axis (eg unit)
|
---|
56 | Byte_t fStyleBits; // Set the range of a histogram automatically in Finalize
|
---|
57 |
|
---|
58 | TFormula *fConversion; // Conversion function for displaying the histogram
|
---|
59 |
|
---|
60 | void HandleLogAxis(TAxis &axe) const;
|
---|
61 | void Convert(TH1 &h) const;
|
---|
62 |
|
---|
63 | void StreamPrimitive(ostream &out) const;
|
---|
64 |
|
---|
65 |
|
---|
66 | enum {
|
---|
67 | kIsLogx = BIT(17),
|
---|
68 | kIsLogy = BIT(18),
|
---|
69 | kIsLogz = BIT(19)
|
---|
70 | };
|
---|
71 |
|
---|
72 | public:
|
---|
73 | enum Type_t {
|
---|
74 | kHistogram,
|
---|
75 | kProfile,
|
---|
76 | };
|
---|
77 |
|
---|
78 | MH3(const Int_t dim=0, Type_t type=MH3::kHistogram);
|
---|
79 | MH3(const TH1 &h1);
|
---|
80 | MH3(const char *memberx, Type_t type=MH3::kHistogram);
|
---|
81 | MH3(const char *memberx, const char *membery, Type_t type=MH3::kHistogram);
|
---|
82 | MH3(const char *memberx, const char *membery, const char *memberz, Type_t type=MH3::kHistogram);
|
---|
83 | ~MH3();
|
---|
84 |
|
---|
85 | // Setter
|
---|
86 | void SetScaleX(Double_t scale) { fScale[0] = scale; }
|
---|
87 | void SetScaleY(Double_t scale) { fScale[1] = scale; }
|
---|
88 | void SetScaleZ(Double_t scale) { fScale[2] = scale; }
|
---|
89 | void SetScale(Double_t x, Double_t y=1, Double_t z=2) { SetScaleX(x); SetScaleY(y); SetScaleZ(z); }
|
---|
90 |
|
---|
91 | void SetLogx(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogx) : fHist->ResetBit(kIsLogx); }
|
---|
92 | void SetLogy(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogy) : fHist->ResetBit(kIsLogy); }
|
---|
93 | void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); }
|
---|
94 | void SetLog(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetLogx(x); SetLogy(y); SetLogz(z); }
|
---|
95 |
|
---|
96 | void SetAutoRangeX(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 0) : CLRBIT(fStyleBits, 0); }
|
---|
97 | void SetAutoRangeY(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 1) : CLRBIT(fStyleBits, 1); }
|
---|
98 | void SetAutoRangeZ(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 2) : CLRBIT(fStyleBits, 2); }
|
---|
99 | void SetAutoRange(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetAutoRangeX(x); SetAutoRangeY(y); SetAutoRangeZ(z); }
|
---|
100 |
|
---|
101 | void SetBinningX(MBinning *x) { fBins[0] = x; }
|
---|
102 | void SetBinningY(MBinning *y) { fBins[1] = y; }
|
---|
103 | void SetBinningZ(MBinning *z) { fBins[2] = z; }
|
---|
104 | void SetBinnings(MBinning *x=0, MBinning *y=0, MBinning *z=0) { SetBinningX(x); SetBinningY(y); SetBinningZ(z); }
|
---|
105 |
|
---|
106 | void Sumw2() const { if (fHist) fHist->Sumw2(); }
|
---|
107 |
|
---|
108 | void InitLabels(Labels_t labels) const;
|
---|
109 |
|
---|
110 | void DefaultLabel(char axe, const char *name=0);
|
---|
111 | void DefaultLabelX(const char *name=0) { DefaultLabel('x', name); }
|
---|
112 | void DefaultLabelY(const char *name=0) { DefaultLabel('y', name); }
|
---|
113 | void DefaultLabelZ(const char *name=0) { DefaultLabel('z', name); }
|
---|
114 |
|
---|
115 | void DefineLabel(char axe, Int_t label=0, const char *name=0);
|
---|
116 | void DefineLabelX(Int_t label, const char *name) { DefineLabel('x', label, name); }
|
---|
117 | void DefineLabelY(Int_t label, const char *name) { DefineLabel('y', label, name); }
|
---|
118 | void DefineLabelZ(Int_t label, const char *name) { DefineLabel('z', label, name); }
|
---|
119 |
|
---|
120 | void DefineLabels(char axe, const TString &labels);
|
---|
121 | void DefineLabelsX(const TString &labels) { DefineLabels('x', labels); }
|
---|
122 | void DefineLabelsY(const TString &labels) { DefineLabels('y', labels); }
|
---|
123 | void DefineLabelsZ(const TString &labels) { DefineLabels('z', labels); }
|
---|
124 |
|
---|
125 | void SetWeight(const char *phrase);
|
---|
126 |
|
---|
127 | Bool_t SetConversion(const char *func="");
|
---|
128 |
|
---|
129 | // Getter
|
---|
130 | Int_t GetDimension() const { return TMath::Abs(fDimension); }
|
---|
131 | Int_t GetNbins() const;
|
---|
132 | Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
|
---|
133 |
|
---|
134 | TH1 &GetHist() { return *fHist; }
|
---|
135 | const TH1 &GetHist() const { return *fHist; }
|
---|
136 |
|
---|
137 | TString GetDataMember() const;
|
---|
138 | TString GetRule(const Char_t axis='x') const;
|
---|
139 |
|
---|
140 | // MH
|
---|
141 | Bool_t SetupFill(const MParList *pList);
|
---|
142 | Int_t Fill(const MParContainer *par, const Stat_t w=1);
|
---|
143 | Bool_t Finalize();
|
---|
144 |
|
---|
145 | TH1 *GetHistByName(const TString name="") const { return fHist; }
|
---|
146 | TObject *FindObject(const TObject *obj) const { return 0; }
|
---|
147 | TObject *FindObject(const char *name) const
|
---|
148 | {
|
---|
149 | return (TObject*)GetHistByName(name);
|
---|
150 | }
|
---|
151 |
|
---|
152 | // MParContainer
|
---|
153 | MParContainer *New() const;
|
---|
154 |
|
---|
155 | // TObject
|
---|
156 | void SetName(const char *name);
|
---|
157 | void SetTitle(const char *title);
|
---|
158 |
|
---|
159 | const char *GetTitle() const { return fHist ? fHist->GetTitle() : static_cast<const char *>(fTitle); }
|
---|
160 | const TString &GetFullTitle() const { return fTitle; }
|
---|
161 |
|
---|
162 | void Draw(Option_t *opt=NULL);
|
---|
163 | void Paint(Option_t *opt="");
|
---|
164 |
|
---|
165 | void RecursiveRemove(TObject *obj);
|
---|
166 |
|
---|
167 | ClassDef(MH3, 5) // Generalized 1/2/3D-histogram for Mars variables
|
---|
168 | };
|
---|
169 |
|
---|
170 | #endif
|
---|