TH1::Fit is odly not plotting the function

Dear co-rooters,

I am trying to perform a simple linear fit in a certain range on a TH1D histogram which I get from a root file (The root file can be found in
My code is the following

#include "TCanvas.h"
#include "TStyle.h"
#include "TFile.h"
#include "TH1.h"

void fit(){

	TFile *fin = new TFile("fit.root", "OPEN");
	TH1D *h = (TH1D*) fin->Get("histo_movie");								

	TCanvas *canvas = new TCanvas("canvas", "HPGe", 500, 500);
	canvas->Divide(1, 2);
	// Pad 1
	h->Draw("histo ][");	
	h->TH1::Fit("pol1", "WCQF", "C SAME", 5.6005e6, 5.6021e6);	
	//Pad 2
	h->Draw("histo ][");

Although the code compiles and runs there is no plotted curve.

Any idea on what is going on?

Thanks in advance!

Note that I am running this on lxplus7, using whichever version is the latest in the cluster.


Thank you very much for the answer!

Although I can now see the fitting curve, the way the histogram is drawn is strange.

Any idea why?


  h->Fit("pol1", "WCQF", "HIST ][", 5.6005e6, 5.6021e6);

This seems to be working!
Thank you very much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.