Logo ROOT   6.10/09
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 = 1000000000 ///< If this bit is not set it is vertical
47  };
48 
49 protected:
50 
51  bool fIsRaw; ///< 0: for TH1 projection, 1: using raw data
54  bool fDismiss; ///< True if the candle cannot be painted
55 
56  Double_t fPosCandleAxis; ///< x-pos for a vertical candle
57  Double_t fCandleWidth; ///< The candle width
58 
59  Double_t fMean; ///< Position of the mean
60  Double_t fMedian; ///< Position of the median
61  Double_t fMedianErr; ///< The size of the notch
62  Double_t fBoxUp; ///< Position of the upper box end
63  Double_t fBoxDown; ///< Position of the lower box end
64  Double_t fWhiskerUp; ///< Position of the upper whisker end
65  Double_t fWhiskerDown; ///< Position of the lower whisker end
66 
67  Double_t * fDatapoints; ///< position of all Datapoints within this candle
68  Long64_t fNDatapoints; ///< Number of Datapoints within this candle
69 
70  Double_t fDrawPointsX[kNMAXPOINTS]; ///< x-coord for every outlier, ..
71  Double_t fDrawPointsY[kNMAXPOINTS]; ///< y-coord for every outlier, ..
72  Long64_t fNDrawPoints; ///< max number of outliers or other point to be shown
73 
74  Double_t fHistoPointsX[kNMAXPOINTS]; ///< x-coord for the polyline of the histo
75  Double_t fHistoPointsY[kNMAXPOINTS]; ///< y-coord for the polyline of the histo
77 
78  CandleOption fOption; ///< Setting the style of the candle
79  int fLogX; ///< make the candle appear logx-like
80  int fLogY; ///< make the candle appear logy-like
81 
82  Double_t fAxisMin; ///< The Minimum which is visible by the axis (used by zero indicator)
83  Double_t fAxisMax; ///< The Maximum which is visible by the axis (used by zero indicator)
84 
85  void Calculate();
86 
87  int GetCandleOption(const int pos) {return (fOption/(int)TMath::Power(10,pos))%10;}
88  bool IsOption(CandleOption opt);
89  void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
90  void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t swapXY);
91 
92 public:
93 
94  TCandle();
95  TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
96  TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
97  TCandle(const TCandle &candle);
98  virtual ~TCandle();
99 
100  Double_t GetMean() const {return fMean;}
101  Double_t GetMedian() const {return fMedian;}
102  Double_t GetQ1() const {return fBoxUp;}
103  Double_t GetQ2() const {return fMedian;}
104  Double_t GetQ3() const {return fBoxDown;}
107 
108  void SetOption(CandleOption opt) { fOption = opt; }
109  void SetLog(int x, int y) { fLogX = x; fLogY = y; }
110  void SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
111 
112  void SetWidth(const Double_t width) { fCandleWidth = width; }
113  void SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
114 
115  virtual void Paint(Option_t *option="");
116  void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
117 
118  virtual void SetMean(Double_t mean) { fMean = mean; }
119  virtual void SetMedian(Double_t median) { fMedian = median; }
120  virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
121  virtual void SetQ2(Double_t q2) { fMedian = q2; }
122  virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
123 
124  int ParseOption(char *optin);
125 
126  ClassDef(TCandle,1) //A Candle
127 };
128 #endif
Double_t GetMean() const
Definition: TCandle.h:100
virtual void SetMean(Double_t mean)
Definition: TCandle.h:118
TCandle()
TCandle default constructor.
Definition: TCandle.cxx:36
Double_t fMedian
Position of the median.
Definition: TCandle.h:60
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsHorizontal()
Definition: TCandle.h:105
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:64
bool IsOption(CandleOption opt)
Return true is this option is activated in fOption.
Definition: TCandle.cxx:698
const char Option_t
Definition: RtypesCore.h:62
int ParseOption(char *optin)
Parsing of the option-string.
Definition: TCandle.cxx:135
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetHistogram(TH1D *proj)
Definition: TCandle.h:113
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:82
Double_t * fDatapoints
position of all Datapoints within this candle
Definition: TCandle.h:67
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition: TCandle.h:70
void SetLog(int x, int y)
Definition: TCandle.h:109
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:742
void SetOption(CandleOption opt)
Definition: TCandle.h:108
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:628
Double_t fMean
Position of the mean.
Definition: TCandle.h:59
Marker Attributes class.
Definition: TAttMarker.h:19
CandleOption
Definition: TCandle.h:28
virtual void SetMedian(Double_t median)
Definition: TCandle.h:119
static const double x2[5]
Fill Area Attributes class.
Definition: TAttFill.h:19
bool fIsCalculated
Definition: TCandle.h:52
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
Double_t fCandleWidth
The candle width.
Definition: TCandle.h:57
int fLogX
make the candle appear logx-like
Definition: TCandle.h:79
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition: TCandle.cxx:714
Double_t GetQ3() const
Definition: TCandle.h:104
Double_t GetMedian() const
Definition: TCandle.h:101
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition: TCandle.h:71
Bool_t IsVertical()
Definition: TCandle.h:106
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition: TCandle.h:74
Double_t fBoxDown
Position of the lower box end.
Definition: TCandle.h:63
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:781
point * points
Definition: X3DBuffer.c:20
Double_t fBoxUp
Position of the upper box end.
Definition: TCandle.h:62
Double_t GetQ1() const
Definition: TCandle.h:102
int fLogY
make the candle appear logy-like
Definition: TCandle.h:80
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:256
void SetWidth(const Double_t width)
Definition: TCandle.h:112
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:83
tomato 1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:594
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition: TCandle.cxx:523
bool fDismiss
True if the candle cannot be painted.
Definition: TCandle.h:54
static const double x1[5]
TH1D * fProj
Definition: TCandle.h:53
double Double_t
Definition: RtypesCore.h:55
CandleOption fOption
Setting the style of the candle.
Definition: TCandle.h:78
Double_t fMedianErr
The size of the notch.
Definition: TCandle.h:61
Double_t y[n]
Definition: legend1.C:17
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition: TCandle.h:75
int GetCandleOption(const int pos)
Definition: TCandle.h:87
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition: TCandle.h:72
virtual void SetQ2(Double_t q2)
Definition: TCandle.h:121
Double_t fWhiskerDown
Position of the lower whisker end.
Definition: TCandle.h:65
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition: TCandle.h:56
const Int_t kNMAXPOINTS
Definition: TCandle.h:23
virtual void SetQ1(Double_t q1)
Definition: TCandle.h:120
virtual ~TCandle()
TCandle default destructor.
Definition: TCandle.cxx:127
virtual void SetQ3(Double_t q3)
Definition: TCandle.h:122
bool fIsRaw
0: for TH1 projection, 1: using raw data
Definition: TCandle.h:51
int fNHistoPoints
Definition: TCandle.h:76
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:18
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition: TCandle.h:68
void SetAxisPosition(const Double_t candlePos)
Definition: TCandle.h:110
Double_t GetQ2() const
Definition: TCandle.h:103