Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:30

0001 // @(#)root/treeplayer:$Id$
0002 // Author: Rene Brun   12/01/96
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_TTreePlayer
0013 #define ROOT_TTreePlayer
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TTreePlayer                                                          //
0019 //                                                                      //
0020 // A TTree object is a list of TBranch.                                 //
0021 //   To Create a TTree object one must:                                 //
0022 //    - Create the TTree header via the TTree constructor               //
0023 //    - Call the TBranch constructor for every branch.                  //
0024 //                                                                      //
0025 //   To Fill this object, use member function Fill with no parameters.  //
0026 //     The Fill function loops on all defined TBranch.                  //
0027 //                                                                      //
0028 //////////////////////////////////////////////////////////////////////////
0029 
0030 #include "TVirtualTreePlayer.h"
0031 
0032 #include "TSelectorDraw.h"
0033 #include "TTree.h"
0034 
0035 class TVirtualIndex;
0036 
0037 class TTreePlayer : public TVirtualTreePlayer {
0038 
0039 private:
0040    TTreePlayer(const TTreePlayer &) = delete;
0041    TTreePlayer& operator=(const TTreePlayer &) = delete;
0042 
0043 protected:
0044    TTree         *fTree;            ///<! Pointer to current Tree
0045    bool           fScanRedirect;    ///<  Switch to redirect TTree::Scan output to a file
0046    const char    *fScanFileName;    ///<  Name of the file where Scan is redirected
0047    Int_t          fDimension;       ///<  Dimension of the current expression
0048    Long64_t       fSelectedRows;    ///<  Number of selected entries
0049    TH1           *fHistogram;       ///<! Pointer to histogram used for the projection
0050    TSelectorDraw *fSelector;        ///<! Pointer to current selector
0051    TSelector     *fSelectorFromFile;///<! Pointer to a user defined selector created by this TTreePlayer object
0052    TClass        *fSelectorClass;   ///<! Pointer to the actual class of the TSelectorFromFile
0053    TList         *fInput;           ///<! input list to the selector
0054    TList         *fFormulaList;     ///<! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
0055    TSelector     *fSelectorUpdate;  ///<! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves function
0056 
0057 protected:
0058    const   char  *GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex);
0059    void           DeleteSelectorFromFile();
0060 
0061 public:
0062    TTreePlayer();
0063    ~TTreePlayer() override;
0064    TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname) override;
0065    TTree    *CopyTree(const char *selection, Option_t *option
0066                               ,Long64_t nentries, Long64_t firstentry) override;
0067    Long64_t  DrawScript(const char* wrapperPrefix,
0068                                 const char *macrofilename, const char *cutfilename,
0069                                 Option_t *option, Long64_t nentries, Long64_t firstentry) override;
0070    Long64_t  DrawSelect(const char *varexp, const char *selection, Option_t *option
0071                                 ,Long64_t nentries, Long64_t firstentry) override;
0072    Int_t     Fit(const char *formula ,const char *varexp, const char *selection,Option_t *option ,
0073                          Option_t *goption ,Long64_t nentries, Long64_t firstentry) override;
0074    Int_t     GetDimension() const override {return fDimension;}
0075    TH1              *GetHistogram() const override {return fHistogram;}
0076    Long64_t  GetEntries(const char *selection) override;
0077    virtual Long64_t  GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
0078    Int_t     GetNfill() const override {return fSelector->GetNfill();}
0079    const char       *GetScanFileName() const {return fScanFileName;}
0080    TTreeFormula     *GetSelect() const override    {return fSelector->GetSelect();}
0081    Long64_t  GetSelectedRows() const override {return fSelectedRows;}
0082    TSelector *GetSelector() const override {return fSelector;}
0083    TSelector *GetSelectorFromFile() const override {return fSelectorFromFile;}
0084    /// See TSelectorDraw::GetVar
0085    TTreeFormula     *GetVar(Int_t i) const override {return fSelector->GetVar(i);};
0086    /// See TSelectorDraw::GetVar
0087    TTreeFormula     *GetVar1() const override {return fSelector->GetVar1();}
0088    /// See TSelectorDraw::GetVar
0089    TTreeFormula     *GetVar2() const override {return fSelector->GetVar2();}
0090    /// See TSelectorDraw::GetVar
0091    TTreeFormula     *GetVar3() const override {return fSelector->GetVar3();}
0092    /// See TSelectorDraw::GetVar
0093    TTreeFormula     *GetVar4() const override {return fSelector->GetVar4();}
0094    /// See TSelectorDraw::GetVal
0095    Double_t *GetVal(Int_t i) const override {return fSelector->GetVal(i);};
0096    /// See TSelectorDraw::GetVal
0097    Double_t *GetV1() const override   {return fSelector->GetV1();}
0098    /// See TSelectorDraw::GetVal
0099    Double_t *GetV2() const override   {return fSelector->GetV2();}
0100    /// See TSelectorDraw::GetVal
0101    Double_t *GetV3() const override   {return fSelector->GetV3();}
0102    /// See TSelectorDraw::GetVal
0103    Double_t *GetV4() const override   {return fSelector->GetV4();}
0104    Double_t *GetW() const override    {return fSelector->GetW();}
0105    Int_t     MakeClass(const char *classname, Option_t *option) override;
0106    Int_t     MakeCode(const char *filename) override;
0107    Int_t     MakeProxy(const char *classname,
0108                                const char *macrofilename = nullptr, const char *cutfilename = nullptr,
0109                                const char *option = nullptr, Int_t maxUnrolling = 3) override;
0110    Int_t     MakeReader(const char *classname, Option_t *option) override;
0111    TPrincipal       *Principal(const char *varexp, const char *selection, Option_t *option
0112                                ,Long64_t nentries, Long64_t firstentry) override;
0113    Long64_t  Process(const char *filename,Option_t *option, Long64_t nentries, Long64_t firstentry) override;
0114    Long64_t  Process(TSelector *selector,Option_t *option,  Long64_t nentries, Long64_t firstentry) override;
0115    void      RecursiveRemove(TObject *obj) override;
0116    Long64_t  Scan(const char *varexp, const char *selection, Option_t *option
0117                           ,Long64_t nentries, Long64_t firstentry) override;
0118    bool              ScanRedirected() {return fScanRedirect;}
0119    TSQLResult       *Query(const char *varexp, const char *selection, Option_t *option
0120                              ,Long64_t nentries, Long64_t firstentry) override;
0121    void              SetEstimate(Long64_t n) override;
0122    void              SetScanRedirect(bool on=false) {fScanRedirect = on;}
0123    void              SetScanFileName(const char *name) {fScanFileName=name;}
0124    void              SetTree(TTree *t) override {fTree = t;}
0125    void              StartViewer(Int_t ww, Int_t wh) override;
0126    Int_t             UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option
0127                                  ,Long64_t nentries, Long64_t firstentry) override;
0128    void              UpdateFormulaLeaves() override;
0129 
0130    ClassDefOverride(TTreePlayer,3);  //Manager class to play with TTrees
0131 };
0132 
0133 #endif