Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-27 08:33:49

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsPlugins/Root/RootHistogramFit.hpp"
0010 
0011 #include "ActsPlugins/Root/HistogramConverter.hpp"
0012 
0013 #include <memory>
0014 
0015 #include <TFitResult.h>
0016 #include <TH1.h>
0017 
0018 namespace ActsPlugins {
0019 
0020 std::optional<RootHistogramFit::Result> RootHistogramFit::operator()(
0021     const Acts::Experimental::Histogram1& hist,
0022     std::optional<Range> range) const {
0023   const std::unique_ptr<TH1F> rootHist = toRoot(hist);
0024 
0025   const TFitResultPtr result =
0026       range.has_value()
0027           ? rootHist->Fit("gaus", (m_config.fitOptions + "R").c_str(), nullptr,
0028                           range->first, range->second)
0029           : rootHist->Fit("gaus", m_config.fitOptions.c_str(), nullptr);
0030 
0031   if (result.Get() == nullptr || result->Status() % 1000 != 0) {
0032     return std::nullopt;
0033   }
0034 
0035   return Result{result->Parameter(1), result->Parameter(2), result->ParError(1),
0036                 result->ParError(2)};
0037 }
0038 
0039 }  // namespace ActsPlugins