Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/base:$Id$
0002 // Author: Philippe Canal 13/05/2003
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun, Fons Rademakers and al.           *
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_TBranchProxyDirector
0013 #define ROOT_TBranchProxyDirector
0014 
0015 #include "RtypesCore.h"
0016 #include <vector>
0017 #include <list>
0018 #include <algorithm>
0019 
0020 class TH1F;
0021 class TTree;
0022 
0023 namespace ROOT {
0024 namespace Detail {
0025    class TBranchProxy;
0026    class TFriendProxy;
0027 }
0028 
0029 namespace Internal{
0030    class TFriendProxy;
0031 
0032    /// Helper function to call SetReadEntry on all TFriendProxy
0033    void ResetReadEntry(TFriendProxy *fp);
0034 
0035    class TBranchProxyDirector {
0036 
0037       //This class could actually be the selector itself.
0038       TTree   *fTree;  ///< TTree we are currently looking at.
0039       Long64_t fEntry; ///< Entry currently being read (in the local TTree rather than the TChain)
0040 
0041       std::list<Detail::TBranchProxy*> fDirected;
0042       std::vector<TFriendProxy*> fFriends;
0043 
0044       TBranchProxyDirector(const TBranchProxyDirector &) : fTree(nullptr), fEntry(-1) {}
0045       TBranchProxyDirector& operator=(const TBranchProxyDirector&) {return *this;}
0046 
0047    public:
0048 
0049       TBranchProxyDirector(TTree* tree, Long64_t i);
0050       TBranchProxyDirector(TTree* tree, Int_t i);     // cint has (had?) a problem casting int to long long
0051 
0052       void     Attach(Detail::TBranchProxy* p);
0053       void     Attach(TFriendProxy* f);
0054       TH1F*    CreateHistogram(const char *options);
0055 
0056       /// Return the current 'local' entry number; i.e. in the 'local' TTree rather than the TChain.
0057       /// This value will be passed directly to TBranch::GetEntry.
0058       Long64_t GetReadEntry() const { return fEntry; }
0059 
0060       TTree*   GetTree() const { return fTree; };
0061       // void   Print();
0062 
0063       /// Move to a new entry to read
0064       /// entry is the 'local' entry number; i.e. in the 'local' TTree rather than the TChain.
0065       /// This value will be passed directly to TBranch::GetEntry.
0066       void     SetReadEntry(Long64_t entry) {
0067          fEntry = entry;
0068          if (!fFriends.empty()) {
0069             std::for_each(fFriends.begin(), fFriends.end(), ResetReadEntry);
0070          }
0071       }
0072       TTree*   SetTree(TTree *newtree);
0073       bool     Notify();
0074 
0075    };
0076 
0077 } // namespace Internal
0078 } // namespace ROOT
0079 
0080 #endif