![]() |
GWOLLUM 4.2.0
Tools for gravitational-wave analyses
|
Interface to manage options. More...
#include <GwollumOptions.h>
Public Member Functions | |
void | Add (const string aTag, const string aKey, const double aDefaultValue, const unsigned int aSize=0) |
Adds an option to the list (double). | |
void | Add (const string aTag, const string aKey, const int aDefaultValue, const unsigned int aSize=0) |
Adds an option to the list (int). | |
void | Add (const string aTag, const string aKey, const string aDefaultValue, const unsigned int aSize=0) |
Adds an option to the list (string). | |
void | Add (const string aTag, const string aKey, const unsigned int aDefaultValue, const unsigned int aSize=0) |
Adds an option to the list (unsigned int). | |
void | AddOptionValue (const string aTag, const string aKey, const double aValue) |
Appends a value to a variable-size option (double). | |
void | AddOptionValue (const string aTag, const string aKey, const int aValue) |
Appends a value to a variable-size option (int). | |
void | AddOptionValue (const string aTag, const string aKey, const string aValue) |
Appends a value to a variable-size option (string). | |
void | AddOptionValue (const string aTag, const string aKey, const unsigned int aValue) |
Appends a value to a variable-size option (unsigned int). | |
void | Copy (GwollumOptions *aG) |
Copies an external GwollumOptions object into this. | |
void | FillTree (void) |
Saves options in a TTree. | |
double | GetOptionDefaultD (const unsigned int aOptionIndex) |
Returns an option default value. | |
int | GetOptionDefaultI (const unsigned int aOptionIndex) |
Returns an option default value. | |
string | GetOptionDefaultS (const unsigned int aOptionIndex) |
Returns an option default value. | |
unsigned int | GetOptionDefaultU (const unsigned int aOptionIndex) |
Returns an option default value. | |
unsigned int | GetOptionIndex (const string aTag, const string aKey) |
Returns the option index. | |
string | GetOptionKey (const unsigned int aOptionIndex) |
Returns an option key. | |
unsigned int | GetOptionNumberOfValues (const string aTag, const string aKey) |
Returns the option number of values. | |
unsigned int | GetOptionSize (const string aTag, const string aKey) |
Returns the option size. | |
unsigned int | GetOptionSize (const unsigned int aOptionIndex) |
Returns an option size. | |
unsigned int | GetOptionsN (void) |
Returns the number of options. | |
string | GetOptionTag (const unsigned int aOptionIndex) |
Returns an option tag. | |
char | GetOptionType (const string aTag, const string aKey) |
Returns the option type. | |
char | GetOptionType (const unsigned int aOptionIndex) |
Returns an option type. | |
double | GetOptionValueD (const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (double). | |
bool | GetOptionValueD (double &aValue, const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (double). | |
int | GetOptionValueI (const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (int). | |
bool | GetOptionValueI (int &aValue, const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (int). | |
string | GetOptionValueS (const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (string). | |
bool | GetOptionValueS (string &aValue, const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (string). | |
vector< double > | GetOptionValuesD (const string aTag, const string aKey) |
Returns the list of option values (double). | |
vector< int > | GetOptionValuesI (const string aTag, const string aKey) |
Returns the list of option values (int). | |
vector< string > | GetOptionValuesS (const string aTag, const string aKey) |
Returns the list of option values (string). | |
vector< unsigned int > | GetOptionValuesU (const string aTag, const string aKey) |
Returns the list of option values (unsigned int). | |
unsigned int | GetOptionValueU (const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (unsigned int). | |
bool | GetOptionValueU (unsigned int &aValue, const string aTag, const string aKey, const unsigned int aValIndex) |
Returns an option value (unsigned int). | |
bool | Is (const string aTag, const string aKey) |
Checks whether an option exists. | |
bool | IsProvided (const string aTag, const string aKey) |
Checks whether an option was provided. | |
bool | IsTheSame (GwollumOptions *aG) |
Checks whether two GwollumOptions objects are identical. | |
bool | ReadChain (bool &aIsUniform, TChain *aChain) |
Reads options from a TChain. | |
unsigned int | ReadTextFile (const string aOptionFile) |
Reads an option file and extract the list of options. | |
bool | ReadTree (const string aRootFileName, const string aTreeName) |
Reads options from a TTree in a ROOT file. | |
bool | ReadTree (TTree *aTree) |
Reads options from a TTree. | |
void | RemoveOption (const string aTag, const string aKey) |
Removes an option. | |
void | Reset (void) |
Resets the list of options. | |
void | ResetOption (const string aTag, const string aKey) |
Resets the list of option values. | |
void | SetDefault (const string aTag, const string aKey) |
Sets an option to default value. | |
void | SetOptionValue (const string aTag, const string aKey, const unsigned int aValIndex, const double aValue) |
Sets a value of an option (double). | |
void | SetOptionValue (const string aTag, const string aKey, const unsigned int aValIndex, const int aValue) |
Sets a value of an option (int). | |
void | SetOptionValue (const string aTag, const string aKey, const unsigned int aValIndex, const string aValue) |
Sets a value of an option (string). | |
void | SetOptionValue (const string aTag, const string aKey, const unsigned int aValIndex, const unsigned int aValue) |
Sets a value of an option (unsigned int). | |
void | WriteH5 (H5::H5File *aFile, H5::DataSpace &aDataSpace) |
Writes the options as attributes in a hdf5 file. | |
void | WriteTextFile (const string aFileName) |
Writes all options in a text file. | |
void | WriteTree (const string aTreeName) |
Writes the option TTree in a TFile. | |
void | WriteTree (const string aTreeName, const string aRootFileName, const string aSubDirectory="") |
Writes the option TTree in a TFile. | |
Constructors and destructors | |
GwollumOptions (void) | |
Constructor of the GwollumOptions class. | |
virtual | ~GwollumOptions (void) |
Destructor of the GwollumOptions class. | |
Private Attributes | |
Monitor * | mon |
Class monitor. | |
vector< GwollumOption > | options |
List of options. | |
TTree * | OptTree |
Option TTree. | |
double | t_ddef |
Option TTree: default (double). | |
double | t_dval |
Option TTree: value (double). | |
int | t_idef |
Option TTree: default (int). | |
int | t_ival |
Option TTree: value (int). | |
string | t_key |
Option TTree: key. | |
string | t_sdef |
Option TTree: default (string). | |
unsigned int | t_size |
Option TTree: size. | |
string | t_sval |
Option TTree: value (string). | |
string | t_tag |
Option TTree: tag. | |
char | t_type |
Option TTree: type. | |
unsigned int | t_udef |
Option TTree: default (unsigned int). | |
unsigned int | t_uval |
Option TTree: value (unsigned int). | |
Interface to manage options.
This class offers a single interface to manage a list of options. A single option is described by the GwollumOption class.
A set of options can be created "manually" by calling the Add() functions. Then, it is possible to parse a text file to get the values for the options with ReadTextFile().
Another possibility is to call the ReadTree() or ReadChain() functions which downloads the option value from a TTree. In this case, the list of options is completely determined by the content of the TTree.
A set of options can then be saved:
GwollumOptions::GwollumOptions | ( | void | ) |
Constructor of the GwollumOptions class.
|
virtual |
Destructor of the GwollumOptions class.
void GwollumOptions::Add | ( | const string | aTag, |
const string | aKey, | ||
const double | aDefaultValue, | ||
const unsigned int | aSize = 0 |
||
) |
Adds an option to the list (double).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aDefaultValue | Default value. |
[in] | aSize | Number of values for this option. Use 0 for no limits on the size. |
void GwollumOptions::Add | ( | const string | aTag, |
const string | aKey, | ||
const int | aDefaultValue, | ||
const unsigned int | aSize = 0 |
||
) |
Adds an option to the list (int).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aDefaultValue | Default value. |
[in] | aSize | Number of values for this option. Use 0 for no limits on the size. |
void GwollumOptions::Add | ( | const string | aTag, |
const string | aKey, | ||
const string | aDefaultValue, | ||
const unsigned int | aSize = 0 |
||
) |
Adds an option to the list (string).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aDefaultValue | Default value. |
[in] | aSize | Number of values for this option. Use 0 for no limits on the size. |
void GwollumOptions::Add | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aDefaultValue, | ||
const unsigned int | aSize = 0 |
||
) |
Adds an option to the list (unsigned int).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aDefaultValue | Default value. |
[in] | aSize | Number of values for this option. Use 0 for no limits on the size. |
void GwollumOptions::AddOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const double | aValue | ||
) |
Appends a value to a variable-size option (double).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValue | New value to append. |
void GwollumOptions::AddOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const int | aValue | ||
) |
Appends a value to a variable-size option (int).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValue | New value to append. |
void GwollumOptions::AddOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const string | aValue | ||
) |
Appends a value to a variable-size option (string).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValue | New value to append. |
void GwollumOptions::AddOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValue | ||
) |
Appends a value to a variable-size option (unsigned int).
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValue | New value to append. |
void GwollumOptions::Copy | ( | GwollumOptions * | aG | ) |
Copies an external GwollumOptions object into this.
Previous options are reset (as well as the TTree). New options are imported.
[in] | aG | GwollumOptions object to copy. |
void GwollumOptions::FillTree | ( | void | ) |
Saves options in a TTree.
The options are saved in a TTree. Call this function when all options have been set. Then, the option TTree can be saved in a ROOT file by calling WriteTree().
|
inline |
Returns an option default value.
[in] | aOptionIndex | Option index. |
|
inline |
Returns an option default value.
[in] | aOptionIndex | Option index. |
|
inline |
Returns an option default value.
[in] | aOptionIndex | Option index. |
|
inline |
Returns an option default value.
[in] | aOptionIndex | Option index. |
|
inline |
Returns the option index.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
|
inline |
Returns an option key.
[in] | aOptionIndex | Option index. |
unsigned int GwollumOptions::GetOptionNumberOfValues | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the option number of values.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
unsigned int GwollumOptions::GetOptionSize | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the option size.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
|
inline |
Returns an option size.
[in] | aOptionIndex | Option index. |
|
inline |
Returns the number of options.
|
inline |
Returns an option tag.
[in] | aOptionIndex | Option index. |
char GwollumOptions::GetOptionType | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the option type.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
|
inline |
Returns an option type.
[in] | aOptionIndex | Option index. |
double GwollumOptions::GetOptionValueD | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (double).
The option is identified by its tag and key words. For this option, the value index must be provided.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
bool GwollumOptions::GetOptionValueD | ( | double & | aValue, |
const string | aTag, | ||
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (double).
The option is identified by its tag and key words. For this option, the value index must be provided.
[out] | aValue | Returned option value. |
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
int GwollumOptions::GetOptionValueI | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (int).
The option is identified by its tag and key words. For this option, the value index must be provided.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
bool GwollumOptions::GetOptionValueI | ( | int & | aValue, |
const string | aTag, | ||
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (int).
The option is identified by its tag and key words. For this option, the value index must be provided.
[out] | aValue | Returned option value. |
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
string GwollumOptions::GetOptionValueS | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (string).
The option is identified by its tag and key words. For this option, the value index must be provided.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
bool GwollumOptions::GetOptionValueS | ( | string & | aValue, |
const string | aTag, | ||
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (string).
The option is identified by its tag and key words. For this option, the value index must be provided.
[out] | aValue | Returned option value. |
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
vector< double > GwollumOptions::GetOptionValuesD | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the list of option values (double).
The option is identified by its tag and key words.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
vector< int > GwollumOptions::GetOptionValuesI | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the list of option values (int).
The option is identified by its tag and key words.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
vector< string > GwollumOptions::GetOptionValuesS | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the list of option values (string).
The option is identified by its tag and key words.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
vector< unsigned int > GwollumOptions::GetOptionValuesU | ( | const string | aTag, |
const string | aKey | ||
) |
Returns the list of option values (unsigned int).
The option is identified by its tag and key words.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
unsigned int GwollumOptions::GetOptionValueU | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (unsigned int).
The option is identified by its tag and key words. For this option, the value index must be provided.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
bool GwollumOptions::GetOptionValueU | ( | unsigned int & | aValue, |
const string | aTag, | ||
const string | aKey, | ||
const unsigned int | aValIndex | ||
) |
Returns an option value (unsigned int).
The option is identified by its tag and key words. For this option, the value index must be provided.
[out] | aValue | Returned option value. |
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
|
inline |
Checks whether an option exists.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
bool GwollumOptions::IsProvided | ( | const string | aTag, |
const string | aKey | ||
) |
Checks whether an option was provided.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
bool GwollumOptions::IsTheSame | ( | GwollumOptions * | aG | ) |
Checks whether two GwollumOptions objects are identical.
They are said to be identical if:
[in] | aG | GwollumOptions object to test. |
bool GwollumOptions::ReadChain | ( | bool & | aIsUniform, |
TChain * | aChain | ||
) |
Reads options from a TChain.
The first tree in the TChain is used to define the option set. Then, the next trees in the TChain are scanned and tested against the option set with IsTheSame(). If the list of options (not the values!) are consistent across the TChain, the option set is said to be uniform. The result of this check is returned.
[out] | aIsUniform | Flag set to true if the list of options (not the values!) are uniform across the TChain. |
[in] | aChain | Pointer to the option TChain. |
unsigned int GwollumOptions::ReadTextFile | ( | const string | aOptionFile | ) |
Reads an option file and extract the list of options.
The input text file is scanned with the IO class. All the key/tag options defined until now are extracted:
[in] | aOptionFile | Path to the option file. |
bool GwollumOptions::ReadTree | ( | const string | aRootFileName, |
const string | aTreeName | ||
) |
Reads options from a TTree in a ROOT file.
[in] | aRootFileName | Path to the ROOT file. |
[in] | aTreeName | Option TTree name. |
bool GwollumOptions::ReadTree | ( | TTree * | aTree | ) |
Reads options from a TTree.
[in] | aTree | Pointer to the option TTree. |
void GwollumOptions::RemoveOption | ( | const string | aTag, |
const string | aKey | ||
) |
Removes an option.
The option matching the input tag and key is removed from the list.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
|
inline |
Resets the list of options.
void GwollumOptions::ResetOption | ( | const string | aTag, |
const string | aKey | ||
) |
Resets the list of option values.
All the option values are removed. Fixed-size option values are set to default. Variable-size options are simply empty.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
void GwollumOptions::SetDefault | ( | const string | aTag, |
const string | aKey | ||
) |
Sets an option to default value.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
void GwollumOptions::SetOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex, | ||
const double | aValue | ||
) |
Sets a value of an option (double).
This function can only be used to update an existing option value.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
[in] | aValue | New value. |
void GwollumOptions::SetOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex, | ||
const int | aValue | ||
) |
Sets a value of an option (int).
This function can only be used to update an existing option value.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
[in] | aValue | New value. |
void GwollumOptions::SetOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex, | ||
const string | aValue | ||
) |
Sets a value of an option (string).
This function can only be used to update an existing option value.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
[in] | aValue | New value. |
void GwollumOptions::SetOptionValue | ( | const string | aTag, |
const string | aKey, | ||
const unsigned int | aValIndex, | ||
const unsigned int | aValue | ||
) |
Sets a value of an option (unsigned int).
This function can only be used to update an existing option value.
[in] | aTag | Option tag. |
[in] | aKey | Option aKey. |
[in] | aValIndex | Value index. |
[in] | aValue | New value. |
void GwollumOptions::WriteH5 | ( | H5::H5File * | aFile, |
H5::DataSpace & | aDataSpace | ||
) |
Writes the options as attributes in a hdf5 file.
[in] | aFile | Pointer to an open Hdf5 file. |
[in] | aDataSpace | Data space for the attributes. |
void GwollumOptions::WriteTextFile | ( | const string | aFileName | ) |
Writes all options in a text file.
[in] | aFileName | Path to the output text file. |
|
inline |
Writes the option TTree in a TFile.
[in] | aTreeName | TTree name. |
void GwollumOptions::WriteTree | ( | const string | aTreeName, |
const string | aRootFileName, | ||
const string | aSubDirectory = "" |
||
) |
Writes the option TTree in a TFile.
[in] | aTreeName | TTree name. |
[in] | aRootFileName | Path to the ROOT file. |
[in] | aSubDirectory | Sub-directory name. |
|
private |
Class monitor.
|
private |
List of options.
|
private |
Option TTree.
|
private |
Option TTree: default (double).
|
private |
Option TTree: value (double).
|
private |
Option TTree: default (int).
|
private |
Option TTree: value (int).
|
private |
Option TTree: key.
|
private |
Option TTree: default (string).
|
private |
Option TTree: size.
|
private |
Option TTree: value (string).
|
private |
Option TTree: tag.
|
private |
Option TTree: type.
|
private |
Option TTree: default (unsigned int).
|
private |
Option TTree: value (unsigned int).