RootUtils
FileUtils.h
1 #ifndef FileUtils_hh
2 #define FileUtils_hh 1
3 
4 #include <TList.h>
5 #include <TH1.h>
6 #include <TFile.h>
7 #include <TString.h>
8 #include <TFile.h>
9 #include <TTree.h>
10 #include <TBranch.h>
11 #include <TCanvas.h>
12 #include <vector>
13 
30  TString path;
31  TString base;
32  TString name;
33  TString extension;
34 };
35 
41 namespace FileUtils {
42 
53  TList* findFilesInDirectory(const char *dirPath, const char *extension = 0);
54 
64  TFile* openFile(const char *filePathName, Option_t *option = "READ");
65 
74  TTree* getTree(TFile *file, const char *treeName);
75 
84  TBranch* getBranch(TTree *tree, const char *branchName);
85 
92  Double_t getBranchMinimum(TTree *tree, const char *branchName);
93 
100  Double_t getBranchMaximum(TTree *tree, const char *branchName);
101 
111  Double_t getBranchMinimumInFiles(TList *filePaths, const char *treeName, const char *branchName);
112 
122  Double_t getBranchMaximumInFiles(TList *filePaths, const char *treeName, const char *branchName);
123 
134  TH1* getBranchHistogram(TTree *tree, const char *branchName, Int_t nBins = 150);
135 
144  PathComponents parseFilePath(const char *filePathName);
145 
157  Int_t exportValuesToGnuplot(const char *filename, std::vector<std::string> colNames, std::vector<double> values,
158  const char *delimeter = " ");
159 
170  Int_t exportCanvasToGnuplot(TCanvas *canvas, const char *delimeter = " ");
171 
172  Int_t exportHistToGnuplot(TH1 *hist, const char *canvasName, const char *delimeter = " ");
173  Int_t exportFuncToGnuplot(TF1 *hist, const char *canvasName, const char *delimeter = " ");
174 }
175 
176 #endif
Definition: RootUtils.cxx:49
Double_t getBranchMinimumInFiles(TList *filePaths, const char *treeName, const char *branchName)
Get minimum value in a tree branch across multiple files.
Definition: FileUtils.cpp:156
TFile * openFile(const char *filePathName, Option_t *option="READ")
Open ROOT file with given absolute path.
Definition: FileUtils.cpp:78
Double_t getBranchMaximum(TTree *tree, const char *branchName)
Get maximum value in a tree branch.
Definition: FileUtils.cpp:115
TBranch * getBranch(TTree *tree, const char *branchName)
Safely get a branch from a ROOT tree.
Definition: FileUtils.cpp:99
Int_t exportCanvasToGnuplot(TCanvas *canvas, const char *delimeter=" ")
Export ROOT canvas to ASCII file with data columns.
Definition: FileUtils.cpp:303
Double_t getBranchMinimum(TTree *tree, const char *branchName)
Get minimum value in a tree branch.
Definition: FileUtils.cpp:108
PathComponents parseFilePath(const char *filePathName)
Parse absolute file path into path, name and extension.
Definition: FileUtils.cpp:122
TTree * getTree(TFile *file, const char *treeName)
Parse absolute file path into path, name and extension.
Definition: FileUtils.cpp:90
TList * findFilesInDirectory(const char *dirPath, const char *extension=0)
Obtain list of file paths in directory (with given extension).
Definition: FileUtils.cpp:25
TH1 * getBranchHistogram(TTree *tree, const char *branchName, Int_t nBins=150)
Shortcut to get a histogram from ROOT tree branch.
Definition: FileUtils.cpp:194
Double_t getBranchMaximumInFiles(TList *filePaths, const char *treeName, const char *branchName)
Get maximum value in a tree branch across multiple files.
Definition: FileUtils.cpp:175
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.
Definition: FileUtils.cpp:208
Struct contains path components returned by the parseFilePath() method.
Definition: FileUtils.h:29
TString base
Definition: FileUtils.h:31
TString extension
Definition: FileUtils.h:33
TString name
Definition: FileUtils.h:32
TString path
Definition: FileUtils.h:30