File indexing completed on 2026-09-24 09:25:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TCandle
0013 #define ROOT_TCandle
0014
0015 #include "TObject.h"
0016 #include "TAttLine.h"
0017 #include "TAttFill.h"
0018 #include "TAttMarker.h"
0019 #include "TString.h"
0020
0021 #include "TMath.h"
0022
0023 class TH1D;
0024
0025 const Int_t kNMAXPOINTS = 2010;
0026
0027 class TCandle : public TAttLine, public TAttFill, public TAttMarker {
0028 public:
0029
0030 enum CandleOption: long {
0031 kNoOption = 0,
0032
0033 #if defined(__clang__) && __clang_major__ < 20
0034 #pragma clang diagnostic push
0035 #pragma clang diagnostic ignored "-Wshadow"
0036 #endif
0037 kBox = 1,
0038 #if defined(__clang__) && __clang_major__ < 20
0039 #pragma clang diagnostic pop
0040 #endif
0041 kMedianLine = 10,
0042 kMedianNotched = 20,
0043 kMedianCircle = 30,
0044 kMeanLine = 100,
0045 kMeanCircle = 300,
0046 kWhiskerAll = 1000,
0047 kWhisker15 = 2000,
0048 kAnchor = 10000,
0049 kPointsOutliers = 100000,
0050 kPointsAll = 200000,
0051 kPointsAllScat = 300000,
0052 kHistoLeft = 1000000,
0053 kHistoRight = 2000000,
0054 kHistoViolin = 3000000,
0055 kHistoZeroIndicator = 10000000,
0056 kHorizontal = 100000000
0057 };
0058
0059
0060 protected:
0061
0062 bool fIsRaw;
0063 bool fIsCalculated;
0064 TH1D *fProj{nullptr};
0065 bool fDismiss;
0066
0067 Double_t fPosCandleAxis;
0068 Double_t fCandleWidth;
0069 Double_t fHistoWidth;
0070
0071 Double_t fMean;
0072 Double_t fMedian;
0073 Double_t fMedianErr;
0074 Double_t fBoxUp;
0075 Double_t fBoxDown;
0076 Double_t fWhiskerUp;
0077 Double_t fWhiskerDown;
0078
0079 Double_t *fDatapoints{nullptr};
0080 Long64_t fNDatapoints;
0081
0082 Double_t fDrawPointsX[kNMAXPOINTS];
0083 Double_t fDrawPointsY[kNMAXPOINTS];
0084 Long64_t fNDrawPoints;
0085
0086 Double_t fHistoPointsX[kNMAXPOINTS];
0087 Double_t fHistoPointsY[kNMAXPOINTS];
0088 int fNHistoPoints;
0089
0090 CandleOption fOption;
0091 TString fOptionStr;
0092 int fLogX;
0093 int fLogY;
0094 int fLogZ;
0095
0096 Double_t fAxisMin;
0097 Double_t fAxisMax;
0098
0099 void Calculate();
0100
0101 int GetCandleOption(const int pos) const {return (fOption/(long)TMath::Power(10,pos))%10;}
0102
0103 void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
0104 void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t swapXY);
0105
0106 public:
0107
0108 TCandle();
0109 TCandle(const char *opt);
0110 TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
0111 TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
0112 TCandle(const TCandle &candle);
0113 ~TCandle() override;
0114
0115 Double_t GetMean() const {return fMean;}
0116 Double_t GetMedian() const {return fMedian;}
0117 Double_t GetQ1() const {return fBoxUp;}
0118 Double_t GetQ2() const {return fMedian;}
0119 Double_t GetQ3() const {return fBoxDown;}
0120 Bool_t IsHorizontal() const {return IsOption(kHorizontal); }
0121 Bool_t IsVertical() const {return !IsOption(kHorizontal); }
0122 Bool_t IsCandleScaled() const;
0123 Bool_t IsViolinScaled() const;
0124
0125 void SetOption(CandleOption opt) { fOption = opt; }
0126 void SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
0127 void SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
0128
0129 void SetCandleWidth(const Double_t width) { fCandleWidth = width; }
0130 void SetHistoWidth(const Double_t width) { fHistoWidth = width; }
0131 void SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
0132
0133 virtual void Paint(Option_t *option="");
0134 void ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
0135
0136 virtual void SetMean(Double_t mean) { fMean = mean; }
0137 virtual void SetMedian(Double_t median) { fMedian = median; }
0138 virtual void SetQ1(Double_t q1) { fBoxUp = q1; }
0139 virtual void SetQ2(Double_t q2) { fMedian = q2; }
0140 virtual void SetQ3(Double_t q3) { fBoxDown = q3; }
0141
0142 int ParseOption(char *optin);
0143 const char *GetDrawOption() const { return fOptionStr.Data(); }
0144 long GetOption() const { return fOption; }
0145 bool IsOption(CandleOption opt) const;
0146 static void SetWhiskerRange(const Double_t wRange);
0147 static void SetBoxRange(const Double_t bRange);
0148 static void SetScaledCandle(const Bool_t cScale = true);
0149 static void SetScaledViolin(const Bool_t vScale = true);
0150
0151 ClassDefOverride(TCandle,2)
0152 };
0153 #endif