Re: Creating Branches

Rene Brun (Rene.Brun@cern.ch)
Thu, 26 Jun 1997 14:40:45 +0200


Maarten Bruinsma wrote:
>
> Dear fellow ROOT users,
>
> I just made my first TTree, but when compiling I keep getting a parse
> error. I have tried several things, as it seems there are many ways to
> create branches, but alas, all in vain. Could anyone tell me what's wrong
> with the following?
>
> TROOT simple("simple","Test of histogramming and I/O");
> TFile hfile("mijnhistos.root","RECREATE","ROOT with all info on muons");
>
> typedef struct {Float_t x,y,z;} POINT;
> POINT begin_vertex;
> static POINT end_vertex;
> static POINT momentum;
> static Int_t mother;
> static Float_t p;
> static Float_t pt;
> static Float_t track_length;
>
> // this tree contain momenta etc. of several types of muons
>
> TTree *muontree = new TTree("muontree","Data for all muons");
>
> muontree->Branch("Momentum",&momentum,"Px:Py:Pz");
> muontree->Branch("Begin_Vertex",&begin_vertex,"Xvert:Yvert:Zvert");
> muontree->Branch("EndVertex".&end_vertex,"Xvert2:Yvert2:Zvert2");
> muontree->Branch("Tracklength",&track_length,"Tracklength");
> muontree->Branch("P",&p,"P");
> muontree->Branch("Pt",&pt,"Pt");
> muontree->Branch("Mother",&mother,"Mother/I");
>
> I get a parse error at the line creating the first branch.
>
> Thanks in advance,
>

Maarten,
You have a typing mistake in the line creating the 3rd branch (dot instead of comma).
This line should be:

muontree->Branch("EndVertex",&end_vertex,"Xvert2:Yvert2:Zvert2");

If you make this change, your program will work.
muontree->Print() will produce:
root [7] muontree->Print()
************************************************************************************
*Tree :muontree : Data for all muons *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
* : : Tree compression factor = 1.00 *
************************************************************************************
*Branch :Momentum : Px:Py:Pz *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :Begin_Vertex : Xvert:Yvert:Zvert *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :EndVertex : Xvert2:Yvert2:Zvert2 *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :Tracklength : Tracklength *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :P : P *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :Pt : Pt *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*
*Branch :Mother : Mother/I *
*Entries : 0 : Total Size = 0 bytes File Size = 0 bytes *
*Baskets : 0 : Basket Size = 32000 bytes EvOffsetLen= 0 *
* : : Branch compression factor = 1.00 *
*..................................................................................*

Rene Brun