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

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