JG ROOT Tools libraries  version 5.0 - august 2014
RHistoFunctions.cpp File Reference
#include "RHistoFunctions.hh"
#include "RBaseFunctions.hh"
#include <TAxis.h>
#include <TPad.h>
#include <TAttLine.h>
#include <TAttFill.h>
#include <THistPainter.h>
#include <TFile.h>

Functions

TH1 * RReadHisto (const string &fname, const string &hname)
 
TH1 * RSmoothHisto (const TH1 *hptr, const int n, const char *title)
 
TH1 * RSmoothHisto1D (const TH1 *hptr, const int n, const char *title)
 
TH1 * RSmoothHisto2D (const TH1 *hptr, const int n, const char *title)
 
Double_t RGetHistoCorrelation (const TH2 *hptr, Double_t &sum, Double_t &sigx, Double_t &sigy)
 
Double_t RGetHistoCorrelation (const TH2 *hptr, Double_t x1, Double_t x2, Double_t y1, Double_t y2, Double_t &sum, Double_t &sigx, Double_t &sigy)
 
Double_t RGetHistoCorrelation (const TH2 *hptr, Int_t ix1, Int_t ix2, Int_t iy1, Int_t iy2, Double_t &sum, Double_t &sigx, Double_t &sigy)
 
void RGetHistoErrorLimits (const TH1 *hptr, Double_t &vinf, Double_t &vsup, Int_t ixmin, Int_t ixmax, Int_t iymin, Int_t iymax)
 
void RDrawHistoError (const TH1 *hptr, const TH1 *herr, const char opts[], Double_t yinf, Double_t ysup)
 
void RDrawHistoError (const TH1 *hptr, const char opts[], Double_t yinf, Double_t ysup)
 
int RExportPOV (const string &fname, TH1 *hptr, double thr, const string &fmt)
 
int RExportPOV (FILE *fptr, TH1 *hptr, double thr, const string &fmt)
 
int RExportDF3 (const string &fname, TH3 *hptr, double thr, double scale)
 
int RExportDF3 (FILE *fptr, TH3 *hptr, double thr, double scale)
 

Detailed Description

Source file for functions related to ROOT histograms.

Function Documentation

TH1* RReadHisto ( const string &  fname,
const string &  hname 
)

Read an histogram in a ROOT file, and return a pointer to the histogram. The histogram is taken to "local" directory. This function is redundant with RGetFileHisto.

Parameters
fnameROOT file name
hnamehistogram name
TH1* RSmoothHisto ( const TH1 *  hptr,
const int  n,
const char *  title 
)

Histogram smoothing: a new histogram is created and its pointer is returned. In case of error, a NULL pointer is returned.

Parameters
hptrinitial histogram pointer
nnumber of smoothing loops
titlesmoothed histogram name

References RSmoothHisto1D(), and RSmoothHisto2D().

TH1* RSmoothHisto1D ( const TH1 *  hptr,
const int  n,
const char *  title 
)

1D histogram smoothing: a new histogram is created and its pointer is returned. In case of error, a NULL pointer is returned.

Parameters
hptrinitial histogram pointer
nnumber of smoothing loops
titlesmoothed histogram name

Referenced by RSmoothHisto().

TH1* RSmoothHisto2D ( const TH1 *  hptr,
const int  n,
const char *  title 
)

2D histogram smoothing: a new histogram is created and its pointer is returned. In case of error, a NULL pointer is returned.

Parameters
hptrinitial histogram pointer
nnumber of smoothing loops
titlesmoothed histogram name

Referenced by RSmoothHisto().

Double_t RGetHistoCorrelation ( const TH2 *  hptr,
Double_t &  sum,
Double_t &  sigx,
Double_t &  sigy 
)

Compute the correlation coefficient for a 2D histogram. It also returns (arguments) the standard deviations on X and Y dimensions.

Parameters
hptr2D histogram pointer
sumhistogram sum (output)
sigxX dimension standard deviation (output)
sigyY dimension standard deviation (output)

References RGetHistoCorrelation().

Referenced by RGetHistoCorrelation().

Double_t RGetHistoCorrelation ( const TH2 *  hptr,
Double_t  x1,
Double_t  x2,
Double_t  y1,
Double_t  y2,
Double_t &  sum,
Double_t &  sigx,
Double_t &  sigy 
)

Compute the correlation coefficient for a 2D histogram. It also returns (arguments) the standard deviations on X and Y dimensions.

Parameters
hptr2D histogram pointer
x1lower calculation limit along X
x2upper calculation limit along X
y1lower calculation limit along Y
y2upper calculation limit along Y
sumhistogram sum (output)
sigxX dimension standard deviation (output)
sigyY dimension standard deviation (output)

References RGetHistoCorrelation().

Double_t RGetHistoCorrelation ( const TH2 *  hptr,
Int_t  ix1,
Int_t  ix2,
Int_t  iy1,
Int_t  iy2,
Double_t &  sum,
Double_t &  sigx,
Double_t &  sigy 
)

Compute the correlation coefficient for a 2D histogram. It also returns (arguments) the standard deviations on X and Y dimensions.

Parameters
hptr2D histogram pointer
ix1lower calculation bin along X
ix2upper calculation bin along X
iy1lower calculation bin along Y
iy2upper calculation bin along Y
sumhistogram sum (output)
sigxX dimension standard deviation (output)
sigyY dimension standard deviation (output)
void RGetHistoErrorLimits ( const TH1 *  hptr,
Double_t &  vinf,
Double_t &  vsup,
Int_t  ixmin,
Int_t  ixmax,
Int_t  iymin,
Int_t  iymax 
)

Computes minimum and maximum values for an histogram, including errors.

Parameters
hptrhistogram pointer (1D or 2D)
vinfreturned minimum value
vsupreturned maximum value
ixminlower X bin (included)
ixmaxupper X bin (included)
iyminlower Y bin (included)
iymaxupper Y bin (included)

Referenced by RGFitBase1D::Construct(), and RGFitBase2D::Construct().

void RDrawHistoError ( const TH1 *  hptr,
const TH1 *  herr,
const char  opts[],
Double_t  yinf,
Double_t  ysup 
)

Plot an histogram in current pad, with its error. The current X lower and upper plotting values are used. This function uses an independant histogram that contains errors associated to the plotted histogram. If yinf and ysup are not specified, the vertical scale is adjusted automatically.

Parameters
hptrpointer on histogram
herrpointer on error histogram
optsoptions de tracé (non utilisé);
yinfvaleur inférieure du tracé en Y
ysupvaleur supérieure du tracé en Y

References RDrawHistoError().

Referenced by RFitBase1D::DrawHisto(), RGFitBase1D::DrawPadHisto(), and RDrawHistoError().

void RDrawHistoError ( const TH1 *  hptr,
const char  opts[],
Double_t  yinf,
Double_t  ysup 
)

Plot an histogram in current pad, with its error. The current X lower and upper plotting values are used. If yinf and ysup are not specified, the vertical scale is adjusted automatically.

Parameters
hptrpointer on histogram (with errors defined)
optsoptions de tracé (non utilisé);
yinfvaleur inférieure du tracé en Y
ysupvaleur supérieure du tracé en Y
int RExportPOV ( const string &  fname,
TH1 *  hptr,
double  thr,
const string &  fmt 
)

Export the histogram data to a text file for use as an input file in Persistence Of Vision. The file contains 2, 3 or 4 columns for 1D, 2D and 3D histograms respectively: the bins indexes and the histogram content.

Parameters
fnameoutput file name
hptrhistogram pointer
thrthreshold (only values above threshold are exported)
fmtvalues format

References RExportPOV().

Referenced by RExportPOV().

int RExportPOV ( FILE *  fptr,
TH1 *  hptr,
double  thr,
const string &  fmt 
)

Export the histogram data to a text file for use as an input file in Persistence Of Vision. The file contains 2, 3 or 4 columns for 1D, 2D and 3D histograms respectively: the bins indexes and the histogram content.

Parameters
fptroutput file pointer
hptrhistogram pointer
thrthreshold (only values above threshold are exported)
fmtvalues format
int RExportDF3 ( const string &  fname,
TH3 *  hptr,
double  thr,
double  scale 
)

Export the 3D histogram data to a DF3 density file (for Persistence Of Vision).

Parameters
fnameoutput file name
hptrhistogram pointer
thrthreshold (only values above threshold are exported)
scalescaling factor: 0 for normalization to max value

References RExportDF3().

Referenced by RExportDF3().

int RExportDF3 ( FILE *  fptr,
TH3 *  hptr,
double  thr,
double  scale 
)

Export the 3D histogram data to a DF3 density file (for Persistence Of Vision).

Parameters
fptroutput file pointer
hptrhistogram pointer
thrthreshold (only values above threshold are exported)
scalescaling factor: 0 for normalization to max value