I’m simply trying to fit an exponential of the form [0]exp(-1[0]*x) to a histogram. Minuit produces an output, but when the graph is drawn the fit is simply a flat line. What’s wrong with my code?
#include <iostream>
#include <fstream>
int muonsim(){
TRandom *r1 = new TRandom();
float lifetime = 0.0000022;
TH1F *hist = new TH1F("hist","Histogram",100,0,10*lifetime);
TF1 *eqn = new TF1("eqn","-1*[0]*log(x)/0.434294482");
eqn->FixParameter(0,lifetime);
for (int i=0;i<10000;i++){
hist->Fill(eqn->Eval(r1->Uniform(0,1)));
}
TF1 *fitfnc = new TF1("fitfnc","[0]*exp(-1*[0]*x)",0,10*lifetime);
fitfnc->SetParameter(0,lifetime);
hist->Fit(fitfnc);
}