JG ROOT Tools libraries  version 5.0 - august 2014
RGraphFunctions.hh File Reference
#include "RBaseFunctions.hh"
#include "GOptionString.hh"
#include <TGraph.h>
#include <TGraphErrors.h>
#include <TGraph2D.h>
#include <TGraph2DErrors.h>
#include <TH1.h>
#include <TH2.h>
#include <TPolyLine.h>
#include <TPolyLine3D.h>
#include <TTree.h>
#include <TBranch.h>
#include <TLeaf.h>
#include <TTreeFormula.h>

Go to the source code of this file.

Functions

Graphs simple functions
TGraph * RGraphDifference (int n, const Double_t *t1, const Double_t *t2)
 
TGraph * RGraphDifference (int n, const Double_t xmin, const Double_t xmax, const Double_t *t1, const Double_t *t2)
 
TGraphErrors * RCreateYmeanGraph (TH2 *hptr, const string &options)
 
TGraphErrors * RConcatGraph (TGraphErrors *gtot, const TGraphErrors *gnew)
 
TGraphErrors * RConcatGraph (TGraphErrors *gtot, const TGraph *gnew)
 
TGraph * RConcatGraph (TGraph *gtot, const TGraph *gnew)
 
Graph from extraction of sub-sets of data
Int_t RGetGraphSeries (const Int_t n, const Double_t *p, const Double_t *x, const Double_t *y, const Double_t *dx, const Double_t *dy, TGraphErrors *&tab_gr, Double_t *&tab_p, const Double_t eps=1.e-6)
 
Int_t RGetPolyLineSeries (const Int_t n, const Double_t *p, const Double_t *x, const Double_t *y, TPolyLine *&tab_l, Double_t *&tab_p, const Double_t eps=1.e-6)
 
Int_t RGetPolyLine3DSeries (const Int_t n, const Double_t *p, const Double_t *x, const Double_t *y, const Double_t *z, TPolyLine3D *&tab_l, Double_t *&tab_p, const Double_t eps=1.e-6)
 
Graph from a TTree
TGraph * RGraphFromTree (TTree &tree, const string &varx, const string &vary, const string &selection="")
 
TGraphErrors * RGraphFromTree (TTree &tree, const string &varx, const string &vary, const string &errx, const string &erry, const string &selection)
 
TGraphErrors ** RGraphSerieFromTree (TTree &tree, const string &varc, u_int n, double ctab[], const string &varx, const string &vary, const string &errx="", const string &erry="", const string &selection="", double prec=0.001)
 

Detailed Description

Include file for functions related to ROOT TGraph class.

Function Documentation

TGraph* RGraphDifference ( int  n,
const Double_t *  t1,
const Double_t *  t2 
)

Create a graph from the difference between 2 arrays (with same size). The X coordinate for the graph is set as the point number.

Parameters
narrays size
t1first array
t2second array

References RGraphDifference().

Referenced by RGraphDifference().

TGraph* RGraphDifference ( int  n,
const Double_t  xmin,
const Double_t  xmax,
const Double_t *  t1,
const Double_t *  t2 
)

Create a graph from the difference between 2 arrays (with same size). The X coordinate for the graph is computed from xmin to xmax, with constant interval.

Parameters
narrays size
xminX coordimate of the first point
xmaxX coordimate of the last point
t1first array
t2second array
TGraphErrors* RCreateYmeanGraph ( TH2 *  hptr,
const string &  options 
)

Create a TGraphErrors (that must be deleted by the calling function) from a 2D histogram. For each X bin of the histogram, the function computes an average value (and an associated error) of the data along Y. By default, the errors for each point are taken as RMS/sqrt(N), except if the "RMS" option is set.

Parameters
hptrpointer to the 2D histogram
optionsthe options may specify some limitations on 2D histogram data to be accepted for building the graph:
  • "Smin=<val>": minimum sum value along Y to keep the point in the graph
  • "Amin=<val>": minimum value for the maximum along Y to keep the point in the graph
  • "Vmin=<val>": minimum count to consider the point in the average for the corresponding graph point
  • "Xoff=<val>": shift of X axis (for better lisibility of multiple graphs)
  • "RMS": graph error bars are the RMS instead of the center uncertainty
TGraphErrors* RConcatGraph ( TGraphErrors *  gtot,
const TGraphErrors *  gnew 
)

Add points from the graph
gnew to the graph gtot. This function is defined because the Merge() function from TGraphErrors class does not include the errors (ROOT 5.28).

Parameters
gtotgraph that receives new points
gnewgraph to be added
TGraphErrors* RConcatGraph ( TGraphErrors *  gtot,
const TGraph *  gnew 
)

Add points from the graph
gnew to the graph gtot. This function is defined because the Merge() function from TGraphErrors class does not include the errors (ROOT 5.28).

Parameters
gtotgraph that receives new points
gnewgraph to be added
TGraph* RConcatGraph ( TGraph *  gtot,
const TGraph *  gnew 
)

Add points from the graph
gnew to the graph gtot. This function is defined because the Merge() function from TGraphErrors class does not include the errors (ROOT 5.28).

Parameters
gtotgraph that receives new points
gnewgraph to be added
Int_t RGetGraphSeries ( const Int_t  n,
const Double_t *  p,
const Double_t *  x,
const Double_t *  y,
const Double_t *  dx,
const Double_t *  dy,
TGraphErrors *&  tab_gr,
Double_t *&  tab_p,
const Double_t  eps 
)

Pour des tableaux de données p, x, y, la fonction crée un tableau de graphes (x,y) pour chacune des valeurs de p. Les graphes sont de type TGraphErrors, et si les tableaux pour les erreurs sur x et/ou y sont NULL, les erreurs correspondantes sont mises à 0. La fonction retourne le nombre de graphes, qui correspond au nombre de valeurs différentes de p.

Parameters
nnombre de données dans les tableaux
ptable des valeurs qui sont comparées
xtable des abscisses des graphes
ytable des ordonnées des graphes
dxtable des erreurs en abscisses (NULL si ignorées)
dytable des erreurs en ordonnées (NULL si ignorées)
tab_grtable des graphes en retour
tab_ptable des valeurs de p pour chaque graphe en retour
epsprécision pour test d'égalité des valeurs de p
Int_t RGetPolyLineSeries ( const Int_t  n,
const Double_t *  p,
const Double_t *  x,
const Double_t *  y,
TPolyLine *&  tab_l,
Double_t *&  tab_p,
const Double_t  eps 
)

Pour des tableaux de données p, x, y, la fonction crée un tableau de lignes TPolyLine (x,y) pour chacune des valeurs de p. La fonction retourne le nombre de lignes, qui correspond au nombre de valeurs différentes de p.

Parameters
nnombre de données dans les tableaux
ptable des valeurs qui sont comparées
xtable des abscisses des points
ytable des ordonnées des points
tab_ltable des polylines en retour
tab_ptable des valeurs de p pour chaque polyline en retour
epsprécision pour test d'égalité des valeurs de p
Int_t RGetPolyLine3DSeries ( const Int_t  n,
const Double_t *  p,
const Double_t *  x,
const Double_t *  y,
const Double_t *  z,
TPolyLine3D *&  tab_l,
Double_t *&  tab_p,
const Double_t  eps 
)

Pour des tableaux de données p, x, y, la fonction crée un tableau de lignes TPolyLine (x,y) pour chacune des valeurs de p. La fonction retourne le nombre de lignes, qui correspond au nombre de valeurs différentes de p.

Parameters
nnombre de données dans les tableaux
ptable des valeurs qui sont comparées
xtable des coordonnées X
ytable des coordonnées Y
ztable des coordonnées Z
tab_ltable des polylines en retour
tab_ptable des valeurs de p pour chaque polyline en retour
epsprécision pour test d'égalité des valeurs de p
TGraph* RGraphFromTree ( TTree &  tree,
const string &  varx,
const string &  vary,
const string &  selection 
)

Create a TGraph from a TTree, with selection conditions.

Parameters
treesource TTree
varxname of parameter for variable X of the graph
varyname of parameter for variable Y of the graph
selectionconditions for events selection

References RGetTreeFormula(), and RIsTreeFormula().

Referenced by RGraphSerieFromTree().

TGraphErrors* RGraphFromTree ( TTree &  tree,
const string &  varx,
const string &  vary,
const string &  errx = "",
const string &  erry = "",
const string &  selection = "" 
)

Create a TGraphErrors from a TTree, with selection conditions. The variables may be aliases of the tree.

Parameters
treesource TTree
varxname of parameter for variable X of the graph
varyname of parameter for variable Y of the graph
errxname of parameter for error X of the graph
erryname of parameter for error Y of the graph
selectionconditions for events selection

References RGetTreeFormula(), and RIsTreeFormula().

TGraphErrors** RGraphSerieFromTree ( TTree &  tree,
const string &  varc,
u_int  n,
double  ctab[],
const string &  varx,
const string &  vary,
const string &  errx,
const string &  erry,
const string &  selection,
double  prec 
)

Create a serie of TGraphErrors from a TTree, with selection conditions, creating one TGraph for each value of the selection variable. Each graph pointer and the array of pointers must be deleted by the calling program.

Parameters
treesource TTree
varcname of the selection variable for graphs
nnumber of values of the selection variable
ctabarray of values of the selection variable
varxname of parameter for variable X of the graph
varxname of parameter for variable X of the graph
varyname of parameter for variable Y of the graph
errxname of parameter for error X of the graph
erryname of parameter for error Y of the graph
selectionconditions for events selection
precconditions relative precision for selected graphs variable

References RGraphFromTree(), and RTreeSelectEq().