9 #include "gtest/gtest.h" 16 unsigned int ny = 100;
25 tree->
Branch(
"one", &
x,
"x[3]/D");
26 tree->
Branch(
"two", &yData,
"ny/i:y[ny]/I");
27 tree->
Branch(
"three", &z,
"z");
29 tree->
Branch(
"d32", &Double32);
30 tree->
Branch(
"f16", &Float16);
44 for (
int entry = 2; entry < 20; ++entry) {
45 z = entry * (1 - 2 * (entry % 2));
46 str = std::string(entry,
'*');
55 TEST(TTreeReaderBasic, Interfaces) {
81 EXPECT_TRUE(tr.
Next());
82 EXPECT_TRUE(tr.
Next());
102 EXPECT_DOUBLE_EQ(43., x[2]);
105 for (
int entry = 2; entry < 20; ++entry)
106 EXPECT_TRUE(tr.
Next());
108 EXPECT_FALSE(tr.
Next());
113 TEST(TTreeReaderBasic, ErrorProbing) {
116 EXPECT_EQ(
nullptr, tr.
GetTree());
120 EXPECT_EQ(
nullptr, tr.
GetTree());
123 EXPECT_FALSE(val.IsValid());
133 EXPECT_TRUE(tr.
Next());
137 EXPECT_TRUE(tr.
Next());
141 EXPECT_TRUE(tr.
Next());
146 EXPECT_FALSE(tr.
Next());
151 EXPECT_FALSE(tr.
Next());
160 EXPECT_TRUE(tr.
Next());
164 EXPECT_TRUE(tr.
Next());
169 EXPECT_FALSE(tr.
Next());
175 TEST(TTreeReaderBasic, InvalidRange) {
182 EXPECT_TRUE(tr.
Next());
188 TEST(TTreeReaderBasic, OneEntryRange) {
194 EXPECT_TRUE(tr.
Next());
199 EXPECT_FALSE(tr.
Next());
203 for (
int entry = 2; entry < tree->
GetEntries(); ++entry)
204 EXPECT_FALSE(tr.
Next());
208 TEST(TTreeReaderBasic, ZeroEntryRange) {
215 EXPECT_TRUE(tr.
Next());
219 EXPECT_TRUE(tr.
Next());
224 EXPECT_FALSE(tr.
Next());
231 TEST(TTreeReaderBasic, InvertedEntryRange) {
237 EXPECT_TRUE(tr.
Next());
241 EXPECT_TRUE(tr.
Next());
246 EXPECT_FALSE(tr.
Next());
253 TEST(TTreeReaderBasic, EntryList) {
256 EXPECT_EQ(9, tree->
Draw(
">>negZ",
"three.z<0",
"entrylistarray"));
265 while (aReader.
Next()) {
275 EXPECT_TRUE(aReader.
Next());
282 TEST(TTreeReaderBasic, EntryListBeyondEnd) {
292 EXPECT_TRUE(aReader.
Next());
296 EXPECT_FALSE(aReader.
Next());
302 TEST(TTreeReaderBasic, Values) {
313 EXPECT_TRUE(tr.
Next());
315 EXPECT_DOUBLE_EQ(42, x[1]);
319 EXPECT_STREQ(
"first", str->c_str());
320 EXPECT_FLOAT_EQ(12, *d32);
321 EXPECT_FLOAT_EQ(-12, *f16);
virtual const char * GetName() const
Returns name of object.
TEST(TTreeReaderBasic, Interfaces)
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
The branch class type is not a collection.
A list of entries and subentries in a TTree or TChain.
Long64_t GetCurrentEntry() const
Returns the index of the current entry being read.
virtual Int_t Fill()
Fill all branches.
EReadStatus ProxyRead()
Try to read the value from the TBranchProxy, returns the status of the read.
the tree entry number does not exist
const char * GetBranchName() const
virtual EReadStatus GetReadStatus() const
Iterator_t begin()
Return an iterator to the 0th TTree entry.
Extracts data from a TTree.
Iterator_t end() const
Return an iterator beyond the last TTree entry.
Long64_t GetEntries(Bool_t force) const
no entry has been loaded yet
void * GetAddress()
Returns the memory address of the object being read.
void Restart()
Restart a Next() loop from entry 0 (of TEntryList index 0 of fEntryList is set).
Extracts array data from a TTree.
please use SetEntriesRange()!")
virtual void ResetBranchAddresses()
Tell all of our branches to drop their current objects and allocate new ones.
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
EEntryStatus GetEntryStatus() const
virtual Long64_t GetEntries() const
TLeaf * GetLeaf()
If we are reading a leaf, return the corresponding TLeaf.
you should not use this method at all Int_t Int_t z
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
Bool_t Next()
Move to the next entry (or index of the TEntryList if that is set).
A TTree object has a header with a name and a title.
void SetTree(TTree *tree, TEntryList *entryList=nullptr)
ESetupStatus GetSetupStatus() const
A List of entry numbers in a TTree or TChain.
last entry loop has reached its end