Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TCandle.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/graf:$Id$
0002 // Author: Georg Troska 2016/04/14
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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;  // Max outliers per candle
0026 
0027 class TCandle : public TAttLine, public TAttFill, public TAttMarker {
0028 public:
0029    //Candle Option
0030    enum CandleOption: long {
0031       kNoOption           = 0,
0032       kBox                = 1,
0033       kMedianLine         = 10,
0034       kMedianNotched      = 20,
0035       kMedianCircle       = 30,
0036       kMeanLine           = 100,
0037       kMeanCircle         = 300,
0038       kWhiskerAll         = 1000,
0039       kWhisker15          = 2000,
0040       kAnchor             = 10000,
0041       kPointsOutliers     = 100000,
0042       kPointsAll          = 200000,
0043       kPointsAllScat      = 300000,
0044       kHistoLeft          = 1000000,
0045       kHistoRight         = 2000000,
0046       kHistoViolin        = 3000000,
0047       kHistoZeroIndicator = 10000000,
0048       kHorizontal         = 100000000     ///< If this bit is not set it is vertical
0049    };
0050 
0051 
0052 protected:
0053 
0054    bool fIsRaw;                           ///< 0: for TH1 projection, 1: using raw data
0055    bool fIsCalculated;
0056    TH1D *fProj{nullptr};
0057    bool fDismiss;                         ///< True if the candle cannot be painted
0058 
0059    Double_t fPosCandleAxis;               ///< x-pos for a vertical candle
0060    Double_t fCandleWidth;                 ///< The candle width
0061    Double_t fHistoWidth;                  ///< The histo width (the height of the max bin)
0062 
0063    Double_t fMean;                        ///< Position of the mean
0064    Double_t fMedian;                      ///< Position of the median
0065    Double_t fMedianErr;                   ///< The size of the notch
0066    Double_t fBoxUp;                       ///< Position of the upper box end
0067    Double_t fBoxDown;                     ///< Position of the lower box end
0068    Double_t fWhiskerUp;                   ///< Position of the upper whisker end
0069    Double_t fWhiskerDown;                 ///< Position of the lower whisker end
0070 
0071    Double_t *fDatapoints{nullptr};        ///< position of all Datapoints within this candle
0072    Long64_t fNDatapoints;                 ///< Number of Datapoints within this candle
0073 
0074    Double_t fDrawPointsX[kNMAXPOINTS];    ///< x-coord for every outlier, ..
0075    Double_t fDrawPointsY[kNMAXPOINTS];    ///< y-coord for every outlier, ..
0076    Long64_t fNDrawPoints;                 ///< max number of outliers or other point to be shown
0077 
0078    Double_t fHistoPointsX[kNMAXPOINTS];   ///< x-coord for the polyline of the histo
0079    Double_t fHistoPointsY[kNMAXPOINTS];   ///< y-coord for the polyline of the histo
0080    int  fNHistoPoints;
0081 
0082    CandleOption fOption;                  ///< Setting the style of the candle
0083    TString fOptionStr;                    ///< String to draw the candle
0084    int fLogX;                             ///< make the candle appear logx-like
0085    int fLogY;                             ///< make the candle appear logy-like
0086    int fLogZ;                             ///< make the candle appear logz-like
0087 
0088    Double_t fAxisMin;                     ///< The Minimum which is visible by the axis (used by zero indicator)
0089    Double_t fAxisMax;                     ///< The Maximum which is visible by the axis (used by zero indicator)
0090 
0091    void Calculate();
0092 
0093    int  GetCandleOption(const int pos) const {return (fOption/(long)TMath::Power(10,pos))%10;}
0094 
0095    void PaintBox(Int_t nPoints, Double_t *x, Double_t *y, Bool_t swapXY);
0096    void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t swapXY);
0097 
0098 public:
0099 
0100    TCandle();
0101    TCandle(const char *opt);
0102    TCandle(const Double_t candlePos, const Double_t candleWidth, Long64_t n, Double_t * points);
0103    TCandle(const Double_t candlePos, const Double_t candleWidth, TH1D *proj);
0104    TCandle(const TCandle &candle);
0105    ~TCandle() override;
0106 
0107    Double_t       GetMean() const {return fMean;}
0108    Double_t       GetMedian() const {return fMedian;}
0109    Double_t       GetQ1() const {return fBoxUp;}
0110    Double_t       GetQ2() const {return fMedian;}
0111    Double_t       GetQ3() const {return fBoxDown;}
0112    Bool_t         IsHorizontal() const {return IsOption(kHorizontal); }
0113    Bool_t         IsVertical() const {return !IsOption(kHorizontal); }
0114    Bool_t         IsCandleScaled() const;
0115    Bool_t         IsViolinScaled() const;
0116 
0117    void           SetOption(CandleOption opt) { fOption = opt; }
0118    void           SetLog(int x, int y, int z) { fLogX = x; fLogY = y; fLogZ = z;}
0119    void           SetAxisPosition(const Double_t candlePos) { fPosCandleAxis = candlePos; }
0120 
0121    void           SetCandleWidth(const Double_t width) { fCandleWidth = width; }
0122    void           SetHistoWidth(const Double_t width) { fHistoWidth = width; }
0123    void           SetHistogram(TH1D *proj) { fProj = proj; fIsCalculated = false;}
0124 
0125    virtual void   Paint(Option_t *option="");
0126    void           ConvertToPadCoords(Double_t minAxis, Double_t maxAxis, Double_t axisMinCoord, Double_t axisMaxCoord);
0127 
0128    virtual void   SetMean(Double_t mean) { fMean = mean; }
0129    virtual void   SetMedian(Double_t median) { fMedian = median; }
0130    virtual void   SetQ1(Double_t q1) { fBoxUp = q1; }
0131    virtual void   SetQ2(Double_t q2) { fMedian = q2; }
0132    virtual void   SetQ3(Double_t q3) { fBoxDown = q3; }
0133 
0134    int            ParseOption(char *optin);
0135    const char    *GetDrawOption() const { return fOptionStr.Data(); }
0136    long           GetOption() const { return fOption; }
0137    bool           IsOption(CandleOption opt) const;
0138    static void    SetWhiskerRange(const Double_t wRange);
0139    static void    SetBoxRange(const Double_t bRange);
0140    static void    SetScaledCandle(const Bool_t cScale = true);
0141    static void    SetScaledViolin(const Bool_t vScale = true);
0142 
0143    ClassDefOverride(TCandle,2)  //A Candle
0144 };
0145 #endif