Re: How to correctly add a branch to a saved TTree?

From: Pierre-Luc Drouin <pldrouin_at_physics.carleton.ca>
Date: Sat, 20 Jun 2009 23:11:47 -0400


Hi,

I am using 5.22/00. I have that version compiled with gcc on a 32 bits machine and the same version compiled with icc on a 64 bits machine. I get the same errors on both machines. As I said it works with a few thousand entries but fails with about 500 000 entries (like if it was failing when using multiple baskets?)

The error messages are the following:
Error in <TObjArray::AddAt>: index 10 out of bounds (size: 10, this: 0x09ce4fd0)
Error in <TObjArray::AddAt>: index 10 out of bounds (size: 10, this: 0x09ce4fd0)
Error in <TObjArray::AddAt>: index 10 out of bounds (size: 10, this: 0x09ce4fd0)
Error in <TObjArray::AddAt>: index 10 out of bounds (size: 10, this: 0x09ce4fd0)

...
...(thousands of lines of the same error)
...

Thanks!
Pierre-Luc

Philippe Canal wrote:
> Hi Pierre-Luc,
>
> I do not see any problem with this code, nor can I reproduce any issue.
>
> How does it fail in your case? Which version of ROOT are you using?
>
> Cheers,
> Philippe.
>
> Pierre-Luc Drouin wrote:
>> Hi,
>>
>> I am trying to add and fill a branch to an existing TTree and I get a
>> segmentation violation error when the number of entries exceeds some
>> value
>>
>> Here is some code to reproduce the problem:
>> {
>> Int_t nentries=500000;
>> TFile *file=new TFile("file.root","recreate");
>> TTree *tree=new TTree("tree","tree");
>> Float_t val=0;
>> tree->Branch("br1",&val,"br1/F");
>>
>> for(Int_t i=0; i<nentries; ++i) {
>> val=i;
>> tree->Fill();
>> }
>>
>> file->Write();
>> file->Close();
>> delete file;
>>
>> file=new TFile("file.root","update");
>> tree=(TTree*)file->Get("tree");
>> TBranch *br=tree->Branch("br2",&val,"br2/F");
>>
>> for(Int_t i=0; i<nentries; ++i) {
>> val=i;
>> br->Fill();
>> }
>> tree->SetEntries(br->GetEntries());
>>
>> file->Write();
>> file->Close();
>> delete file;
>>
>> file=new TFile("file.root","read");
>> tree=(TTree*)file->Get("tree");
>> tree->Draw("br1");
>> }
>>
>> The code above works correctly when nentries is 25000 but fails with
>> 500000.
>>
>> How can I fix this problem?
>>
>> Thank you!
>> Pierre-Luc Drouin
>>
>
Received on Sun Jun 21 2009 - 05:11:54 CEST

This archive was generated by hypermail 2.2.0 : Sun Jun 21 2009 - 05:50:05 CEST