Error in fitting data from an ASCII file

Hi,
after reading the tutorial, I tried to modify the example called intro1, switching from a gaussian to an exponential function. Everything works fine when I generate data from a distribution (both plotting and fitting). The next step was replace the generation from a function with data coming from a file. I can plot correctly my data but when i try to fit it crashes with errors.
For your knowledge I’m using Root 5.19/02 with RooFit v2.31.

This is my code:

[code]expo()
{
gSystem->Load(“libRooFit”);
using namespace RooFit;

RooRealVar pid(“pid”,“pid”,-600,600) ;
RooRealVar dectime(“dectime”,“dectime”,0,15) ;

// Build Gaussian PDF
RooRealVar x(“x”,“x”,0,15) ;
RooRealVar tau(“tau”,"",-0.714286,-1,-0.5) ;
RooExponential expo(“expo”,“expo PDF”,x,tau) ;

// Generate a toy MC set
// RooDataSet* data = expo.generate(x,500) ;
RooDataSet* data = RooDataSet::read(“MC/piddectime_1.txt”,RooArgList(pid,dectime));

// Fit pdf to toy
tau.setConstant(kFALSE) ;

expo.fitTo(*data,Range(0.1,8),Minos(false)) ;

// Plot PDF and toy data overlaid
RooPlot* xframe2 = dectime.frame() ;
data->plotOn(xframe2) ;
expo.plotOn(xframe2) ;
xframe2->Draw() ;

// Print final value of parameters
tau.Print() ;
}
[/code]

and this is the error:

[#0] ERROR:Plotting -- RooExponential::expo:plotOn: WARNING: variable is not an explicit dependent: dectime

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Attaching to program: /proc/28202/exe, process 28202
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread -1208943808 (LWP 28202)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
0x005b67a2 in _dl_sysinfo_int80
    () from /lib/ld-linux.so.2
#1  0x01b8d7e3 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2  0x01b37649 in do_system () from /lib/tls/libc.so.6
#3  0x002408bd in system () from /lib/tls/libpthread.so.0
#4  0x0078b34b in TUnixSystem::Exec () from /nfs/cern/root5.19/lib/libCore.so
#5  0x00790df9 in TUnixSystem::StackTrace () from /nfs/cern/root5.19/lib/libCore.so
#6  0x0078da16 in TUnixSystem::DispatchSignals () from /nfs/cern/root5.19/lib/libCore.so
#7  0x0078daa4 in SigHandler () from /nfs/cern/root5.19/lib/libCore.so
#8  0x0078ccf1 in sighandler () from /nfs/cern/root5.19/lib/libCore.so
#9  <signal handler called>
#10 0x068ae967 in RooAbsPdf::plotOn () from /nfs/cern/root5.19/lib/libRooFitCore.so
#11 0x068b2b3b in RooAbsReal::plotOn () from /nfs/cern/root5.19/lib/libRooFitCore.so
#12 0x0688faaa in RooAbsPdf::plotOn () from /nfs/cern/root5.19/lib/libRooFitCore.so
#13 0x069cd4d8 in G__G__RooFitCore1_164_0_44 () from /nfs/cern/root5.19/lib/libRooFitCore.so
#14 0x00bef99f in Cint::G__ExceptionWrapper () from /nfs/cern/root5.19/lib/libCint.so
#15 0x00ca54ad in G__call_cppfunc () from /nfs/cern/root5.19/lib/libCint.so
#16 0x00c8b741 in G__interpret_func () from /nfs/cern/root5.19/lib/libCint.so
#17 0x00c7a94b in G__getfunction () from /nfs/cern/root5.19/lib/libCint.so
#18 0x00d33609 in G__getstructmem () from /nfs/cern/root5.19/lib/libCint.so
#19 0x00d2b676 in G__getvariable () from /nfs/cern/root5.19/lib/libCint.so
#20 0x00c5fe32 in G__getitem () from /nfs/cern/root5.19/lib/libCint.so
#21 0x00c62c83 in G__getexpr () from /nfs/cern/root5.19/lib/libCint.so
#22 0x00cd229b in G__exec_statement () from /nfs/cern/root5.19/lib/libCint.so
#23 0x00c8c47a in G__interpret_func () from /nfs/cern/root5.19/lib/libCint.so
#24 0x00c7a7ce in G__getfunction () from /nfs/cern/root5.19/lib/libCint.so
#25 0x00c60158 in G__getitem () from /nfs/cern/root5.19/lib/libCint.so
#26 0x00c62c83 in G__getexpr () from /nfs/cern/root5.19/lib/libCint.so
#27 0x00c6b11c in G__calc_internal () from /nfs/cern/root5.19/lib/libCint.so
#28 0x00cddc3e in G__process_cmd () from /nfs/cern/root5.19/lib/libCint.so
#29 0x0075dcdf in TCint::ProcessLine () from /nfs/cern/root5.19/lib/libCore.so
#30 0x0075de54 in TCint::ProcessLineSynch () from /nfs/cern/root5.19/lib/libCore.so
#31 0x006ccbd7 in TApplication::ExecuteFile () from /nfs/cern/root5.19/lib/libCore.so
#32 0x006ccefa in TApplication::ProcessFile () from /nfs/cern/root5.19/lib/libCore.so
#33 0x006caf22 in TApplication::ProcessLine () from /nfs/cern/root5.19/lib/libCore.so
#34 0x0011ce99 in TRint::Run () from /nfs/cern/root5.19/lib/libRint.so
#35 0x08048d46 in main ()
Root > Function expo() busy flag cleared

thanks a lot for your help
ciao
giordano

Hi Giordano,

I’d like to debug your problem. Can you send me your data file?
Somewhat unfortunately I’m about to be away for ~1.5 weeks,
so it will take a little while.

Wouter

Thanks a lot Wouter.
I just renamed the file to .cpp from .cc just to attach it.
piddectime_1.txt (86.8 KB)
expo.cpp (776 Bytes)

[quote=“Wouter Verkerke”]Hi Giordano,

I’d like to debug your problem. Can you send me your data file?
Somewhat unfortunately I’m about to be away for ~1.5 weeks,
so it will take a little while.

Wouter[/quote]

problem solved. i called x what it should have been called dectime. sorry for disturbing you.