Access of histogram to be fitted in user fit function

I’m using this user function for Breit Wigner fitting of histogram.

``````double Breit_Wigner(double *x, double *par)
{
// par[0] : Area
// par[1] : Mean
// par[2] : Width

double fitval = (1/(2*TMath::Pi()))*par[0]*par[2];
fitval /= ( (x[0]-par[1])*(x[0]-par[1]) + par[2]*par[2]/4 );
return fitval;
}``````

I would like to get the yield instead of the area with par[0].
If the user function can access the width of histogram to be fitted, it is possible like this.

``````double Breit_Wigner(double *x, double *par)
{
// par[0] : Yield
// par[1] : Mean
// par[2] : Width

double fitval = (1/(2*TMath::Pi()))*par[0]*par[2];
fitval /= ( (x[0]-par[1])*(x[0]-par[1]) + par[2]*par[2]/4 );
return fitval * gTH1->GetBinWidth(0);
}``````

How can we get the pointer of the histogram?

You can define a global variable (say gTH1) pointing to the histogram
or inside your Breit-Wigner function, do
TH1 myhist = (TH1)TVirtualFitter::GetFitter()->GetObjectFit()

Rene