Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hist] Add TGraph2D::GetFunction as with TGraph #17812

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hist/hist/inc/TGraph2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMar
virtual void FitPanel(); // *MENU*
TList *GetContourList(Double_t contour);
TDirectory *GetDirectory() const {return fDirectory;}
TF2 *GetFunction(const char *name) const;
Int_t GetNpx() const {return fNpx;}
Int_t GetNpy() const {return fNpy;}
TH2D *GetHistogram(Option_t *option="");
Expand Down
12 changes: 12 additions & 0 deletions hist/hist/src/TGraph2D.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,18 @@ void TGraph2D::CreateInterpolator(Bool_t oldInterp)
}
}

////////////////////////////////////////////////////////////////////////////////
/// Return pointer to function with name.
///
/// Functions such as TGraph2D::Fit store the fitted function in the list of
/// functions of this graph.

TF2 *TGraph2D::GetFunction(const char *name) const
{
if (!fFunctions) return nullptr;
return (TF2*)fFunctions->FindObject(name);
}

////////////////////////////////////////////////////////////////////////////////
/// By default returns a pointer to the Delaunay histogram. If fHistogram
/// doesn't exist, books the 2D histogram fHistogram with a margin around
Expand Down
6 changes: 3 additions & 3 deletions hist/hist/src/TH1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ When using the options 2 or 3 above, the labels are automatically

\anchor associated-functions
### Associated functions
One or more object (typically a TF1*) can be added to the list
One or more objects (typically a TF1*) can be added to the list
of functions (fFunctions) associated to each histogram.
When TH1::Fit is invoked, the fitted function is added to this list.
Given a histogram h, one can retrieve an associated function
Given a histogram (or TGraph) `h`, one can retrieve an associated function
with:
~~~ {.cpp}
TF1 *myfunc = h->GetFunction("myfunc");
Expand Down Expand Up @@ -4063,7 +4063,7 @@ TFitResultPtr TH1::Fit(const char *fname ,Option_t *option ,Option_t *goption, D
///
/// ##### Associated functions
///
/// One or more object ( can be added to the list
/// One or more objects (typically a TF1*) can be added to the list
/// of functions (fFunctions) associated to each histogram.
/// When TH1::Fit is invoked, the fitted function is added to the histogram list of functions (fFunctions).
/// If the histogram is made persistent, the list of associated functions is also persistent.
Expand Down
2 changes: 1 addition & 1 deletion hist/hist/src/TMultiGraph.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ TFitResultPtr TMultiGraph::Fit(const char *fname, Option_t *option, Option_t *,
///
/// ### Associated functions
///
/// One or more object (typically a TF1*) can be added to the list
/// One or more objects (typically a TF1*) can be added to the list
/// of functions (fFunctions) associated to each graph.
/// When TGraph::Fit is invoked, the fitted function is added to this list.
/// Given a graph gr, one can retrieve an associated function
Expand Down
Loading