Array as Leaf in TTree

Dear All,

I want to create several leaves inside a Branch where leaves are arrays. I am trying to explain this with a simple branch from that particular section of the code.

[code]///a data member in header file
int _plns[10][2];

/// Now inside .cpp+++++++

///vector of trajectories
std::vector<Trajectory*> &trajs = Fit.get_trajs();

//total number of trajectories
_trajs_no = trajs.size();

//loop over trajectories
for(int i=0; i<_trajs.size(); i++ ){
_plns[i][0] = (int)(trajs[i]->quality(“nplanes”)) ;
_plns[i][1] = (int)(trajs[i]->quality(“freeplanes”)) ;

cout<<"nplanes= “<<_plns[i][0]<<” freeplanes = "<<_plns[i][1]<<endl;

///while filling the tree
Tree->Branch(“TrajectoryNo”, &_trajs_no, “trajNo/I”);
Tree->Branch(“NoPlanes”, _plns, “nplanes[trajNo]/I:freeplanes[trajNo]/I”);
[/code]

There is no execution error., however when I am getting the leaf information from the tree, nplanes and freeplanes are giving the same value. The are actual values are different , e.g, planes =60, freeplanes =50 ; the print (cout) is giving the correct value. However from tree I am getting nplanes =60, freeplanes =60 for a particular event.

Please can anyone help me, it will be really fruitful for me. I apologize I could not send a running code.

Regards,
Tapasi

Hi,

I recommend your clarify the code as follow (as it is I think the order of things is not what you and/or TTree are expecting):[code]///a data member in header file
int _plns[10];
int _freeplns[10];

/// Now inside .cpp+++++++

///vector of trajectories
std::vector<Trajectory*> &trajs = Fit.get_trajs();

//total number of trajectories
_trajs_no = trajs.size();

//loop over trajectories
for(int i=0; i<_trajs.size(); i++ ){
_plns[i] = (int)(trajs[i]->quality(“nplanes”)) ;
_freeplns[i] = (int)(trajs[i]->quality(“freeplanes”)) ;

cout<<"nplanes= “<<_plns[i]<<” freeplanes = "<<_freeplns[i]<<endl;

///while filling the tree
Tree->Branch(“TrajectoryNo”, &_trajs_no, “trajNo/I”);
Tree->Branch(“NoPlanes”, _plns, “nplanes[trajNo]/I”);
Tree->Branch(“FreePlanes”, _freeplns, “freeplanes[trajNo]/I”);[/code]

Cheers,
Philippe.