Access to STL Classes: std.vector('TCanvas')()

Hi ROOT,

I was just looking through the root user guide on page 354 in the PyROOT and Ruby section.

Apparently I can make an STL object of ROOT objects e.g.

but i get the error,

Traceback (most recent call last): File "pyroot.py", line 9, in <module> v2 = std.vector('TCanvas') File "lib/ROOT.py", line 181, in __call__ result = _root.MakeRootTemplateClass( *newargs ) AttributeError: type object 'ROOT' has no attribute 'vector<TCanvas>'

any idea why?

few more questions,

question 1. How to I instantiate a vector of pointers?
I tried

but receive the error,

Traceback (most recent call last): File "pyroot.py", line 5, in <module> vec = std.vector("double*")() File "lib/ROOT.py", line 181, in __call__ result = _root.MakeRootTemplateClass( *newargs ) AttributeError: type object 'ROOT' has no attribute 'vector<double*>'

question 2. I am trying to import a class I wrote in c++ for which one of its members is,

which when loaded into PyROOT gives the error,

is there a fix around this?

Hi,

Try to generate the dictionary first;gInterpreter.GenerateDictionary("vector<double*>","vector"); gInterpreter.GenerateDictioanry("map<string, double*>","string;map");

Cheers,
Philippe.

I get the error

<ROOT.TCint object ("C/C++") at 0x10027cb60> Traceback (most recent call last): File "pyroot.py", line 6, in <module> gInterpreter.GenerateDictionary("vector<double*>","vector"); AttributeError: 'TCint' object has no attribute 'GenerateDictionary'

Hi,

Your version of ROOT must too old (you would need v5.28). See root.cern.ch/drupal/faq#n676 for alternative.

Cheers,
Philippe.

Hi,

I am now using root v5.28.00b (previously was v5.26/00)
and managed to generate a dictionary for the vector<double*> class.

But for the map<string, double*> class I receive the error,

[code]lxplus313 23:49 python pyroot.py
<ROOT.TCint object (“C/C++”) at 0x1c834bb0>
TClassTable::Add:0: RuntimeWarning: class vector<double,allocator >::iterator already in TClassTable
0
In file included from /tmp/rootcint_nYaVen.h:3,
from /tmp/Zf8z5T_cint.cxx:1:
/afs/cern.ch/user/d/dvoong/playgrounds/pyroot_c++user_classes/AutoDict_map_string__double_.cxx:2:16: error: map: No such file or directory
Error: external preprocessing failed. :0:
!!!Removing /afs/cern.ch/user/d/dvoong/playgrounds/pyroot_c++user_classes/AutoDict_map_string__double___cxx_ACLiC_dict.cxx /afs/cern.ch/user/d/dvoong/playgrounds/pyroot_c++user_classes/AutoDict_map_string__double___cxx_ACLiC_dict.h !!!
Error: /afs/cern.ch/sw/lcg/app/releases/ROOT/5.28.00a/x86_64-slc5-gcc43-opt/root/bin/rootcint: error loading headers…
Error in : Dictionary generation failed!
AutoDict_map_string__double
.cxx:2:16: error: map: No such file or directory
2

[/code]

my pyroot script

from ROOT import * print gInterpreter gInterpreter.GenerateDictionary("vector<double*>","vector"); gInterpreter.GenerateDictionary("map<string, double*>","string;map");

it’s working now, not sure why… but I’m happy

thanks a lot

error: map: No such file or directoryI suspect there was a stray space in the 2nd argument to GenerateDictionary.

Cheers,
Philippe.

I find that generating a dictionary works with maps in which entries corresponding to pointers to unsigned integers but does not work for pointers to [ints, floats or doubles]

with output,

TClass::TClass:0: RuntimeWarning: no dictionary for class pair<string,unsigned int*> is available <ROOT.map<string,unsigned int*> object at 0x105c8d880> track_eta: 2
works fine but,

returns with output

TClass::TClass:0: RuntimeWarning: no dictionary for class pair<string,int*> is available <ROOT.map<string,int*> object at 0x105852de0> pyroot.py:19: RuntimeWarning: return type not handled (using void): int*& print track.m_object_quantities["eta"] None

I’m not too sure what is going on with the run time error

which is seen in both cases but as I said, the first case seems to work (at first glance at least)

pyroot.py:19: RuntimeWarning: return type not handled (using void): int*& print track.m_object_quantities["eta"]This is seems a somewhat unrelated limitation of pyroot. Can you post a separate question on this.

Cheers,
Philippe.