Hi Stefan, You will find below a simple example with a variable length array indexed on a variable part of the structure. To execute, do: Root > .x test.C This will generate the file test.root. In a second Root session, do: Root > TFile f("test.root"); Root > T.Draw("count"); Root > T.Draw("meas"); Root > T.Draw("meas","count<40"); Rene Brun //--------------file struct.C------------------- typedef struct{ int eventnr; int count; float meas[100]; } event_struct; void test() { TFile f("test.root","recreate"); TTree T("T","test struct"); event_struct event; T.Branch("first",&event.eventnr,"eventnr/I:count/I:meas[count]/F"); for (Int_t i=0;i<1000;i++) { event.eventnr = i; event.count = 100*gRandom->Rndm(); for (Int_t j=0;j<event.count;j++) event.meas[j] = i+j; T.Fill(); } T.Print(); T.Write(); } Stefan Stonjek wrote: > > Hello, > > I want to store some variables in a branch. One on this variables is a > counter for an array which sould be stored too. This array can have > different numbers of entries for differnet events. But of course I want > to store run and event number only once. But when I draw the array I > want all elements of the array taken into account. (like CWN in HBOOK) > > What is the best way doing this? One idea was: > > -------------------------------------------------------------------------- > typedef struct{ > int eventnr; > int count > float meas[10; > } event_struct > > event_struct event; > > Tree->Branch("first",&event.eventnr,"eventnr/I:count/I:meas[40]/I",bsize); > ------------------------------------------------------------------------- > > This seems not to work. Only the first entry for every event is filled. So > which is the coerrect syntax. > > Or is this to simple and there is a better way? > > Tschuess > Stefan > > ********* Stefan Stonjek ********* > ***** DESY / ZEUS ***** > ***** Stefan.Stonjek@desy.de ***** > ********* Tel.: +49-40-8998-3159 *********
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET