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

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