Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTreeReaderValueFast.cxx
Go to the documentation of this file.
1// @(#)root/treeplayer:$Id$
2// Author: Axel Naumann, 2011-09-28
3
4/*************************************************************************
5 * Copyright (C) 1995-2013, Rene Brun and 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
13
14#include "TTreeReader.h"
15#include "TBranchClones.h"
16#include "TBranchElement.h"
17#include "TBranchRef.h"
18#include "TBranchSTL.h"
20#include "TLeaf.h"
21#include "TTreeProxyGenerator.h"
22#include "TTreeReaderValue.h"
23#include "TRegexp.h"
24#include "TStreamerInfo.h"
25#include "TStreamerElement.h"
26#include "TNtuple.h"
27#include <vector>
28
29/** \class TTreeReaderValueFast
30
31Extracts data from a TTree.
32*/
33
34////////////////////////////////////////////////////////////////////////////////
35/// Unregister from tree reader, cleanup.
36
38{
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Attach this value to the appropriate branch on the tree. For now, we don't
44/// support the complex branch lookup of the TTreeReader -- only a fixed leaf!
45
49 if (fLeafName.size() > 0){
50
51 Long64_t newChainOffset = fTreeReader->GetTree()->GetChainOffset();
52
53 if (newChainOffset != fLastChainOffset){
54 fLastChainOffset = newChainOffset;
55
56 TTree *myTree = fTreeReader->GetTree();
57
58 if (!myTree) {
59 Error("TTreeReaderValueBase::GetLeaf()", "Unable to get the tree from the TTreeReader");
60 return;
61 }
62
63 TBranch *myBranch = myTree->GetBranch(fBranchName.c_str());
64
65 if (!myBranch) {
66 Error("TTreeReaderValueBase::GetLeaf()", "Unable to get the branch from the tree");
67 return;
68 }
69
70 fLeaf = myBranch->GetLeaf(fLeafName.c_str());
71 if (!fLeaf) {
72 Error("TTreeReaderValueBase::GetLeaf()", "Failed to get the leaf from the branch");
73 }
74 fBranch = myBranch;
75 }
76 }
77 else {
78 Error("TTreeReaderValueBase::GetLeaf()", "We are not reading a leaf");
79 }
82}
83
long long Long64_t
Definition RtypesCore.h:80
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void CreateProxy()
Attach this value to the appropriate branch on the tree.
virtual ~TTreeReaderValueFastBase()
Unregister from tree reader, cleanup.
void DeregisterValueReader(ROOT::Experimental::Internal::TTreeReaderValueFastBase *reader)
Remove a value reader for this tree.
@ kSetupMissingBranch
The specified branch cannot be found.
@ kSetupMatch
This branch has been set up, branch data type and reader template type match, reading should succeed.
A TTree is a list of TBranches.
Definition TBranch.h:93
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
Definition TBranch.cxx:2055
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5291
virtual TTree * GetTree() const
Definition TTree.h:517