Default canvas created during fit

Dear experts,

do you know the option to disable the the default canvas created during a fit?
I tried these options as 2d argument “N” or “O” without success. This is a piece of code[1]:
By doing that a default canvas with the histogram and the fit is created, and I want to disable this option?

I also tried: hrsp->GetFunction(“gaus”)->ResetBit(kNotDraw);
but then I have the error message:
use of undeclared identifier 'kNotDraw’
hrsp->GetFunction(“gaus”)->ResetBit(kNotDraw);

Do you know what is wrong?

[1]
code(){

hrsp->Fit(“gaus”, “QO”, “”, minGaus, xbinmax );
hrsp->GetFunction(“gaus”)->ResetBit(kNotDraw);

}

Regards

Use “Q0”, not “QO”.
See also the ‘Warning when using the option “0”’ in the TH1::Fit method description and use:
const Int_t kNotDraw = TF1::kNotDraw;
or simply:
hrsp->GetFunction(“gaus”)->ResetBit(TF1::kNotDraw);

Dear Coyote,

“0” option works fine in a statement like:
hrsp->Fit(“gaus”, “0”, “”, minGaus, xbinmax );

But when I defined my own fit and use “0” it does not work any more, I still have
a default canvas created, like:

void fit(){
TF1 *gausLeft{0};
string gaus {"[0]TMath::Exp(-0.5TMath::Power((x-[1])/[2],2))"};
gausLeft = new TF1(“gausLeft”, gaus.data(), newMinGausLeft, xbinmax);
hrsp->Fit(gausLeft,“0R+”);
}

Do you know why?

Regards

At least “gaus.data()” should be replaced with “gaus.c_str()”.
Note also that you are expected to initialize all three function’s parameters before trying to use it (this is not the case if you use the predefined “gaus”).

{ TH1F *h = new TH1F("h", "h", 100, -5, 5); h->FillRandom("gaus", 1000); #if 0 /* 0 or 1 */ h->Fit("gaus", "Q0+"); #else /* 0 or 1 */ std::string s("[0]*TMath::Exp(-0.5*TMath::Power((x-[1])/[2],2))"); TF1 *f = new TF1("f", s.c_str(), -2, 2); f->SetParameters(40, 0, 1); h->Fit(f, "Q0R+"); #endif /* 0 or 1 */ h->GetListOfFunctions()->ls(); // h->GetListOfFunctions()->Print(); }

Dear coyote,

ok, thank you for your answer.

Regards