I am running into an infinite loop when starting the FitEditor. It seems to be connected to the existence of a custom subclass of TF1, but I can’t see anything out of the ordinary with the subclass. A minimum example that reproduces the issue is as follows, using root6.06/02.
In GGaus.hh, I define a subclass of TF1. This is a stripped down example, as my main code has more features to it.
#ifndef GGAUS_H
#define GGAUS_H
#include "TF1.h"
class GGaus : public TF1 {
public:
GGaus() : TF1("gausbg","gaus(0)+pol1(3)") { }
GGaus(double xlow, double xhigh)
: TF1(Form("gausbg_%d_to_%d", (int)xlow, (int)xhigh),
"gaus(0) + pol1(3)", xlow, xhigh) {
}
private:
ClassDef(GGaus,1)
};
#endif
In my LinkDef.h,
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class GGaus+;
#endif
To compile this, I run the following commands.
rootcling -f Dictionary.cc -c -I. GGaus.hh LinkDef.h
g++ `shell root-config --cflags` -I. -fPIC -shared -o libAnalysis.so Dictionary.cc
I have a test script that I can run as follows.
username@hostname ~/temp $ cat test.C
void test(){
// Generate a reasonable histogram for the fit function.
TH1* hist = new TH1F("hist","hist",200,0,200);
for(int i=0; i<2e4; i++) {
hist->Fill(gRandom->Uniform(0,200));
hist->Fill(gRandom->Gaus(70, 15));
}
hist->Draw();
// Construct my custom class, set default parameters.
GGaus* gaus = new GGaus(0,200);
gaus->SetParameters(100,70,15,15,0);
// Fit the histogram
hist->Fit(gaus);
// Open the fit panel
std::cout << "before" << std::endl;
hist->FitPanel();
std::cout << "after" << std::endl;
}
username@hostname ~/temp $ root -n
root [0] gSystem->Load("libHist.so");
root [1] gSystem->Load("libAnalysis.so");
root [2] .x test.C
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
FCN=199.125 FROM MIGRAD STATUS=CONVERGED 184 CALLS 185 TOTAL
EDM=4.84367e-10 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 1.8 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 5.31126e+02 5.42544e+00 -6.92829e-03 1.60535e-06
2 p1 6.96843e+01 1.45362e-01 1.80876e-04 -1.31359e-04
3 p2 1.51326e+01 1.42370e-01 3.77597e-04 -4.82442e-05
4 p3 9.75654e+01 1.97032e+00 2.43662e-03 3.41978e-05
5 p4 7.06457e-03 1.41665e-02 1.72091e-06 3.59065e-03
before
I expect to see both print messages occur. Instead, I see only the print message from before the call to TH1::FitPanel. The program hangs, and must be stopped with Ctrl-C. During this time, CPU usage is at 100%, and I see a steady increase in memory usage.