Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TMath.h"
21
22class TH1D;
23
24const Int_t kNMAXPOINTS = 2010; // Max outliers per candle
25
26class TCandle : public TAttLine, public TAttFill, public TAttMarker {
27public:
28 //Candle Option
29 enum CandleOption: long {
31 kBox = 1,
35 kMeanLine = 100,
38 kWhisker15 = 2000,
39 kAnchor = 10000,
41 kPointsAll = 200000,
43 kHistoLeft = 1000000,
44 kHistoRight = 2000000,
45 kHistoViolin = 3000000,
47 kHorizontal = 100000000 ///< If this bit is not set it is vertical
48 };
49
50
51protected:
52
53 bool fIsRaw; ///< 0: for TH1 projection, 1: using raw data
55 TH1D *fProj{nullptr};
56 bool fDismiss; ///< True if the candle cannot be painted
57
58 Double_t fPosCandleAxis; ///< x-pos for a vertical candle
59 Double_t fCandleWidth; ///< The candle width
60 Double_t fHistoWidth; ///< The histo width (the height of the max bin)
61
62 Double_t fMean; ///< Position of the mean
63 Double_t fMedian; ///< Position of the median
64 Double_t fMedianErr; ///< The size of the notch
65 Double_t fBoxUp; ///< Position of the upper box end
66 Double_t fBoxDown; ///< Position of the lower box end
67 Double_t fWhiskerUp; ///< Position of the upper whisker end
68 Double_t fWhiskerDown; ///< Position of the lower whisker end
69
70 Double_t *fDatapoints{nullptr}; ///< position of all Datapoints within this candle
71 Long64_t fNDatapoints; ///< Number of Datapoints within this candle
72
73 Double_t fDrawPointsX[kNMAXPOINTS]; ///< x-coord for every outlier, ..
74 Double_t fDrawPointsY[kNMAXPOINTS]; ///< y-coord for every outlier, ..
75 Long64_t fNDrawPoints; ///< max number of outliers or other point to be shown
76
77 Double_t fHistoPointsX[kNMAXPOINTS]; ///< x-coord for the polyline of the histo
78 Double_t fHistoPointsY[kNMAXPOINTS]; ///< y-coord for the polyline of the histo
80
81 CandleOption fOption; ///< Setting the style of the candle
82 char fOptionStr[128]; ///< String to draw the candle
83 int fLogX; ///< make the candle appear logx-like
84 int fLogY; ///< make the candle appear logy-like
85 int fLogZ; ///< make the candle appear logz-like
86
87 Double_t fAxisMin; ///< The Minimum which is visible by the axis (used by zero indicator)
88 Double_t fAxisMax; ///< The Maximum which is visible by the axis (used by zero indicator)
89
90 static Double_t fWhiskerRange; ///< The fraction which is covered by the whiskers (0 < x < 1), default 1
91 static Double_t fBoxRange; ///< The fraction which is covered by the box (0 < x < 1), default 0.5
92
93 static Bool_t fScaledCandle; ///< shall the box-width be scaled to each other by the integral of a box?
94 static Bool_t fScaledViolin; ///< shall the violin or histos be scaled to each other by the maximum height?
95
96 void Calculate();
97
98 int GetCandleOption(const int pos) {return (fOption/(long)TMath::Power(10,pos))%10;}
99
100 void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
102
103public:
104
105 TCandle();
106 TCandle(const char *opt);
107 TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
108 TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
109 TCandle(const TCandle &candle);
110 virtual ~TCandle();
111
112 Double_t GetMean() const {return fMean;}
113 Double_t GetMedian() const {return fMedian;}
114 Double_t GetQ1() const {return fBoxUp;}
115 Double_t GetQ2() const {return fMedian;}
116 Double_t GetQ3() const {return fBoxDown;}
121
122 void SetOption(CandleOption opt) { fOption = opt; }
123 void SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
124 void SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
125
128 void SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
129
130 virtual void Paint(Option_t *option="");
131 void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
132
133 virtual void SetMean(Double_t mean) { fMean = mean; }
134 virtual void SetMedian(Double_t median) { fMedian = median; }
135 virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
136 virtual void SetQ2(Double_t q2) { fMedian = q2; }
137 virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
138
139 int ParseOption(char *optin);
140 const char *GetDrawOption() { return fOptionStr; }
141 long GetOption() { return fOption; }
142 bool IsOption(CandleOption opt);
143 static void SetWhiskerRange(const Double_t wRange);
144 static void SetBoxRange(const Double_t bRange);
145 static void SetScaledCandle(const Bool_t cScale = true);
146 static void SetScaledViolin(const Bool_t vScale = true);
147
149};
150#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
const Int_t kNMAXPOINTS
Definition TCandle.h:24
Option_t Option_t option
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t width
Option_t Option_t TPoint TPoint const char y1
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:26
Double_t fMedian
Position of the median.
Definition TCandle.h:63
void SetLog(int x, int y, int z)
Definition TCandle.h:123
static Double_t fBoxRange
The fraction which is covered by the box (0 < x < 1), default 0.5.
Definition TCandle.h:91
CandleOption
Definition TCandle.h:29
@ kHorizontal
If this bit is not set it is vertical.
Definition TCandle.h:47
@ kAnchor
Definition TCandle.h:39
@ kWhiskerAll
Definition TCandle.h:37
@ kMeanCircle
Definition TCandle.h:36
@ kHistoZeroIndicator
Definition TCandle.h:46
@ kPointsAllScat
Definition TCandle.h:42
@ kNoOption
Definition TCandle.h:30
@ kHistoRight
Definition TCandle.h:44
@ kMeanLine
Definition TCandle.h:35
@ kBox
Definition TCandle.h:31
@ kWhisker15
Definition TCandle.h:38
@ kMedianLine
Definition TCandle.h:32
@ kPointsAll
Definition TCandle.h:41
@ kPointsOutliers
Definition TCandle.h:40
@ kMedianNotched
Definition TCandle.h:33
@ kHistoLeft
Definition TCandle.h:43
@ kMedianCircle
Definition TCandle.h:34
@ kHistoViolin
Definition TCandle.h:45
Double_t GetQ1() const
Definition TCandle.h:114
Double_t GetQ2() const
Definition TCandle.h:115
TH1D * fProj
Definition TCandle.h:55
void SetHistoWidth(const Double_t width)
Definition TCandle.h:127
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:53
static Double_t fWhiskerRange
The fraction which is covered by the whiskers (0 < x < 1), default 1.
Definition TCandle.h:90
CandleOption fOption
Setting the style of the candle.
Definition TCandle.h:81
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition TCandle.h:88
int fLogZ
make the candle appear logz-like
Definition TCandle.h:85
bool IsOption(CandleOption opt)
Return true is this option is activated in fOption.
Definition TCandle.cxx:837
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition TCandle.h:58
Double_t GetMean() const
Definition TCandle.h:112
virtual void SetQ2(Double_t q2)
Definition TCandle.h:136
int fNHistoPoints
Definition TCandle.h:79
Double_t fMean
Position of the mean.
Definition TCandle.h:62
Double_t fWhiskerDown
Position of the lower whisker end.
Definition TCandle.h:68
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition TCandle.h:75
const char * GetDrawOption()
Definition TCandle.h:140
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition TCandle.cxx:662
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition TCandle.h:87
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:920
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition TCandle.h:74
Bool_t IsViolinScaled()
Definition TCandle.cxx:190
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition TCandle.h:71
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition TCandle.h:78
Bool_t IsHorizontal()
Definition TCandle.h:117
virtual void SetMedian(Double_t median)
Definition TCandle.h:134
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition TCandle.h:77
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:70
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:56
virtual void SetQ3(Double_t q3)
Definition TCandle.h:137
Bool_t IsVertical()
Definition TCandle.h:118
Double_t fWhiskerUp
Position of the upper whisker end.
Definition TCandle.h:67
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:122
void SetHistogram(TH1D *proj)
Definition TCandle.h:128
static Bool_t fScaledViolin
shall the violin or histos be scaled to each other by the maximum height?
Definition TCandle.h:94
int fLogY
make the candle appear logy-like
Definition TCandle.h:84
Double_t fMedianErr
The size of the notch.
Definition TCandle.h:64
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition TCandle.cxx:853
Double_t fBoxUp
Position of the upper box end.
Definition TCandle.h:65
virtual ~TCandle()
TCandle default destructor.
Definition TCandle.cxx:181
int fLogX
make the candle appear logx-like
Definition TCandle.h:83
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition TCandle.h:73
TCandle(const TCandle &candle)
TCandle()
TCandle default constructor.
Definition TCandle.cxx:42
Double_t fBoxDown
Position of the lower box end.
Definition TCandle.h:66
void Calculate()
Calculates all values needed by the candle definition depending on the candle options.
Definition TCandle.cxx:379
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:881
Bool_t IsCandleScaled()
Definition TCandle.cxx:185
virtual void SetMean(Double_t mean)
Definition TCandle.h:133
Double_t fHistoWidth
The histo width (the height of the max bin)
Definition TCandle.h:60
virtual void SetQ1(Double_t q1)
Definition TCandle.h:135
Double_t GetMedian() const
Definition TCandle.h:113
int GetCandleOption(const int pos)
Definition TCandle.h:98
void SetCandleWidth(const Double_t width)
Definition TCandle.h:126
long GetOption()
Definition TCandle.h:141
bool fIsCalculated
Definition TCandle.h:54
void SetAxisPosition(const Double_t candlePos)
Definition TCandle.h:124
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:116
static Bool_t fScaledCandle
shall the box-width be scaled to each other by the integral of a box?
Definition TCandle.h:93
char fOptionStr[128]
String to draw the candle.
Definition TCandle.h:82
Double_t fCandleWidth
The candle width.
Definition TCandle.h:59
1-D histogram with a double per channel (see TH1 documentation)}
Definition TH1.h:620
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)
Returns x raised to the power y.
Definition TMath.h:719