ROOT logo
// @(#)root/treeplayer:$Id: TTreePlayer.h 28514 2009-05-11 10:44:08Z brun $
// Author: Rene Brun   12/01/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TTreePlayer
#define ROOT_TTreePlayer


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TTreePlayer                                                          //
//                                                                      //
// A TTree object is a list of TBranch.                                 //
//   To Create a TTree object one must:                                 //
//    - Create the TTree header via the TTree constructor               //
//    - Call the TBranch constructor for every branch.                  //
//                                                                      //
//   To Fill this object, use member function Fill with no parameters.  //
//     The Fill function loops on all defined TBranch.                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TTree
#include "TTree.h"
#endif
#ifndef ROOT_TSelectorDraw
#include "TSelectorDraw.h"
#endif
#ifndef ROOT_TVirtualTreePlayer
#include "TVirtualTreePlayer.h"
#endif


class TVirtualIndex;

class TTreePlayer : public TVirtualTreePlayer {

private:
   TTreePlayer(const TTreePlayer &);
   TTreePlayer& operator=(const TTreePlayer &);

protected:
   TTree         *fTree;            //!  Pointer to current Tree
   Bool_t         fScanRedirect;    //  Switch to redirect TTree::Scan output to a file
   const char    *fScanFileName;    //  Name of the file where Scan is redirected
   Int_t          fDimension;       //  Dimension of the current expression
   Long64_t       fSelectedRows;    //  Number of selected entries
   TH1           *fHistogram;       //! Pointer to histogram used for the projection
   TSelectorDraw *fSelector;        //! Pointer to current selector
   TSelector     *fSelectorFromFile;//! Pointer to a user defined selector created by this TTreePlayer object
   TClass        *fSelectorClass;   //! Pointer to the actual class of the TSelectorFromFile
   TList         *fInput;           //! input list to the selector
   TList         *fFormulaList;     //! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
   TSelector     *fSelectorUpdate;  //! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves function

protected:
   const   char  *GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex);
   void           TakeAction(Int_t nfill, Int_t &npoints, Int_t &action, TObject *obj, Option_t *option);
   void           TakeEstimate(Int_t nfill, Int_t &npoints, Int_t action, TObject *obj, Option_t *option);
   void           DeleteSelectorFromFile();
   
public:
   TTreePlayer();
   virtual ~TTreePlayer();   
   virtual TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname);
   virtual TTree    *CopyTree(const char *selection, Option_t *option
                              ,Long64_t nentries, Long64_t firstentry);
   virtual Long64_t  DrawScript(const char* wrapperPrefix,
                                const char *macrofilename, const char *cutfilename,
                                Option_t *option, Long64_t nentries, Long64_t firstentry);
   virtual Long64_t  DrawSelect(const char *varexp, const char *selection, Option_t *option
                                ,Long64_t nentries, Long64_t firstentry);
   virtual Int_t     Fit(const char *formula ,const char *varexp, const char *selection,Option_t *option ,
                         Option_t *goption ,Long64_t nentries, Long64_t firstentry);
   virtual Int_t     GetDimension() const {return fDimension;}
   TH1              *GetHistogram() const {return fHistogram;}
   virtual Long64_t  GetEntries(const char *selection);
   virtual Long64_t  GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
   virtual Int_t     GetNfill() const {return fSelector->GetNfill();}
   const char       *GetScanFileName() const {return fScanFileName;}
   TTreeFormula     *GetSelect() const    {return fSelector->GetSelect();}
   virtual Long64_t  GetSelectedRows() const {return fSelectedRows;}
   TSelector        *GetSelector() const {return fSelector;}
   TSelector        *GetSelectorFromFile() const {return fSelectorFromFile;}
   TTreeFormula     *GetVar(Int_t i) const {return fSelector->GetVar(i);};
   TTreeFormula     *GetVar1() const {return fSelector->GetVar1();}
   TTreeFormula     *GetVar2() const {return fSelector->GetVar2();}
   TTreeFormula     *GetVar3() const {return fSelector->GetVar3();}
   TTreeFormula     *GetVar4() const {return fSelector->GetVar4();}
   virtual Double_t *GetVal(Int_t i) const {return fSelector->GetVal(i);};
   virtual Double_t *GetV1() const   {return fSelector->GetV1();}
   virtual Double_t *GetV2() const   {return fSelector->GetV2();}
   virtual Double_t *GetV3() const   {return fSelector->GetV3();}
   virtual Double_t *GetV4() const   {return fSelector->GetV4();}
   virtual Double_t *GetW() const    {return fSelector->GetW();}
   virtual Int_t     MakeClass(const char *classname, Option_t *option);
   virtual Int_t     MakeCode(const char *filename);
   virtual Int_t     MakeProxy(const char *classname,
                               const char *macrofilename = 0, const char *cutfilename = 0,
                               const char *option = 0, Int_t maxUnrolling = 3);
   TPrincipal       *Principal(const char *varexp, const char *selection, Option_t *option
                               ,Long64_t nentries, Long64_t firstentry);
   virtual Long64_t  Process(const char *filename,Option_t *option, Long64_t nentries, Long64_t firstentry);
   virtual Long64_t  Process(TSelector *selector,Option_t *option,  Long64_t nentries, Long64_t firstentry);
   virtual void      RecursiveRemove(TObject *obj);
   virtual Long64_t  Scan(const char *varexp, const char *selection, Option_t *option
                          ,Long64_t nentries, Long64_t firstentry);
   Bool_t            ScanRedirected() {return fScanRedirect;}
   virtual TSQLResult *Query(const char *varexp, const char *selection, Option_t *option
                             ,Long64_t nentries, Long64_t firstentry);
   virtual void      SetEstimate(Long64_t n);
   void              SetScanRedirect(Bool_t on=kFALSE) {fScanRedirect = on;}
   void              SetScanFileName(const char *name) {fScanFileName=name;}
   virtual void      SetTree(TTree *t) {fTree = t;}
   virtual void      StartViewer(Int_t ww, Int_t wh);
   virtual Int_t     UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option
                                 ,Long64_t nentries, Long64_t firstentry);
   virtual void      UpdateFormulaLeaves();

   ClassDef(TTreePlayer,3);  //Manager class to play with TTrees
};

#endif
 TTreePlayer.h:1
 TTreePlayer.h:2
 TTreePlayer.h:3
 TTreePlayer.h:4
 TTreePlayer.h:5
 TTreePlayer.h:6
 TTreePlayer.h:7
 TTreePlayer.h:8
 TTreePlayer.h:9
 TTreePlayer.h:10
 TTreePlayer.h:11
 TTreePlayer.h:12
 TTreePlayer.h:13
 TTreePlayer.h:14
 TTreePlayer.h:15
 TTreePlayer.h:16
 TTreePlayer.h:17
 TTreePlayer.h:18
 TTreePlayer.h:19
 TTreePlayer.h:20
 TTreePlayer.h:21
 TTreePlayer.h:22
 TTreePlayer.h:23
 TTreePlayer.h:24
 TTreePlayer.h:25
 TTreePlayer.h:26
 TTreePlayer.h:27
 TTreePlayer.h:28
 TTreePlayer.h:29
 TTreePlayer.h:30
 TTreePlayer.h:31
 TTreePlayer.h:32
 TTreePlayer.h:33
 TTreePlayer.h:34
 TTreePlayer.h:35
 TTreePlayer.h:36
 TTreePlayer.h:37
 TTreePlayer.h:38
 TTreePlayer.h:39
 TTreePlayer.h:40
 TTreePlayer.h:41
 TTreePlayer.h:42
 TTreePlayer.h:43
 TTreePlayer.h:44
 TTreePlayer.h:45
 TTreePlayer.h:46
 TTreePlayer.h:47
 TTreePlayer.h:48
 TTreePlayer.h:49
 TTreePlayer.h:50
 TTreePlayer.h:51
 TTreePlayer.h:52
 TTreePlayer.h:53
 TTreePlayer.h:54
 TTreePlayer.h:55
 TTreePlayer.h:56
 TTreePlayer.h:57
 TTreePlayer.h:58
 TTreePlayer.h:59
 TTreePlayer.h:60
 TTreePlayer.h:61
 TTreePlayer.h:62
 TTreePlayer.h:63
 TTreePlayer.h:64
 TTreePlayer.h:65
 TTreePlayer.h:66
 TTreePlayer.h:67
 TTreePlayer.h:68
 TTreePlayer.h:69
 TTreePlayer.h:70
 TTreePlayer.h:71
 TTreePlayer.h:72
 TTreePlayer.h:73
 TTreePlayer.h:74
 TTreePlayer.h:75
 TTreePlayer.h:76
 TTreePlayer.h:77
 TTreePlayer.h:78
 TTreePlayer.h:79
 TTreePlayer.h:80
 TTreePlayer.h:81
 TTreePlayer.h:82
 TTreePlayer.h:83
 TTreePlayer.h:84
 TTreePlayer.h:85
 TTreePlayer.h:86
 TTreePlayer.h:87
 TTreePlayer.h:88
 TTreePlayer.h:89
 TTreePlayer.h:90
 TTreePlayer.h:91
 TTreePlayer.h:92
 TTreePlayer.h:93
 TTreePlayer.h:94
 TTreePlayer.h:95
 TTreePlayer.h:96
 TTreePlayer.h:97
 TTreePlayer.h:98
 TTreePlayer.h:99
 TTreePlayer.h:100
 TTreePlayer.h:101
 TTreePlayer.h:102
 TTreePlayer.h:103
 TTreePlayer.h:104
 TTreePlayer.h:105
 TTreePlayer.h:106
 TTreePlayer.h:107
 TTreePlayer.h:108
 TTreePlayer.h:109
 TTreePlayer.h:110
 TTreePlayer.h:111
 TTreePlayer.h:112
 TTreePlayer.h:113
 TTreePlayer.h:114
 TTreePlayer.h:115
 TTreePlayer.h:116
 TTreePlayer.h:117
 TTreePlayer.h:118
 TTreePlayer.h:119
 TTreePlayer.h:120
 TTreePlayer.h:121
 TTreePlayer.h:122
 TTreePlayer.h:123
 TTreePlayer.h:124
 TTreePlayer.h:125
 TTreePlayer.h:126
 TTreePlayer.h:127
 TTreePlayer.h:128
 TTreePlayer.h:129
 TTreePlayer.h:130