However the tutorial macro doesn’t compile for me:
$ root -l -b -q hvector.C++
root [0]
Processing hvector.C++…
Info in TUnixSystem::ACLiC: creating shared library /nfs/home/efeng/./hvector_C.so
Note: Link requested for already precompiled class vector<float,allocator > (ignore this message) :0:
In file included from /nfs/home/efeng/./fileiA66ET.h:32,
from /nfs/home/efeng/./fileiA66ET.cxx:16:
/nfs/home/efeng/./hvector.C: In function void write()': /nfs/home/efeng/./hvector.C:39: error: invalid conversion fromstd::vector<float, std::allocator >’ to Int_t' /nfs/home/efeng/./hvector.C:39: error: initializing argument 2 ofvirtual Int_t TTree::Branch(const char, Int_t, Int_t)’
It appears that it cannot find a suitable implementation of TTree::Branch() that takes these arguments. What should I do?
Upgrade to v5.22. The tutorials on the web site pertains to the latest release.
Alternatively in v5.18 you will need to use something like:
std::vector<float> *myp = new std::vector<float>();
....
tree->Branch("mybranch","vector<float>",&myp);
Thanks but I’m stuck to this ROOT version which is associated to a software release for the ATLAS experiment. Is there an example of the correct syntax that I can use in this version?
I imagine something like:
std::vector *vecPt = new std::vector;
mytree->Branch(“Pt”, &vecPt);
However, while this compiles I get an empty branch.
Thanks,
Eric
[quote=“pcanal”]Hi,
Upgrade to v5.22. The tutorials on the web site pertains to the latest release.
Alternatively in v5.18 you will need to use something like:
std::vector<float> *myp = new std::vector<float>();
....
tree->Branch("mybranch","vector<float>",&myp);
[quote=“pcanal”][quote]I imagine something like:
std::vector *vecPt = new std::vector;
mytree->Branch(“Pt”, &vecPt); [/quote]Yes this should also work.
It should have worked, assuming that you filled the vector you created with the call to operator new.
Cheers,
Philippe.,[/quote]
Hi Philippe,
I see now (partly) what the problem is. My branches aren’t empty, but I’m having some problems reading them. I’ve attached an example ROOT file.
If I just open a TBrowser, I can draw all the branches fine.
However, I need to create a macro. So I call:
CollectionTree->MakeClass(“analysis”)
Then edit analysis.h: #include
using namespace std;
Then compile class and load tree:
.L analysis.C++
analysis A
tree = A.fChain
Finally I can scan any branches with primitives, and vectors of ints. But strangely I cannot scan vector of doubles:
tree->Scan(“NPhot”) //integer – works
tree->Scan(“PhotNTrack”) //vector – works
tree->Scan(“PhotPt”) //vector – FAILS
Do you have any idea why this might be? My ROOTSYS is:
root/5.18.00d/slc4_ia32_gcc34/
The machine is actually 64-bit, but have specified to run in 32-bit compatibility mode (standard for ATLAS software).