|
BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Configuration and configuration parser class. More...
#include <Config.hh>

Public Member Functions | |
| void | ParseInputFile () |
| const std::vector< HistogramDef * > & | HistogramDefinitions (const std::string &treeName) const |
| Access all histogram definitions. | |
| const std::vector< HistogramDef * > & | HistogramDefinitionsSimple (const std::string &treeName) const |
| Access all simple histogram definitions - throws exception if out of range. | |
| const std::vector< HistogramDef * > & | HistogramDefinitionsPerEntry (const std::string &treeName) const |
| Access all per entry histogram definitions - throws exception if out of range. | |
| const std::vector< HistogramDefSet * > & | EventHistogramSetDefinitionsSimple () const |
| const std::vector< HistogramDefSet * > & | EventHistogramSetDefinitionsPerEntry () const |
| const std::vector< std::string > & | EventParticleSetNamesSimple () const |
| const std::vector< std::string > & | EventParticleSetNamesPerEntry () const |
| const RBDS::VectorString & | BranchesToBeActivated (const std::string &treeName) const |
| const RBDS::BranchMap & | BranchesToBeActivated () const |
| Access the map of all branches to be activated per tree. | |
| void | SetBranchToBeActivated (const std::string &treeName, const std::string &branchName) |
| Set a branch to be activated if not already. | |
| void | PrintHistogramSetDefinitions () const |
| void | FixCylindricalAndSphericalSamplerVariablesInSets (const std::set< std::string > &allCNames, const std::set< std::string > &allSNames) |
| std::string | GetOptionString (const std::string &key) const |
| General accessor for option. | |
| bool | GetOptionBool (const std::string &key) const |
| General accessor for option. | |
| double | GetOptionNumber (const std::string &key) const |
| General accessor for option. | |
| std::string | InputFilePath () const |
| Accessor. | |
| std::string | OutputFileName () const |
| Accessor. | |
| std::string | CalculateOpticalFunctionsFileName () const |
| Accessor. | |
| bool | AllBranchesToBeActivated () const |
| Accessor. | |
| bool | Debug () const |
| Accessor. | |
| bool | CalculateOpticalFunctions () const |
| Accessor. | |
| bool | EmittanceOnTheFly () const |
| Accessor. | |
| bool | ProcessSamplers () const |
| Accessor. | |
| bool | PrintOut () const |
| Accessor. | |
| double | PrintModuloFraction () const |
| Accessor. | |
| bool | PerEntryBeam () const |
| bool | PerEntryEvent () const |
| bool | PerEntryRun () const |
| bool | PerEntryOption () const |
| bool | PerEntryModel () const |
Static Public Member Functions | |
| static Config * | Instance (const std::string &fileName="", const std::string &inputFilePath="", const std::string &outputFileName="", const std::string &defaultOutputFileSuffix="_ana") |
| Singleton accessor. | |
Protected Member Functions | |
| Config ()=delete | |
| Private constructor for singleton pattern. | |
| Config (const std::string &inputFilePathIn, const std::string &outputFileNameIn, const std::string &defaultOutputFileSuffix="_ana") | |
| Constructor used when merging only. | |
| Config (const std::string &fileNameIn, const std::string &inputFilePathIn, const std::string &outputFileNameIn, const std::string &defaultOutputFileSuffix) | |
| Desired constructor, also private for singleton pattern. | |
| void | InitialiseOptions (const std::string &analysisFile) |
| void | ParseHistogramLine (const std::string &line) |
| Parse a line beginning with histogram. Uses other functions if appropriately defined. | |
| void | ParseSpectraLine (const std::string &line) |
| Parse a spectra definition line. | |
| void | ParseParticleSetLine (const std::string &line) |
| Parse a particle set line. | |
| void | ParseHistogram (const std::string &line, const int nDim) |
| Parse everything after the histogram declaration and check all parameters. | |
| void | ParsePerEntry (const std::string &name, bool &perEntry) const |
| bool | ContainsWordCI (const std::string &input, const std::string &word) const |
| Return true if 'input' contains 'word' - CI = case insensitive. | |
| void | ParseLog (const std::string &definition, bool &xLog, bool &yLog, bool &zLog) const |
| Parse whether each dimension is log or linear. | |
| void | UpdateRequiredBranches (const HistogramDef *def) |
| void | UpdateRequiredBranches (const std::string &treeName, const std::string &var) |
| bool | InvalidTreeName (const std::string &treeName) const |
| void | CheckValidTreeName (std::string &treeName) const |
| void | ParseBins (const std::string &bins, int nDim, BinSpecification &xBinning, BinSpecification &yBinning, BinSpecification &zBinning) const |
| void | ParseBinning (const std::string &binning, int nDim, BinSpecification &xBinning, BinSpecification &yBinning, BinSpecification &zBinning, bool xLog, bool yLog, bool zLog) const |
| std::vector< std::string > | SplitOnWhiteSpace (const std::string &line) const |
| Return a vector of strings by splitting on whitespace. | |
| std::set< ParticleSpec > | ParseParticles (const std::string &word) const |
| Parser a list of particle PDG IDs into a set. | |
| void | ParseSetting (const std::string &line) |
| Parse a settings line in input file and appropriate update member map. | |
| std::string | LowerCase (const std::string &st) const |
| Return a lower case copy of a string. | |
| bool | RegisterHistogramName (const std::string &newHistName) |
| ClassDef (Config, 1) | |
Protected Attributes | |
| int | lineCounter = 0 |
| Index of which line in the file we're on while parsing - for feedback. | |
| RBDS::BranchMap | branches |
| Cache of which branches need to be activated for this analysis. | |
| std::map< std::string, int > | spectraNames |
| std::set< std::string > | histogramNames |
Static Protected Attributes | |
| static Config * | instance |
| static std::vector< std::string > | treeNames |
| Vector of permitted tree names. | |
Private Attributes | |
| std::map< std::string, std::string > | alternateKeys |
| Private members first as required in accessors. | |
| std::map< std::string, std::vector< HistogramDef * > > | histoDefs |
| std::map< std::string, std::vector< HistogramDef * > > | histoDefsSimple |
| Copy of definition used to identify only 'simple' histogram definitions. Doesn't own. | |
| std::map< std::string, std::vector< HistogramDef * > > | histoDefsPerEntry |
| Copy of definition used to identify only 'per entry' histogram definitions. Doesn't own. | |
| std::vector< HistogramDefSet * > | eventHistoDefSetsSimple |
| Sets of histogram definitions per particle. Only for event branch. | |
| std::vector< HistogramDefSet * > | eventHistoDefSetsPerEntry |
| std::vector< std::string > | eventParticleSetBranches |
| List of branches in event tree to produce ParticleSet objects on. (per event and simple). | |
| std::vector< std::string > | eventParticleSetSimpleBranches |
| std::map< std::string, bool > | optionsBool |
| Storage of options. | |
| std::map< std::string, std::string > | optionsString |
| Storage of options. | |
| std::map< std::string, double > | optionsNumber |
| Storage of options. | |
|
protected |
Constructor used when merging only.
Definition at line 49 of file Config.cc.
References branches, RBDS::DefaultOutputName(), InitialiseOptions(), optionsBool, and optionsString.

|
protected |
Desired constructor, also private for singleton pattern.
Definition at line 73 of file Config.cc.
References RBDS::DefaultOutputName(), InitialiseOptions(), and optionsString.

|
inline |
|
inline |
|
inline |
Access all branches that are required for activation. This does not specialise on the leaf inside the branch and if one variable is required, the whole branch will be activated as there isn't much difference. This can of course be revised in future.
Definition at line 113 of file Config.hh.
References branches.
|
inline |
|
inline |
|
protected |
Check whether the tree name ends in a '.' or not and fix it (simple mistake. Then apply InvalidTreeName and throw std::string error if it's a problem.
Definition at line 587 of file Config.cc.
References InvalidTreeName(), and treeNames.
Referenced by ParseHistogram().


|
protected |
Return true if 'input' contains 'word' - CI = case insensitive.
Definition at line 495 of file Config.cc.
References LowerCase().
Referenced by ParseSpectraLine().


|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void Config::FixCylindricalAndSphericalSamplerVariablesInSets | ( | const std::set< std::string > & | allCNames, |
| const std::set< std::string > & | allSNames | ||
| ) |
Update the "energy" variable of any spectra histograms to "totalEnergy" for cylindrical and spherical samplers only as they have different variable names. This can only be done after loading data and knowing which samplers are of these types. Also, provide both sets of names so we can categorise each as plane, cylindrical or spherical sampler. This is done on sets of histograms which is uniquely for spectra.
Definition at line 565 of file Config.cc.
References eventHistoDefSetsSimple.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Access all per entry histogram definitions - throws exception if out of range.
Definition at line 98 of file Config.hh.
References histoDefsPerEntry.
|
inline |
Access all simple histogram definitions - throws exception if out of range.
Definition at line 94 of file Config.hh.
References histoDefsSimple.
Referenced by Analysis::SimpleHistograms().

|
protected |
Set defaults in member maps for all options so that the keys can always be accessed.
Definition at line 111 of file Config.cc.
References alternateKeys, branches, histoDefs, histoDefsPerEntry, histoDefsSimple, optionsBool, optionsNumber, optionsString, and treeNames.
Referenced by Config(), and Config().

|
inline |
|
static |
Singleton accessor.
Definition at line 153 of file Config.cc.
References Config().
Referenced by Analysis::PreparePerEntryHistograms(), Analysis::SimpleHistograms(), and EventAnalysis::SimpleHistograms().


|
protected |
Check if the supplied tree name is one of the static member vector of allowed tree names.
Definition at line 603 of file Config.cc.
References treeNames.
Referenced by CheckValidTreeName().

|
protected |
Return a lower case copy of a string.
Definition at line 785 of file Config.cc.
Referenced by ContainsWordCI(), ParseHistogram(), ParseHistogramLine(), ParseLog(), ParseParticles(), ParsePerEntry(), and ParseSetting().

|
inline |
|
protected |
Parse binning substring and check it has the right number of dimensions. Writes out via reference to pre-existing variables.
Definition at line 626 of file Config.cc.
References lineCounter, and RBDS::LoadBins().
Referenced by ParseHistogram(), and ParseSpectraLine().


|
protected |
Parse the bin substring and check it has the right number of dimensions. Writes out via reference to pre-existing variables.
Definition at line 608 of file Config.cc.
Referenced by ParseHistogram(), and ParseSpectraLine().

|
protected |
Parse everything after the histogram declaration and check all parameters.
Definition at line 276 of file Config.cc.
References CheckValidTreeName(), histoDefs, histoDefsPerEntry, histoDefsSimple, LowerCase(), optionsBool, ParseBinning(), ParseBins(), ParseLog(), ParsePerEntry(), RegisterHistogramName(), and UpdateRequiredBranches().
Referenced by ParseHistogramLine().


|
protected |
Parse a line beginning with histogram. Uses other functions if appropriately defined.
Definition at line 250 of file Config.cc.
References LowerCase(), ParseHistogram(), and ParseSetting().

|
protected |
Parse whether each dimension is log or linear.
Definition at line 503 of file Config.cc.
References LowerCase().
Referenced by ParseHistogram(), and ParseSpectraLine().


|
protected |
Parser a list of particle PDG IDs into a set.
Definition at line 720 of file Config.cc.
References LowerCase().
Referenced by ParseSpectraLine().


|
protected |
Parse a particle set line.
Definition at line 470 of file Config.cc.
References eventParticleSetBranches, ParsePerEntry(), SetBranchToBeActivated(), and SplitOnWhiteSpace().

|
protected |
Check whether a histogram definition word contains the world 'simple' and if so, it's not a per-entry histogram.
Definition at line 489 of file Config.cc.
References LowerCase().
Referenced by ParseHistogram(), ParseParticleSetLine(), and ParseSpectraLine().


|
protected |
Parse a settings line in input file and appropriate update member map.
Definition at line 792 of file Config.cc.
References alternateKeys, LowerCase(), optionsBool, optionsNumber, and optionsString.
Referenced by ParseHistogramLine().


|
protected |
Parse a spectra definition line.
Definition at line 389 of file Config.cc.
References ContainsWordCI(), eventHistoDefSetsSimple, ParseBinning(), ParseBins(), ParseLog(), ParseParticles(), ParsePerEntry(), SetBranchToBeActivated(), spectraNames, and SplitOnWhiteSpace().

|
inline |
Whether per entry loading is needed. Alternative is only TTree->Draw().
Definition at line 135 of file Config.hh.
References optionsBool.
|
inline |
Whether per entry loading is needed. Alternative is only TTree->Draw().
Definition at line 136 of file Config.hh.
References optionsBool.
|
inline |
Whether per entry loading is needed. Alternative is only TTree->Draw().
Definition at line 139 of file Config.hh.
References optionsBool.
|
inline |
Whether per entry loading is needed. Alternative is only TTree->Draw().
Definition at line 138 of file Config.hh.
References optionsBool.
|
inline |
Whether per entry loading is needed. Alternative is only TTree->Draw().
Definition at line 137 of file Config.hh.
References optionsBool.
| void Config::PrintHistogramSetDefinitions | ( | ) | const |
Print out the per event and simple histogram set definitions as these are (assumed to be) spectra definitions that people might want to see expanded.
Definition at line 554 of file Config.cc.
References eventHistoDefSetsSimple.
|
inline |
|
inline |
|
inline |
|
protected |
Register a histogram name for future checking against. If it already exists, the function returns true, else false for successful registration.
Definition at line 832 of file Config.cc.
Referenced by ParseHistogram().

| void Config::SetBranchToBeActivated | ( | const std::string & | treeName, |
| const std::string & | branchName | ||
| ) |
Set a branch to be activated if not already.
Definition at line 546 of file Config.cc.
References branches.
Referenced by ParseParticleSetLine(), ParseSpectraLine(), and UpdateRequiredBranches().

|
protected |
Return a vector of strings by splitting on whitespace.
Definition at line 705 of file Config.cc.
Referenced by ParseParticleSetLine(), and ParseSpectraLine().

|
protected |
Update the vector of required branches for a particular tree to be activated for analysis. Note this is not required for simple histograms that will be used with TTree->Draw(). Only per-entry histograms require loading the data.
Definition at line 521 of file Config.cc.
References UpdateRequiredBranches().
Referenced by ParseHistogram(), and UpdateRequiredBranches().


|
protected |
Update the vector of required branches for a particular tree to be activated for analysis based on a single string definition such as Primary.x.
Definition at line 527 of file Config.cc.
References SetBranchToBeActivated().

|
private |
Private members first as required in accessors.
Optional version of option keys in file.
Definition at line 46 of file Config.hh.
Referenced by InitialiseOptions(), and ParseSetting().
|
protected |
Cache of which branches need to be activated for this analysis.
Definition at line 259 of file Config.hh.
Referenced by BranchesToBeActivated(), BranchesToBeActivated(), Config(), InitialiseOptions(), and SetBranchToBeActivated().
|
private |
|
private |
Sets of histogram definitions per particle. Only for event branch.
Definition at line 65 of file Config.hh.
Referenced by FixCylindricalAndSphericalSamplerVariablesInSets(), ParseSpectraLine(), and PrintHistogramSetDefinitions().
|
private |
List of branches in event tree to produce ParticleSet objects on. (per event and simple).
Definition at line 69 of file Config.hh.
Referenced by ParseParticleSetLine().
|
private |
|
private |
Storage of histogram options. This owns the HistogramDef objects. Key is tree name, value is vector of all histogram definitions for that tree.
Definition at line 56 of file Config.hh.
Referenced by HistogramDefinitions(), InitialiseOptions(), and ParseHistogram().
|
private |
Copy of definition used to identify only 'per entry' histogram definitions. Doesn't own.
Definition at line 62 of file Config.hh.
Referenced by HistogramDefinitionsPerEntry(), InitialiseOptions(), and ParseHistogram().
|
private |
Copy of definition used to identify only 'simple' histogram definitions. Doesn't own.
Definition at line 59 of file Config.hh.
Referenced by HistogramDefinitionsSimple(), InitialiseOptions(), and ParseHistogram().
|
protected |
Index of which line in the file we're on while parsing - for feedback.
Definition at line 256 of file Config.hh.
Referenced by ParseBinning().
|
private |
Storage of options.
Definition at line 49 of file Config.hh.
Referenced by AllBranchesToBeActivated(), CalculateOpticalFunctions(), Config(), Debug(), EmittanceOnTheFly(), GetOptionBool(), InitialiseOptions(), ParseHistogram(), ParseSetting(), PerEntryBeam(), PerEntryEvent(), PerEntryModel(), PerEntryOption(), PerEntryRun(), PrintOut(), and ProcessSamplers().
|
private |
Storage of options.
Definition at line 51 of file Config.hh.
Referenced by GetOptionNumber(), InitialiseOptions(), ParseSetting(), and PrintModuloFraction().
|
private |
Storage of options.
Definition at line 50 of file Config.hh.
Referenced by CalculateOpticalFunctionsFileName(), Config(), Config(), GetOptionString(), InitialiseOptions(), InputFilePath(), OutputFileName(), and ParseSetting().
|
protected |
Cache of all spectra names declared to permit unique naming of histograms when there's more than one spectra per branch used.
Definition at line 263 of file Config.hh.
Referenced by ParseSpectraLine().
|
staticprotected |
Vector of permitted tree names.
Definition at line 47 of file Config.hh.
Referenced by CheckValidTreeName(), InitialiseOptions(), and InvalidTreeName().