I am now having trouble invoking the linear fitter.
If I run the following code in cint I get the expected result:
$ root
FreeType Engine v2.1.9 used to render TrueType fonts.
Compiled on 1 November 2005 for linux with thread support.
CINT/ROOT C/C++ Interpreter version 5.16.2, July 14 2005
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] double dataArray[10]={1,2,3,4,5,6,7,8,9,10};
root [1] TH1D *h1LogGamma=new TH1D(“h1logGamma”,“Log Gamma Histogram;Bucket Number;ADC Log Value”,10,0.,11.);
root [2] h1LogGamma->FillN(10,dataArray,dataArray);
root [3] TF1 *innerGammaFit=new TF1(“innerGammaFit”,“1++x++log(x)”,0,20);
root [4] innerGammaFit->Print();
innerGammaFit : 1++x++log(x) Ndim= 1, Npar= 3, Noper= 12
fExpr[0] = [0] action = 140 action param = 0
fExpr[1] = 1 action = 141 action param = 0
fExpr[2] = * action = 3 action param = 0
fExpr[3] = [1] action = 140 action param = 1
fExpr[4] = x action = 144 action param = 0
fExpr[5] = * action = 3 action param = 0
fExpr[6] = + action = 1 action param = 0
fExpr[7] = [2] action = 140 action param = 2
fExpr[8] = x action = 144 action param = 0
fExpr[9] = log action = 30 action param = 0
fExpr[10] = * action = 3 action param = 0
fExpr[11] = + action = 1 action param = 0
Optimized expresion
fExpr[0] = [0],1,* action = 148 action param = 0
fExpr[1] = [1],x,* action = 148 action param = 0
fExpr[2] = + action = 1 action param = 0
fExpr[3] = [2] action = 146 action param = 2
fExpr[4] = x,log action = 147 action param = 0
fExpr[5] = * action = 3 action param = 0
fExpr[6] = + action = 1 action param = 0
Par 0 p0 = 0
Par 1 p1 = 0
Par 2 p2 = 0
root [5] h1LogGamma->Fit(innerGammaFit);
Fitting results:
Parameters:
NO. VALUE ERROR
0 0.500000 1.034926
1 0.909091 0.526501
2 0.000000 1.475368
TCanvas::MakeDefCanvas: created default TCanvas with name c1
But when I compile the following code (testFit.cc):
#include
#include “TH1D.h”
#include “TF1.h”
int main(){
double dataArray[10]={1,2,3,4,5,6,7,8,9,10};
TH1D *h1LogGamma=new TH1D(“h1logGamma”,“Log Gamma Histogram;Bucket Number;ADC Log Value”,10,0.,11.);
h1LogGamma->FillN(10,dataArray,dataArray);
TF1 *innerGammaFit=new TF1(“innerGammaFit”,“1++x++log(x)”,0,20);
innerGammaFit->Print();
std::cout<<std::endl<<“Will this fit?”<<std::endl;
std::cin.get();
h1LogGamma->Fit(“innerGammaFit”);
std::cout<<std::endl<<“Did this fit?”<<std::endl;
std::cin.get();
}
With g++:
g++ -ggdb -o testFit root-config --cflags
root-config --glibs
testFit.cc
Where:
root-config --cflags = "-pthread -I/home/demiller/ROOT5.06.00/root/include"
root-config --glibs = “-L/home/demiller/ROOT5.06.00/root/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -lm -ldl -rdynamic”
I get a crash when I call the fit:
OUTPUT:
$ ./testFit
innerGammaFit : 1++x++log(x) Ndim= 1, Npar= 3, Noper= 12
fExpr[0] = [0] action = 140 action param = 0
fExpr[1] = 1 action = 141 action param = 0
fExpr[2] = * action = 3 action param = 0
fExpr[3] = [1] action = 140 action param = 1
fExpr[4] = x action = 144 action param = 0
fExpr[5] = * action = 3 action param = 0
fExpr[6] = + action = 1 action param = 0
fExpr[7] = [2] action = 140 action param = 2
fExpr[8] = x action = 144 action param = 0
fExpr[9] = log action = 30 action param = 0
fExpr[10] = * action = 3 action param = 0
fExpr[11] = + action = 1 action param = 0
Optimized expresion
fExpr[0] = [0],1,* action = 148 action param = 0
fExpr[1] = [1],x,* action = 148 action param = 0
fExpr[2] = + action = 1 action param = 0
fExpr[3] = [2] action = 146 action param = 2
fExpr[4] = x,log action = 147 action param = 0
fExpr[5] = * action = 3 action param = 0
fExpr[6] = + action = 1 action param = 0
Par 0 p0 = 0
Par 1 p1 = 0
Par 2 p2 = 0
Will this fit?
*** Break *** segmentation violation
Generating stack trace…
0x001ad761 in TH1::Fit(TF1*, char const*, char const*, double, double) + 0x509 from /home/demiller/ROOT5.06.00/root/lib/
libHist.so
0x001ad24f in TH1::Fit(char const*, char const*, char const*, double, double) + 0x1a7 from /home/demiller/ROOT5.06.00/root/
lib/libHist.so
0x08048dc2 in main + 0x1e2 from ./testFit
0x0427379d in __libc_start_main + 0xed from /lib/tls/libc.so.6
0x08048b55 in std::ios_base::Init::~Init() + 0x31 from ./testFit
Abort
Can anyone explain this to me?
Thank you,
-David Eric Miller