Re: Loading a user-defined function in ROOT

From: Tomasz Bold <bold_at_fatcat.ftj.agh.edu.pl>
Date: Wed, 19 Jan 2005 17:24:50 +0100


Hi,
Consider an example which works for me:
I have function simplef() defined in simplef.C double simplef ()
{

double a = 1;
double b = 4;
return a+a+b;

}

I run root and load this function:

root [1] gROOT->LoadMacro("simplef.C")
(Int_t)0
root [2] simplef(
double simplef()
root [2] simplef()

(double)6.00000000000000000e+00

root [3] .! emacs &
 >>>> here I edit my function settng paramater b = 8
 >>>> reaload by caling the same method LoadMacro and call.
 >>>> Indeed the function was reloaded.



root [4] gROOT->LoadMacro("simplef.C")
(Int_t)0
root [5] simplef()

(double)1.00000000000000000e+01

The reult is different and correct. So I guess you should simple recall LoadMacro
Probablu the method ls() called on list yields in crash. Indded having look ath the TList class methods
http://root.cern.ch/root/html/TList.html and this class pedecessors there is no method ls().
Good luck,
tb

Germano Percossi wrote:

> Hi everybody,
> I've subscribed only a few time ago this ML and surely this question
> has been answered in another thread. I apologize in advance if this is
> the case.
> Anyway, I have some problems loading a function written by me; I load
> the function with
>
> gROOT->LoadMacro("name_of_file_of_my_func")
>
> with previous versions I used .L to load it.
> If I'd need to change my function is there a way to unload the old one
> and load a new one?
> Till now I load the new one with the same name, hoping to do the right
> thing but typing
>
> root [56] gROOT->GetListOfGlobalFunctions()->ls()
>
> I had the errors written at the end of the e-mail and I cannot do
> anything else than kill root from another shell. I've done anything
> wrong? Is there any workaround?
> I'm running a precompiled version of root (v4.00.04 with gcc 3.3.2) on
> a Linux machine with gcc 3.4.1.
>
> Greets, Germano Percossi
>
> *** Break *** segmentation violation
> Generating stack trace...
> 0x406470f7 in G__interpret_func + 0x1692 from
> /usr/local/root/lib/libCint.so
> 0x4063cc83 in G__compile_bytecode + 0x203 from
> /usr/local/root/lib/libCint.so
> 0x406cad05 in G__MethodInfo::GetBytecode() + 0x5d from
> /usr/local/root/lib/libCint.so
> 0x4018baff in TFunction::InterfaceMethod() const + 0x31 from
> /usr/local/root/lib/libCore.so
> 0x4017a011 in TCint::UpdateListOfGlobalFunctions() + 0x111 from
> /usr/local/root/lib/libCore.so
> 0x40139b04 in TROOT::GetListOfGlobalFunctions(bool) + 0xac from
> /usr/local/root/lib/libCore.so
> 0x402c7788 in <unknown> from /usr/local/root/lib/libCore.so
> 0x40656373 in G__call_cppfunc + 0x258 from /usr/local/root/lib/libCint.so
> 0x40646163 in G__interpret_func + 0x6fe from
> /usr/local/root/lib/libCint.so
> 0x4062b1d5 in G__getfunction + 0x12b4 from /usr/local/root/lib/libCint.so
> 0x406b335a in G__getstructmem + 0x235 from /usr/local/root/lib/libCint.so
> 0x406aca12 in G__getvariable + 0x4a9 from /usr/local/root/lib/libCint.so
> 0x406b38c9 in G__getstructmem + 0x7a4 from /usr/local/root/lib/libCint.so
> 0x406aca12 in G__getvariable + 0x4a9 from /usr/local/root/lib/libCint.so
> 0x406228fe in G__getitem + 0x5bf from /usr/local/root/lib/libCint.so
> 0x40621524 in G__getexpr + 0x77ec from /usr/local/root/lib/libCint.so
> 0x4066bad2 in G__exec_function + 0x1d5 from
> /usr/local/root/lib/libCint.so
> 0x40672619 in G__exec_statement + 0x23bd from
> /usr/local/root/lib/libCint.so
> 0x4060ab1d in G__exec_tempfile_core + 0x2bd from
> /usr/local/root/lib/libCint.so
> 0x4060acee in G__exec_tempfile_fp + 0x22 from
> /usr/local/root/lib/libCint.so
> 0x4067a767 in G__process_cmd + 0x471a from /usr/local/root/lib/libCint.so
> 0x401799bf in TCint::ProcessLine(char const*,
> TInterpreter::EErrorCode*) + 0xa9 from /usr/local/root/lib/libCore.so
> 0x400f1470 in TApplication::ProcessLine(char const*, bool, int*) +
> 0x596 from /usr/local/root/lib/libCore.so
> 0x40e74f4f in TRint::HandleTermInput() + 0x1dd from
> /usr/local/root/lib/libRint.so
> 0x40e73d3a in TTermInputHandler::Notify() + 0x24 from
> /usr/local/root/lib/libRint.so
> 0x40e759de in TTermInputHandler::ReadNotify() + 0x12 from
> /usr/local/root/lib/libRint.so
> 0x401e6388 in TUnixSystem::CheckDescriptors() + 0xf2 from
> /usr/local/root/lib/libCore.so
> 0x401e5bdd in TUnixSystem::DispatchOneEvent(bool) + 0xf7 from
> /usr/local/root/lib/libCore.so
> 0x40147df0 in TSystem::InnerLoop() + 0x18 from
> /usr/local/root/lib/libCore.so
> 0x40147d95 in TSystem::Run() + 0x6f from /usr/local/root/lib/libCore.so
> 0x400f2069 in TApplication::Run(bool) + 0x2d from
> /usr/local/root/lib/libCore.so
> 0x40e74a2e in TRint::Run(bool) + 0x30a from
> /usr/local/root/lib/libRint.so
> 0x08048e45 in main + 0x71 from /usr/local/root/bin/root.exe
> 0x40fb6ea0 in __libc_start_main + 0xe0 from /lib/tls/libc.so.6
> 0x08048d45 in TApplicationImp::ShowMembers(TMemberInspector&, char*) +
> 0x31 from /usr/local/root/bin/root.exe
> Root > Function Energy() busy flag cleared
> Function () busy flag cleared
> Function () busy flag cleared
> Function () busy flag cleared
> Function () busy flag cleared
> Function () busy flag cleared
> Function () busy flag cleared
>
Received on Wed Jan 19 2005 - 17:34:40 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET