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

Last change on this file since 8886 was 8709, checked in by tbretz, 17 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 HandleLogAxis(TAxis &axe) const;
31
32 void StreamPrimitive(ostream &out) const;
33
34 enum {
35 kIsLogx = BIT(17),
36 kIsLogy = BIT(18),
37 kIsLogz = BIT(19)
38 };
39
40public:
41 MH3(const unsigned int dim=0);
42 MH3(const TH1 &h1);
43 MH3(const char *memberx);
44 MH3(const char *memberx, const char *membery);
45 MH3(const char *memberx, const char *membery, const char *memberz);
46 ~MH3();
47
48 // Setter
49 void SetScaleX(Double_t scale) { fScale[0] = scale; }
50 void SetScaleY(Double_t scale) { fScale[1] = scale; }
51 void SetScaleZ(Double_t scale) { fScale[2] = scale; }
52 void SetScale(Double_t x, Double_t y=1, Double_t z=2) { SetScaleX(x); SetScaleY(y); SetScaleZ(z); }
53
54 void SetLogx(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogx) : fHist->ResetBit(kIsLogx); }
55 void SetLogy(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogy) : fHist->ResetBit(kIsLogy); }
56 void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); }
57 void SetLog(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetLogx(x); SetLogy(y); SetLogz(z); }
58
59 void SetAutoRangeX(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 0) : CLRBIT(fStyleBits, 0); }
60 void SetAutoRangeY(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 1) : CLRBIT(fStyleBits, 1); }
61 void SetAutoRangeZ(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 2) : CLRBIT(fStyleBits, 2); }
62 void SetAutoRange(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetAutoRangeX(x); SetAutoRangeY(y); SetAutoRangeZ(z); }
63
64 void SetBinningX(MBinning *x) { fBins[0] = x; }
65 void SetBinningY(MBinning *y) { fBins[1] = y; }
66 void SetBinningZ(MBinning *z) { fBins[2] = z; }
67 void SetBinnings(MBinning *x=0, MBinning *y=0, MBinning *z=0) { SetBinningX(x); SetBinningY(y); SetBinningZ(z); }
68
69 void Sumw2() const { if (fHist) fHist->Sumw2(); }
70
71 // Getter
72 Int_t GetDimension() const { return fDimension; }
73 Int_t GetNbins() const;
74 Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
75
76 TH1 &GetHist() { return *fHist; }
77 const TH1 &GetHist() const { return *fHist; }
78
79 TString GetDataMember() const;
80 TString GetRule(const Char_t axis='x') const;
81
82 // MH
83 Bool_t SetupFill(const MParList *pList);
84 Bool_t Fill(const MParContainer *par, const Stat_t w=1);
85 Bool_t Finalize();
86
87 TH1 *GetHistByName(const TString name="") const { return fHist; }
88 TObject *FindObject(const TObject *obj) const { return 0; }
89 TObject *FindObject(const char *name) const
90 {
91 return (TObject*)GetHistByName(name);
92 }
93
94 // MParContainer
95 MParContainer *New() const;
96
97 // TObject
98 void SetName(const char *name);
99 void SetTitle(const char *title);
100
101 void Draw(Option_t *opt=NULL);
102 void Paint(Option_t *opt="");
103
104 ClassDef(MH3, 3) // Generalized 1/2/3D-histogram for Mars variables
105};
106
107#endif
Note: See TracBrowser for help on using the repository browser.