Hi,
I am trying to run a script for a new root file with a histogram, but for some reason, calling the fit function for this new file doesn’t even fit the data, whereas with a previous file it did. Below is the script to generate the problem, and attached is the root file. Can someone help figure out how to fix this fit problem?
double FiveParam2015TEV_plus_Gauss(double *x, double *har){double Ecm=13.;double fCenterOfMassEnergy = Ecm;bool fUseWindowExclusion = false;double y = x[0] / fCenterOfMassEnergy;double ff1=har[0]*TMath::Power((1.0-y),har[1]);double ff2=TMath::Power(y,(har[2]+har[3]*log(y)+har[4]*log(y)*log(y)));double ff=((ff1*ff2));return ff;}
string xdir="";
string figdir="figs/";
char nameX[]="m_{jjl} [TeV]";
char nameY[]="Events / TeV";
double Ymin=0.9;
double Ymax=1000000000.0-100000.0;
double YRMIN=-4.999;
double YRMAX=4.999;
double Xmin=400.0;
double Xmax=10000.0;
Xmin=Xmin*0.001;
Xmax=Xmax*0.001;
double NN=0.0;
gROOT->SetStyle("Plain");
TCanvas* c1 = new TCanvas("c","BPRE",10,10,600,600);
c1->Divide(1,1,0.005,0.005);
c1->SetTickx();
c1->SetTicky();
c1->SetTitle("");
c1->SetLineWidth(3);
c1->SetBottomMargin(0.1);
c1->SetTopMargin(0.05);
c1->SetRightMargin(0.01);
c1->SetFillColor(0);
TPad* pad1 = new TPad("pad1","pad1",0,0.3,1,0.97);
pad1->SetBottomMargin(0);
pad1->SetLeftMargin(0.13);
pad1->SetRightMargin(0.04);
pad1->SetTopMargin(0.02);
pad1->Draw();
pad1->cd();
pad1->SetLogy(1);
pad1->SetLogx(1);
TH1F *h=pad1->DrawFrame(Xmin,Ymin,Xmax,Ymax);
TAxis *ay = h->GetYaxis();
ay->SetLabelFont(42);
ay->SetLabelSize(0.05);
ay->SetTitleSize(0.06);
ay->SetNdivisions(505);
ay->SetTitle(nameY);
TAxis *ax=h->GetXaxis();
ax->SetTitle(nameX);
ax->SetTitleOffset(1.18);
ay->SetTitleOffset(0.8);
ax->SetLabelFont(42);
ay->SetLabelFont(42);
ax->SetLabelSize(0.12);
ax->SetTitleSize(0.14);
ax->Draw("same");
ay->Draw("same");
string dir = xdir;
TFile *ff = new TFile("mjjl_smooth_mc.root");
ff->ls();
char name[] = "jjlmass";
TH1* hh = static_cast<TH1*>(ff->Get(name));
TH1* hhorg = static_cast<TH1*>(hh->Clone());
TFile TFdata("mjjl_smooth_mc.root");
cout << TFdata.GetName()<< endl;
TH1* bids= static_cast<TH1*>(TFdata.Get("bins_m"));
TH1* bins= static_cast<TH1*>(TFdata.Get("bins_m"));
bids->Scale(1.0/92.0);
cout << "Bool: "<< hh->Divide(bids) << endl;
hh->SetTitle("");
hh->SetStats(0);
hh->SetLineWidth(2);
hh->Print("All");
hh->SetAxisRange(Ymin,Ymax,"y"); //0.00001
hh->SetAxisRange(Xmin,Xmax,"x");
hh->SetMarkerColor( 3 );
hh->SetMarkerStyle( 20 );
hh->SetMarkerSize( 0.8 );
double MyMinX=Xmin;
double MyMaxX=Xmax;
hh->Draw("pe");
TF1 ball("5p+gauss",FiveParam2015TEV_plus_Gauss,MyMinX,MyMaxX,5);
ball.SetNpx(200);
ball.SetLineColor(4);
ball.SetLineStyle(1);
ball.SetLineWidth(2);
ball.SetParameter(0,6.05059e+04);
ball.SetParameter(1,1.32594e+01);
ball.SetParameter(2,5.85506e-01);
ball.SetParameter(3,1.78302e+00);
ball.SetParameter(4,2.83882e-01);
auto fitr=hh->Fit(&ball,"SL","");fitr->Print();
mjjl_smooth_mc.root (6.7 KB)
ROOT Version: 6.23/01