Hi @meixue
this should work for you
TH1D *h_diff =new TH1D(); //this should have the same binning of your histogram
double x,y;
for(int i=h->FindBin(2040);i<h->FindBin(2410);i++)//h here is your histogram
{
y=h->GetBinContent(i);
x=h->GetBinCenter(i);
h_diff->SetBinContent( i , y - f->Eval(x) );//f is your fitted function
}
I have also same issue any suggestion for this so please reply. Thanks in advnance.
Hi @Thomas265, the solution proposed should work also for you
Blockquote TH1D *h_diff =new TH1D(); //this should have the same binning of your histogram
double x,y;
for(int i=h->FindBin(2040);iFindBin(2410);i++)//h here is your histogram
{
y=h->GetBinContent(i);
x=h->GetBinCenter(i);
h_diff->SetBinContent( i , y - f->Eval(x) );//f is your fitted function
}
