RE: Example needed: Character String as a tree branch

From: Stefan Piperov <>
Date: Mon, 07 Feb 2005 15:32:03 -0600 (CST)

OK, adding a character string leaf worked out fine. But can one add an array of character strings?

The following code compiles and runs, but does not fill the array into the leaf:

char v1secPartName[100][20];
tree->Branch("v1nsec",&v1nsec,"v1nsec/I"); tree->Branch("v1secPartName",v1secPartName,"v1secPartName[v1nsec]/C"); ...
snprintf(v1secPartName[v1nsec],20,"%s%s(%i)\0",,sign[pCharge+2],pdg); ...

After execution the leaf is simply empty.

Thanks for your consideration,

On Tue, 1 Feb 2005, Philippe Canal wrote:

> See $ROOTSYS/tutorials/cernbuild.C and staff.C
> Cheers,
> Philippe.
> -----Original Message-----
> From: []
> On Behalf Of Stefan Piperov
> Sent: Tuesday, February 01, 2005 8:13 AM
> To:
> Subject: [ROOT] Example needed: Character String as a tree branch
> Dear RootTalk,
> According to the ROOT Users Guide, one can have a tree branch of type
> "character string terminated by the 0 character". I have attempted to
> create such a branch, but no matter how I try, I get a runtime error at
> best...
> Can somebody show an example code of creating and filling such a branch?
> For some reason this is not shown in the Guide, and I guess that many
> users will find it useful.
> I have seen that many people, faced with the same problem, have chosen
> to embed their strings into a user-defined class derived from TObject,
> and then store this object into the tree. However for me this is not an
> option, because my environment (SCRAM) cannot handle the Link/Dictionary
> machinery of this approach.
> (Or can it? Somebody with any suggestions here?)
> Your help will be appreciated!
> With Best Regards,
> Stefan Piperov.

  Stefan Piperov      Mail: FNAL P.O.Box 500, MS 205, Batavia, IL-60510
  Phone: (630) 840-5686                        E-Mail: 
Received on Mon Feb 07 2005 - 22:32:10 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET