File indexing completed on 2024-04-06 11:56:30
0001 #ifndef __GFHISTMANAGER_H
0002 #define __GFHISTMANAGER_H
0003
0004
0005 #include <TObject.h>
0006 #include <TArrayI.h>
0007 #include <TArrayC.h>
0008 #include <TH1.h> // for type Color_t etc.
0009
0010 class TObjArray;
0011 class TCollection;
0012
0013 class TCanvas;
0014 class TVirtualPad;
0015 class TFile;
0016 class TLegend;
0017 class TLegendEntry;
0018 class GFHistArray;
0019
0020 class GFHistManager : public TObject{
0021 public:
0022 GFHistManager();
0023 explicit GFHistManager(TH1* hist);
0024 explicit GFHistManager(TCollection* hists);
0025 virtual ~GFHistManager();
0026
0027 virtual TLegendEntry* AddHist(TH1* hist, Int_t layer = 0, const char* legendTitle = NULL,
0028 const char* legOpt = NULL);
0029 virtual void AddHists(TCollection* hists, Int_t layer = 0,
0030 const char* legendTitle = NULL, const char* legOpt = NULL);
0031 virtual TLegendEntry* AddHistSame(TH1* hist, Int_t layer, Int_t nPad,
0032 const char* legendTitle=NULL, const char* legOpt=NULL);
0033 virtual void AddHistsSame(GFHistArray* hists, Int_t layer,
0034 const char* legendTitle = NULL, const char* legOpt = NULL);
0035 virtual void AddHistsSame(GFHistArray* hists, Int_t layer, Int_t nPad);
0036 virtual void AddLayers(GFHistManager* other);
0037 virtual void AddLayer(GFHistManager* other, Int_t layer);
0038 virtual void Overlay(GFHistManager* other, Int_t otherLayer, Int_t myLayer,
0039 const char* legendTitle);
0040 virtual TLegend* AddLegend(Int_t layer, Int_t nPad, const char* header = NULL,
0041 Bool_t referAll = kTRUE);
0042 virtual Bool_t RemoveLegend(Int_t layer, Int_t nPad);
0043 virtual void AddLegend(TLegend* leg, Int_t layer, Int_t nPad);
0044 virtual void AddObject(TObject* obj, Int_t layer, Int_t histoNum, Option_t* opt = NULL);
0045
0046 virtual void Draw(Option_t * opt = "");
0047 virtual void Draw(Int_t layer);
0048 using TObject::Print;
0049 virtual void Print(const char* filename, Bool_t add = kFALSE);
0050
0051 virtual void Clear(Bool_t deleteHists);
0052 void Clear(Option_t * = "") {this->Clear(kFALSE);}
0053 void Delete(Option_t * = "") {this->Clear(kTRUE);}
0054 virtual void SetLegendX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
0055 virtual void SetLegendX1(Double_t x1);
0056 virtual void SetLegendY1(Double_t y1);
0057 virtual void SetLegendX2(Double_t x2);
0058 virtual void SetLegendY2(Double_t y2);
0059 virtual void SetStatsX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
0060 virtual void SetNumHistsX(UInt_t numX);
0061 virtual void SetNumHistsX(UInt_t numX, Int_t layer);
0062 virtual void SetNumHistsY(UInt_t numY);
0063 virtual void SetNumHistsY(UInt_t numY, Int_t layer);
0064 virtual void SetNumHistsXY(UInt_t numX, UInt_t numY);
0065 virtual void SetNumHistsXY(UInt_t numX, UInt_t numY, Int_t layer);
0066 virtual void SetLogY(Bool_t yesNo = kTRUE);
0067 virtual void SetLogY(Int_t layer, Bool_t yesNo = kTRUE);
0068 void SetCanvasName(const TString& name);
0069 virtual void SetCanvasWidth(Int_t w) {fCanvasWidth = w;}
0070 virtual void SetCanvasHeight(Int_t h) {fCanvasHeight = h;}
0071 virtual void SetHistsOption(Option_t* option);
0072 virtual void SetHistsOption(Option_t* option, Int_t layer);
0073 virtual void SetHistsMinMax(Double_t minMax, Bool_t min);
0074 virtual void SetHistsMinMax(Double_t minMax, Bool_t min, Int_t layer);
0075 static void SetLegendEntryOption(const char* option) {fgLegendEntryOption = option;}
0076 virtual void AddHistsOption(Option_t* option);
0077 virtual void AddHistsOption(Option_t* option, Int_t layer);
0078 virtual void SetHistsXTitle(const char* title);
0079 virtual void SetHistsXTitle(const char* title, Int_t layer);
0080 virtual void SetHistsYTitle(const char* title);
0081 virtual void SetHistsYTitle(const char* title, Int_t layer);
0082 virtual void SetHistsFillColor(Color_t color);
0083 virtual void SetHistsFillColor(Color_t color, Int_t layer);
0084 virtual void SetHistsLineWidth(Width_t width);
0085 virtual void SetHistsLineWidth(Width_t width, Int_t layer);
0086 virtual void SetHistsLineStyle(Int_t style);
0087 virtual void SetHistsLineStyle(Int_t style, Int_t layer, Int_t numHistInPad = -1);
0088 virtual void SetHistsLineColor(Color_t color);
0089 virtual void SetHistsLineColor(Color_t color, Int_t layer);
0090 virtual void WriteCanvases(TFile* file);
0091 virtual void WriteHistos(TFile* file);
0092 virtual void Update();
0093 virtual void Update(Int_t layer);
0094 virtual Bool_t SetBatch(Bool_t set = kTRUE) {Bool_t r = fBatch; fBatch = set; return r;}
0095 virtual Bool_t IsBatch() const {return fBatch;}
0096 virtual void ExpandTo(Int_t newDepth);
0097
0098 virtual GFHistArray* GetHistsOf(Int_t layer, Int_t histNum, Bool_t mayExpand = kFALSE);
0099 virtual TList* GetObjectsOf(Int_t layer, Int_t histNum);
0100 virtual Int_t GetNumHistsOf(Int_t layer);
0101 virtual TLegend* GetLegendOf(Int_t layer, Int_t nPad);
0102 virtual Int_t GetCanvasWidth() const {return fCanvasWidth;}
0103 virtual Int_t GetCanvasHeight() const {return fCanvasHeight;}
0104 virtual Int_t GetNumHistsX(Int_t layer) const;
0105 virtual Int_t GetNumHistsY(Int_t layer) const;
0106 virtual Double_t MaxOfHist(const TH1* h) const;
0107 virtual Double_t MaxOfHists(const TObjArray* hists) const;
0108 virtual Double_t MinOfHist(const TH1* h) const;
0109 virtual Double_t MinOfHists(const TObjArray* hists) const;
0110 virtual TVirtualPad* GetPad(Int_t layer, Int_t histNum);
0111 virtual TCanvas* GetCanvas(Int_t layer, Int_t number = 0);
0112 Int_t GetNumLayers() const {return fDepth;}
0113 virtual void GetLegendX1Y1X2Y2(Double_t& x1, Double_t& y1, Double_t& x2, Double_t& y2) const;
0114
0115 static const Int_t kDefaultPadsPerCanX;
0116 static const Int_t kDefaultPadsPerCanY;
0117 static const Int_t kDefaultDepth;
0118
0119 static Int_t NumberOfSubPadsOf(TCanvas* can);
0120 static void MakeDifferentStyle(GFHistArray* hists);
0121 Bool_t DrawDiffStyle(Bool_t yesNo) {
0122 const Bool_t old = fDrawDiffStyle; fDrawDiffStyle = yesNo; return old;}
0123 Bool_t SameWithStats(Bool_t yesNo) {
0124 const Bool_t old = fSameWithStats; fSameWithStats = yesNo; return old;}
0125
0126 protected:
0127 virtual void DrawReally(Int_t layer);
0128 virtual void DrawLegend(Int_t layer, Int_t histNo);
0129 virtual void DrawObjects(Int_t layer, Int_t histNo);
0130 virtual void MakeCanvases(Int_t layer);
0131 virtual TObjArray* MakeLegends(Int_t layer);
0132 virtual TList* MakeObjList(Int_t layer, Int_t histoNum);
0133 virtual void Initialise();
0134 virtual Bool_t CheckDepth(const char* method, Int_t layer, Bool_t mayExpand = kTRUE);
0135 virtual Bool_t CheckHistNum(const char* method, Int_t layer, Int_t histNum,
0136 Bool_t mayExpand = kFALSE);
0137 void DrawFuncs(const TH1* hist) const;
0138 void ColourStatsBoxes(GFHistArray *hists) const;
0139 void ColourFuncs(GFHistArray *hists) const;
0140
0141 private:
0142 Int_t fDepth;
0143 TArrayI fNoX;
0144 TArrayI fNoY;
0145 TArrayC fLogY;
0146 Double_t fLegendX1;
0147 Double_t fLegendY1;
0148 Double_t fLegendX2;
0149 Double_t fLegendY2;
0150 Double_t fStatsX1;
0151 Double_t fStatsX2;
0152 Double_t fStatsY1;
0153 Double_t fStatsY2;
0154 TString fCanvasName;
0155 Int_t fCanvasWidth;
0156 Int_t fCanvasHeight;
0157 static TString fgLegendEntryOption;
0158 TObjArray* fHistArrays;
0159 TObjArray* fLegendArrays;
0160 TObjArray* fObjLists;
0161 TObjArray* fCanArrays;
0162 Bool_t fBatch;
0163 Bool_t fDrawDiffStyle;
0164 Bool_t fSameWithStats;
0165
0166 ClassDef(GFHistManager, 0)
0167 };
0168
0169 #endif