Std::vector of TLorentzVector

Hello,

I would like to store in some output tree a ROOT.std.vector(ROOT.TLorentzVector())() .
If I store a branch with ROOT.TLorentzVector, it works.
If I store a branch with ROOT.std.vector(float)(), it works.
But if I combine both, it fails probably due to missing dictionnary.
Do you know what code I should add to make it work with pyroot ?

Thanks a lot in advance,
Renaud

ps : I’m using 5.18.00d and have to stick to it.

Hi,

Write a file loader.C// Loader.C #include "TLorentzVector.h" #include <vector> #ifdef __MAKECINT__ #pragma link C++ class vector<TLorentzVector>+; #endifand use with:gROOT.ProcessLine(".L loader.C+")

Cheers,
Philippe.

Hi,

just one additional question, I need 2D-vectors, so it is straight forward to declare something like:

#pragma link C++ class vector<TLorentzVector>+;
#pragma link C++ class vector< vector < TLorentzVector > >+;

that also works, but which class should I use if I want to do the same with ints and floats?
When I use something like this:

v=std.vector(std.vector(int))()
v does not know the append function and I cannot use v for anything.

Cheers
Duc

Duc,

same thing: a dictionary needs to be generated for the vector of vector of ints. In some experiments (e.g. ATLAS), there are standard libs that already contain (Reflex) dictionaries of such containers. Otherwise, follow the same recipe as for the vector of TLorentzVector.

Cheers,
Wim

Hi Wim,

I followed your instructions above but I get the following error:

Info in <TUnixSystem::ACLiC>: creating shared library /home/vm1023/ZeroLeptonTestArea/./loadVector_C.so
Traceback (most recent call last):
  File "./createNewTrees.py", line 56, in <module>
    jetInfo = ROOT.std.vector(ROOT.TLorentzVector())
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/lib/cppyy.py", line 90, in __call__
    result = _backend.MakeRootTemplateClass( *newargs )
SystemError: error return without exception set

as you can see, I’m using ROOT6
Any help is highly appreciated.

Thanks,
Veronika

Veronika,

that’s a clearly a bug. Recommend filing one on Jira. (ATLAS pulled me off PyROOT some time ago, so I’m no longer maintaining it, but the ROOT team still is.)

Best,
Wim

Hi Wim,

thanks for your quick reply.
I’ll fill the JIRA ticket and hope for a fix :slight_smile:

Hi Veronika,

we’ll look into this error message but the right syntax to get a std::vector should be

>>> ROOT.std.vector(ROOT.TLorentzVector)
<class 'cppyy.vector<TLorentzVector>'>

You still need a dictionary for such collection if you want to do I/O with it.

Cheers,
Danilo