ROOT logo
ROOT » HIST » HIST » TMultiGraph

class TMultiGraph: public TNamed

TMultiGraph class

A TMultiGraph is a collection of TGraph (or derived) objects Use TMultiGraph::Add to add a new graph to the list. The TMultiGraph owns the objects in the list. Drawing options are the same as for TGraph.


     TGraph *gr1 = new TGraph(...
     TGraphErrors *gr2 = new TGraphErrors(...
     TMultiGraph *mg = new TMultiGraph();
The drawing option for each TGraph may be specified as an optional second argument of the Add function. If a draw option is specified, it will be used to draw the graph, otherwise the graph will be drawn with the option specified in TMultiGraph::Draw.

Function Members (Methods)

TMultiGraph(const char* name, const char* title)
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TGraph* graph, Option_t* chopt = "")
virtual voidAdd(TMultiGraph* multigraph, Option_t* chopt = "")
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidBrowse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
virtual voidDraw(Option_t* chopt = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual TFitResultPtrFit(const char* formula, Option_t* option = "", Option_t* goption = "", Axis_t xmin = 0, Axis_t xmax = 0)
virtual TFitResultPtrFit(TF1* f1, Option_t* option = "", Option_t* goption = "", Axis_t rxmin = 0, Axis_t rxmax = 0)
virtual voidFitPanel()MENU
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
TF1*GetFunction(const char* name) const
virtual Option_t*GetGraphDrawOption(const TGraph* gr) const
TH1F*GetHistogram() const
virtual const char*TObject::GetIconName() const
const TList*GetListOfFunctions() const
TList*GetListOfGraphs() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
TAxis*GetXaxis() const
TAxis*GetYaxis() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidInitExpo(Double_t xmin, Double_t xmax)
virtual voidInitGaus(Double_t xmin, Double_t xmax)
virtual voidInitPolynom(Double_t xmin, Double_t xmax)
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
virtual Int_tIsInside(Double_t x, Double_t y) const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidLeastSquareFit(Int_t m, Double_t* a, Double_t xmin, Double_t xmax)
virtual voidLeastSquareLinearFit(Int_t ndata, Double_t& a0, Double_t& a1, Int_t& ifail, Double_t xmin, Double_t xmax)
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidPaint(Option_t* chopt = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* chopt = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidRecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidSavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidSetMaximum(Double_t maximum = -1111)
virtual voidSetMinimum(Double_t minimum = -1111)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
TMultiGraph(const TMultiGraph&)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
TMultiGraph&operator=(const TMultiGraph&)

Data Members

TList*fFunctionsPointer to list of functions (fits and user)
TList*fGraphsPointer to list of TGraphs
TH1F*fHistogramPointer to histogram used for drawing axis
Double_tfMaximumMaximum value for plotting along y
Double_tfMinimumMinimum value for plotting along y
TStringTNamed::fNameobject identifier
TStringTNamed::fTitleobject title

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

 TMultiGraph default constructor
TMultiGraph(const char* name, const char* title)
 constructor with name and title
TMultiGraph(const TMultiGraph& )
copy constructor
TMultiGraph& operator=(const TMultiGraph& )
assignement operator
 TMultiGraph destructor
void Add(TGraph* graph, Option_t* chopt = "")
 add a new graph to the list of graphs
 note that the graph is now owned by the TMultigraph.
 Deleting the TMultiGraph object will automatically delete the graphs.
 You should not delete the graphs when the TMultigraph is still active.
void Add(TMultiGraph* multigraph, Option_t* chopt = "")
 add all the graphs in "multigraph" to the list of graphs.
void Browse(TBrowser* b)
 Browse multigraph.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
 Compute distance from point px,py to each graph
void Draw(Option_t* chopt = "")
 Draw this multigraph with its current attributes.

   Options to draw a graph are described in TGraph::PainGraph

  The drawing option for each TGraph may be specified as an optional
  second argument of the Add function. You can use GetGraphDrawOption
  to return this option.
  If a draw option is specified, it will be used to draw the graph,
  otherwise the graph will be drawn with the option specified in
  TMultiGraph::Draw. Use GetDrawOption to return the option specified
  when drawin the TMultiGraph.
TFitResultPtr Fit(const char* formula, Option_t* option = "", Option_t* goption = "", Axis_t xmin = 0, Axis_t xmax = 0)
 Fit this graph with function with name fname.

  interface to TF1::Fit(TF1 *f1...
TFitResultPtr Fit(TF1* f1, Option_t* option = "", Option_t* goption = "", Axis_t rxmin = 0, Axis_t rxmax = 0)
 Fit this multigraph with function f1.

   In this function all graphs of the multigraph are fitted simultaneously

   f1 is an already predefined function created by TF1.
   Predefined functions such as gaus, expo and poln are automatically
   created by ROOT.

   The list of fit options is given in parameter option.
      option = "W"  Set all errors to 1
             = "U" Use a User specified fitting algorithm (via SetFCN)
             = "Q" Quiet mode (minimum printing)
             = "V" Verbose mode (default is between Q and V)
             = "B" Use this option when you want to fix one or more parameters
                   and the fitting function is like "gaus","expo","poln","landau".
             = "R" Use the Range specified in the function range
             = "N" Do not store the graphics function, do not draw
             = "0" Do not plot the result of the fit. By default the fitted function
                   is drawn unless the option"N" above is specified.
             = "+" Add this new fitted function to the list of fitted functions
                   (by default, any previous function is deleted)
             = "C" In case of linear fitting, not calculate the chisquare
                    (saves time)
             = "F" If fitting a polN, switch to minuit fitter
             = "ROB" In case of linear fitting, compute the LTS regression
                     coefficients (robust(resistant) regression), using
                     the default fraction of good points
               "ROB=0.x" - compute the LTS regression coefficients, using
                           0.x as a fraction of good points

   When the fit is drawn (by default), the parameter goption may be used
   to specify a list of graphics options. See TGraph::Paint for a complete
   list of these options.

   In order to use the Range option, one must first create a function
   with the expression to be fitted. For example, if your graph
   has a defined range between -4 and 4 and you want to fit a gaussian
   only in the interval 1 to 3, you can do:
        TF1 *f1 = new TF1("f1","gaus",1,3);

   who is calling this function

   Note that this function is called when calling TGraphErrors::Fit
   or TGraphAsymmErrors::Fit ot TGraphBentErrors::Fit
   see the discussion below on the errors calulation.

   Setting initial conditions

   Parameters must be initialized before invoking the Fit function.
   The setting of the parameter initial values is automatic for the
   predefined functions : poln, expo, gaus, landau. One can however disable
   this automatic computation by specifying the option "B".
   You can specify boundary limits for some or all parameters via
        f1->SetParLimits(p_number, parmin, parmax);
   if parmin>=parmax, the parameter is fixed
   Note that you are not forced to fix the limits for all parameters.
   For example, if you fit a function with 6 parameters, you can do:
     func->SetParLimits(5, 1,1);
   With this setup, parameters 0->3 can vary freely
   Parameter 4 has boundaries [-10,-4] with initial value -8
   Parameter 5 is fixed to 100.

  Fit range

  The fit range can be specified in two ways:
    - specify rxmax > rxmin (default is rxmin=rxmax=0)
    - specify the option "R". In this case, the function will be taken
      instead of the full graph range.

  Changing the fitting function

   By default a chi2 fitting function is used for fitting the TGraphs's.
   The function is implemented in FitUtil::EvaluateChi2.
   In case of TGraphErrors an effective chi2 is used
   (see TGraphErrors fit in TGraph::Fit) and is implemented in
   To specify a User defined fitting function, specify option "U" and
   call the following functions:
   where MyFittingFunction is of type:
   extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);

  Access to the fit result

  The function returns a TFitResultPtr which can hold a  pointer to a TFitResult object.
  By default the TFitResultPtr contains only the status of the fit and it converts
  automatically to an integer. If the option "S" is instead used, TFitResultPtr contains
  the TFitResult and behaves as a smart pointer to it. For example one can do:
     TFitResultPtr r = graph->Fit("myFunc","S");
     TMatrixDSym cov = r->GetCovarianceMatrix();  //  to access the covariance matrix
     Double_t par0   = r->Parameter(0); // retrieve the value for the parameter 0
     Double_t err0   = r->ParError(0); // retrieve the error for the parameter 0
     r->Print("V");     // print full information of fit including covariance matrix
     r->Write();        // store the result in a file

   The fit parameters, error and chi2 (but not covariance matrix) can be retrieved also
   from the fitted function.

   Associated functions

  One or more object (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
  with:  TF1 *myfunc = gr->GetFunction("myfunc");

  If the graph is made persistent, the list of
  associated functions is also persistent. Given a pointer (see above)
  to an associated function myfunc, one can retrieve the function/fit
  parameters with calls such as:
    Double_t chi2 = myfunc->GetChisquare();
    Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
    Double_t err0 = myfunc->GetParError(0);  //error on first parameter

   Fit Statistics

  You can change the statistics box to display the fit parameters with
  the TStyle::SetOptFit(mode) method. This mode has four digits.
  mode = pcev  (default = 0111)
    v = 1;  print name/values of parameters
    e = 1;  print errors (if e=1, v must be 1)
    c = 1;  print Chisquare/Number of degress of freedom
    p = 1;  print Probability

  For example: gStyle->SetOptFit(1011);
  prints the fit probability, parameter names/values, and errors.
  You can change the position of the statistics box with these lines
  (where g is a pointer to the TGraph):

  Root > TPaveStats *st = (TPaveStats*)g->GetListOfFunctions()->FindObject("stats")
  Root > st->SetX1NDC(newx1); //new x start position
  Root > st->SetX2NDC(newx2); //new x end position
void FitPanel()
   -*-*-*-*-*Display a panel with all histogram fit options*-*-*-*-*-*

      See class TFitPanel for example
Option_t * GetGraphDrawOption(const TGraph* gr) const
 Return the draw option for the TGraph gr in this TMultiGraph
 The return option is the one specified when calling TMultiGraph::Add(gr,option).
void InitGaus(Double_t xmin, Double_t xmax)
 Compute Initial values of parameters for a gaussian.
void InitExpo(Double_t xmin, Double_t xmax)
 Compute Initial values of parameters for an exponential.
void InitPolynom(Double_t xmin, Double_t xmax)
 Compute Initial values of parameters for a polynom.
void LeastSquareFit(Int_t m, Double_t* a, Double_t xmin, Double_t xmax)
 Least squares lpolynomial fitting without weights.

  m     number of parameters
  a     array of parameters
  first 1st point number to fit (default =0)
  last  last point number to fit (default=fNpoints-1)

   based on CERNLIB routine LSQ: Translated to C++ by Rene Brun
void LeastSquareLinearFit(Int_t ndata, Double_t& a0, Double_t& a1, Int_t& ifail, Double_t xmin, Double_t xmax)
 Least square linear fit without weights.

  Fit a straight line (a0 + a1*x) to the data in this graph.
  ndata:  number of points to fit
  first:  first point number to fit
  last:   last point to fit O(ndata should be last-first
  ifail:  return parameter indicating the status of the fit (ifail=0, fit is OK)

   extracted from CERNLIB LLSQ: Translated to C++ by Rene Brun
Int_t IsInside(Double_t x, Double_t y) const
 Return 1 if the point (x,y) is inside one of the graphs 0 otherwise.
TH1F * GetHistogram() const
 Returns a pointer to the histogram used to draw the axis
 Takes into account the two following cases.
    1- option 'A' was specified in TMultiGraph::Draw. Return fHistogram
    2- user had called TPad::DrawFrame. return pointer to hframe histogram
TF1 * GetFunction(const char* name) const
 Return pointer to function with name.

 Functions such as TGraph::Fit store the fitted function in the list of
 functions of this graph.
TList * GetListOfFunctions()
 Return pointer to list of functions
 if pointer is null create the list
TAxis * GetXaxis() const
 Get x axis of the graph.
TAxis * GetYaxis() const
 Get y axis of the graph.
void Paint(Option_t* chopt = "")
 paint all the graphs of this multigraph
void Print(Option_t* chopt = "") const
 Print the list of graphs
void RecursiveRemove(TObject* obj)
 Recursively remove this object from a list. Typically implemented
 by classes that can contain mulitple references to a same object.
void SavePrimitive(ostream& out, Option_t* option = "")
 Save primitive as a C++ statement(s) on output stream out
void SetMaximum(Double_t maximum = -1111)
 Set multigraph maximum.
void SetMinimum(Double_t minimum = -1111)
 Set multigraph minimum.
TList * GetListOfGraphs() const
{ return fGraphs; }
TList * GetListOfFunctions()