3.1. Properties files¶
The class Properties provides the parsing of simple properties files.
3.1.1. Definition of a property¶
A simple property can be defined by:
key: value
or with a unit (the CLHEP system of units is used):
key: value * unit
Also available as a unit is the “%” sign.
3.1.2. Definition of a properties table¶
You can think of many properties which have to be supplied as a function of a certain variable. For this, a table can be defined. The header reads:
table-name: tabular
field1 field2 field3 ....
- Or again with units::
- table-name: tabular
- field1 / unit field2 / unit field3 / unit ...
whereas the columns should be separated by tabulators to increased readability. Additionally, the properties could be edited with a spreadsheet software when importing / exporting as CSV file.
3.1.2.1. Example¶
For SiPMs, the photon detection efficiency is a function of the photon wavelength:
photonDetectionEfficiency: tabular
entry wavelength / nm efficiency / %
1 319.490 9.18187959596
1 320.882 9.79401373737
1 322.274 10.2530812121
1 323.666 12.7016177778
1 326.450 14.3849535354
1 327.842 14.9970876768
1 329.234 16.2213559596
1 330.626 16.833490101
...
3.1.3. Source¶
-
class
Properties
¶ This class can parse ”.properties” files containing key-value-pairs and tables.
Uses boost::regex to match the contents.
Public Types
-
typedef std::map<std::string, std::vector<double>>
tabular
¶ Type represents a table in the property file.
Public Functions
-
bool
load
(std::string filename)¶ - Return
- boolean - true if the file could be parsed completely.
- Parameters
filename
: - the properties file name.
-
double
getNumber
(std::string key) const¶ - Return
- double - the number.
- Parameters
key
: - the key.
-
std::string
getString
(std::string key) const¶ - Return
- string - the string.
- Parameters
key
: - the key.
-
Properties::tabular
getTabular
(std::string key) const¶ - Return
- map - the tabular data.
- Parameters
key
: - the key.
-
bool
containsNumber
(std::string key) const¶ - Return
- boolean - true if the key-number-pair exists.
- Parameters
key
: - the key.
-
bool
containsString
(std::string key) const¶ - Return
- boolean - true if the key-string-pair exists.
- Parameters
key
: - the key.
-
bool
containsTabular
(std::string key) const¶ - Return
- boolean - true if the key-tabular-pair exists.
- Parameters
key
: - the key.
-
std::string
toString
() const¶ - Return
- prints all properties to a string which is compatible with the file format.
-
void
print
() const¶ Print all read properties.
-
std::string
getFilename
() const¶ - Return
- string - the file name.
-
typedef std::map<std::string, std::vector<double>>