BCH2D.h
1 #ifndef __BCH2D__H
2 #define __BCH2D__H
3 
16 /*
17  * Copyright (C) 2007-2018, the BAT core developer team
18  * All rights reserved.
19  *
20  * For the licensing terms see doc/COPYING.
21  * For documentation see http://mpp.mpg.de/bat
22  */
23 
24 // ---------------------------------------------------------
25 
26 #include "BCHistogramBase.h"
27 
28 #include <vector>
29 #include <string>
30 
31 class TH2;
32 class TGraph;
33 class TObject;
34 
35 // ---------------------------------------------------------
36 
37 class BCH2D : public BCHistogramBase
38 {
39 
40 public:
41 
48  kNoBands = -1,
50  // kCentralIntervalOfYGivenX = 1, //!< 1D central intervals in Y for each bin in X
51  // kCentralIntervalOfXGivenY = 2, //!< 1D central intervals in X for each bin in Y
52  // kSmallestIntervalOfYGivenX = 3, //!< 1D smallest intervals in Y for each bin in X
53  // kSmallestIntervalOfXGivenY = 4, //!< 1D smallest intervals in X for each bin in Y
54  // kUpperLimitOfYGivenX = 5, //!< 1D upper limits of Y for each bin in X
55  // kUpperLimitOfXGivenY = 6, //!< 1D upper limits of X for each bin in Y
56  // kLowerLimitOfYGivenX = 7, //!< 1D lower limits of Y for each bin in X
57  // kLowerLimitOfXGivenY = 8 //!< 1D lower limits of X for each bin in Y
58  };
59 
63  kProfileMean = 0,
64  kProfileMedian = 1,
65  kProfileMode = 2
66  };
67 
71  kProfileX = 0,
72  kProfileY = 1
73  };
74 
82  BCH2D(const TH2* const h = 0);
83 
86  BCH2D(const BCH2D& other);
87 
90  virtual ~BCH2D() {};
91 
101  { return (TH2*)fHistogram; }
102 
106  { return fBandType; }
107 
110  bool GetLogz()
111  { return fLogz; }
112 
116  { return fDrawProfileX; }
117 
121  { return fProfileXType; }
122 
126  { return fProfileXLineColor; }
127 
131  { return fProfileXLineStyle; }
132 
136  { return fDrawProfileY; }
137 
141  { return fProfileYType; }
142 
146  { return fProfileYLineColor; }
147 
151  { return fProfileYLineStyle; }
152 
160 
163  void CopyOptions(const BCH2D& other);
164 
166 
171  void SetGlobalMode(double x, double y)
172  { std::vector<double> m(1, x); m.push_back(y); SetGlobalMode(m); }
173 
175 
180  void SetLocalMode(double x, double y)
181  { std::vector<double> m(1, x); m.push_back(y); SetLocalMode(m); }
182 
185  { fBandType = bt; }
186 
189  void SetLogz(bool flag = true)
190  { fLogz = flag; }
191 
194  void SetDrawProfileX(bool flag = true)
195  { fDrawProfileX = flag; }
196 
200  { fProfileXType = pt; }
201 
205  { fProfileXLineColor = c; }
206 
210  { fProfileXLineStyle = s; }
211 
214  void SetDrawProfileY(bool flag = true)
215  { fDrawProfileY = flag; }
216 
220  { fProfileYType = pt; }
221 
225  { fProfileYLineColor = c; }
226 
230  { fProfileYLineStyle = s; }
231 
239 
243  virtual void CheckIntervals(std::vector<double>& intervals);
244 
249  virtual std::vector<double> DefaultIntervals(int nbands = -1);
250 
253  virtual void DrawBands(const std::string& options = "same");
254 
257  virtual void DrawMarkers();
258 
266  TGraph* CalculateProfileGraph(BCH2DProfileAxis axis, BCH2DProfileType pt = kProfileMean);
267 
270  void DrawProfileGraphs();
271 
274 protected:
275 
279 
282  bool fLogz;
283 
287 
291 
295 
299 
303 
307 
311 
315 
316 };
317 
318 // ---------------------------------------------------------
319 
320 #endif
bool fDrawProfileX
flag for drawing x profile.
Definition: BCH2D.h:286
BCH2DProfileType GetProfileXType()
Definition: BCH2D.h:120
int fProfileYLineColor
color of y profile.
Definition: BCH2D.h:310
void SetDrawProfileY(bool flag=true)
Set drawing of y profile.
Definition: BCH2D.h:214
BCH2DProfileType fProfileXType
profile type of x profile.
Definition: BCH2D.h:290
bool GetDrawProfileX()
Definition: BCH2D.h:115
bool fLogz
flag for drawing log z.
Definition: BCH2D.h:282
virtual void DrawBands(const std::string &options="same")
Draw band, or if band type set to no bands, histogram.
Definition: BCH2D.cxx:91
virtual std::vector< double > DefaultIntervals(int nbands=-1)
Return default intervals.
Definition: BCH2D.cxx:74
BCH2DProfileAxis
Enum for axis to profile.
Definition: BCH2D.h:70
void SetGlobalMode(std::vector< double > gm)
Set global mode.
A class for handling 2D distributions.
Definition: BCH2D.h:37
no bands
Definition: BCH2D.h:48
virtual void CheckIntervals(std::vector< double > &intervals, int sort)
Check intervals: remove values below 0 or above 1.
TH2 * GetHistogram()
Return the TH2 histogram.
Definition: BCH2D.h:100
bool GetDrawProfileY()
Definition: BCH2D.h:135
void SetLogz(bool flag=true)
Sets drawing of z axis in log.
Definition: BCH2D.h:189
void SetProfileYType(BCH2DProfileType pt)
Set profile type of y profile.
Definition: BCH2D.h:219
virtual void CopyOptions(const BCHistogramBase &other)
Copy options from.
virtual void DrawMarkers()
Draw Markers: global mode, local mode, etc.
Definition: BCH2D.cxx:175
BCH2DProfileType GetProfileYType()
Definition: BCH2D.h:140
TH1 * fHistogram
The histogram.
BCH2D(const TH2 *const h=0)
The complete constructor.
Definition: BCH2D.cxx:28
virtual ~BCH2D()
The default destructor.
Definition: BCH2D.h:90
BCH2DProfileType
Enum for type of profile.
Definition: BCH2D.h:62
A base class for drawing histograms in BAT style.
BCH2DProfileType fProfileYType
profile type of y profile.
Definition: BCH2D.h:306
smallest intervals containing probability mass
Definition: BCH2D.h:49
void SetLocalMode(double x, double y)
Set local mode.
Definition: BCH2D.h:180
void SetProfileYLineStyle(int s)
Set line style of y profile.
Definition: BCH2D.h:229
BCH2DBandType fBandType
band type.
Definition: BCH2D.h:278
void SetProfileXLineStyle(int s)
Set line style of x profile.
Definition: BCH2D.h:209
int GetProfileYLineColor()
Definition: BCH2D.h:145
int fProfileXLineStyle
line style of x profile.
Definition: BCH2D.h:298
virtual void CheckIntervals(std::vector< double > &intervals)
Check intervals: remove values below 0 or above 1, and sort to proper order band type.
Definition: BCH2D.cxx:67
void CopyOptions(const BCH2D &other)
copy options from
Definition: BCH2D.cxx:52
void SetLocalMode(std::vector< double > lm)
Set local mode.
int fProfileXLineColor
color of x profile.
Definition: BCH2D.h:294
void SetProfileXLineColor(int c)
Set line color of x profile.
Definition: BCH2D.h:204
int GetProfileXLineColor()
Definition: BCH2D.h:125
bool GetLogz()
Definition: BCH2D.h:110
bool fDrawProfileY
flag for drawing y profile.
Definition: BCH2D.h:302
BCH2DBandType
Enum for type of bands to draw on plot.
Definition: BCH2D.h:47
BCH2DBandType GetBandType()
Definition: BCH2D.h:105
void DrawProfileGraphs()
Draw the profiles along x and y.
Definition: BCH2D.cxx:263
int fProfileYLineStyle
line style of y profile.
Definition: BCH2D.h:314
int GetProfileXLineStyle()
Definition: BCH2D.h:130
void SetBandType(BCH2DBandType bt)
Set band type.
Definition: BCH2D.h:184
void SetProfileYLineColor(int c)
Set line color of y profile.
Definition: BCH2D.h:224
void SetGlobalMode(double x, double y)
Set global mode.
Definition: BCH2D.h:171
void SetDrawProfileX(bool flag=true)
Set drawing of x profile.
Definition: BCH2D.h:194
int GetProfileYLineStyle()
Definition: BCH2D.h:150
void SetProfileXType(BCH2DProfileType pt)
Set profile type of x profile.
Definition: BCH2D.h:199
TGraph * CalculateProfileGraph(BCH2DProfileAxis axis, BCH2DProfileType pt=kProfileMean)
Return a graph of the profile along x or y.
Definition: BCH2D.cxx:182