34 if (gPad ==
nullptr) {
35 Info(
"Cmd",
"warning: no pad");
40 TObject *hist_now = gPad->GetPrimitive(
"htemp");
42 hist_now = TCatHistManager::Instance()->GetCurrent();
43 if (!hist_now || !hist_now->InheritsFrom(
"TH1")) {
44 Info(
"Cmd",
"warning: no hist, please check using ls command");
50 if (hist_now->InheritsFrom(TH2::Class())) {
51 Info(
"Cmd",
"warning: The current hist does not inherit from TH1 class (TH2)");
56 Double_t x1 = 0., y1 = 0., x2 = 0., y2 = 0.;
57 Info(
"Cmd",
"click on the lowest edge: ");
58 TCatCmdXval::Instance()->Run(&x1, &y1);
65 Info(
"Cmd",
"click on the highest edge: ");
66 TCatCmdXval::Instance()->Run(&x2, &y2);
74 Info(
"Cmd",
"X1: %g, X2: %g", x1, x2);
79 TF1 *func =
new TF1(hist_now->GetName(),
"gaus(0)", x1, x2);
80 func->SetParameters(((y1 + y2) / 2) * (x2 - x1), (x1 + x2) / 2., (x2 - x1) / 4.);
81 func->SetParLimits(2, 0, 1000. * (x2 - x1));
82 dynamic_cast<TH1 *
>(hist_now)->Fit(func,
"",
"", x1, x2);
85 TCmdComment::Instance()->Run(
86 TString::Format(
"[xfitg] mean=%g: FWHM=%g", func->GetParameter(1), 2.35 * func->GetParameter(2)));