Hi experts.
I have question. I was fitting the histogram with gaus function using fix the parameter.
So when i integrate the fitted function it doesn’t show the correct error i think.
Below code is what i use.
void Fit_N37()
{
TCanvas *c = new TCanvas(“K40”,“K40”,800,600);
TFile *f = new TFile(“NaI37_boxcut3.root”);
TH1F *N_new = new TH1F(“N_new”,“N_new”,20,0,10);
TH1F N_37 = (TH1F)f->Get(“N_37”);
N_37->Draw(“E”);
Double_t par1[13];
TF1 *fp = new TF1(“fp”,“pol0”,1.5,10);
N_37->Fit(fp,“R”);
TF1 *fg = new TF1(“fg”,“gaus”,2,4);
fg->FixParameter(1, 3.2);
fg->FixParameter(2, 6.76268e-1);
//fg->FixParameter(2, 0.179234);
N_37->Fit(fg,“B”,“R+”);
TF1 *f1 = new TF1(“f1”,“pol0(0)+gaus(1)”,1.5,10);
f1->Draw(“same”);
f1->SetLineColor(kRed);
fp->GetParameters(&par1[0]);
fg->GetParameters(&par1[1]);
f1->SetParameters(par1);
f1->FixParameter(1, f1->GetParameter(1)-f1->GetParameter(0));
f1->FixParameter(2, f1->GetParameter(2));
f1->FixParameter(3, f1->GetParameter(3));
f1->SetLineColor(kRed);
N_37->Fit(f1,“B”,“R+”,1.5,10);
TF1 *f2 = new TF1(“f2”,“pol0”,1.5,10);
f2->Draw(“same”);
f2->SetLineColor(kBlue);
f2->SetParameters(par1);
f2->FixParameter(0, f1->GetParameter(0));
N_37->Fit(f2,“B”,“R+”,1.5,10);
auto fitresult1 = N_37->Fit(f1,“S”,"",1.5,10);
auto fitresult2 = N_37->Fit(f2,“S+”,"",1.5,10);
double integral1 = f1->Integral(1.5,10);
double integral2 = f2->Integral(1.5,10);
auto covMatrix1 = fitresult1->GetCovarianceMatrix();
auto covMatrix2 = fitresult2->GetCovarianceMatrix();
double sigma_integral1 = f1->IntegralError(1.5,10,fitresult1->GetParams(),covMatrix1.GetMatrixArray());
double sigma_integral2 = f2->IntegralError(1.5,10,fitresult2->GetParams(),covMatrix2.GetMatrixArray());
Float_t mass = 0.7111;
Double_t time = 7996060;
Double_t efficiency = 0.00383328;
Double_t bqtoppb = 33.33;
Float_t Signalevent = integral1-integral2;
Float_t error = sigma_integral1-sigma_integral2;
std::cout << "Number of signal event = " << Signalevent*2 << std::endl;
std::cout << "Activity = " << Signalevent/efficiency/(time*mass) 2.331000 *bqtoppb 2 << “+/-” << error/efficiency/(timemass) *1000 *bqtoppb << “ppb” <<std::endl ;
And the result is below.
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 8.26109e+00 fixed
FCN=11.8364 FROM MIGRAD STATUS=CONVERGED 11 CALLS 12 TOTAL
EDM=9.5913e-20 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 8.26109e+00 1.01571e+00 -0.00000e+00 6.09814e-10
2 p1 5.43198e+00 fixed
3 p2 3.20000e+00 fixed
4 p3 6.76268e-01 fixed
Error in <operator()>: Request column(1) outside matrix range of 0 - 1
Error in <operator()>: Request column(1) outside matrix range of 0 - 1
Error in ROOT::Math::FitResult: FitConfiguration and Minimizer result are not consistent
Number of free parameters from FitConfig = 0
Number of free parameters from Minimizer = 1
Minimizer is Linear
Chi2 = 10.4507
NDf = 8
p0 = 8.26109 (fixed)
Number of signal event = 18.3061
Activity = 181.316+/-36.7008ppb
Chi2 =11.8364
ndf = 8
So how can i get the integral error using different method?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided