Writing a vector in to a tree and reading it

I am trying to write a vector to a tree as a branch. Tha attached testW.C does this. And it produces testW.root output file.

I use testR.C to read the tree.

I use compile method. Both compile fine. I use root version 5.12.0.

But somethings are wrong in my codes. Here are my questions:

  1. testW.C wites the vector to the tree. But when i scan the tree, i get the below awkward number… Is this normal, is this because i use a vector? Or i couldn’t fill my vector in to the tree?

root [0]
Attaching file testW.root as _file0…
root [1] t->Scan()

  • Row * a *

  •    0 * 2.249e-33 *

root [2]

  1. testR.C compiles fine too. But it crashes when i run it. It doesn’t read the numbers i filled in to the vector. Is this because there is something wrong in testR.C or is it because the root file doesn’t contain the vector properly?

Thanks for the help.
testW.root (4.59 KB)
testR.C (476 Bytes)
testW.C (463 Bytes)


You need to load the dictionary for the vector
For that use:gROOT->ProcessLine("#include <vector>");