Re: Bug in TBranchClones::Fill() ?
Rene Brun (Rene.Brun@cern.ch)
Thu, 26 Mar 1998 19:10:24 +0100
Manuel Sanchez Garcia wrote:
>
> Hello Rooters,
>
> I have just seen that when you try to store a TClonesArray in a
> TTree using a TBranchClones with split=1. It happens that if the
> TClonesArray has holes, then Root crashes when doing TTree::Fill.
>
> To illustrate the problem i've written the following macro:
>
> {
> gROOT->Reset();
> gSystem->Load("FullHades.so");
> TClonesArray clones("HRichRaw",1000);
> TClonesArray* pClones=&clones;
> HRichRaw *pRaw;
> TFile f("test.root","RECREATE");
> TTree *tree=new TTree("T","Test tree");
> tree->Branch("Data",&pClones,32000,1);
>
> Int_t i,j;
> for (i=0;i<10;i++) {
> clones.Clear();
> for (j=0;j<100;j++) {
> pRaw=new(clones[j]) HRichRaw(gRandom->Gaus(3,1));
> }
> for (j=200;j<1000;j++) {
> // if i use: "for (j=100;j<100;j++) {" then everything works
> pRaw=new(clones[j]) HRichRaw(gRandom->Gaus(4,1));
> }
> tree->Fill();
> }
>
> f.Write();
> }
>
> This macro gives a Segmentation Violation; meanwhile if i start the
> second loop in j=100 everything works Ok
>
> Is this a bug or a feature?
TClonesArray cannot have holes when used in split mode.
Rene Brun