Re: PyROOT and Athena: Cannot read LVL1NameMap

From: Alexander Mann <amann_at_uni-goettingen.de>
Date: Tue, 30 Nov 2010 10:31:55 +0100

Hi Philippe,

my problem arises from the fact that these lines:

import ROOT
f = ROOT.TFile("NTUP.root")
x = f.FindObjectAny("TrigConfTree")
x.GetEntry(0)
for t in [a.first for a in x.LVL1NameMap]:

   print t

work alright in Python, but in Athena I get:

Traceback (most recent call last):

   File "<stdin>", line 1, in <module>
TypeError: int& map<string,int>::operator[](const string& __k) =>

     could not convert argument 1

TrigConfTree is of type <ROOT.map<string,int> object at 0xad894e0>. The access via the at or [] operator does not work in Python either:

 >>> y = x.LVL1NameMap
 >>> y[0]
Traceback (most recent call last):

   File "<stdin>", line 1, in <module>
TypeError: int& map<string,int,less<string>,allocator<pair<const string,int> > >::operator[](const string& x) =>

     could not convert argument 1

But the list comprehension does work in Python, the following line will return a proper list:

[a.first for a in x.LVL1NameMap]

The reason for this is maybe a different dictionary? (or a different Python version used by Athena?)

cu,
Alexander

On 11/29/2010 11:39 PM, Philippe Canal wrote:
> Shortened traceback (most recent user call last):
> File "./ntuple_trigger_metstatus.py", line 66, in <module>
> for trigger in [y.first for y in x]:
> TypeError: int& map<string,int>::operator[](const string& __k) =>
> could not convert argument 1
>
> What are y and x? Is the argument to the map compatible with a string?
>
> Philippe.
>
> On 11/26/10 10:07 AM, Alexander Mann wrote:
>>
>> Hi,
>>
>> I have the same problem as described on
>>
>> http://root.cern.ch/phpBB3/viewtopic.php?f=14&t=11627
>>
>> My code runs within Python, but not within Athena. Unfortunately, the
>> solutions described in the forum do not help in my case :( I always get
>>
>> TClass::TClass:0: RuntimeWarning: no dictionary for class
>> AttributeListLayout is available
>> Shortened traceback (most recent user call last):
>> File "./ntuple_trigger_metstatus.py", line 66, in <module>
>> for trigger in [y.first for y in x]:
>> TypeError: int& map<string,int>::operator[](const string& __k) =>
>> could not convert argument 1
>> Py:Athena INFO leaving with code 8: "an unknown exception occurred"
>>
>> cu,
>> Alexander
>>
>> @tamsett: Can you send me the relevant parts of your code? A minimal
>> example just reading out the LVL1NameMap?
>>
Received on Tue Nov 30 2010 - 10:32:02 CET

This archive was generated by hypermail 2.2.0 : Tue Nov 30 2010 - 11:50:01 CET