本文整理汇总了C++中TF1::Derivative方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::Derivative方法的具体用法?C++ TF1::Derivative怎么用?C++ TF1::Derivative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::Derivative方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeDrellYanPtllWeight
//.........这里部分代码省略.........
ratio->Fit(fNew, "mlr0");
fNew->Draw("same");
// Draw the updated error band
//------------------------------------------------------------------------------
if (errorband)
{
TF1* fNew_down = (TF1*)fNew->Clone("fNew_down");
TF1* fNew_up = (TF1*)fNew->Clone("fNew_up");
fNew_down->SetParameter(0, 0.97 * fNew->GetParameter(0));
fNew_down->SetParameter(1, 0.97 * fNew->GetParameter(1));
fNew_up->SetParameter(0, 1.03 * fNew->GetParameter(0));
fNew_up->SetParameter(1, 1.03 * fNew->GetParameter(1));
fNew_down->Draw("same");
fNew_up ->Draw("same");
}
// Fit Lorenzo's function
//
// 1 p0 1.17864e-01 7.44869e-01 1.03478e-05 1.79528e-03
// 2 p1 1.34231e+01 6.10789e+01 2.78074e-03 6.38697e-06
// 3 p2 9.76801e+00 1.03947e+02 5.51661e-03 -2.28998e-06
// 4 p3 1.01367e+00 6.56154e-01 1.29644e-05 -1.36428e-04
// 5 p4 2.50141e-03 2.62347e-02 1.53669e-07 -1.11290e-01
// 6 p5 1.10637e-05 1.42769e-04 1.32442e-09 1.17953e+01
//
//----------------------------------------------------------------------------
TF1* fLo = new TF1("fLo", "([3] + [4]*x - [5]*x*x) * (0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 150);
fLo->SetLineColor (kBlue);
fLo->SetMarkerColor(kBlue);
fLo->SetParameter(0, 0.131835);
fLo->SetParameter(1, 14.1972);
fLo->SetParameter(2, 10.1525);
fLo->SetParameter(3, 0.876979);
fLo->SetParameter(4, 4.11598e-03);
fLo->SetParameter(5, 2.35520e-05);
ratio->Fit(fLo, "mlr0");
// Get the point where the first derivative is closest to zero
//
// fLo = 0.9608 and d(fLo)/d(ptll) = -0.000110 for ptll = 119 GeV
//
//----------------------------------------------------------------------------
float smallest_derivative_value = 999;
float smallest_derivative_x = 999;
for (int x=90; x<120; x++)
{
if (fLo->Derivative(x) < smallest_derivative_value)
{
smallest_derivative_value = fLo->Derivative(x);
smallest_derivative_x = x;
}
}
printf("\n fLo = %.4f and d(fLo)/d(ptll) = %f for ptll = %.0f GeV\n\n",
fLo->Eval(smallest_derivative_x),
fLo->Derivative(smallest_derivative_x),
smallest_derivative_x);
// Draw Lorenzo's function in two ranges
//----------------------------------------------------------------------------
fLo->SetRange(0, smallest_derivative_x);
fLo->Draw("same");
TF1* fHi = new TF1("fHi", "[0]", smallest_derivative_x, 150);
fHi->SetLineColor (kBlue);
fHi->SetMarkerColor(kBlue);
fHi->SetParameter(0, fLo->Eval(smallest_derivative_x));
fHi->Draw("same");
// Legend
//----------------------------------------------------------------------------
DrawLegend(0.69, 0.83, (TObject*)fOld, " old fit");
DrawLegend(0.69, 0.77, (TObject*)fNew, " new fit");
DrawLegend(0.69, 0.71, (TObject*)fLo, " Lorenzo's fit");
// Save
//----------------------------------------------------------------------------
ratio->Draw("ep,same");
c1->SaveAs(fname + "_ratio_fit.png");
}