How to save a TVector in a Tree?

Dear ROOT experts,
I have got a problem while using TVectors of floats.
I’d like to save a TVectorF (with non define size) in a tree named tree but my method doesn’t work: :blush:

TFile *hfile = new TFile("event.root","RECREATE");
TTree *tree = new TTree("DAQ16/03/09", "DATA_capteurs");
TVectorF vect_pos;
tree->Branch("vect_pos", "TVector" ,&vect_pos);

 while (!feof(Dgain))
{
//Get Size --> nbcan
........
vect_pos.Clear();
vect_pos.ResizeTo(nb_can);
//Fill The TVector
.......
tree->Fill();
}

  tree->Write();
  hfile->Close();

If it is possible, please also teach me how to save my TVector preperly.
thanks


My ROOT Version : 5.08/00

Hi,

In v5/08, you must pass the address of a pointer (not the address of an object) to TTree::Branch.

Cheers,
Philippe.

I’m sorry but it still doesn’t work … I must have missed something

I’v tried

	TVectorF vect_pos;
	TVectorF *Vect_pos = &vect_pos;
        tree->Branch("Vect_pos",&Vect_pos);

But it cause that warning and a TFile with no keys

Warning in <TTree::Bronch>: TVectorF cannot be split, resetting splitlevel to 0

Thanks for your help !

Cheers,
Philippe.

thanks for all

here is what worked

  TFile *hfile = new TFile(event.root,"RECREATE");
  TTree *tree = new TTree("daqroot", "DATA_capteurs");
  
  TVectorF *vect_pos = new TVectorF(0);
  tree->Branch("vect_pos",&vect_pos,32000,0);  

/*_______A PROPOS DES TVectors__________________
//http://root.cern.ch/root/html400/TVectorF.html
	TVectorF *test = new TVectorF(X);
	test->Clear; //effacer
	test->ResizeTo(); //redim
	test->GetNoElements();//nombre d'element
	test->GetLwb();//borne min
	test->GetUpb();//borne max
	(*test)(i) = X; //remplire au rang i avec X
	test->Print(); //montrer le vecteur	
*/

tree->Fill();
tree->Write();  
hfile->Close();