Skip to content

Commit b6d84ca

Browse files
[hist] Clarify that TGraph/TH1::Fit(name) are not thread safe.
Co-authored-by: ferdymercury <ferdymercury@users.noreply.github.com>
1 parent b6379f9 commit b6d84ca

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

hist/hist/src/TGraph.cxx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,14 +1267,17 @@ TFitResultPtr TGraph::Fit(TF1 *f1, Option_t *option, Option_t *goption, Axis_t r
12671267
}
12681268

12691269
////////////////////////////////////////////////////////////////////////////////
1270-
/// Fit this graph with function with name `fname`.
1270+
/// Fit this graph with the global function named `fname`.
12711271
///
1272-
/// This is a different interface to TGraph fitting using TGraph::Fit(TF1 *f1,Option_t *, Option_t *, Axis_t, Axis_t)
1273-
/// See there for the details about fitting a TGraph.
1272+
/// This will retrieve the function with name `fname` from ROOT's global list of functions, and use it to
1273+
/// fit the data in the TGraph.
1274+
/// TF1 or TF2 functions that have been created in the same ROOT session can be accessed using `fname`.
1275+
/// Predefined functions such as gaus, expo, poln, etc. are automatically created by ROOT.
1276+
/// @see TF1::InitStandardFunctions, TF2::InitStandardFunctions, TF3::InitStandardFunctions
12741277
///
1275-
/// The parameter `fname` is the name of an already predefined function created by TF1 or TF2
1276-
/// Predefined functions such as gaus, expo and poln are automatically
1277-
/// created by ROOT.
1278+
/// Note that using a global function is not thread safe. In this case, use the overload
1279+
/// TGraph::Fit(TF1 *f1,Option_t *, Option_t *, Axis_t, Axis_t) with a locally created function.
1280+
/// For more details about fitting a TGraph, see the same overload.
12781281
///
12791282
/// The parameter `fname` can also be a formula, accepted by the linear fitter (linear parts divided
12801283
/// by "++" sign), for example "x++sin(x)" for fitting "[0]*x+[1]*sin(x)"

hist/hist/src/TGraph2D.cxx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,19 @@ TObject *TGraph2D::FindObject(const TObject *obj) const
799799
return fFunctions ? fFunctions->FindObject(obj) : nullptr;
800800
}
801801

802-
803802
////////////////////////////////////////////////////////////////////////////////
804-
/// Fits this graph with function with name fname
805-
/// Predefined functions such as gaus, expo and poln are automatically
806-
/// created by ROOT.
803+
/// Fit this graph with the global function named `fname`.
804+
///
805+
/// This will retrieve the function with name `fname` from ROOT's global list of functions, and use it to
806+
/// fit the data in the TGraph.
807+
/// TF1 or TF2 functions that have been created in the same ROOT session can be accessed using `fname`.
808+
/// Predefined functions such as gaus, expo and poln are automatically created by ROOT.
809+
///
810+
/// Note that using a global function is not thread safe. In this case, use the overload
811+
/// TGraph2D::Fit(TF2 *, Option_t *, Option_t *) with a locally created function.
812+
///
813+
/// For more details about fitting a TGraph, see TGraph::Fit().
814+
///
807815
/// fname can also be a formula, accepted by the linear fitter (linear parts divided
808816
/// by "++" sign), for example "x++sin(y)" for fitting "[0]*x+[1]*sin(y)"
809817

hist/hist/src/TH1.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3864,7 +3864,7 @@ TObject *TH1::FindObject(const TObject *obj) const
38643864
///
38653865
///
38663866
/// fname is the name of a function available in the global ROOT list of functions
3867-
/// `gROOT->GetListOfFunctions`
3867+
/// `gROOT->GetListOfFunctions`. Note that this is not thread safe.
38683868
/// The list include any TF1 object created by the user plus some pre-defined functions
38693869
/// which are automatically created by ROOT the first time a pre-defined function is requested from `gROOT`
38703870
/// (i.e. when calling `gROOT->GetFunction(const char *name)`).

0 commit comments

Comments
 (0)