Ordering on trees

Hi all,

When I am trying to save things in a TTree that I have created I am finding that it the values are not saved in the same order that they are put in there.

what I do:

{
#include <vector>  
std::vector<float> Angle;
TFile* f= new TFile("SomeFile.root","RECREATE");
TTree* MyTree = new TTree("MyTree","Blah");
MyTree->Branch("Angle",&Angle,"Angle/F");

for (int i=0;i<Nevents;i++)
 {
  Angle.clear();
   \\DO SOME STUFF TO CALCULATE "Angle"
  Angle.push_back(somevalue);
  MyTree->SetBranchAddress("Angle",&Angle[0]);
  MyTree->Fill();
 }//end of loop over events
MyTree->Write();
}//end of whole thing

And then when i go back and I make a plot of the calculated angle and the angle that I stored on my tree, I find that most of the time they agree, but sometimes they do not.

Did I have to do something extra to make sure that the angles are stored in the appropriate order?

thanks,

J

Hi,

did you have the time to try out the strategy proposed here root.cern.ch/root/htmldoc/tutori … tor.C.html ?
It deals exactly with your use case.