cate@catelenovolinux:~/Work/DijetResonances2012Full/BCH/TileTripReaderMapping/MakeMapOfTrips$ python MakeMapOfTripsGRL.py
TClass::TClass:0: RuntimeWarning: no dictionary for class TripRegion is available
Note: (file "(tmpfile)", line 2) File "vector" already loaded
<ROOT.vector<TripRegion> object at 0x323ee10>
Traceback (most recent call last):
File "MakeMapOfTripsGRL.py", line 45, in <module>
print len(TripRegions)
TypeError: object of type 'vector<TripRegion,allocator<TripRegion> >' has no len()
My first guess would be that I have to generate a dictionary for the struct, but even in that case I’d appreciate guidance as I’ve never done it before and my basic attempts following root.cern.ch/drupal/content/how- … dictionary have not succeeded.
yes, a dictionary is needed. If the header for the class (which I presume to be TripRegion.h, change as appropriate) is accessible from a standard include path or local directory, then this should do:ROOT.gInterpreter.GenerateDictionary("vector<TripRegion>","TripRegion.h;vector")
If you need more details, then let us know what “not succeeded” means in your case.
and I can use the standard attributes of a stl::vector. I suspect my previous attempt failed because the full header was too complicated to process (the struct was inside another class and CINT tried to generate a dictionary for the entire thing), and now that the struct is in its separate header it works.
I now have a followup question on how to access the attributes of my struct:
<ROOT.vector<TripRegion> object at 0x2fb02c0>
2
<ROOT.TripRegion object at 0x2fb0410>
Traceback (most recent call last):
File "MakeMapOfTripsGRL.py", line 47, in <module>
print TripRegions[0].eta1
AttributeError: 'TripRegion' object has no attribute 'eta1'