Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:47

0001 // @(#)root/tree:$Id$
0002 // Author: Rene Brun   07/04/2001
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 #ifndef ROOT_TFriendElement
0012 #define ROOT_TFriendElement
0013 
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TFriendElement                                                       //
0018 //                                                                      //
0019 // A TFriendElement TF describes a TTree object TF in a file.           //
0020 // When a TFriendElement TF is added to the list of friends of an   //
0021 // existing TTree T, any variable from TF can be referenced in a query  //
0022 // to T.                                                                //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 
0027 #include "TNamed.h"
0028 
0029 class TFile;
0030 class TTree;
0031 class TClass;
0032 
0033 class TFriendElement : public TNamed {
0034 
0035 protected:
0036    TTree        *fParentTree;  ///<! pointer to the parent TTree
0037    TTree        *fTree;        ///<! pointer to the TTree described by this element
0038    TFile        *fFile;        ///<! pointer to the file containing the friend TTree
0039    TString       fTreeName;    ///<  name of the friend TTree
0040    bool          fOwnFile;     ///<  true if file is managed by this class
0041 
0042    TFriendElement(const TFriendElement&) = delete;
0043    TFriendElement& operator=(const TFriendElement&) = delete;
0044 
0045    friend void TFriendElement__SetTree(TTree *tree, TList *frlist);
0046 
0047 public:
0048    enum EStatusBits {
0049       kFromChain = BIT(9),  // Indicates a TChain inserted this element in one of its content TTree
0050       kUpdated   = BIT(10)  // Indicates that the chain 'fTree' went through a LoadTree
0051    };
0052    TFriendElement();
0053    TFriendElement(TTree *tree, const char *treename, const char *filename);
0054    TFriendElement(TTree *tree, const char *treename, TFile *file);
0055    TFriendElement(TTree *tree, TTree* friendtree, const char *alias);
0056    ~TFriendElement() override;
0057    virtual TTree      *Connect();
0058    virtual TTree      *DisConnect();
0059    virtual TFile      *GetFile();
0060    virtual TTree      *GetParentTree() const {return fParentTree;}
0061    virtual TTree      *GetTree();
0062    /// Get the actual TTree name of the friend.
0063    /// If an alias is present, it can be retrieved with GetName().
0064    virtual const char *GetTreeName() const {return fTreeName.Data();}
0065    void        ls(Option_t *option="") const override;
0066            void        Reset() { fTree = nullptr; fFile = nullptr; }
0067            bool        IsUpdated() const { return TestBit(kUpdated); }
0068            void        ResetUpdated() { ResetBit(kUpdated); }
0069            void        MarkUpdated() { SetBit(kUpdated); }
0070    void        RecursiveRemove(TObject *obj) override;
0071 
0072 
0073    ClassDefOverride(TFriendElement,2)  //A friend element of another TTree
0074 };
0075 
0076 #endif
0077