Logo ROOT  
Reference Guide
TFriendProxy.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Philippe Canal 13/05/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al. *
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 /** \class TFriendProxy
13 Concrete implementation of the proxy around a Friend Tree.
14 */
15 
16 #include "TFriendProxy.h"
17 #include "TTree.h"
18 #include "TList.h"
19 #include "TFriendElement.h"
20 
22 
23 namespace ROOT {
24 namespace Internal {
25 
26 /////////////////////////////////////////////////////////////////////////////
27 
28 TFriendProxy::TFriendProxy() : fDirector(0,-1), fIndex(-1)
29 {
30 }
31 
32  /////////////////////////////////////////////////////////////////////////////
33  /// Constructor.
34 
36  fDirector(0,-1), fIndex(index)
37  {
38  // The list of friends needs to be accessed via GetTree()->GetListOfFriends()
39  // (and not directly GetListOfFriends()), otherwise when `main` is a TChain we
40  // might not recover the list correctly (see #6993 for the TTreeReader issue
41  // and #6741 for a more complete discussion/explanation).
42  if (main && main->GetTree()->GetListOfFriends()) {
43  TObject *obj = main->GetTree()->GetListOfFriends()->At(fIndex);
44  TFriendElement *element = dynamic_cast<TFriendElement*>( obj );
45  if (element) fDirector.SetTree(element->GetTree());
46  }
47  director->Attach(this);
48  }
49 
50  /////////////////////////////////////////////////////////////////////////////
51  /// Return the entry number currently being looked at.
52 
54  {
55  return fDirector.GetReadEntry();
56  }
57 
58  /////////////////////////////////////////////////////////////////////////////
59  /// Refresh the cached read entry number from the original tree.
60 
62  {
63  // The 2nd call to GetTree is to insure we get the 'local' tree's entry in the case of a
64  // chain.
66  }
67 
68  //////////////////////////////////////////////////////////////////////////////
69  /// Update the address of the underlying tree.
70 
71  void TFriendProxy::Update(TTree *newmain)
72  {
73  if (newmain && newmain->GetTree()->GetListOfFriends()) {
74  TObject *obj = newmain->GetTree()->GetListOfFriends()->At(fIndex);
75  TFriendElement *element = dynamic_cast<TFriendElement*>( obj );
76  if (element) fDirector.SetTree(element->GetTree());
77  else fDirector.SetTree(0);
78  } else {
79  fDirector.SetTree(0);
80  }
81  }
82 
83 } // namespace Internal
84 } // namespace ROOT
ROOT::Internal::TBranchProxyDirector::SetReadEntry
void SetReadEntry(Long64_t entry)
Move to a new entry to read entry is the 'local' entry number; i.e.
Definition: TBranchProxyDirector.h:66
ROOT::Internal::TBranchProxyDirector
Definition: TBranchProxyDirector.h:35
ROOT::Internal::TFriendProxy::fIndex
Int_t fIndex
Definition: TFriendProxy.h:25
TTree::GetListOfFriends
virtual TList * GetListOfFriends() const
Definition: TTree.h:485
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
ROOT::Internal::TBranchProxyDirector::GetTree
TTree * GetTree() const
Definition: TBranchProxyDirector.h:60
ROOT::Internal::TBranchProxyDirector::GetReadEntry
Long64_t GetReadEntry() const
Return the current 'local' entry number; i.e.
Definition: TBranchProxyDirector.h:58
ROOT::Internal::TFriendProxy::fDirector
TBranchProxyDirector fDirector
Definition: TFriendProxy.h:24
TList.h
TFriendElement
A TFriendElement TF describes a TTree object TF in a file.
Definition: TFriendElement.h:33
TFriendElement.h
TTree.h
ROOT::Internal::TFriendProxy::Update
void Update(TTree *newmain)
Update the address of the underlying tree.
Definition: TFriendProxy.cxx:71
ROOT::Internal::TBranchProxyDirector::SetTree
TTree * SetTree(TTree *newtree)
Definition: TBranchProxyDirector.cxx:129
TTree::GetTree
virtual TTree * GetTree() const
Definition: TTree.h:512
TList::At
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:357
TTree::GetReadEntry
virtual Long64_t GetReadEntry() const
Definition: TTree.h:504
TFriendElement::GetTree
virtual TTree * GetTree()
Return pointer to friend TTree.
Definition: TFriendElement.cxx:209
main
int main(int argc, char **argv)
Definition: histspeedtest.cxx:751
ROOT::Internal::TFriendProxy
Definition: TFriendProxy.h:22
ROOT::Internal::TBranchProxyDirector::Attach
void Attach(Detail::TBranchProxy *p)
Definition: TBranchProxyDirector.cxx:64
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ROOT::Internal::TFriendProxy::TFriendProxy
TFriendProxy()
Definition: TFriendProxy.cxx:28
ROOT::Internal::TFriendProxy::ResetReadEntry
void ResetReadEntry()
Refresh the cached read entry number from the original tree.
Definition: TFriendProxy.cxx:61
ROOT::Internal::TFriendProxy::GetReadEntry
Long64_t GetReadEntry() const
Return the entry number currently being looked at.
Definition: TFriendProxy.cxx:53
TFriendProxy.h
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
int