Replacing a TBranch in a TTree...

From: Pierre-Luc Drouin <pldrouin_at_physics.carleton.ca>
Date: Mon, 14 Apr 2008 23:29:15 -0400


Hi,

How can I replace the content of a TBranch in a TTree? I have tried the following test but this leads to a segmentation fault when the branch "y" is created the second time...

TFile file("test.root","recreate");

    TTree *tree=new TTree("mytree","mytree");     Double_t x,y;
    tree->Branch("x",&x,"x/D");

    for(Int_t i=0; i<1000000; i++){

        x=i;
        tree->Fill();

}

    TBranch *yb;

    for(Int_t j=0; j<10; j++){

        yb=tree->Branch("y",&y,"y/D");

        for(Int_t i=0; i<1000000; i++){
            x=i;
            y=2*i;
            yb->Fill();
        }
        tree->GetListOfBranches()->Remove(yb);
        yb->Delete();

}

    file.Write();
    file.Close();

Thanks!
Pierre-Luc Drouin Received on Tue Apr 15 2008 - 05:29:31 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 15 2008 - 11:50:02 CEST