Re: [ROOT] TPolyLine(3D) Streamer problem?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jul 17 2001 - 17:08:19 MEST


Hi Gerco,

TPolyLine3D is one of the few ROOT classes still with a hand-written Streamer.
Classes with a hand-written Streamer cannot be used in split mode in a branch.
You can force the branch to not use the split mode and call the Streamer
function by using split=-1. We expect this to be automatic in the next release.
So, in your example, change the line:

  TBranch *b = tree->Branch("tracks", "TPolyLine3D", &l, 64000,kTRUE);
to
  TBranch *b = tree->Branch("tracks", "TPolyLine3D", &l, 64000,-1);

Note that your argument kTRUE was not correct.

Rene Brun


Gerco Onderwater wrote:
> 
> Hi Rooters,
> 
> I thought I was making a trivial program to write a series of TPolyLine3D
> objects to a file. To my surprise it didn't work. The problem seems to be
> that the actual points of the polyline line aren't written (or maybe at
> the wrong place?).
> 
> Here is a little test macro that shows what happens:
> 
> void doit()
> {
>   TFile* file= new TFile("/tmp/ppp.root","recreate");
>   TTree* tree = new TTree("tree","a tree");
>   TPolyLine3D* l =  new TPolyLine3D();
>   TBranch *b = tree->Branch("tracks", "TPolyLine3D", &l, 64000,kTRUE);
>   l->SetNextPoint(1,1,1);
>   l->SetNextPoint(3,3,3);
>   tree->Fill();
>   file->Write();
> }
> 
> void didit()
> {
>   TFile* file= new TFile("/tmp/ppp.root");
>   TTree* tree = (TTree*)file->Get("tree");
>   TBranch* b = tree->GetBranch("tracks");
>   TPolyLine3D* l =  new TPolyLine3D();
>   b->SetAddress(&l);
>   tree->GetEntry(0,0);
>   printf("Number of points: %d\n",l->GetN());
>   printf("Location of fP: 0x%x\n",l->GetP());
> }
> 
> Its output:
> 
> root [0] .L test.c
> root [1] doit()
> root [2] didit()
> Number of points: 2
> Location of fP: 0x0
> 
> I get similar results for a TPolyLine. I'm using the ancient Root version
> 2.25/03, but don't see any (obviously relevant) changes between it and
> version 3.01 as far as it concerns TPolyLine3D.
> 
> Something I did notice was that when I open a browser, it shows the
> peculiar field "fOption.*fData" (see attached gif).
> 
> If you have a simple solution or if I made a mistake somewhere, please let
> me know.
> 
> Thanks,
> 
> -- Gerco
> 
> Dr. C.J.G. Onderwater
> Nuclear Physics Laboratory
> 401B Loomis Laboratory of Physics
> University of Illinois at Urbana-Champaign
> 1110 West Green Street
> Urbana, IL 61801-3080
> Phone : (217) 244-7363
> Fax   : (217) 333-1215
> E-mail: onderwat@uiuc.edu
> 
>   --------------------------------------------------------------------------------
> 
>                      Name: browser.gif
>    browser.gif       Type: GIF Image (IMAGE/gif)
>                  Encoding: BASE64



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:52 MET