Hi all, new to ROOT and my first post so please excuse anything I ask which may seem trivial.
I am having some issues in trying to put TVector3’s in a TTree and then accessing later. After searching around here, (I think) I determined from this thread ([url]Filling a TVector3 into a TTree that I want to fill the Tree as such:
TVector3* r1 = new TVector3;
TFile *f = new TFile("VDB.root","RECREATE");
TTree *tree = new TTree("VDB","VDB Tube Positions");
where my object r1 is a pointer.
However I was also a little confused when comparing this to the tutorial hvector.C )http://root.cern.ch/root/html/tutorials/tree/hvector.C.html) where a a different type of vector, std::vector, is filled in a tree. There the object there is created by:
TTree *t = new TTree("tvec","Tree with vectors");
where vpx is not a pointer. Are these two types of vectors completely different such that you need to use a pointer for one but not the other? Some clarification would be nice.
My other problem comes when I try to read this tree in a different MACRO. What I want to be able to do is read the TVector3 out of the TTree and then use normal operators (+,-,=, etc.) with other TVector3’s initiated in the new MACRO. I am unsure of the proper way to do this, and any way I have tried so far has resulted in a segmentation violation. Here is what I’ve tried which I thought had the best potential
TChain *chain = new TChain("VDB");
This gives a segmentation violation and presents a problem when I want to add this to a TVector3 from that MACRO since now r1 is a pointer. I also tried doing this where r1 is not a pointer, again sementation violation.
Thanks for the help.