| 1 | #ifndef MARS_MH
|
|---|
| 2 | #define MARS_MH
|
|---|
| 3 |
|
|---|
| 4 | #ifndef MARS_MParContainer
|
|---|
| 5 | #include "MParContainer.h"
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | class TH1;
|
|---|
| 9 | class TH1I;
|
|---|
| 10 | class TH1D;
|
|---|
| 11 | class TH2;
|
|---|
| 12 | class TH3;
|
|---|
| 13 | class TAxis;
|
|---|
| 14 | class TArrayF;
|
|---|
| 15 | class TArrayD;
|
|---|
| 16 | class MArrayF;
|
|---|
| 17 | class MArrayD;
|
|---|
| 18 | class TCanvas;
|
|---|
| 19 | class TProfile;
|
|---|
| 20 |
|
|---|
| 21 | class MBinning;
|
|---|
| 22 | class MParList;
|
|---|
| 23 | #include <TH2.h>
|
|---|
| 24 | #include <TH3.h>
|
|---|
| 25 | class MH : public MParContainer
|
|---|
| 26 | {
|
|---|
| 27 | private:
|
|---|
| 28 | Byte_t fSerialNumber; // Serial number (eg of telecope)
|
|---|
| 29 | UInt_t fNumExecutions; // Number of calls to Fill function
|
|---|
| 30 |
|
|---|
| 31 | static MBinning GetBinningForLabels(TAxis &x, const MBinning *bins);
|
|---|
| 32 | static void RestoreBinningForLabels(TAxis &x);
|
|---|
| 33 |
|
|---|
| 34 | public:
|
|---|
| 35 | MH(const char *name=NULL, const char *title=NULL);
|
|---|
| 36 |
|
|---|
| 37 | virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
|
|---|
| 38 | Byte_t GetSerialNumber() const { return fSerialNumber; }
|
|---|
| 39 | TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
|
|---|
| 40 | TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
|
|---|
| 41 |
|
|---|
| 42 | UInt_t GetNumExecutions() const { return fNumExecutions; }
|
|---|
| 43 | void SetNumExecutions(UInt_t n) { fNumExecutions=n; }
|
|---|
| 44 |
|
|---|
| 45 | void PrintSkipped(UInt_t n, const char *str);
|
|---|
| 46 |
|
|---|
| 47 | Bool_t OverwritesDraw(TClass *cls=NULL) const;
|
|---|
| 48 |
|
|---|
| 49 | virtual Bool_t SetupFill(const MParList *) { return kTRUE; }
|
|---|
| 50 | virtual Bool_t ReInit(MParList *) { return kTRUE; }
|
|---|
| 51 | virtual Int_t Fill(const MParContainer *par, const Stat_t weight=1);
|
|---|
| 52 | virtual Bool_t Finalize() { return kTRUE; }
|
|---|
| 53 |
|
|---|
| 54 | virtual TString GetDataMember() const { return ""; }
|
|---|
| 55 |
|
|---|
| 56 | virtual TH1 *GetHistByName(const TString name) const;
|
|---|
| 57 |
|
|---|
| 58 | static TCanvas *MakeDefCanvas(TString name="", const char *title="",
|
|---|
| 59 | UInt_t w=625, UInt_t h=440,
|
|---|
| 60 | Bool_t usescreenfactor=kTRUE);
|
|---|
| 61 | static TCanvas *MakeDefCanvas(const TObject *obj,
|
|---|
| 62 | UInt_t w=625, UInt_t h=440,
|
|---|
| 63 | Bool_t usescreenfactor=kFALSE);
|
|---|
| 64 |
|
|---|
| 65 | static void RemoveFromPad(const char *name);
|
|---|
| 66 |
|
|---|
| 67 | // Functions to applay new binnings to histograms
|
|---|
| 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 CopyBinning(const TH1 &x, TH1 &h);
|
|---|
| 81 |
|
|---|
| 82 | static Bool_t ApplyBinning(const MParList &plist, const TString x, TH1 &h);
|
|---|
| 83 | static Bool_t ApplyBinning(const MParList &plist, const TString x, TString y, TH2 &h);
|
|---|
| 84 | static Bool_t ApplyBinning(const MParList &plist, const TString x, TString y, TString z, TH3 &h);
|
|---|
| 85 |
|
|---|
| 86 | // Warpper functions not to break macros (new functions take references)
|
|---|
| 87 | static void SetBinning(TH1 *h, const MBinning *binsx) { SetBinning(*h, *binsx); }
|
|---|
| 88 | static void SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy) { SetBinning(*h, *binsx, *binsy); }
|
|---|
| 89 | static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz) { SetBinning(*h, *binsx, *binsy, *binsz); }
|
|---|
| 90 |
|
|---|
| 91 | static void SetBinning(TH1 *h, const TArrayD &binsx) { SetBinning(*h, binsx); }
|
|---|
| 92 | static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy) { SetBinning(*h, binsx, binsy); }
|
|---|
| 93 | static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz) { SetBinning(*h, binsx, binsy, binsz); }
|
|---|
| 94 |
|
|---|
| 95 | static void SetBinning(TH1 *h, const TAxis *binsx) { SetBinning(*h, *binsx); }
|
|---|
| 96 | static void SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy) { SetBinning(*h, *binsx, *binsy); }
|
|---|
| 97 | static void SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz) { SetBinning(*h, *binsx, *binsy, *binsz); }
|
|---|
| 98 |
|
|---|
| 99 | static Bool_t ApplyBinning(const MParList &plist, TString x, TH1 *h) { return ApplyBinning(plist, x, *h); }
|
|---|
| 100 | static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TH2 *h) { return ApplyBinning(plist, x, y, *h); }
|
|---|
| 101 | static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h) { return ApplyBinning(plist, x, y, z, *h); }
|
|---|
| 102 |
|
|---|
| 103 | // Other helpers for histogram treatment
|
|---|
| 104 | static void SetBinomialErrors(TH1 &hres, const TH1 &h1, const TH1 &h2, Double_t c1=1, Double_t c2=1);
|
|---|
| 105 |
|
|---|
| 106 | static void RemoveFirstBin(TH1 &h);
|
|---|
| 107 |
|
|---|
| 108 | static void ScaleArray(TArrayD &bins, Double_t f);
|
|---|
| 109 | static TArrayD ScaleAxis(TAxis &axe, Double_t f);
|
|---|
| 110 | static void ScaleAxis(TH1 &bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
|
|---|
| 111 |
|
|---|
| 112 | static Double_t GetBinCenterLog(const TAxis &axe, Int_t nbin);
|
|---|
| 113 |
|
|---|
| 114 | static void DrawSameCopy(const TH1 &hist1, const TH1 &hist2, const TString title);
|
|---|
| 115 | static void DrawSame(TH1 &hist1, TH1 &hist2, const TString title, Bool_t same=kFALSE);
|
|---|
| 116 |
|
|---|
| 117 | TObject *Clone(const char *name="") const;
|
|---|
| 118 |
|
|---|
| 119 | TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const;
|
|---|
| 120 | TObject *DrawClone(Option_t *opt="") const
|
|---|
| 121 | {
|
|---|
| 122 | return MH::DrawClone(opt, 625, 440);
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | static TVirtualPad *GetNewPad(TString &opt);
|
|---|
| 126 |
|
|---|
| 127 | static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
|
|---|
| 128 | static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
|
|---|
| 129 | static Int_t StripZeros(TH1 &h, Int_t nbins);
|
|---|
| 130 |
|
|---|
| 131 | static TH1I* ProjectArray(const TArrayF &array, Int_t nbins=30,
|
|---|
| 132 | const char* name="ProjectArray", const char* title="Projected Array");
|
|---|
| 133 | static TH1I* ProjectArray(const TArrayD &array, Int_t nbins=30,
|
|---|
| 134 | const char* name="ProjectArray", const char* title="Projected Array");
|
|---|
| 135 | static TH1I* ProjectArray(const MArrayF &array, Int_t nbins=30,
|
|---|
| 136 | const char* name="ProjectArray", const char* title="Projected Array");
|
|---|
| 137 | static TH1I* ProjectArray(const MArrayD &array, Int_t nbins=30,
|
|---|
| 138 | const char* name="ProjectArray", const char* title="Projected Array");
|
|---|
| 139 |
|
|---|
| 140 | static void GetRangeUser(const TH1 &hist, Axis_t &lo, Axis_t &hi);
|
|---|
| 141 | static void GetRangeUserX(const TH1 &hist, Axis_t &lo, Axis_t &hi);
|
|---|
| 142 | static void GetRangeUserY(const TH1 &hist, Axis_t &lo, Axis_t &hi);
|
|---|
| 143 | static void GetRange(const TH1 &hist, Int_t &lo, Int_t &hi);
|
|---|
| 144 | static void GetRangeX(const TH1 &hist, Int_t &lo, Int_t &hi);
|
|---|
| 145 | static void GetRangeY(const TH1 &hist, Int_t &lo, Int_t &hi);
|
|---|
| 146 |
|
|---|
| 147 | static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
|
|---|
| 148 |
|
|---|
| 149 | static void SetPalette(TString paletteName="pretty", Int_t ncol=50);
|
|---|
| 150 | static void SetPadRange(Float_t max, Float_t aspect=1);
|
|---|
| 151 | static void SetPadRange(Float_t x0, Float_t y0, Float_t x1, Float_t y1);
|
|---|
| 152 |
|
|---|
| 153 | static char *GetObjectInfoH(Int_t px, Int_t py, const TH1 &h);
|
|---|
| 154 | static char *GetObjectInfoP(Int_t px, Int_t py, const TProfile &p);
|
|---|
| 155 | static char *GetObjectInfo(Int_t px, Int_t py, const TObject &o);
|
|---|
| 156 | char *GetObjectInfo(Int_t px, Int_t py) const { return MParContainer::GetObjectInfo(px, py); }
|
|---|
| 157 |
|
|---|
| 158 | ClassDef(MH, 2) //A base class for Mars histograms
|
|---|
| 159 | };
|
|---|
| 160 |
|
|---|
| 161 | #endif
|
|---|
| 162 |
|
|---|