JG ROOT Tools libraries  version 5.0 - august 2014
RRootFilesFunctions.cpp File Reference
#include "RRootFilesFunctions.hh"
#include "RBaseFunctions.hh"
#include <TSystem.h>
#include <TFile.h>
#include <TKey.h>

Functions

TH1 * RGetFileHisto (const char file_name[], const char histo_name[])
 
TH1 * RGetFileHisto (TDirectory *dir, const char histo_name[], bool recur)
 
Int_t RGetHistoNames (const char file_name[], string *&histo_names, Int_t *&histo_dim, Int_t dmin, Int_t dmax)
 
Int_t RGetHistoNames (const char file_name[], string *&histo_names, Int_t dmin, Int_t dmax)
 
bool RCheckDirObjects (TDirectory *dir, const string &obj_class, bool recur)
 
u_int RCountDirObjects (TDirectory *dir, const string &obj_class, bool recur)
 
RTreeBranchTObjectRGetObjectTree (TDirectory *dir, const string &obj_class)
 
RTreeBranchTObjectRGetHistoTree (TDirectory *dir, bool local)
 

Detailed Description

Source file for functions related to ROOT files.

Function Documentation

TH1* RGetFileHisto ( const char  file_name[],
const char  histo_name[] 
)

Read an histogram in a ROOT file, and return a pointer to the histogram. The histogram is taken to "local" directory. This function should replace RReadHisto that may not be used anymore.

Parameters
file_nameROOT file name
histo_namehistogram name

References RGetFileHisto().

Referenced by RGetFileHisto().

TH1* RGetFileHisto ( TDirectory *  dir,
const char  histo_name[],
bool  recur 
)

Read an histogram in a ROOT directory, and return a pointer to the histogram. The histogram is taken to "local" directory. If the histogram is not found in the directory, it may be searched for in sub-directories.

Parameters
dirROOT directory
histo_namehistogram name*
recurwhether to search recursively in sub-directories

References RGetFileHisto().

Int_t RGetHistoNames ( const char  file_name[],
string *&  histo_names,
Int_t *&  histo_dim,
Int_t  dmin,
Int_t  dmax 
)

This function creates (allocates) a table of histogram names and a table of histogram dimensions from a ROOT file. It only considers the last version of each histogram (highest cycle number). It returns a positive value if some histograms have been found, corresponding to the number of histograms (the tables must then be deleted by calling program). It returns 0 if no histogram was found, and a negative value in case of error.

Parameters
file_nameROOT file name
histo_namesallocated array of histogram names
histo_dimallocated array of histogram dimensions
dminminimum dimension (1, 2 or 3)
dmaxmaximum dimension (1, 2 or 3)

Referenced by RGetHistoNames(), and RGHistoTools::SetFile().

Int_t RGetHistoNames ( const char  file_name[],
string *&  histo_names,
Int_t  dmin,
Int_t  dmax 
)

This function creates (allocates) a table of histogram names from a ROOT file. It only considers the last version of each histogram (highest cycle number). It returns a positive value if some histograms have been found, corresponding to the number of histograms (the tables must then be deleted by calling program). It returns 0 if no histogram was found, and a negative value in case of error.

Parameters
file_nameROOT file name
histo_namesallocated array of histogram names
dminminimum dimension (1, 2 or 3)
dmaxmaximum dimension (1, 2 or 3)

References RGetHistoNames().

bool RCheckDirObjects ( TDirectory *  dir,
const string &  obj_class,
bool  recur 
)

This function returns "true" if the ROOT directory contains one or more ROOT objects inheriting from the class name given as argument.

Parameters
dirROOT directory
obj_classROOT objects class name
recurrecursive search in sub-directories

References RCheckDirObjects().

Referenced by RCheckDirHisto(), RCheckDirObjects(), and RGetObjectTree().

u_int RCountDirObjects ( TDirectory *  dir,
const string &  obj_class,
bool  recur 
)

This function returns the number of ROOT objects inheriting from the class name given as argument in the directory. If several versions of the objects exist, they are counted only once.

Parameters
dirROOT directory
obj_classROOT objects class name
recurrecursive search in sub-directories

References RCountDirObjects().

Referenced by RCountDirHisto(), and RCountDirObjects().

RTreeBranchTObject* RGetObjectTree ( TDirectory *  dir,
const string &  obj_class 
)

Function creating a tree structure with pointers (RObject) on object from class given as argument in the ROOT directory.

Parameters
dirROOT directory
obj_classclass name of the objects to extract

References RCheckDirObjects(), and RGetObjectTree().

Referenced by RGetHistoTree(), and RGetObjectTree().

RTreeBranchTObject* RGetHistoTree ( TDirectory *  dir,
bool  local 
)

Function creating a tree structure with pointers (RObject) on histograms from the ROOT directory.

Parameters
dirROOT directory pointer
localif true, the histograms are set in local directory (0)

References RGetObjectTree().