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

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