Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TTreeDrawArgsParser.h
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Marek Biskup 24/01/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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_TTreeDrawArgsParser
13 #define ROOT_TTreeDrawArgsParser
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TTreeDrawArgsParser //
18 // //
19 // A class that parses all parameters for TTree::Draw(). //
20 // See TTree::Draw() for the format description. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TObject.h"
25 
26 #include "TString.h"
27 
28 
29 class TTreeDrawArgsParser : public TObject {
30 
31 public:
32  enum EOutputType {
33  kUNKNOWN,
34  kEVENTLIST,
35  kENTRYLIST,
36  kPROFILE,
37  kPROFILE2D,
38  kGRAPH,
39  kPOLYMARKER3D,
40  kHISTOGRAM1D,
41  kHISTOGRAM2D,
42  kLISTOFGRAPHS,
43  kLISTOFPOLYMARKERS3D,
44  kHISTOGRAM3D
45  };
46 
47  static Int_t fgMaxDimension; // = 4
48  static Int_t fgMaxParameters; // = 9
49 
50 protected:
51  TString fExp; // complete variable expression
52  TString fSelection; // selection expression
53  TString fOption; // draw options
54 
55  Int_t fDimension; // dimension of the histogram/plot
56  TString fVarExp[4]; // variable expression 0 - X, 1 - Y, 2 - Z, 3 - W
57  // if dimension < fgMaxDimension then some
58  // expressions are empty
59 
60  Bool_t fAdd; // values should be added to an existing object
61  TString fName; // histogram's/plot's name
62 
63  Int_t fNoParameters; // if dimensions of the plot was specified
64  Bool_t fParameterGiven[9]; // true if the parameter was given, otherwise false
65  Double_t fParameters[9]; // parameters in brackets
66 
67  Bool_t fShouldDraw; // if to draw the plot
68  Bool_t fOptionSame; // if option contained "same"
69  Bool_t fEntryList; // if fill a TEntryList
70  TObject *fOriginal; // original plot (if it is to be reused)
71  Bool_t fDrawProfile; // true if the options contain :"prof"
72  EOutputType fOutputType; // type of the output
73 
74  void ClearPrevious();
75  TTreeDrawArgsParser::EOutputType DefineType();
76  Bool_t SplitVariables(TString variables);
77  Bool_t ParseName(TString name);
78  Bool_t ParseOption();
79  Bool_t ParseVarExp();
80 
81 public:
82  TTreeDrawArgsParser();
83  ~TTreeDrawArgsParser();
84 
85  Bool_t Parse(const char *varexp, const char *selection, Option_t *option);
86  Bool_t GetAdd() const { return fAdd; }
87  Int_t GetDimension() const { return fDimension; }
88  Bool_t GetShouldDraw() const { return fShouldDraw; }
89  TString GetExp() const { return fExp; }
90  Double_t GetIfSpecified(Int_t num, Double_t def) const;
91  Int_t GetNoParameters() const { return fNoParameters; }
92  Double_t GetParameter(int num) const;
93  TString GetProofSelectorName() const;
94  TString GetObjectName() const { return fName; }
95  TString GetObjectTitle() const;
96  Bool_t GetOptionSame() const { return fOptionSame; }
97  TObject *GetOriginal() const { return fOriginal; }
98  TString GetSelection() const { return fSelection; }
99  TString GetVarExp(Int_t num) const;
100  TString GetVarExp() const;
101  Bool_t IsSpecified(int num) const;
102  void SetObjectName(const char *s) { fName = s; }
103  void SetOriginal(TObject *o) { fOriginal = o; }
104  static Int_t GetMaxDimension();
105 
106  ClassDef(TTreeDrawArgsParser,0); // Helper class to parse the argument to TTree::Draw
107 };
108 
109 #endif
110