source: trunk/MagicSoft/Mars/mhbase/MH.h@ 9492

Last change on this file since 9492 was 9312, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 5.8 KB
Line 
1#ifndef MARS_MH
2#define MARS_MH
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8class TH1;
9class TH1I;
10class TH1D;
11class TH2;
12class TH3;
13class TAxis;
14class TArrayF;
15class TArrayD;
16class MArrayF;
17class MArrayD;
18class TCanvas;
19class TProfile;
20
21class MBinning;
22class MParList;
23
24class MH : public MParContainer
25{
26private:
27 Byte_t fSerialNumber; // Serial number (eg of telecope)
28 UInt_t fNumExecutions; // Number of calls to Fill function
29
30 static MBinning GetBinningForLabels(TAxis &x, const MBinning *bins);
31 static void RestoreBinningForLabels(TAxis &x);
32
33public:
34 MH(const char *name=NULL, const char *title=NULL);
35
36 virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
37 Byte_t GetSerialNumber() const { return fSerialNumber; }
38 TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
39 TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
40
41 UInt_t GetNumExecutions() const { return fNumExecutions; }
42 void SetNumExecutions(UInt_t n) { fNumExecutions=n; }
43
44 void PrintSkipped(UInt_t n, const char *str);
45
46 Bool_t OverwritesDraw(TClass *cls=NULL) const;
47
48 virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
49 virtual Bool_t ReInit(MParList *pList) { return kTRUE; }
50 virtual Int_t Fill(const MParContainer *par, const Stat_t weight=1);
51 virtual Bool_t Finalize() { return kTRUE; }
52
53 virtual TString GetDataMember() const { return ""; }
54
55 virtual TH1 *GetHistByName(const TString name) const;
56
57 static TCanvas *MakeDefCanvas(TString name="", const char *title="",
58 UInt_t w=625, UInt_t h=440,
59 Bool_t usescreenfactor=kTRUE);
60 static TCanvas *MakeDefCanvas(const TObject *obj,
61 UInt_t w=625, UInt_t h=440,
62 Bool_t usescreenfactor=kFALSE);
63
64 static void RemoveFromPad(const char *name);
65
66 // FIXME: * --> & !!!
67
68 static void SetBinning(TH1 *h, const MBinning *binsx);
69 static void SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy);
70 static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
71
72 static void SetBinning(TH1 *h, const TArrayD &binsx);
73 static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy);
74 static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz);
75
76 static void SetBinning(TH1 *h, const TAxis *binsx);
77 static void SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy);
78 static void SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);
79
80 static void SetBinning(TH1 *h, const TH1 *x);
81
82 static void SetBinomialErrors(TH1 &hres, const TH1 &h1, const TH1 &h2, Double_t c1=1, Double_t c2=1);
83
84 static void RemoveFirstBin(TH1 &h);
85
86 static Bool_t ApplyBinning(const MParList &plist, TString x, TH1 *h);
87 static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TH2 *h);
88 static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h);
89
90 static void ScaleArray(TArrayD &bins, Double_t f);
91 static TArrayD ScaleAxis(TAxis &axe, Double_t f);
92 static void ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
93
94 static Double_t GetBinCenterLog(const TAxis &axe, Int_t nbin);
95
96 static void DrawSameCopy(const TH1 &hist1, const TH1 &hist2, const TString title);
97 static void DrawSame(TH1 &hist1, TH1 &hist2, const TString title, Bool_t same=kFALSE);
98
99 TObject *Clone(const char *name="") const;
100
101 TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const;
102 TObject *DrawClone(Option_t *opt="") const
103 {
104 return MH::DrawClone(opt, 625, 440);
105 }
106
107 static TVirtualPad *GetNewPad(TString &opt);
108
109 static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
110 static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
111 static Int_t StripZeros(TH1 *h, Int_t nbins);
112
113 static TH1I* ProjectArray(const TArrayF &array, Int_t nbins=30,
114 const char* name="ProjectArray", const char* title="Projected Array");
115 static TH1I* ProjectArray(const TArrayD &array, Int_t nbins=30,
116 const char* name="ProjectArray", const char* title="Projected Array");
117 static TH1I* ProjectArray(const MArrayF &array, Int_t nbins=30,
118 const char* name="ProjectArray", const char* title="Projected Array");
119 static TH1I* ProjectArray(const MArrayD &array, Int_t nbins=30,
120 const char* name="ProjectArray", const char* title="Projected Array");
121
122 static void GetRangeUser(const TH1 &hist, Axis_t &lo, Axis_t &hi);
123 static void GetRangeUserX(const TH1 &hist, Axis_t &lo, Axis_t &hi);
124 static void GetRangeUserY(const TH1 &hist, Axis_t &lo, Axis_t &hi);
125 static void GetRange(const TH1 &hist, Int_t &lo, Int_t &hi);
126 static void GetRangeX(const TH1 &hist, Int_t &lo, Int_t &hi);
127 static void GetRangeY(const TH1 &hist, Int_t &lo, Int_t &hi);
128
129 static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
130
131 static void SetPalette(TString paletteName="pretty", Int_t ncol=50);
132 static void SetPadRange(Float_t max, Float_t aspect=1);
133 static void SetPadRange(Float_t x0, Float_t y0, Float_t x1, Float_t y1);
134
135 static char *GetObjectInfoH(Int_t px, Int_t py, const TH1 &h);
136 static char *GetObjectInfoP(Int_t px, Int_t py, const TProfile &p);
137 static char *GetObjectInfo(Int_t px, Int_t py, const TObject &o);
138 char *GetObjectInfo(Int_t px, Int_t py) const { return MParContainer::GetObjectInfo(px, py); }
139
140 ClassDef(MH, 2) //A base class for Mars histograms
141};
142
143#endif
144
Note: See TracBrowser for help on using the repository browser.