Reading strings from a tree?

stefan kluth (skluth@mh1.lbl.gov)
Mon, 27 Jul 1998 17:52:20 -0700 (PDT)


Hello,

I try to write strings into a tree (and to read them back of course!). I
seem to be able to write strings ok, but I can't read them back. Here is
what I do:

...

TFile myfile( "treetest.root", "RECREATE" );
TTree* tree = new TTree( "tree", "ROOT test tree" );
char* ach;
TBranch* brach= tree->Branch( "ach", (void*)ach, "ach/C", 8000 );

... now loop and fill ach with different strings, works ok.

Then I do in root (2.00/08):

root [0] #include <iostream.h>
root [1] TFile myfile( "treetest.root");
root [2] myfile.ls();
TFile** treetest.root
TFile* treetest.root
KEY: TTree tree;1 ROOT test tree
root [3] TBranch *brach = tree.GetBranch("ach");
root [4] char* ach;
root [5] brach->SetAddress(ach);
root [6] tree.GetEvent(3);
root [7] cout << ach << endl;

root [8]

So, somehow the strings stored in the tree branch "ach" don't get assigned
to the char* ach.

Any ideas as what am I doing wrong here?

cheers, Stefan

---Stefan Kluth---------------Lynen Fellow----------------|\--|\-------
- LBNL, MS 50A 2160 - phone: +1 510 495 2376 - |/ |/ -
- 1 Cyclotron Rd. - fax: +1 510 495 2957 - |\/\|\/\|' -
---Berkeley, CA94720, USA-----e-mail: SKluth@lbl.gov------|/\/|/\/|----