[ROOT] Problems with accessing vector-elements in TTree

From: A.Dietz@mpi-hd.mpg.de
Date: Tue Jun 03 2003 - 13:36:45 MEST


Dear Rooters,

I created a TTree with some elements in it, e.g.:

...
 treeRun->Branch("run",&run.run,"run/I");
 treeRun->Branch("trig",run.trig,"trig[5]/I");
...

I can work very well with thie TTree but I have some problems in accessing
the elements of the TTree.
To access the values of the variable 'run' I do the following:


  treeRun->Draw(">>runList");
  TEventList* runList=(TEventList*)gDirectory->Get("runList");

  for (int i=0;i<runList->GetN();i++) {

    treeRun->GetEntry(runList->GetEntry(i));
    TBranch* branch=treeRun->GetBranch("run");
    TLeaf* leaf=(TLeaf*)branch->FindLeaf("run");
    int run=*( (Int_t*)leaf->GetValuePointer());
  }

This works fine (but seems to be very cumbersonely).
But how can I access the different elements of the vector 'trig' in my
TTree.
Neither

    TBranch* branch=treeRun->GetBranch("trig[1]");
    TLeaf* leaf=(TLeaf*)branch->FindLeaf("trig[1]");
    int trig=*( (Int_t*)leaf->GetValuePointer());

nor

    TBranch* branch=treeRun->GetBranch("trig");
    TLeaf* leaf=(TLeaf*)branch->FindLeaf("trig");
    int* trig=( (Int_t*)leaf->GetValuePointer());

is working!


Does someone has any idea how to handle that?


Cheers
Alexander



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET