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// clang++ <v20 (-Wshadow) complains about shadowing Buttons.h global enum EEditMode. Let's silence warning:
33#if defined(__clang__) && __clang_major__ < 20
34#pragma clang diagnostic push
35#pragma clang diagnostic ignored "-Wshadow"
36#endif
37 kBox = 1,
38#if defined(__clang__) && __clang_major__ < 20
39#pragma clang diagnostic pop
40#endif
44 kMeanLine = 100,
47 kWhisker15 = 2000,
48 kAnchor = 10000,
50 kPointsAll = 200000,
52 kHistoLeft = 1000000,
53 kHistoRight = 2000000,
54 kHistoViolin = 3000000,
56 kHorizontal = 100000000 ///< If this bit is not set it is vertical
57 };
58
59
60protected:
61
62 bool fIsRaw; ///< 0: for TH1 projection, 1: using raw data
64 TH1D *fProj{nullptr};
65 bool fDismiss; ///< True if the candle cannot be painted
66
67 Double_t fPosCandleAxis; ///< x-pos for a vertical candle
68 Double_t fCandleWidth; ///< The candle width
69 Double_t fHistoWidth; ///< The histo width (the height of the max bin)
70
71 Double_t fMean; ///< Position of the mean
72 Double_t fMedian; ///< Position of the median
73 Double_t fMedianErr; ///< The size of the notch
74 Double_t fBoxUp; ///< Position of the upper box end
75 Double_t fBoxDown; ///< Position of the lower box end
76 Double_t fWhiskerUp; ///< Position of the upper whisker end
77 Double_t fWhiskerDown; ///< Position of the lower whisker end
78
79 Double_t *fDatapoints{nullptr}; ///< position of all Datapoints within this candle
80 Long64_t fNDatapoints; ///< Number of Datapoints within this candle
81
82 Double_t fDrawPointsX[kNMAXPOINTS]; ///< x-coord for every outlier, ..
83 Double_t fDrawPointsY[kNMAXPOINTS]; ///< y-coord for every outlier, ..
84 Long64_t fNDrawPoints; ///< max number of outliers or other point to be shown
85
86 Double_t fHistoPointsX[kNMAXPOINTS]; ///< x-coord for the polyline of the histo
87 Double_t fHistoPointsY[kNMAXPOINTS]; ///< y-coord for the polyline of the histo
89
90 CandleOption fOption; ///< Setting the style of the candle
91 TString fOptionStr; ///< String to draw the candle
92 int fLogX; ///< make the candle appear logx-like
93 int fLogY; ///< make the candle appear logy-like
94 int fLogZ; ///< make the candle appear logz-like
95
96 Double_t fAxisMin; ///< The Minimum which is visible by the axis (used by zero indicator)
97 Double_t fAxisMax; ///< The Maximum which is visible by the axis (used by zero indicator)
98
99 void Calculate();
100
101 int GetCandleOption(const int pos) const {return (fOption/(long)TMath::Power(10,pos))%10;}
102
105
106public:
107
108 TCandle();
109 TCandle(const char *opt);
113 ~TCandle() override;
114
115 Double_t GetMean() const {return fMean;}
116 Double_t GetMedian() const {return fMedian;}
117 Double_t GetQ1() const {return fBoxUp;}
118 Double_t GetQ2() const {return fMedian;}
119 Double_t GetQ3() const {return fBoxDown;}
122 Bool_t IsCandleScaled() const;
123 Bool_t IsViolinScaled() const;
124
125 void SetOption(CandleOption opt) { fOption = opt; }
126 void SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
128
132
133 virtual void Paint(Option_t *option="");
135
136 virtual void SetMean(Double_t mean) { fMean = mean; }
138 virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
139 virtual void SetQ2(Double_t q2) { fMedian = q2; }
140 virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
141
142 int ParseOption(char *optin);
143 const char *GetDrawOption() const { return fOptionStr.Data(); }
144 long GetOption() const { return fOption; }
145 bool IsOption(CandleOption opt) const;
146 static void SetWhiskerRange(const Double_t wRange);
147 static void SetBoxRange(const Double_t bRange);
148 static void SetScaledCandle(const Bool_t cScale = true);
149 static void SetScaledViolin(const Bool_t vScale = true);
150
152};
153#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
const Int_t kNMAXPOINTS
Definition TCandle.h:25
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:20
Line Attributes class.
Definition TAttLine.h:20
Marker Attributes class.
Definition TAttMarker.h:20
The candle plot painter class.
Definition TCandle.h:27
Double_t fMedian
Position of the median.
Definition TCandle.h:72
void SetLog(int x, int y, int z)
Definition TCandle.h:126
CandleOption
Definition TCandle.h:30
@ kHorizontal
If this bit is not set it is vertical.
Definition TCandle.h:56
@ kAnchor
Definition TCandle.h:48
@ kWhiskerAll
Definition TCandle.h:46
@ kMeanCircle
Definition TCandle.h:45
@ kHistoZeroIndicator
Definition TCandle.h:55
@ kPointsAllScat
Definition TCandle.h:51
@ kNoOption
Definition TCandle.h:31
@ kHistoRight
Definition TCandle.h:53
@ kMeanLine
Definition TCandle.h:44
@ kBox
Definition TCandle.h:37
@ kWhisker15
Definition TCandle.h:47
@ kMedianLine
Definition TCandle.h:41
@ kPointsAll
Definition TCandle.h:50
@ kPointsOutliers
Definition TCandle.h:49
@ kMedianNotched
Definition TCandle.h:42
@ kHistoLeft
Definition TCandle.h:52
@ kMedianCircle
Definition TCandle.h:43
@ kHistoViolin
Definition TCandle.h:54
Double_t GetQ1() const
Definition TCandle.h:117
Double_t GetQ2() const
Definition TCandle.h:118
TH1D * fProj
Definition TCandle.h:64
void SetHistoWidth(const Double_t width)
Definition TCandle.h:130
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition TCandle.cxx:234
bool fIsRaw
0: for TH1 projection, 1: using raw data
Definition TCandle.h:62
CandleOption fOption
Setting the style of the candle.
Definition TCandle.h:90
TString fOptionStr
String to draw the candle.
Definition TCandle.h:91
long GetOption() const
Definition TCandle.h:144
Double_t fAxisMax
The Maximum which is visible by the axis (used by zero indicator)
Definition TCandle.h:97
~TCandle() override
TCandle default destructor.
Definition TCandle.cxx:174
int fLogZ
make the candle appear logz-like
Definition TCandle.h:94
Double_t fPosCandleAxis
x-pos for a vertical candle
Definition TCandle.h:67
Double_t GetMean() const
Definition TCandle.h:115
int GetCandleOption(const int pos) const
Definition TCandle.h:101
virtual void SetQ2(Double_t q2)
Definition TCandle.h:139
int fNHistoPoints
Definition TCandle.h:88
Double_t fMean
Position of the mean.
Definition TCandle.h:71
Double_t fWhiskerDown
Position of the lower whisker end.
Definition TCandle.h:77
Long64_t fNDrawPoints
max number of outliers or other point to be shown
Definition TCandle.h:84
virtual void Paint(Option_t *option="")
Paint one candle with its current attributes.
Definition TCandle.cxx:665
Double_t fAxisMin
The Minimum which is visible by the axis (used by zero indicator)
Definition TCandle.h:96
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:934
Double_t fDrawPointsY[kNMAXPOINTS]
y-coord for every outlier, ..
Definition TCandle.h:83
Long64_t fNDatapoints
Number of Datapoints within this candle.
Definition TCandle.h:80
Bool_t IsViolinScaled() const
Returns true if violin plot should be scaled.
Definition TCandle.cxx:190
Double_t fHistoPointsY[kNMAXPOINTS]
y-coord for the polyline of the histo
Definition TCandle.h:87
Bool_t IsHorizontal() const
Definition TCandle.h:120
virtual void SetMedian(Double_t median)
Definition TCandle.h:137
Double_t fHistoPointsX[kNMAXPOINTS]
x-coord for the polyline of the histo
Definition TCandle.h:86
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition TCandle.cxx:224
Double_t * fDatapoints
position of all Datapoints within this candle
Definition TCandle.h:79
int ParseOption(char *optin)
Parsing of the option-string.
Definition TCandle.cxx:243
bool fDismiss
True if the candle cannot be painted.
Definition TCandle.h:65
virtual void SetQ3(Double_t q3)
Definition TCandle.h:140
Double_t fWhiskerUp
Position of the upper whisker end.
Definition TCandle.h:76
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:215
void SetOption(CandleOption opt)
Definition TCandle.h:125
void SetHistogram(TH1D *proj)
Definition TCandle.h:131
bool IsOption(CandleOption opt) const
Return true is this option is activated in fOption.
Definition TCandle.cxx:847
int fLogY
make the candle appear logy-like
Definition TCandle.h:93
Double_t fMedianErr
The size of the notch.
Definition TCandle.h:73
void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY)
Paint a box for candle.
Definition TCandle.cxx:863
Double_t fBoxUp
Position of the upper box end.
Definition TCandle.h:74
Bool_t IsVertical() const
Definition TCandle.h:121
const char * GetDrawOption() const
Definition TCandle.h:143
int fLogX
make the candle appear logx-like
Definition TCandle.h:92
Double_t fDrawPointsX[kNMAXPOINTS]
x-coord for every outlier, ..
Definition TCandle.h:82
TCandle(const TCandle &candle)
TCandle()
TCandle default constructor.
Definition TCandle.cxx:37
Double_t fBoxDown
Position of the lower box end.
Definition TCandle.h:75
void Calculate()
Calculates all values needed by the candle definition depending on the candle options.
Definition TCandle.cxx:378
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
virtual void SetMean(Double_t mean)
Definition TCandle.h:136
Double_t fHistoWidth
The histo width (the height of the max bin)
Definition TCandle.h:69
virtual void SetQ1(Double_t q1)
Definition TCandle.h:138
Double_t GetMedian() const
Definition TCandle.h:116
Bool_t IsCandleScaled() const
Returns true if candle plot should be scaled.
Definition TCandle.cxx:182
void SetCandleWidth(const Double_t width)
Definition TCandle.h:129
bool fIsCalculated
Definition TCandle.h:63
void SetAxisPosition(const Double_t candlePos)
Definition TCandle.h:127
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:203
Double_t GetQ3() const
Definition TCandle.h:119
Double_t fCandleWidth
The candle width.
Definition TCandle.h:68
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:926
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
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:732