source: trunk/MagicSoft/Mars/mhbase/MH3.h@ 8702

Last change on this file since 8702 was 8698, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.5 KB
Line 
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
11class TH1;
12class MData;
13class MBinning;
14
15class MH3 : public MH
16{
17private:
18 static const TString gsDefName;
19 static const TString gsDefTitle;
20
21protected:
22 // Could be const but root < 3.02/06 doesn't like this...
23 Int_t fDimension; // Number of dimensions of histogram
24 TH1 *fHist; // Histogram to fill
25 MData *fData[3]; // Object from which the data is filled
26 MBinning *fBins[3]; // Binning set omitting the parlist access
27 Double_t fScale[3]; // Scale for the three axis (eg unit)
28 Byte_t fStyleBits; // Set the range of a histogram automatically in Finalize
29
30 void StreamPrimitive(ostream &out) const;
31
32 enum {
33 kIsLogx = BIT(17),
34 kIsLogy = BIT(18),
35 kIsLogz = BIT(19)
36 };
37
38public:
39 MH3(const unsigned int dim=0);
40 MH3(const TH1 &h1);
41 MH3(const char *memberx);
42 MH3(const char *memberx, const char *membery);
43 MH3(const char *memberx, const char *membery, const char *memberz);
44 ~MH3();
45
46 // Setter
47 void SetScaleX(Double_t scale) { fScale[0] = scale; }
48 void SetScaleY(Double_t scale) { fScale[1] = scale; }
49 void SetScaleZ(Double_t scale) { fScale[2] = scale; }
50 void SetScale(Double_t x, Double_t y=1, Double_t z=2) { SetScaleX(x); SetScaleY(y); SetScaleZ(z); }
51
52 void SetLogx(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogx) : fHist->ResetBit(kIsLogx); }
53 void SetLogy(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogy) : fHist->ResetBit(kIsLogy); }
54 void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); }
55 void SetLog(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetLogx(x); SetLogy(y); SetLogz(z); }
56
57 void SetAutoRangeX(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 0) : CLRBIT(fStyleBits, 0); }
58 void SetAutoRangeY(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 1) : CLRBIT(fStyleBits, 1); }
59 void SetAutoRangeZ(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 2) : CLRBIT(fStyleBits, 2); }
60 void SetAutoRange(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetAutoRangeX(x); SetAutoRangeY(y); SetAutoRangeZ(z); }
61
62 void SetBinningX(MBinning *x) { fBins[0] = x; }
63 void SetBinningY(MBinning *y) { fBins[1] = y; }
64 void SetBinningZ(MBinning *z) { fBins[2] = z; }
65 void SetBinnings(MBinning *x=0, MBinning *y=0, MBinning *z=0) { SetBinningX(x); SetBinningY(y); SetBinningZ(z); }
66
67 void Sumw2() const { if (fHist) fHist->Sumw2(); }
68
69 // Getter
70 Int_t GetDimension() const { return fDimension; }
71 Int_t GetNbins() const;
72 Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
73
74 TH1 &GetHist() { return *fHist; }
75 const TH1 &GetHist() const { return *fHist; }
76
77 TString GetDataMember() const;
78 TString GetRule(const Char_t axis='x') const;
79
80 // MH
81 Bool_t SetupFill(const MParList *pList);
82 Bool_t Fill(const MParContainer *par, const Stat_t w=1);
83 Bool_t Finalize();
84
85 TH1 *GetHistByName(const TString name="") const { return fHist; }
86 TObject *FindObject(const TObject *obj) const { return 0; }
87 TObject *FindObject(const char *name) const
88 {
89 return (TObject*)GetHistByName(name);
90 }
91
92 // MParContainer
93 MParContainer *New() const;
94
95 // TObject
96 void SetName(const char *name);
97 void SetTitle(const char *title);
98
99 void Draw(Option_t *opt=NULL);
100 void Paint(Option_t *opt="");
101
102 ClassDef(MH3, 3) // Generalized 1/2/3D-histogram for Mars variables
103};
104
105#endif
Note: See TracBrowser for help on using the repository browser.