Problems with TTree::GetEntry() method

Ok it is solved :smiley:

[code]void simple_dump(){

gSystem->Load(“HptEventOld.so”); // <— Create and load the library using TFile::MakeProject class

TFile *file = new TFile (“P1G.root”);

TTree tree = (TTree)file->Get(“USR1”);

if(tree==0) return;

//tree->SetMakeClass(1); // no need to SetMakeClass()

Int_t Run;
Int_t Spill;
Int_t Evinspill;

//tree->SetBranchStatus("*", 0); // no need to “turn off” all branches

HptEventOld *ptr = 0; // <— create a pointer for the structure

tree->SetBranchAddress(“Event”,&ptr); // <— and use to hold the whole tree

// no need of these too
// tree->SetBranchAddress(“eRun”,&Run);
// tree->SetBranchAddress(“eSpill”,&Spill);
// tree->SetBranchAddress(“eEvinspill”,&Evinspill);

Long64_t events = tree->GetEntries();

cout<<"****"<<events<<endl;

cout<<“Evt\t”<<“Spill\t”<<“Run\t”<<endl;

for(Long64_t i = 0; i<events; i++)
{
tree->GetEntry(i);

  cout<<ptr->eEvinspill<<'\t'<<ptr->eSpill<<'\t'<<ptr->eRun<<endl; // <--- the way to access the leafs 
}

}[/code]

Long time passed since PCanal reply and I’ve hadn’t the time to say thank you. This is also an embarrasing situation. :blush:

But now I had the opportunity, and this time I won’t wasted: Thank PCanal for your reply ([url]Problem while reading from tree using SetBranchAddress() =D>

Cheers,
LuĂ­s.