RootUtils
|
Functions | |
TList * | findFilesInDirectory (const char *dirPath, const char *extension=0) |
Obtain list of file paths in directory (with given extension). More... | |
TFile * | openFile (const char *filePathName, Option_t *option="READ") |
Open ROOT file with given absolute path. More... | |
TTree * | getTree (TFile *file, const char *treeName) |
Parse absolute file path into path, name and extension. More... | |
TBranch * | getBranch (TTree *tree, const char *branchName) |
Safely get a branch from a ROOT tree. More... | |
Double_t | getBranchMinimum (TTree *tree, const char *branchName) |
Get minimum value in a tree branch. More... | |
Double_t | getBranchMaximum (TTree *tree, const char *branchName) |
Get maximum value in a tree branch. More... | |
Double_t | getBranchMinimumInFiles (TList *filePaths, const char *treeName, const char *branchName) |
Get minimum value in a tree branch across multiple files. More... | |
Double_t | getBranchMaximumInFiles (TList *filePaths, const char *treeName, const char *branchName) |
Get maximum value in a tree branch across multiple files. More... | |
TH1 * | getBranchHistogram (TTree *tree, const char *branchName, Int_t nBins=150) |
Shortcut to get a histogram from ROOT tree branch. More... | |
PathComponents | parseFilePath (const char *filePathName) |
Parse absolute file path into path, name and extension. More... | |
Int_t | exportValuesToGnuplot (const char *filename, std::vector< std::string > colNames, std::vector< double > values, const char *delimeter=" ") |
Append or save data to a Gnuplot file. More... | |
Int_t | exportCanvasToGnuplot (TCanvas *canvas, const char *delimeter=" ") |
Export ROOT canvas to ASCII file with data columns. More... | |
Contains useful functions for ROOT file manipulation.
Int_t FileUtils::exportCanvasToGnuplot | ( | TCanvas * | canvas, |
const char * | delimeter = " " |
||
) |
Export ROOT canvas to ASCII file with data columns.
Function saves objects on Canvas - histograms, graph, function - to a text file ready to plot in Gnuplot.
filename | absolute file path. |
canvas | ROOT canvas to be saved. |
delimeter | column delimeter (default " "). |
Int_t FileUtils::exportValuesToGnuplot | ( | const char * | filename, |
std::vector< std::string > | colNames, | ||
std::vector< double > | values, | ||
const char * | delimeter = " " |
||
) |
Append or save data to a Gnuplot file.
Function creates a new or opens existing ASCII file. Next, it appends a line of values to the file.
filename | absolute file path. |
colNames | vector of strings with column names. |
colNames | vector of doubles with row values. |
delimeter | column delimeter (default " "). |
TList * FileUtils::findFilesInDirectory | ( | const char * | dirPath, |
const char * | extension = 0 |
||
) |
Obtain list of file paths in directory (with given extension).
Function returns a TList* of TObjString* with full absolute paths of files in a given directory with given extension. Program exits if directory does not exist or not readable.
dirPath | Directory path. |
extension | Optional extension of files to find. |
TBranch * FileUtils::getBranch | ( | TTree * | tree, |
const char * | branchName | ||
) |
Safely get a branch from a ROOT tree.
Function will stop program execution if the branch is not found.
tree | pointer to the TTree. |
TH1 * FileUtils::getBranchHistogram | ( | TTree * | tree, |
const char * | branchName, | ||
Int_t | nBins = 150 |
||
) |
Shortcut to get a histogram from ROOT tree branch.
Function automatically determines histogram minimum and maximum.
tree | Pointer to the tree. |
branchName | branchName name of a branch. |
nBins | number of bins in the histogram. Default is 150. |
Double_t FileUtils::getBranchMaximum | ( | TTree * | tree, |
const char * | branchName | ||
) |
Get maximum value in a tree branch.
tree | pointer to the TTree. |
Double_t FileUtils::getBranchMaximumInFiles | ( | TList * | filePaths, |
const char * | treeName, | ||
const char * | branchName | ||
) |
Get maximum value in a tree branch across multiple files.
Function is useful when simultaneously plotting a number of ROOT files with the same structure.
filePaths | list of filepaths to be opened (TObjStrings*). |
treeName | name of the tree in the ROOT file. |
Double_t FileUtils::getBranchMinimum | ( | TTree * | tree, |
const char * | branchName | ||
) |
Get minimum value in a tree branch.
tree | pointer to the TTree. |
Double_t FileUtils::getBranchMinimumInFiles | ( | TList * | filePaths, |
const char * | treeName, | ||
const char * | branchName | ||
) |
Get minimum value in a tree branch across multiple files.
Function is useful when simultaneously plotting a number of ROOT files with the same structure.
filePaths | list of filepaths to be opened (TObjStrings*). |
treeName | name of the tree in the ROOT file. |
TTree * FileUtils::getTree | ( | TFile * | file, |
const char * | treeName | ||
) |
Parse absolute file path into path, name and extension.
Function parses file path into components: path, basename, name, extension.
filePathName | absolute file path. |
TFile * FileUtils::openFile | ( | const char * | filePathName, |
Option_t * | option = "READ" |
||
) |
Open ROOT file with given absolute path.
Function checks if a file is good and returns a pointer to a ROOT file TFile* with given absolute path.
filePathName | full ROOT file URI. |
filePathName | ROOT option "NEW", "RECREATE", "UPDATE", "READ".. (optional, default is "READ"). |
PathComponents FileUtils::parseFilePath | ( | const char * | filePathName | ) |
Parse absolute file path into path, name and extension.
Function parses file path into components: path, basename, name, extension.
filePathName | absolute file path. |