CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GFHistManager.h
Go to the documentation of this file.
1 #ifndef __GFHISTMANAGER_H
2 #define __GFHISTMANAGER_H
3 
4  // ROOT includes
5 #include <TObject.h>
6 #include <TArrayI.h>
7 #include <TArrayC.h>
8 #include <TH1.h> // for type Color_t etc.
9 
10 class TObjArray;
11 class TCollection;
12 // class TH1;
13 class TCanvas;
14 class TVirtualPad;
15 class TFile;
16 class TLegend;
17 class TLegendEntry;
18 class GFHistArray;
19 
20 class GFHistManager : public TObject{
21 public:
22  GFHistManager();
23  explicit GFHistManager(TH1* hist);
24  explicit GFHistManager(TCollection* hists);
25  virtual ~GFHistManager();
26 
27  virtual TLegendEntry* AddHist(TH1* hist, Int_t layer = 0, const char* legendTitle = NULL,
28  const char* legOpt = NULL);
29  virtual void AddHists(TCollection* hists, Int_t layer = 0,
30  const char* legendTitle = NULL, const char* legOpt = NULL);
31  virtual TLegendEntry* AddHistSame(TH1* hist, Int_t layer, Int_t nPad,
32  const char* legendTitle=NULL, const char* legOpt=NULL);
33  virtual void AddHistsSame(GFHistArray* hists, Int_t layer,
34  const char* legendTitle = NULL, const char* legOpt = NULL);
35  virtual void AddHistsSame(GFHistArray* hists, Int_t layer, Int_t nPad);
36  virtual void AddLayers(GFHistManager* other);
37  virtual void AddLayer(GFHistManager* other, Int_t layer);
38  virtual void Overlay(GFHistManager* other, Int_t otherLayer, Int_t myLayer,
39  const char* legendTitle);
40  virtual TLegend* AddLegend(Int_t layer, Int_t nPad, const char* header = NULL,
41  Bool_t referAll = kTRUE);
42  virtual Bool_t RemoveLegend(Int_t layer, Int_t nPad);
43  virtual void AddLegend(TLegend* leg, Int_t layer, Int_t nPad);
44  virtual void AddObject(TObject* obj, Int_t layer, Int_t histoNum, Option_t* opt = NULL);
45 
46  virtual void Draw(Option_t * opt = "");
47  virtual void Draw(Int_t layer);
48  using TObject::Print;
49  virtual void Print(const char* filename, Bool_t add = kFALSE);
50 // virtual void Print(const char* filename, Int_t layer);
51  virtual void Clear(Bool_t deleteHists);
52  void Clear(Option_t * = "") {this->Clear(kFALSE);}
53  void Delete(Option_t * = "") {this->Clear(kTRUE);}
54  virtual void SetLegendX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
55  virtual void SetLegendX1(Double_t x1);// {fLegendX1 = x1;}
56  virtual void SetLegendY1(Double_t y1);// {fLegendY1 = y1;}
57  virtual void SetLegendX2(Double_t x2);// {fLegendX2 = x2;}
58  virtual void SetLegendY2(Double_t y2);// {fLegendY2 = y2;}
59  virtual void SetStatsX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
60  virtual void SetNumHistsX(UInt_t numX);
61  virtual void SetNumHistsX(UInt_t numX, Int_t layer);
62  virtual void SetNumHistsY(UInt_t numY);
63  virtual void SetNumHistsY(UInt_t numY, Int_t layer);
64  virtual void SetNumHistsXY(UInt_t numX, UInt_t numY);
65  virtual void SetNumHistsXY(UInt_t numX, UInt_t numY, Int_t layer);
66  virtual void SetLogY(Bool_t yesNo = kTRUE);
67  virtual void SetLogY(Int_t layer, Bool_t yesNo = kTRUE);
68  virtual void SetCanvasWidth(Int_t w) {fCanvasWidth = w;}
69  virtual void SetCanvasHeight(Int_t h) {fCanvasHeight = h;}
70  virtual void SetHistsOption(Option_t* option);
71  virtual void SetHistsOption(Option_t* option, Int_t layer);
72  virtual void SetHistsMinMax(Double_t minMax, Bool_t min);
73  virtual void SetHistsMinMax(Double_t minMax, Bool_t min, Int_t layer);
74  static void SetLegendEntryOption(const char* option) {fgLegendEntryOption = option;} // some of "lpf"
75  virtual void AddHistsOption(Option_t* option);
76  virtual void AddHistsOption(Option_t* option, Int_t layer);
77  virtual void SetHistsXTitle(const char* title);
78  virtual void SetHistsXTitle(const char* title, Int_t layer);
79  virtual void SetHistsYTitle(const char* title);
80  virtual void SetHistsYTitle(const char* title, Int_t layer);
81  virtual void SetHistsFillColor(Color_t color);
82  virtual void SetHistsFillColor(Color_t color, Int_t layer);
83  virtual void SetHistsLineWidth(Width_t width);
84  virtual void SetHistsLineWidth(Width_t width, Int_t layer);
85  virtual void SetHistsLineStyle(Int_t style);
86  virtual void SetHistsLineStyle(Int_t style, Int_t layer, Int_t numHistInPad = -1);
87  virtual void SetHistsLineColor(Color_t color);
88  virtual void SetHistsLineColor(Color_t color, Int_t layer);
89  virtual void WriteCanvases(TFile* file);
90  virtual void WriteHistos(TFile* file);
91  virtual void Update();
92  virtual void Update(Int_t layer);
93  virtual Bool_t SetBatch(Bool_t set = kTRUE) {Bool_t r = fBatch; fBatch = set; return r;}
94  virtual Bool_t IsBatch() const {return fBatch;}
95  virtual void ExpandTo(Int_t newDepth);
96 
97  virtual GFHistArray* GetHistsOf(Int_t layer, Int_t histNum, Bool_t mayExpand = kFALSE);
98  virtual TList* GetObjectsOf(Int_t layer, Int_t histNum);
99  virtual Int_t GetNumHistsOf(Int_t layer);
100  virtual TLegend* GetLegendOf(Int_t layer, Int_t nPad);
101  virtual Int_t GetCanvasWidth() const {return fCanvasWidth;}
102  virtual Int_t GetCanvasHeight() const {return fCanvasHeight;}
103  virtual Int_t GetNumHistsX(Int_t layer) const;
104  virtual Int_t GetNumHistsY(Int_t layer) const;
105  virtual Double_t MaxOfHist(const TH1* h) const;
106  virtual Double_t MaxOfHists(const TObjArray* hists) const;
107  virtual Double_t MinOfHists(const TObjArray* hists) const;
108  virtual TVirtualPad* GetPad(Int_t layer, Int_t histNum);
109  virtual TCanvas* GetCanvas(Int_t layer, Int_t number = 0);// after draw!!
110  Int_t GetNumLayers() const {return fDepth;}
111  virtual void GetLegendX1Y1X2Y2(Double_t& x1, Double_t& y1, Double_t& x2, Double_t& y2) const;
112 
113  static const Int_t kDefaultPadsPerCanX;// = 2; Doesn't work! Why ???
114  static const Int_t kDefaultPadsPerCanY;// = 2; It should. And it DOES, if we make
115  static const Int_t kDefaultDepth;// = 1; these static const datamembers protected!
116 
117  static Int_t NumberOfSubPadsOf(TCanvas* can);
118  static void MakeDifferentStyle(GFHistArray* hists);
119  Bool_t DrawDiffStyle(Bool_t yesNo) {
120  const Bool_t old = fDrawDiffStyle; fDrawDiffStyle = yesNo; return old;}
121  Bool_t SameWithStats(Bool_t yesNo) {
122  const Bool_t old = fSameWithStats; fSameWithStats = yesNo; return old;}
123 
124 protected:
125  virtual void DrawReally(Int_t layer);
126  virtual void DrawLegend(Int_t layer, Int_t histNo);
127  virtual void DrawObjects(Int_t layer, Int_t histNo);
128  virtual void MakeCanvases(Int_t layer);
129  virtual TObjArray* MakeLegends(Int_t layer);
130  virtual TList* MakeObjList(Int_t layer, Int_t histoNum);
131  virtual void Initialise();
132  virtual Bool_t CheckDepth(const char* method, Int_t layer, Bool_t mayExpand = kTRUE);
133  virtual Bool_t CheckHistNum(const char* method, Int_t layer, Int_t histNum,
134  Bool_t mayExpand = kFALSE);
135  void DrawFuncs(const TH1* hist) const;
136  void ColourStatsBoxes(GFHistArray *hists) const;
137  void ColourFuncs(GFHistArray *hists) const;
138 
139 private:
140  Int_t fDepth; // how many layers of histograms in arrays?
141  TArrayI fNoX; // how many hists in x...
142  TArrayI fNoY; // ... and in y in each canvas array
143  TArrayC fLogY; // whether or not a layer should be plotted in log(y)
144  Double_t fLegendX1; // default position
145  Double_t fLegendY1; // ...of TLegends
146  Double_t fLegendX2; // ... in x
147  Double_t fLegendY2; // .. and y
148  Double_t fStatsX1; // default positions in x and y
149  Double_t fStatsX2; // ...of first statsbox in case
150  Double_t fStatsY1; // ... many have to be drawn
151  Double_t fStatsY2; // ... (subsequent boxes are shifted)
152  Int_t fCanvasWidth; // pixel width
153  Int_t fCanvasHeight; // height of canvases (maybe relativly manipulated...)
154  static TString fgLegendEntryOption; // option used for legend entry style
155  TObjArray* fHistArrays; // array of arrays of arrays of histograms
156  TObjArray* fLegendArrays; // array of arrays to hold potential TLegend's
157  TObjArray* fObjLists; // array of array of lists to hold potential objects
158  TObjArray* fCanArrays; // array of arrays to hold canvases for drawing
159  Bool_t fBatch; // if true: ignore Draw()
160  Bool_t fDrawDiffStyle; // if true(default): call MakeDifferentStyle while Draw
161  Bool_t fSameWithStats; // if true(non-default): use SAMES option to add all stats boxes
162 
163  ClassDef(GFHistManager, 0) // Gero's histogram manager (not writable!)
164 };
165 
166 #endif
void Clear(Option_t *="")
Definition: GFHistManager.h:52
virtual void Print(const char *filename, Bool_t add=kFALSE)
virtual void SetLogY(Bool_t yesNo=kTRUE)
virtual void AddHists(TCollection *hists, Int_t layer=0, const char *legendTitle=NULL, const char *legOpt=NULL)
virtual Bool_t RemoveLegend(Int_t layer, Int_t nPad)
void ColourFuncs(GFHistArray *hists) const
virtual TList * GetObjectsOf(Int_t layer, Int_t histNum)
Bool_t fDrawDiffStyle
Int_t GetNumLayers() const
Bool_t SameWithStats(Bool_t yesNo)
static void MakeDifferentStyle(GFHistArray *hists)
virtual Int_t GetCanvasWidth() const
virtual TLegendEntry * AddHistSame(TH1 *hist, Int_t layer, Int_t nPad, const char *legendTitle=NULL, const char *legOpt=NULL)
virtual void Initialise()
TObjArray * fLegendArrays
static const Int_t kDefaultPadsPerCanX
static TString fgLegendEntryOption
virtual TList * MakeObjList(Int_t layer, Int_t histoNum)
Bool_t DrawDiffStyle(Bool_t yesNo)
virtual void Overlay(GFHistManager *other, Int_t otherLayer, Int_t myLayer, const char *legendTitle)
virtual TLegend * AddLegend(Int_t layer, Int_t nPad, const char *header=NULL, Bool_t referAll=kTRUE)
virtual Int_t GetNumHistsX(Int_t layer) const
virtual void SetHistsMinMax(Double_t minMax, Bool_t min)
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
#define NULL
Definition: scimark2.h:8
virtual Bool_t IsBatch() const
Definition: GFHistManager.h:94
virtual void SetHistsLineStyle(Int_t style)
#define min(a, b)
Definition: mlp_lapack.h:161
virtual void DrawLegend(Int_t layer, Int_t histNo)
virtual Bool_t CheckDepth(const char *method, Int_t layer, Bool_t mayExpand=kTRUE)
virtual void SetLegendX2(Double_t x2)
TObjArray * fObjLists
virtual TVirtualPad * GetPad(Int_t layer, Int_t histNum)
TObjArray * fHistArrays
static Int_t NumberOfSubPadsOf(TCanvas *can)
virtual void SetHistsFillColor(Color_t color)
virtual void GetLegendX1Y1X2Y2(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) const
void ColourStatsBoxes(GFHistArray *hists) const
static void SetLegendEntryOption(const char *option)
Definition: GFHistManager.h:74
TObjArray * fCanArrays
Double_t fLegendX2
virtual void SetHistsLineWidth(Width_t width)
virtual void SetLegendY1(Double_t y1)
virtual TLegend * GetLegendOf(Int_t layer, Int_t nPad)
virtual Double_t MinOfHists(const TObjArray *hists) const
virtual Int_t GetCanvasHeight() const
virtual void DrawObjects(Int_t layer, Int_t histNo)
virtual void ExpandTo(Int_t newDepth)
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
virtual void SetLegendX1(Double_t x1)
void DrawFuncs(const TH1 *hist) const
virtual void Clear(Bool_t deleteHists)
virtual void SetNumHistsX(UInt_t numX)
static const Int_t kDefaultDepth
virtual void WriteCanvases(TFile *file)
virtual void SetHistsXTitle(const char *title)
Bool_t fSameWithStats
Double_t fLegendY1
virtual void Update()
virtual void AddLayer(GFHistManager *other, Int_t layer)
virtual Double_t MaxOfHists(const TObjArray *hists) const
static const Int_t kDefaultPadsPerCanY
virtual void WriteHistos(TFile *file)
virtual void SetCanvasHeight(Int_t h)
Definition: GFHistManager.h:69
virtual void SetStatsX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
virtual void SetHistsLineColor(Color_t color)
virtual Double_t MaxOfHist(const TH1 *h) const
virtual Int_t GetNumHistsOf(Int_t layer)
virtual void SetLegendX1Y1X2Y2(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
unsigned int UInt_t
Definition: FUTypes.h:12
Double_t fLegendY2
virtual void MakeCanvases(Int_t layer)
virtual void DrawReally(Int_t layer)
virtual void SetHistsYTitle(const char *title)
virtual ~GFHistManager()
Double_t fStatsX1
Double_t fStatsY2
virtual void SetLegendY2(Double_t y2)
virtual void AddHistsSame(GFHistArray *hists, Int_t layer, const char *legendTitle=NULL, const char *legOpt=NULL)
virtual Bool_t CheckHistNum(const char *method, Int_t layer, Int_t histNum, Bool_t mayExpand=kFALSE)
virtual TLegendEntry * AddHist(TH1 *hist, Int_t layer=0, const char *legendTitle=NULL, const char *legOpt=NULL)
virtual void Draw(Option_t *opt="")
virtual Int_t GetNumHistsY(Int_t layer) const
virtual void SetHistsOption(Option_t *option)
virtual void AddHistsOption(Option_t *option)
Double_t fLegendX1
virtual TCanvas * GetCanvas(Int_t layer, Int_t number=0)
Double_t fStatsX2
virtual Bool_t SetBatch(Bool_t set=kTRUE)
Definition: GFHistManager.h:93
tuple filename
Definition: lut2db_cfg.py:20
virtual void AddLayers(GFHistManager *other)
virtual void SetCanvasWidth(Int_t w)
Definition: GFHistManager.h:68
virtual void SetNumHistsY(UInt_t numY)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
virtual void SetNumHistsXY(UInt_t numX, UInt_t numY)
void Delete(Option_t *="")
Definition: GFHistManager.h:53
Double_t fStatsY1
virtual TObjArray * MakeLegends(Int_t layer)
virtual void AddObject(TObject *obj, Int_t layer, Int_t histoNum, Option_t *opt=NULL)
virtual GFHistArray * GetHistsOf(Int_t layer, Int_t histNum, Bool_t mayExpand=kFALSE)