Some errors/warnings when calling fitter.Result().Print(...)

Hi,

when I run this script (test.py which requires also myimodel.C and myfcn.C):

[code]import ROOT
from array import array

ROOT.gROOT.ProcessLine(".L myimodel.C++g")
ROOT.gROOT.ProcessLine(".L myfcn.C++g")

x = array(‘d’,[1.])
p = array(‘d’,[1,2])

fitter = ROOT.Fit.Fitter()
fitdata = ROOT.Fit.BinData(1000,1,ROOT.Fit.BinData.kNoError)
fitdata.Add(0,1)
fitdata.Add(1,2)
fitdata.Add(2,3)

myimodel = ROOT.MyIModel()
myfun = ROOT.MyFCN(fitdata,myimodel)
fitter.FitFCN(myfun,p,3)

fitter.Result().Print(ROOT.cout,ROOT.true)[/code]

I get this output (results of the fit seems to be OK and are omited…):

Info in <TUnixSystem::ACLiC>: creating shared library /home/jiri/workspace/./myimodel_C.so Info in <TUnixSystem::ACLiC>: creating shared library /home/jiri/workspace/./myfcn_C.so Error in <TClass::New>: cannot create object of class basic_ostream<char,char_traits<char> > Error in <TClass::New>: cannot create object of class basic_ios<char,char_traits<char> > Error in <TClass::New>: cannot create object of class ios_base TStreamerInfo::Build::0: RuntimeWarning: basic_ios<char,char_traits<char> >: base class ios_base has no streamer or dictionary it will not be saved TStreamerInfo::Build::0: RuntimeWarning: basic_ostream<char,char_traits<char> >: base class basic_ios<char,char_traits<char> > has no streamer or dictionary it will not be saved ...

i.e. several errors/warnings. The are caused by the last line in the test.py:

fitter.Result().Print(ROOT.cout,ROOT.true)

If one converts the test.py to equivalent test.C script (see attachment) and run test.C under CINT then there are no errors/warnings in the output.

Is there any way how to fix the errors and warnings if one uses pyroot?

Thank you in advance,
Jiri

ROOT revision 34604
myfcn.C (237 Bytes)
myimodel.C (1.3 KB)
test.C (449 Bytes)
test.py (437 Bytes)

Jiri,

can’t compare to the .C as it yields:

root.exe: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)’ failed.

on my box.

As for the .py, the issue isn’t in the call but in accessing cout. I’ve never seen it used to be honest, so I’m surprised it works. :slight_smile: But at issue appears to be missing base classes … However, if I generate them, I get:

[code]>>> from ROOT import *

gROOT.LoadMacro( “ios_base.C+” )
Info in TUnixSystem::ACLiC: creating shared library /home/wlav/./ios_base_C.so
Note: Link requested for already precompiled class basic_ios<char,char_traits > (ignore this message) :0:
Note: Link requested for already precompiled class basic_ostream<char,char_traits > (ignore this message) :0:
0
ROOT.cout
<ROOT.basic_ostream<char,char_traits > object at 0xb5301e00>
[/code]
Truly odd: CINT clearly does need them, but thinks they already exist? Perhaps a load order problem … I’ll have a further look.

Later,
Wim

Hi Wim,

[quote]can’t compare to the .C as it yields:

root.exe: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)’ failed[/quote]

wow :open_mouth:; for me .C works without problems :slight_smile: (just the function inside test.C shoud be also named “test” and not “start”, my mistake)

You are right, it is just cout related problem, which may be reproduced also like this:

[code]user@pc ~> python
Python 2.6.5 (r265:79063, Apr 1 2010, 05:28:39)
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
ROOT.cout
Error in TClass::New: cannot create object of class basic_ostream<char,char_traits >
Error in TClass::New: cannot create object of class basic_ios<char,char_traits >
Error in TClass::New: cannot create object of class ios_base
TStreamerInfo::Build::0: RuntimeWarning: basic_ios<char,char_traits >: base class ios_base has no streamer or dictionary it will not be saved
TStreamerInfo::Build::0: RuntimeWarning: basic_ostream<char,char_traits >: base class basic_ios<char,char_traits > has no streamer or dictionary it will not be saved
<ROOT.basic_ostream<char,char_traits > object at 0x7fad25dafc80>[/code]

It would be probably better not to use cout at all from python but the function fitter.Result().Print(ROOT.cout,ROOT.true) unfortunally requires cout (ostream&) , so I can’t avoid using it…

Cheers,
Jiri

Jiri,

the issue comes up when trying the get the actual class of the given class: TClass* clActual = klass->GetActualClass( address );
combined with the virtual inheritance of basic_ostream.

I’ve changed (in SVN trunk) the code to not cast in case the class inherits from ios_base, and I’m following up with Axel in case there’s a better solution.

Cheers,
Wim

and the errors and warnings have disappeared :smiley: . It works at least in my case but I also don’t know whether it is the best solution…

Thanks,
Jiri

Jiri,

Axel improved the error message, which is good, but … I’ll leave the filter in place.

Cheers,
Wim

Hi,

I may just verify that after ‘svn update’ I see no disturbing errors/warnings. Thank you :slight_smile:

Cheers,
Jiri