Logo ROOT   6.12/07
Reference Guide
TCandle.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Georg Troska 2016/04/14
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TCandle
13 #define ROOT_TCandle
14 
15 #include "TObject.h"
16 #include "TAttLine.h"
17 #include "TAttFill.h"
18 #include "TAttMarker.h"
19 
20 #include "TH1D.h"
21 #include "TMath.h"
22 
23 const Int_t kNMAXPOINTS = 2010; // Max outliers per candle
24 
25 class TCandle : public TAttLine, public TAttFill, public TAttMarker {
26 public:
27  //Candle Option
28  enum CandleOption: long {
29  kNoOption = 0,
30  kBox = 1,
34  kMeanLine = 100,
35  kMeanCircle = 300,
36  kWhiskerAll = 1000,
37  kWhisker15 = 2000,
38  kAnchor = 10000,
39  kPointsOutliers = 100000,
40  kPointsAll = 200000,
41  kPointsAllScat = 300000,
42  kHistoLeft = 1000000,
43  kHistoRight = 2000000,
44  kHistoViolin = 3000000,
45  kHistoZeroIndicator = 10000000,
46  kHorizontal = 100000000 ///< If this bit is not set it is vertical
47  };
48 
49 
50 protected:
51 
52  bool fIsRaw; ///< 0: for TH1 projection, 1: using raw data
55  bool fDismiss; ///< True if the candle cannot be painted
56 
57  Double_t fPosCandleAxis; ///< x-pos for a vertical candle
58  Double_t fCandleWidth; ///< The candle width
59  Double_t fHistoWidth; ///< The histo width (the height of the max bin)
60 
61  Double_t fMean; ///< Position of the mean
62  Double_t fMedian; ///< Position of the median
63  Double_t fMedianErr; ///< The size of the notch
64  Double_t fBoxUp; ///< Position of the upper box end
65  Double_t fBoxDown; ///< Position of the lower box end
66  Double_t fWhiskerUp; ///< Position of the upper whisker end
67  Double_t fWhiskerDown; ///< Position of the lower whisker end
68 
69  Double_t * fDatapoints; ///< position of all Datapoints within this candle
70  Long64_t fNDatapoints; ///< Number of Datapoints within this candle
71 
72  Double_t fDrawPointsX[kNMAXPOINTS]; ///< x-coord for every outlier, ..
73  Double_t fDrawPointsY[kNMAXPOINTS]; ///< y-coord for every outlier, ..
74  Long64_t fNDrawPoints; ///< max number of outliers or other point to be shown
75 
76  Double_t fHistoPointsX[kNMAXPOINTS]; ///< x-coord for the polyline of the histo
77  Double_t fHistoPointsY[kNMAXPOINTS]; ///< y-coord for the polyline of the histo
79 
80  CandleOption fOption; ///< Setting the style of the candle
81  char fOptionStr[128]; ///< String to draw the candle
82  int fLogX; ///< make the candle appear logx-like
83  int fLogY; ///< make the candle appear logy-like
84  int fLogZ; ///< make the candle appear logz-like
85 
86  Double_t fAxisMin; ///< The Minimum which is visible by the axis (used by zero indicator)
87  Double_t fAxisMax; ///< The Maximum which is visible by the axis (used by zero indicator)
88 
89  static Double_t fWhiskerRange; ///< The fraction which is covered by the whiskers (0 < x < 1), default 1
90  static Double_t fBoxRange; ///< The fraction which is covered by the box (0 < x < 1), default 0.5
91 
92  static Bool_t fScaledCandle; ///< shall the box-width be scaled to each other by the integral of a box?
93  static Bool_t fScaledViolin; ///< shall the violin or histos be scaled to each other by the maximum height?
94 
95  void Calculate();
96 
97  int GetCandleOption(const int pos) {return (fOption/(long)TMath::Power(10,pos))%10;}
98 
99  void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
100  void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t swapXY);
101 
102 public:
103 
104  TCandle();
105  TCandle(const char *opt);
106  TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
107  TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
108  TCandle(const TCandle &candle);
109  virtual ~TCandle();
110 
111  Double_t GetMean() const {return fMean;}
112  Double_t GetMedian() const {return fMedian;}
113  Double_t GetQ1() const {return fBoxUp;}
114  Double_t GetQ2() const {return fMedian;}
115  Double_t GetQ3() const {return fBoxDown;}
120 
121  void SetOption(CandleOption opt) { fOption = opt; }
122  void SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
123  void SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
124 
125  void SetCandleWidth(const Double_t width) { fCandleWidth = width; }
126  void SetHistoWidth(const Double_t width) { fHistoWidth = width; }
127  void SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
128 
129  virtual void Paint(Option_t *option="");
130  void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
131 
132  virtual void SetMean(Double_t mean) { fMean = mean; }
133  virtual void SetMedian(Double_t median) { fMedian = median; }
134  virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
135  virtual void SetQ2(Double_t q2) { fMedian = q2; }
136  virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
137 
138  int ParseOption(char *optin);
139  const char * GetDrawOption() { return fOptionStr; }
140  long GetOption() { return fOption; }
141  bool IsOption(CandleOption opt);
142  static void SetWhiskerRange(const Double_t wRange);
143  static void SetBoxRange(const Double_t bRange);
144  static void SetScaledCandle(const Bool_t cScale = true);
145  static void SetScaledViolin(const Bool_t vScale = true);
146 
147  ClassDef(TCandle,2) //A Candle
148 };
149 #endif
Double_t GetMean() const
Definition: TCandle.h:111
virtual void SetMean(Double_t mean)
Definition: TCandle.h:132
TCandle()
TCandle default constructor.
Definition: TCandle.cxx:41
Double_t fMedian
Position of the median.
Definition: TCandle.h:62
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsHorizontal()
Definition: TCandle.h:116
static Double_t fBoxRange
The fraction which is covered by the box (0 < x < 1), default 0.5.
Definition: TCandle.h:90
If this bit is not set it is vertical.
Definition: TCandle.h:46
Double_t fWhiskerUp
Position of the upper whisker end.
Definition: TCandle.h:66
bool IsOption(CandleOption opt)
Return true is this option is activated in fOption.
Definition: TCandle.cxx:849
const char Option_t
Definition: RtypesCore.h:62
int ParseOption(char *optin)
Parsing of the option-string.
Definition: TCandle.cxx:244
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static Bool_t fScaledCandle
shall the box-width be scaled to each other by the integral of a box?
Definition: TCandle.h:92
void SetHistogram(TH1D *proj)
Definition: TCandle.h:127
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:86
Double_t * fDatapoints
position of all Datapoints within this candle
Definition: TCandle.h:69
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition: TCandle.h:72
void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t swapXY)
Paint a line for candle.
Definition: TCandle.cxx:893
void SetOption(CandleOption opt)
Definition: TCandle.h:121
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:627
Double_t fMean
Position of the mean.
Definition: TCandle.h:61
Marker Attributes class.
Definition: TAttMarker.h:19
CandleOption
Definition: TCandle.h:28
virtual void SetMedian(Double_t median)
Definition: TCandle.h:133
static const double x2[5]
Fill Area Attributes class.
Definition: TAttFill.h:19
bool fIsCalculated
Definition: TCandle.h:53
Double_t x[n]
Definition: legend1.C:17
Double_t fHistoWidth
The histo width (the height of the max bin)
Definition: TCandle.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:320
Double_t fCandleWidth
The candle width.
Definition: TCandle.h:58
int fLogX
make the candle appear logx-like
Definition: TCandle.h:82
void SetCandleWidth(const Double_t width)
Definition: TCandle.h:125
void SetHistoWidth(const Double_t width)
Definition: TCandle.h:126
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition: TCandle.cxx:865
Bool_t IsCandleScaled()
Definition: TCandle.cxx:185
Double_t GetQ3() const
Definition: TCandle.h:115
Double_t GetMedian() const
Definition: TCandle.h:112
static Bool_t fScaledViolin
shall the violin or histos be scaled to each other by the maximum height?
Definition: TCandle.h:93
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition: TCandle.h:73
Bool_t IsVertical()
Definition: TCandle.h:117
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition: TCandle.h:76
Double_t fBoxDown
Position of the lower box end.
Definition: TCandle.h:65
void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord)
The coordinates in the TParallelCoordVar-class are in Pad-Coordinates, so we need to convert them...
Definition: TCandle.cxx:932
point * points
Definition: X3DBuffer.c:20
Double_t fBoxUp
Position of the upper box end.
Definition: TCandle.h:64
Double_t GetQ1() const
Definition: TCandle.h:113
int fLogY
make the candle appear logy-like
Definition: TCandle.h:83
The candle plot painter class.
Definition: TCandle.h:25
void Calculate()
Calculates all values needed by the candle definition depending on the candle options.
Definition: TCandle.cxx:385
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:87
void SetLog(int x, int y, int z)
Definition: TCandle.h:122
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:610
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition: TCandle.cxx:674
static void SetBoxRange(const Double_t bRange)
Static function to set fBoxRange, by setting whisker-range, one can force the box of the candle-chart...
Definition: TCandle.cxx:217
bool fDismiss
True if the candle cannot be painted.
Definition: TCandle.h:55
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition: TCandle.cxx:227
static Double_t fWhiskerRange
The fraction which is covered by the whiskers (0 < x < 1), default 1.
Definition: TCandle.h:89
static const double x1[5]
TH1D * fProj
Definition: TCandle.h:54
double Double_t
Definition: RtypesCore.h:55
char fOptionStr[128]
String to draw the candle.
Definition: TCandle.h:81
CandleOption fOption
Setting the style of the candle.
Definition: TCandle.h:80
Double_t fMedianErr
The size of the notch.
Definition: TCandle.h:63
Double_t y[n]
Definition: legend1.C:17
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition: TCandle.h:77
long GetOption()
Definition: TCandle.h:140
int GetCandleOption(const int pos)
Definition: TCandle.h:97
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition: TCandle.h:74
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
static void SetWhiskerRange(const Double_t wRange)
Static function to set fWhiskerRange, by setting whisker-range, one can force the whiskers to cover t...
Definition: TCandle.cxx:203
virtual void SetQ2(Double_t q2)
Definition: TCandle.h:135
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition: TCandle.cxx:236
Double_t fWhiskerDown
Position of the lower whisker end.
Definition: TCandle.h:67
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition: TCandle.h:57
const Int_t kNMAXPOINTS
Definition: TCandle.h:23
Bool_t IsViolinScaled()
Definition: TCandle.cxx:190
virtual void SetQ1(Double_t q1)
Definition: TCandle.h:134
virtual ~TCandle()
TCandle default destructor.
Definition: TCandle.cxx:181
virtual void SetQ3(Double_t q3)
Definition: TCandle.h:136
bool fIsRaw
0: for TH1 projection, 1: using raw data
Definition: TCandle.h:52
int fLogZ
make the candle appear logz-like
Definition: TCandle.h:84
int fNHistoPoints
Definition: TCandle.h:78
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:18
const char * GetDrawOption()
Definition: TCandle.h:139
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition: TCandle.h:70
void SetAxisPosition(const Double_t candlePos)
Definition: TCandle.h:123
Double_t GetQ2() const
Definition: TCandle.h:114