00001 #ifndef __GFHISTMANAGER_H
00002 #define __GFHISTMANAGER_H
00003
00004
00005 #include <TObject.h>
00006 #include <TArrayI.h>
00007 #include <TArrayC.h>
00008 #include <TH1.h>
00009
00010 class TObjArray;
00011 class TCollection;
00012
00013 class TCanvas;
00014 class TVirtualPad;
00015 class TFile;
00016 class TLegend;
00017 class TLegendEntry;
00018 class GFHistArray;
00019
00020 class GFHistManager : public TObject{
00021 public:
00022 GFHistManager();
00023 explicit GFHistManager(TH1* hist);
00024 explicit GFHistManager(TCollection* hists);
00025 virtual ~GFHistManager();
00026
00027 virtual TLegendEntry* AddHist(TH1* hist, Int_t layer = 0, const char* legendTitle = NULL,
00028 const char* legOpt = NULL);
00029 virtual void AddHists(TCollection* hists, Int_t layer = 0,
00030 const char* legendTitle = NULL, const char* legOpt = NULL);
00031 virtual TLegendEntry* AddHistSame(TH1* hist, Int_t layer, Int_t nPad,
00032 const char* legendTitle=NULL, const char* legOpt=NULL);
00033 virtual void AddHistsSame(GFHistArray* hists, Int_t layer,
00034 const char* legendTitle = NULL, const char* legOpt = NULL);
00035 virtual void AddHistsSame(GFHistArray* hists, Int_t layer, Int_t nPad);
00036 virtual void AddLayers(GFHistManager* other);
00037 virtual void AddLayer(GFHistManager* other, Int_t layer);
00038 virtual void Overlay(GFHistManager* other, Int_t otherLayer, Int_t myLayer,
00039 const char* legendTitle);
00040 virtual TLegend* AddLegend(Int_t layer, Int_t nPad, const char* header = NULL,
00041 Bool_t referAll = kTRUE);
00042 virtual Bool_t RemoveLegend(Int_t layer, Int_t nPad);
00043 virtual void AddLegend(TLegend* leg, Int_t layer, Int_t nPad);
00044 virtual void AddObject(TObject* obj, Int_t layer, Int_t histoNum, Option_t* opt = NULL);
00045
00046 virtual void Draw(Option_t * opt = "");
00047 virtual void Draw(Int_t layer);
00048 using TObject::Print;
00049 virtual void Print(const char* filename, Bool_t add = kFALSE);
00050
00051 virtual void Clear(Bool_t deleteHists);
00052 void Clear(Option_t * = "") {this->Clear(kFALSE);}
00053 void Delete(Option_t * = "") {this->Clear(kTRUE);}
00054 virtual void SetLegendX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
00055 virtual void SetLegendX1(Double_t x1);
00056 virtual void SetLegendY1(Double_t y1);
00057 virtual void SetLegendX2(Double_t x2);
00058 virtual void SetLegendY2(Double_t y2);
00059 virtual void SetStatsX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
00060 virtual void SetNumHistsX(UInt_t numX);
00061 virtual void SetNumHistsX(UInt_t numX, Int_t layer);
00062 virtual void SetNumHistsY(UInt_t numY);
00063 virtual void SetNumHistsY(UInt_t numY, Int_t layer);
00064 virtual void SetNumHistsXY(UInt_t numX, UInt_t numY);
00065 virtual void SetNumHistsXY(UInt_t numX, UInt_t numY, Int_t layer);
00066 virtual void SetLogY(Bool_t yesNo = kTRUE);
00067 virtual void SetLogY(Int_t layer, Bool_t yesNo = kTRUE);
00068 virtual void SetCanvasWidth(Int_t w) {fCanvasWidth = w;}
00069 virtual void SetCanvasHeight(Int_t h) {fCanvasHeight = h;}
00070 virtual void SetHistsOption(Option_t* option);
00071 virtual void SetHistsOption(Option_t* option, Int_t layer);
00072 virtual void SetHistsMinMax(Double_t minMax, Bool_t min);
00073 virtual void SetHistsMinMax(Double_t minMax, Bool_t min, Int_t layer);
00074 static void SetLegendEntryOption(const char* option) {fgLegendEntryOption = option;}
00075 virtual void AddHistsOption(Option_t* option);
00076 virtual void AddHistsOption(Option_t* option, Int_t layer);
00077 virtual void SetHistsXTitle(const char* title);
00078 virtual void SetHistsXTitle(const char* title, Int_t layer);
00079 virtual void SetHistsYTitle(const char* title);
00080 virtual void SetHistsYTitle(const char* title, Int_t layer);
00081 virtual void SetHistsFillColor(Color_t color);
00082 virtual void SetHistsFillColor(Color_t color, Int_t layer);
00083 virtual void SetHistsLineWidth(Width_t width);
00084 virtual void SetHistsLineWidth(Width_t width, Int_t layer);
00085 virtual void SetHistsLineStyle(Int_t style);
00086 virtual void SetHistsLineStyle(Int_t style, Int_t layer, Int_t numHistInPad = -1);
00087 virtual void SetHistsLineColor(Color_t color);
00088 virtual void SetHistsLineColor(Color_t color, Int_t layer);
00089 virtual void WriteCanvases(TFile* file);
00090 virtual void WriteHistos(TFile* file);
00091 virtual void Update();
00092 virtual void Update(Int_t layer);
00093 virtual Bool_t SetBatch(Bool_t set = kTRUE) {Bool_t r = fBatch; fBatch = set; return r;}
00094 virtual Bool_t IsBatch() const {return fBatch;}
00095 virtual void ExpandTo(Int_t newDepth);
00096
00097 virtual GFHistArray* GetHistsOf(Int_t layer, Int_t histNum, Bool_t mayExpand = kFALSE);
00098 virtual TList* GetObjectsOf(Int_t layer, Int_t histNum);
00099 virtual Int_t GetNumHistsOf(Int_t layer);
00100 virtual TLegend* GetLegendOf(Int_t layer, Int_t nPad);
00101 virtual Int_t GetCanvasWidth() const {return fCanvasWidth;}
00102 virtual Int_t GetCanvasHeight() const {return fCanvasHeight;}
00103 virtual Int_t GetNumHistsX(Int_t layer) const;
00104 virtual Int_t GetNumHistsY(Int_t layer) const;
00105 virtual Double_t MaxOfHist(const TH1* h) const;
00106 virtual Double_t MaxOfHists(const TObjArray* hists) const;
00107 virtual Double_t MinOfHist(const TH1* h) const;
00108 virtual Double_t MinOfHists(const TObjArray* hists) const;
00109 virtual TVirtualPad* GetPad(Int_t layer, Int_t histNum);
00110 virtual TCanvas* GetCanvas(Int_t layer, Int_t number = 0);
00111 Int_t GetNumLayers() const {return fDepth;}
00112 virtual void GetLegendX1Y1X2Y2(Double_t& x1, Double_t& y1, Double_t& x2, Double_t& y2) const;
00113
00114 static const Int_t kDefaultPadsPerCanX;
00115 static const Int_t kDefaultPadsPerCanY;
00116 static const Int_t kDefaultDepth;
00117
00118 static Int_t NumberOfSubPadsOf(TCanvas* can);
00119 static void MakeDifferentStyle(GFHistArray* hists);
00120 Bool_t DrawDiffStyle(Bool_t yesNo) {
00121 const Bool_t old = fDrawDiffStyle; fDrawDiffStyle = yesNo; return old;}
00122 Bool_t SameWithStats(Bool_t yesNo) {
00123 const Bool_t old = fSameWithStats; fSameWithStats = yesNo; return old;}
00124
00125 protected:
00126 virtual void DrawReally(Int_t layer);
00127 virtual void DrawLegend(Int_t layer, Int_t histNo);
00128 virtual void DrawObjects(Int_t layer, Int_t histNo);
00129 virtual void MakeCanvases(Int_t layer);
00130 virtual TObjArray* MakeLegends(Int_t layer);
00131 virtual TList* MakeObjList(Int_t layer, Int_t histoNum);
00132 virtual void Initialise();
00133 virtual Bool_t CheckDepth(const char* method, Int_t layer, Bool_t mayExpand = kTRUE);
00134 virtual Bool_t CheckHistNum(const char* method, Int_t layer, Int_t histNum,
00135 Bool_t mayExpand = kFALSE);
00136 void DrawFuncs(const TH1* hist) const;
00137 void ColourStatsBoxes(GFHistArray *hists) const;
00138 void ColourFuncs(GFHistArray *hists) const;
00139
00140 private:
00141 Int_t fDepth;
00142 TArrayI fNoX;
00143 TArrayI fNoY;
00144 TArrayC fLogY;
00145 Double_t fLegendX1;
00146 Double_t fLegendY1;
00147 Double_t fLegendX2;
00148 Double_t fLegendY2;
00149 Double_t fStatsX1;
00150 Double_t fStatsX2;
00151 Double_t fStatsY1;
00152 Double_t fStatsY2;
00153 Int_t fCanvasWidth;
00154 Int_t fCanvasHeight;
00155 static TString fgLegendEntryOption;
00156 TObjArray* fHistArrays;
00157 TObjArray* fLegendArrays;
00158 TObjArray* fObjLists;
00159 TObjArray* fCanArrays;
00160 Bool_t fBatch;
00161 Bool_t fDrawDiffStyle;
00162 Bool_t fSameWithStats;
00163
00164 ClassDef(GFHistManager, 0)
00165 };
00166
00167 #endif