Error when creating a vector branch in pyroot

I’m trying to create a tree in python that mimics one created in a C++ framework, which can later be read in by that framework. I’m having trouble with one of the branches, a vector of unsigned ints.

In the C++ framework, it’s created this way:
std::vector m_level1TriggerInfo;

And later read like so:
std::vector m_level1TriggerInfo;

Which seems pretty straightforward. In my script, I create it and make a branch:
l1_info = ROOT.vector(‘unsigned int’)()
t_events.Branch(“Level1TriggerInfo”, ‘vector’, l1_info)
#t_events.Branch(“Level1TriggerInfo”, l1_info) #I tried this too…

But when I try to read it in in C++, I get the following error:
FTKFullSimulationBank0 13:44:09 Error in TTree::SetBranchAddress: The address for “Level1TriggerInfo” should be the address of a pointer!

Does anyone know what is causing this problem and how to fix it? BTW, using ROOT 6.04/16. Thanks!


you can have a look to this very complete post: Operation: SetBranchAddress

In general, the way we suggest to read trees is via the TTreeReader:
It has several advantages for example type safety and a more high level interface.

I hope this helps,