Create function from histogram

Hi ROOTers,
I am following up from a topic that was signed as closed even if not (my bad for never noticiging the last reply). The topic is this one.
In the last comment I am suggested to use the constructor

auto f1 = new TF1("f1", conv_histo, &convert_1DHisto::Evaluate, hInput->GetXaxis()->GetXmin(), hInput->GetXaxis()->GetXmax(), 0);

however this line gives me the error

error: use of undeclared identifier 'convert_1DHisto'

and I don’t understand what it means, since the class is defined just above.

Thanks for your help,

Riccardo


ROOT Version: 6.24/00
Platform: Linux 3.10.0-1127.13.1.el7.x86_64

Can you post a small macro reproducing the problem?

Sure, find it here below.
Thanks

#include <TFile.h>
#include <TCanvas.h>
#include <TMath.h>
#include <TH1F.h>
#include <TF1.h>

class convert_1Dhisto {
public:
  TH1F* h_input;
  void set_histo (TH1F* h_in) {
    h_input = (TH1F*)h_in;
    return;
  }
  double Evaluate (double *vx, double *p) {
    double x = vx[0];
    if (x < h_input->GetBinLowEdge(1) || x > h_input->GetBinLowEdge(h_input->GetNbinsX())+ h_input->GetBinWidth(1))
      return 0.;

    return h_input->GetBinContent(h_input->FindBin(x));
  }
};

void test(){

  TFile* file = new TFile("/eos/infnts/belle2/users/rmanfred/rhorho/b2dkpp0_fit/histograms_belle2/angular_b2rhorho_LP22_sidebandReweight_ch2D_rewAll_data.root");
  TH1F* hTest = (TH1F*)file->Get("h1D_sig_lo_dE");

  convert_1Dhisto * conv_histo = new convert_1Dhisto();
  conv_histo->set_histo(hTest);

  auto funcHisto = new TF1("funcHisto", conv_histo, &convert_1DHisto::Evaluate, hTest->GetXaxis()->GetXmin(), hTest->GetXaxis()->GetXmax(), 0);

  TCanvas* c = new TCanvas("c", "c", 400, 800);
  c->Divide(2,1);
  c->cd(1);
  hTest->Draw();
  c->cd(2);
  funcHisto->Draw();

}

auto funcHisto = new TF1("funcHisto", conv_histo, &convert_1Dhisto::Evaluate, hTest->GetXaxis()->GetXmin(), hTest->GetXaxis()->GetXmax(), 0);