Hello All,

I have a TF2 function.I need to integrate it over each bin.I tried to use TH2F->Fit

option “I” but that didn’t work.I mean the histogram is not pop-up.

Is there a way to do it manually?

Here is my few lines of the code(this is not a running code)

```
Double_t Likelihood(Double_t *val,Double_t *par){
double kBeam=10.6;
const double MpSq=0.9383*0.9383;
Float_t x = val[0];
Float_t y = val[1];
Double_t result=0;
Double_t func=0;
if ((y<QSqMin)||(y>QSqMax)) return result;
if ((x<xBjMin(y))||(x>xBjMax(y))) return result;
if (x>0.0) {
func= par[4]*TMath::Power(x,par[0]) * TMath::Power((1-x),par[1])*TMath::Power((1+ (y*y)/ par[3]),-par[2]);
Double_t y_val = y/(x*2.0*kBeam*sqrt(MpSq));
func*= (1-y_val+y_val*y_val/2.)/(x*y*y);
result = func;
}
return result;
}
void Fitting(){
const double QSqBinLow[nQ2+1]={1.5,2.5,4.0 ,6.0 ,10.0};
const int nQ2Log =16;
double Q2BinLowLog[nQ2Log+1];
double fQ2 = pow(QSqBinLow[nQ2]/QSqBinLow[0],1./((double)nQ2Log));
double Q2val = QSqBinLow[0];
for (int iQ2=0; iQ2<=nQ2Log; iQ2++)
{
Q2BinLowLog[iQ2]=Q2val;
Q2val *= fQ2;
}
TH2F* h_QSq_xBj_log_bin_data=new TH2F("h_QSq_xBj_log_bin_data", "QSq vs xBj log binning cross section", 50,0.0,1.0,nQ2Log,Q2BinLowLog);
h_QSq_xBj_log_bin_data->Sumw2();
//line 146
TF2 *f2 = new TF2("f2",Likelihood,0.0,1.0,0.0,10.0,5);
//line 231-235
f2->SetParameter(0,-0.5);
f2->SetParameter(1,2.0);
f2->SetParameter(2,0.0);
f2->FixParameter(3,1.0);
f2->SetParameter(4,7e6);
//multiply by acceptance factor
TH2F *h2_Q2_vs_xB_efficiency_factor_acceptance_factor = (TH2F*)h_QSq_xBj_log_bin_data->Clone("h2_Q2_vs_xB_efficiency_factor_acceptance_factor");
TH2F *h_QSq_xBj_log_bin_data_Stat_Sys_err=new TH2F("h_QSq_xBj_log_bin_data_Stat_Sys_err", "Stat+Sys SetBinContent Relative error", 50,0.0,1.0,nQ2Log,Q2BinLowLog);
h2_Q2_vs_xB_efficiency_factor_acceptance_factor->Multiply(h_ratio); //h_ratio histogram is from SIDIS exclusive Simulation
//divide by Iintegrated Luminosity
TH2F *h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi = (TH2F*)h2_Q2_vs_xB_efficiency_factor_acceptance_factor->Clone("h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi");
h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi->Scale(1/integrated_luminosity);
h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi->Draw("colz");
//line 376-380
h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi->Draw("LEGO");
f2->SetLineColor(1);
f2->DrawClone("lego same");
f2->SetLineColor(2);
h2_Q2_vs_xB_efficiency_factor_acceptance_factor_Inte_Lumi->Fit("f2","I",""); //This option "I" doesn't work.
}
```

Could you please help me to do this?

Thanks

Dil