Hi folks,
When I call Scan() with no arguments on a tree, I get no matching results (return value is -1), even though I’m sure that there’s data in the tree.
Here’s a minimal example
First, make the ROOT file with the TTree
{
TFile* ff = new TFile("test.root","RECREATE");
TTree* tt = new TTree("mytree","mytree title");
int ii;
double xx;
tt->Branch("ii",&ii,"ii/I");
tt->Branch("xx",&xx,"xx/D");
ii=1; xx=5.0; tt->Fill();
ii=2; xx=7.0; tt->Fill();
ff->Write();
}
Next, read the ROOT file from disk (after quitting and restarting CINT)
root [0] TFile f("test.root")
root [1] f.ls()
TFile** test.root
TFile* test.root
KEY: TTree mytree;1 mytree title
root [2] mytree->Print()
******************************************************************************
*Tree :mytree : mytree title *
*Entries : 2 : Total = 1456 bytes File Size = 605 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Br 0 :ii : ii/I *
*Entries : 2 : Total Size= 541 bytes File Size = 79 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :xx : xx/D *
*Entries : 2 : Total Size= 557 bytes File Size = 87 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
OK, looks good so far. Now try to print the contents of the TTree to screen with Scan()
root [3] mytree->Scan()
(Long64_t)(-1)
root [4] mytree->Scan("*")
(Long64_t)(-1)
Hmmmm… OK, well then assign a variable to a branch and pull data out that way?
root [5] int ii;
root [6] mytree->SetBranchAddress("ii",&ii);
root [7] mytree->GetEvent(0);
root [8] ii
(int)1
root [9] mytree->GetEvent(1);
root [10] ii
(int)2
So the data is in the TTree as expected. But why isn’t the data output via Scan()? Apologies in advance if there’s something obvious here. I did search online for advice, but was not able to find a solution.
For reference, here’s some information about my system setup. I installed ROOT via yum.
$ root-config --version
5.34/09
$ cat /etc/redhat-release
Scientific Linux release 6.4 (Carbon)
$ uname -a
Linux name1.name2.edu 2.6.32-358.14.1.el6.x86_64 #1 SMP Tue Jul 16 14:24:33 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Thank you,
James