Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:29:02

0001 // @(#)root/treeplayer:$Id$
0002 // Author: Marek Biskup   24/01/2005
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2005, 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_TTreeDrawArgsParser
0013 #define ROOT_TTreeDrawArgsParser
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TTreeDrawArgsParser                                                  //
0018 //                                                                      //
0019 // A class that parses all parameters for TTree::Draw().                //
0020 // See TTree::Draw() for the format description.                        //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TObject.h"
0025 
0026 #include "TString.h"
0027 
0028 
0029 class TTreeDrawArgsParser : public TObject {
0030 
0031 public:
0032    enum EOutputType {
0033 // clang++ <v20 (-Wshadow) complains about shadowing TQpSolverBase.h global enum ETerminationCode. Let's silence warning:
0034 #if defined(__clang__) && __clang_major__ < 20
0035 #pragma clang diagnostic push
0036 #pragma clang diagnostic ignored "-Wshadow"
0037 #endif
0038       kUNKNOWN,
0039 #if defined(__clang__) && __clang_major__ < 20
0040 #pragma clang diagnostic pop
0041 #endif
0042       kEVENTLIST,
0043       kENTRYLIST,
0044       kPROFILE,
0045       kPROFILE2D,
0046       kGRAPH,
0047       kPOLYMARKER3D,
0048       kHISTOGRAM1D,
0049       kHISTOGRAM2D,
0050       kLISTOFGRAPHS,
0051       kLISTOFPOLYMARKERS3D,
0052       kHISTOGRAM3D
0053    };
0054 
0055    static Int_t   fgMaxDimension;     ///< = 4
0056    static Int_t   fgMaxParameters;    ///< = 9
0057 
0058 protected:
0059    TString        fExp;               ///< Complete variable expression
0060    TString        fSelection;         ///< Selection expression
0061    TString        fOption;            ///< Draw options
0062 
0063    Int_t          fDimension;         ///< Dimension of the histogram/plot
0064    TString        fVarExp[4];         ///< Variable expression 0 - X, 1 - Y, 2 - Z, 3 - W
0065                                       ///< If dimension < fgMaxDimension then some
0066                                       ///< Expressions are empty
0067 
0068    bool           fAdd;               ///< Values should be added to an existing object
0069    TString        fName;              ///< Histogram's/plot's name
0070 
0071    Int_t          fNoParameters;      ///< If dimensions of the plot was specified
0072    bool           fParameterGiven[9]; ///< True if the parameter was given, otherwise false
0073    Double_t       fParameters[9];     ///< Parameters in brackets
0074 
0075    bool           fShouldDraw;        ///< If to draw the plot
0076    bool           fOptionSame;        ///< If option contained "same"
0077    bool           fEntryList;         ///< If fill a TEntryList
0078    TObject       *fOriginal;          ///< Original plot (if it is to be reused)
0079    bool           fDrawProfile;       ///< True if the options contain :"prof"
0080    EOutputType    fOutputType;        ///< Type of the output
0081 
0082    void           ClearPrevious();
0083    TTreeDrawArgsParser::EOutputType DefineType();
0084    bool           SplitVariables(TString variables);
0085    bool           ParseName(TString name);
0086    bool           ParseOption();
0087    bool           ParseVarExp();
0088 
0089 public:
0090    TTreeDrawArgsParser();
0091    ~TTreeDrawArgsParser() override;
0092 
0093    bool           Parse(const char *varexp, const char *selection, Option_t *option);
0094    bool           GetAdd() const { return fAdd; }
0095    Int_t          GetDimension() const { return fDimension; }
0096    bool           GetShouldDraw() const { return fShouldDraw; }
0097    TString const& GetExp() const { return fExp; }
0098    Double_t       GetIfSpecified(Int_t num, Double_t def) const;
0099    Int_t          GetNoParameters() const { return fNoParameters; }
0100    Double_t       GetParameter(int num) const;
0101    TString const& GetObjectName() const { return fName; }
0102    TString        GetObjectTitle() const;
0103    bool           GetOptionSame() const { return fOptionSame; }
0104    TObject       *GetOriginal() const { return fOriginal; }
0105    TString const& GetSelection() const { return fSelection; }
0106    TString        GetVarExp(Int_t num) const;
0107    TString        GetVarExp() const;
0108    bool           IsSpecified(int num) const;
0109    void           SetObjectName(const char *s) { fName = s; }
0110    void           SetOriginal(TObject *o) { fOriginal = o; }
0111    static Int_t   GetMaxDimension();
0112 
0113    ClassDefOverride(TTreeDrawArgsParser,0); // Helper class to parse the argument to TTree::Draw
0114 };
0115 
0116 #endif
0117