A TSimpleAnalysis object creates histograms from a TChain.
These histograms are stored to an output file. The histogrammed (TTreeFormula) expressions, their cuts, the input and output files are configured through a simple config file that allows comments starting with '#'. Here an example of configuration file:
It is possible to use the script rootdrawtree that allows to use the class just in command line through the bash shell.
Definition at line 33 of file TSimpleAnalysis.h.
Public Member Functions | |
TSimpleAnalysis (const std::string &file) | |
TSimpleAnalysis (const std::string &output, const std::vector< std::string > &inputFiles, const std::vector< std::string > &expressions, const std::string &treeName) | |
Constructor for the case of command line parsing arguments. | |
bool | Configure () |
This function has the aim of setting the arguments read from the input file. | |
bool | Run () |
Execute all the TChain::Draw() as configured and stores the output histograms. | |
Private Types | |
enum | EReadingWhat { kReadingOutput , kReadingTreeName , kReadingInput , kReadingExpressions } |
The elements of the enumeration refer to the different types of elements that are in the input file. More... | |
Private Member Functions | |
std::string | GetLine (int &numbLine) |
Skip subsequent empty lines read from fIn and returns the next not empty line. | |
std::string | HandleExpressionConfig (const std::string &line) |
Handle the expression lines of the input file in order to pass the elements to the members of the object. | |
bool | HandleInputFileNameConfig (const std::string &line) |
Returns false if not a tree name, otherwise sets the name of the tree. | |
bool | SetTreeName () |
Disambiguate tree name from first input file and set up fTreeName if it is empty. | |
Private Attributes | |
std::string | fConfigFile |
Name of the configuration file. | |
std::map< std::string, std::pair< std::string, std::string > > | fHists |
The map contains in the first part the names of the histograms written in the output file, in the second part the pair of what is shown in the histograms and the cut applied on the variables. | |
std::ifstream | fIn |
Stream for the input file. | |
std::vector< std::string > | fInputFiles |
.root input files | |
std::string | fOutputFile |
Output file in which are stored the histograms. | |
std::string | fTreeName |
Name of the input tree. | |
#include <TSimpleAnalysis.h>
|
private |
The elements of the enumeration refer to the different types of elements that are in the input file.
Definition at line 48 of file TSimpleAnalysis.h.
|
inline |
Definition at line 62 of file TSimpleAnalysis.h.
TSimpleAnalysis::TSimpleAnalysis | ( | const std::string & | output, |
const std::vector< std::string > & | inputFiles, | ||
const std::vector< std::string > & | expressions, | ||
const std::string & | treeName = "" |
||
) |
Constructor for the case of command line parsing arguments.
It sets the members of the object.
[in] | output | - name of the output file |
[in] | inputFiles | - name of the input .root files |
[in] | expressions | - what is shown in the histograms |
[in] | treeName | - name of the tree |
std::runtime_error | in case of ill-formed expressions |
Definition at line 154 of file TSimpleAnalysis.cxx.
bool TSimpleAnalysis::Configure | ( | ) |
This function has the aim of setting the arguments read from the input file.
Definition at line 414 of file TSimpleAnalysis.cxx.
|
private |
Skip subsequent empty lines read from fIn and returns the next not empty line.
param[in] numbLine - number of the input file line
Definition at line 398 of file TSimpleAnalysis.cxx.
|
private |
Handle the expression lines of the input file in order to pass the elements to the members of the object.
param[in] line - TTreeFormula expression, either read form the configuration file or passed as expression to the constructor
Definition at line 98 of file TSimpleAnalysis.cxx.
|
private |
Returns false if not a tree name, otherwise sets the name of the tree.
param[in] line - line read from the input file
Definition at line 384 of file TSimpleAnalysis.cxx.
bool TSimpleAnalysis::Run | ( | ) |
Execute all the TChain::Draw() as configured and stores the output histograms.
Returns true if the analysis succeeds.
Definition at line 264 of file TSimpleAnalysis.cxx.
|
private |
Disambiguate tree name from first input file and set up fTreeName if it is empty.
Definition at line 234 of file TSimpleAnalysis.cxx.
|
private |
Name of the configuration file.
Definition at line 36 of file TSimpleAnalysis.h.
|
private |
The map contains in the first part the names of the histograms written in the output file, in the second part the pair of what is shown in the histograms and the cut applied on the variables.
Definition at line 44 of file TSimpleAnalysis.h.
|
private |
Stream for the input file.
Definition at line 40 of file TSimpleAnalysis.h.
|
private |
.root input files
Definition at line 37 of file TSimpleAnalysis.h.
|
private |
Output file in which are stored the histograms.
Definition at line 38 of file TSimpleAnalysis.h.
|
private |
Name of the input tree.
Definition at line 39 of file TSimpleAnalysis.h.