Logo ROOT   6.18/05
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
23const Int_t kNMAXPOINTS = 2010; // Max outliers per candle
24
25class TCandle : public TAttLine, public TAttFill, public TAttMarker {
26public:
27 //Candle Option
28 enum CandleOption: long {
30 kBox = 1,
34 kMeanLine = 100,
37 kWhisker15 = 2000,
38 kAnchor = 10000,
40 kPointsAll = 200000,
42 kHistoLeft = 1000000,
43 kHistoRight = 2000000,
44 kHistoViolin = 3000000,
46 kHorizontal = 100000000 ///< If this bit is not set it is vertical
47 };
48
49
50protected:
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
102public:
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
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
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
const Int_t kNMAXPOINTS
Definition: TCandle.h:23
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
point * points
Definition: X3DBuffer.c:22
Fill Area Attributes class.
Definition: TAttFill.h:19
Line Attributes class.
Definition: TAttLine.h:18
Marker Attributes class.
Definition: TAttMarker.h:19
The candle plot painter class.
Definition: TCandle.h:25
Double_t fMedian
Position of the median.
Definition: TCandle.h:62
void SetLog(int x, int y, int z)
Definition: TCandle.h:122
static Double_t fBoxRange
The fraction which is covered by the box (0 < x < 1), default 0.5.
Definition: TCandle.h:90
CandleOption
Definition: TCandle.h:28
@ kHorizontal
If this bit is not set it is vertical.
Definition: TCandle.h:46
@ kAnchor
Definition: TCandle.h:38
@ kWhiskerAll
Definition: TCandle.h:36
@ kMeanCircle
Definition: TCandle.h:35
@ kHistoZeroIndicator
Definition: TCandle.h:45
@ kPointsAllScat
Definition: TCandle.h:41
@ kNoOption
Definition: TCandle.h:29
@ kHistoRight
Definition: TCandle.h:43
@ kMeanLine
Definition: TCandle.h:34
@ kBox
Definition: TCandle.h:30
@ kWhisker15
Definition: TCandle.h:37
@ kMedianLine
Definition: TCandle.h:31
@ kPointsAll
Definition: TCandle.h:40
@ kPointsOutliers
Definition: TCandle.h:39
@ kMedianNotched
Definition: TCandle.h:32
@ kHistoLeft
Definition: TCandle.h:42
@ kMedianCircle
Definition: TCandle.h:33
@ kHistoViolin
Definition: TCandle.h:44
Double_t GetQ1() const
Definition: TCandle.h:113
Double_t GetQ2() const
Definition: TCandle.h:114
TH1D * fProj
Definition: TCandle.h:54
void SetHistoWidth(const Double_t width)
Definition: TCandle.h:126
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition: TCandle.cxx:236
bool fIsRaw
0: for TH1 projection, 1: using raw data
Definition: TCandle.h:52
static Double_t fWhiskerRange
The fraction which is covered by the whiskers (0 < x < 1), default 1.
Definition: TCandle.h:89
CandleOption fOption
Setting the style of the candle.
Definition: TCandle.h:80
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:87
int fLogZ
make the candle appear logz-like
Definition: TCandle.h:84
bool IsOption(CandleOption opt)
Return true is this option is activated in fOption.
Definition: TCandle.cxx:849
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition: TCandle.h:57
Double_t GetMean() const
Definition: TCandle.h:111
virtual void SetQ2(Double_t q2)
Definition: TCandle.h:135
int fNHistoPoints
Definition: TCandle.h:78
Double_t fMean
Position of the mean.
Definition: TCandle.h:61
Double_t fWhiskerDown
Position of the lower whisker end.
Definition: TCandle.h:67
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition: TCandle.h:74
const char * GetDrawOption()
Definition: TCandle.h:139
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition: TCandle.cxx:674
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition: TCandle.h:86
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
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition: TCandle.h:73
Bool_t IsViolinScaled()
Definition: TCandle.cxx:190
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition: TCandle.h:70
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition: TCandle.h:77
Bool_t IsHorizontal()
Definition: TCandle.h:116
virtual void SetMedian(Double_t median)
Definition: TCandle.h:133
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition: TCandle.h:76
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition: TCandle.cxx:227
Double_t * fDatapoints
position of all Datapoints within this candle
Definition: TCandle.h:69
int ParseOption(char *optin)
Parsing of the option-string.
Definition: TCandle.cxx:244
bool fDismiss
True if the candle cannot be painted.
Definition: TCandle.h:55
virtual void SetQ3(Double_t q3)
Definition: TCandle.h:136
Bool_t IsVertical()
Definition: TCandle.h:117
Double_t fWhiskerUp
Position of the upper whisker end.
Definition: TCandle.h:66
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
void SetOption(CandleOption opt)
Definition: TCandle.h:121
void SetHistogram(TH1D *proj)
Definition: TCandle.h:127
static Bool_t fScaledViolin
shall the violin or histos be scaled to each other by the maximum height?
Definition: TCandle.h:93
int fLogY
make the candle appear logy-like
Definition: TCandle.h:83
Double_t fMedianErr
The size of the notch.
Definition: TCandle.h:63
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition: TCandle.cxx:865
Double_t fBoxUp
Position of the upper box end.
Definition: TCandle.h:64
virtual ~TCandle()
TCandle default destructor.
Definition: TCandle.cxx:181
int fLogX
make the candle appear logx-like
Definition: TCandle.h:82
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition: TCandle.h:72
TCandle(const TCandle &candle)
TCandle()
TCandle default constructor.
Definition: TCandle.cxx:41
Double_t fBoxDown
Position of the lower box end.
Definition: TCandle.h:65
void Calculate()
Calculates all values needed by the candle definition depending on the candle options.
Definition: TCandle.cxx:385
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
Bool_t IsCandleScaled()
Definition: TCandle.cxx:185
virtual void SetMean(Double_t mean)
Definition: TCandle.h:132
Double_t fHistoWidth
The histo width (the height of the max bin)
Definition: TCandle.h:59
virtual void SetQ1(Double_t q1)
Definition: TCandle.h:134
Double_t GetMedian() const
Definition: TCandle.h:112
int GetCandleOption(const int pos)
Definition: TCandle.h:97
void SetCandleWidth(const Double_t width)
Definition: TCandle.h:125
long GetOption()
Definition: TCandle.h:140
bool fIsCalculated
Definition: TCandle.h:53
void SetAxisPosition(const Double_t candlePos)
Definition: TCandle.h:123
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
Double_t GetQ3() const
Definition: TCandle.h:115
static Bool_t fScaledCandle
shall the box-width be scaled to each other by the integral of a box?
Definition: TCandle.h:92
char fOptionStr[128]
String to draw the candle.
Definition: TCandle.h:81
Double_t fCandleWidth
The candle width.
Definition: TCandle.h:58
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:614
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:723