ROOT Version: 5.34/36
Platform: Windows 10 - 64 Bit
Compiler: Not Provided
Dear Root-Community,
I’m using root on Windows 10. Since I don’t have Visual Studio available, I only work with the interpreter.
For using classes in my macros I tend to load them with:
gROOT->ProcessLine(.L “scriptname”)
run my code and afterwards do:
gROOT->ProcessLine(.U “scriptname”)
Normally that worked fine. However, it seems that when I try fitting a function in a loaded class object, the error:
Error: Cint::G_CallFunc::SetArgArray() must be initialized with ‘Cint::G__CallFunc::SetFunc(G__ClassInfo* cls,char* fname,char* args,long* poffset)’ first
appears - only if I unload the class afterwards.
Here is a small example:
HistFit.cxx
class HistFit: public TObject
{
public:
HistFit(){};
void FitHist();
static Double_t Lin1D(Double_t* x, Double_t* par);
};
void HistFit::FitHist()
{
TH1D* hist=new TH1D("hist","",5,0,4);
hist->Fill(1,2);
hist->Fill(2,4);
hist->Fill(3,6);
hist->Draw();
TF1* lin=new TF1("Lin1D",HistFit::Lin1D,0,4,2);
hist->Fit("Lin1D","R");
lin->Draw("same");
}
static Double_t HistFit::Lin1D(Double_t* x, Double_t* par)
{
return(par[0]+par[1]*x[0]);
}
main.cxx
void main()
{
gROOT->ProcessLine(".L HistFit.cxx");
HistFit* hf= new HistFit();
hf->FitHist();
gROOT->ProcessLine(".U HistFit.cxx");
}
In this case calling the main function leads to the decribed error.
Is the error caused by some remaining memory occupied by the fit function? Is there a possiblity to unload the class afterwards? If not one might be able to recommend me another way to load classes into a main macro.
Thanks for reading.
Cheers,
Daniel