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#include "TString.h"
20
21#include "TMath.h"
22
23class TH1D;
24
25const Int_t kNMAXPOINTS = 2010; // Max outliers per candle
26
27class TCandle : public TAttLine, public TAttFill, public TAttMarker {
28public:
29 //Candle Option
30 enum CandleOption: long {
32 kBox = 1,
36 kMeanLine = 100,
39 kWhisker15 = 2000,
40 kAnchor = 10000,
42 kPointsAll = 200000,
44 kHistoLeft = 1000000,
45 kHistoRight = 2000000,
46 kHistoViolin = 3000000,
48 kHorizontal = 100000000 ///< If this bit is not set it is vertical
49 };
50
51
52protected:
53
54 bool fIsRaw; ///< 0: for TH1 projection, 1: using raw data
56 TH1D *fProj{nullptr};
57 bool fDismiss; ///< True if the candle cannot be painted
58
59 Double_t fPosCandleAxis; ///< x-pos for a vertical candle
60 Double_t fCandleWidth; ///< The candle width
61 Double_t fHistoWidth; ///< The histo width (the height of the max bin)
62
63 Double_t fMean; ///< Position of the mean
64 Double_t fMedian; ///< Position of the median
65 Double_t fMedianErr; ///< The size of the notch
66 Double_t fBoxUp; ///< Position of the upper box end
67 Double_t fBoxDown; ///< Position of the lower box end
68 Double_t fWhiskerUp; ///< Position of the upper whisker end
69 Double_t fWhiskerDown; ///< Position of the lower whisker end
70
71 Double_t *fDatapoints{nullptr}; ///< position of all Datapoints within this candle
72 Long64_t fNDatapoints; ///< Number of Datapoints within this candle
73
74 Double_t fDrawPointsX[kNMAXPOINTS]; ///< x-coord for every outlier, ..
75 Double_t fDrawPointsY[kNMAXPOINTS]; ///< y-coord for every outlier, ..
76 Long64_t fNDrawPoints; ///< max number of outliers or other point to be shown
77
78 Double_t fHistoPointsX[kNMAXPOINTS]; ///< x-coord for the polyline of the histo
79 Double_t fHistoPointsY[kNMAXPOINTS]; ///< y-coord for the polyline of the histo
81
82 CandleOption fOption; ///< Setting the style of the candle
83 TString fOptionStr; ///< String to draw the candle
84 int fLogX; ///< make the candle appear logx-like
85 int fLogY; ///< make the candle appear logy-like
86 int fLogZ; ///< make the candle appear logz-like
87
88 Double_t fAxisMin; ///< The Minimum which is visible by the axis (used by zero indicator)
89 Double_t fAxisMax; ///< The Maximum which is visible by the axis (used by zero indicator)
90
91 void Calculate();
92
93 int GetCandleOption(const int pos) const {return (fOption/(long)TMath::Power(10,pos))%10;}
94
95 void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
97
98public:
99
100 TCandle();
101 TCandle(const char *opt);
102 TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
103 TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
104 TCandle(const TCandle &candle);
105 ~TCandle() override;
106
107 Double_t GetMean() const {return fMean;}
108 Double_t GetMedian() const {return fMedian;}
109 Double_t GetQ1() const {return fBoxUp;}
110 Double_t GetQ2() const {return fMedian;}
111 Double_t GetQ3() const {return fBoxDown;}
114 Bool_t IsCandleScaled() const;
115 Bool_t IsViolinScaled() const;
116
117 void SetOption(CandleOption opt) { fOption = opt; }
118 void SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
119 void SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
120
123 void SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
124
125 virtual void Paint(Option_t *option="");
126 void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
127
128 virtual void SetMean(Double_t mean) { fMean = mean; }
129 virtual void SetMedian(Double_t median) { fMedian = median; }
130 virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
131 virtual void SetQ2(Double_t q2) { fMedian = q2; }
132 virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
133
134 int ParseOption(char *optin);
135 const char *GetDrawOption() const { return fOptionStr.Data(); }
136 long GetOption() const { return fOption; }
137 bool IsOption(CandleOption opt) const;
138 static void SetWhiskerRange(const Double_t wRange);
139 static void SetBoxRange(const Double_t bRange);
140 static void SetScaledCandle(const Bool_t cScale = true);
141 static void SetScaledViolin(const Bool_t vScale = true);
142
144};
145#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:69
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
const Int_t kNMAXPOINTS
Definition TCandle.h:25
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:27
Double_t fMedian
Position of the median.
Definition TCandle.h:64
void SetLog(int x, int y, int z)
Definition TCandle.h:118
CandleOption
Definition TCandle.h:30
@ kHorizontal
If this bit is not set it is vertical.
Definition TCandle.h:48
@ kAnchor
Definition TCandle.h:40
@ kWhiskerAll
Definition TCandle.h:38
@ kMeanCircle
Definition TCandle.h:37
@ kHistoZeroIndicator
Definition TCandle.h:47
@ kPointsAllScat
Definition TCandle.h:43
@ kNoOption
Definition TCandle.h:31
@ kHistoRight
Definition TCandle.h:45
@ kMeanLine
Definition TCandle.h:36
@ kBox
Definition TCandle.h:32
@ kWhisker15
Definition TCandle.h:39
@ kMedianLine
Definition TCandle.h:33
@ kPointsAll
Definition TCandle.h:42
@ kPointsOutliers
Definition TCandle.h:41
@ kMedianNotched
Definition TCandle.h:34
@ kHistoLeft
Definition TCandle.h:44
@ kMedianCircle
Definition TCandle.h:35
@ kHistoViolin
Definition TCandle.h:46
Double_t GetQ1() const
Definition TCandle.h:109
Double_t GetQ2() const
Definition TCandle.h:110
TH1D * fProj
Definition TCandle.h:56
void SetHistoWidth(const Double_t width)
Definition TCandle.h:122
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition TCandle.cxx:235
bool fIsRaw
0: for TH1 projection, 1: using raw data
Definition TCandle.h:54
CandleOption fOption
Setting the style of the candle.
Definition TCandle.h:82
TString fOptionStr
String to draw the candle.
Definition TCandle.h:83
long GetOption() const
Definition TCandle.h:136
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition TCandle.h:89
~TCandle() override
TCandle default destructor.
Definition TCandle.cxx:175
int fLogZ
make the candle appear logz-like
Definition TCandle.h:86
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition TCandle.h:59
Double_t GetMean() const
Definition TCandle.h:107
int GetCandleOption(const int pos) const
Definition TCandle.h:93
virtual void SetQ2(Double_t q2)
Definition TCandle.h:131
int fNHistoPoints
Definition TCandle.h:80
Double_t fMean
Position of the mean.
Definition TCandle.h:63
Double_t fWhiskerDown
Position of the lower whisker end.
Definition TCandle.h:69
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition TCandle.h:76
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition TCandle.cxx:666
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition TCandle.h:88
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:930
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition TCandle.h:75
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition TCandle.h:72
Bool_t IsViolinScaled() const
Returns true if violin plot should be scaled.
Definition TCandle.cxx:191
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition TCandle.h:79
Bool_t IsHorizontal() const
Definition TCandle.h:112
virtual void SetMedian(Double_t median)
Definition TCandle.h:129
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition TCandle.h:78
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition TCandle.cxx:225
Double_t * fDatapoints
position of all Datapoints within this candle
Definition TCandle.h:71
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:57
virtual void SetQ3(Double_t q3)
Definition TCandle.h:132
Double_t fWhiskerUp
Position of the upper whisker end.
Definition TCandle.h:68
static void SetBoxRange(const Double_t bRange)
Static function to set BoxRange, by setting box-range, one can force the box of the candle-chart to c...
Definition TCandle.cxx:216
void SetOption(CandleOption opt)
Definition TCandle.h:117
void SetHistogram(TH1D *proj)
Definition TCandle.h:123
bool IsOption(CandleOption opt) const
Return true is this option is activated in fOption.
Definition TCandle.cxx:843
int fLogY
make the candle appear logy-like
Definition TCandle.h:85
Double_t fMedianErr
The size of the notch.
Definition TCandle.h:65
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition TCandle.cxx:859
Double_t fBoxUp
Position of the upper box end.
Definition TCandle.h:66
Bool_t IsVertical() const
Definition TCandle.h:113
const char * GetDrawOption() const
Definition TCandle.h:135
int fLogX
make the candle appear logx-like
Definition TCandle.h:84
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition TCandle.h:74
TCandle(const TCandle &candle)
TCandle()
TCandle default constructor.
Definition TCandle.cxx:38
Double_t fBoxDown
Position of the lower box end.
Definition TCandle.h:67
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:889
virtual void SetMean(Double_t mean)
Definition TCandle.h:128
Double_t fHistoWidth
The histo width (the height of the max bin)
Definition TCandle.h:61
virtual void SetQ1(Double_t q1)
Definition TCandle.h:130
Double_t GetMedian() const
Definition TCandle.h:108
Bool_t IsCandleScaled() const
Returns true if candle plot should be scaled.
Definition TCandle.cxx:183
void SetCandleWidth(const Double_t width)
Definition TCandle.h:121
bool fIsCalculated
Definition TCandle.h:55
void SetAxisPosition(const Double_t candlePos)
Definition TCandle.h:119
static void SetWhiskerRange(const Double_t wRange)
Static function to set WhiskerRange, by setting whisker-range, one can force the whiskers to cover th...
Definition TCandle.cxx:204
Double_t GetQ3() const
Definition TCandle.h:111
Double_t fCandleWidth
The candle width.
Definition TCandle.h:60
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:670
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
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:721