Hi Alexander,
With revision 30121 and higher of the svn trunk, you can now use;
if (tree->SetBranchAddress(mybranch,&myvar) < 0 ) {
cerr << "Something went wrong\n";
return;
}
> so that typeid returns rather strange names
This is the case for all C++ class.
> which I cannot compare against the ROOT internal names.
Yes but ROOT knows about the typeid string and you can use it via the line of code I recommended:
TClass *varclass = TClass::GetClass( typeid(T) );
(which is what SetBranchAddress uses).
> > or to catch the error message using a custom error message handler ... > I guess this would be the easiest way then.
It would not :).
> Could you point me to a tutorial / web page where this is described?
See the code for DefaultErrorHandler in core/base/src/TError.cxx (and call SetErrorHandler).
Cheers,
Philippe.
Alexander Mann wrote:
> Hi Philippe,
>
>> However what you can do in your routine is the following:
>> ...
>> This test is stricter than necessary but should work well enough.
>
> I tried to code sth like this myself, but it failed (like your
> proposal) because of the fact that I'm using STL objects (none derived
> from TObject or similar), so that typeid returns rather strange names
>
> ( ERROR ) P2C1V3 : ROOT Does not known about:
> PSt6vectorIfSaIfEE
>
> which I cannot compare against the ROOT internal names.
>
> Which is strange because ROOT actually knows both names (-> "The
> pointer type give (vector<bool>) does not correspond to the class
> needed (vector<int>) by the branch:"), but I was not able to extract
> the mechanism ROOT uses to produce these messages. (It's in some
> function called TTree::CheckBranchAddressType.)
>
>> or to catch the error message using a custom error message handler ...
>
> Could you point me to a tutorial / web page where this is described? I
> guess this would be the easiest way then.
>
> cu,
> Alexander
>
Received on Fri Sep 11 2009 - 18:49:23 CEST
This archive was generated by hypermail 2.2.0 : Fri Sep 11 2009 - 23:50:02 CEST