MARLEY (Model of Argon Reaction Low Energy Yields)  v1.0.0
A Monte Carlo event generator for tens-of-MeV neutrino-nucleus interactions in liquid argon
 All Classes Functions Variables Enumerations Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
marley::ConfigurationFile Class Reference

Parser for a MARLEY Generator configuration file. More...

#include <ConfigurationFile.hh>

Inheritance diagram for marley::ConfigurationFile:
marley::RootConfigurationFile

Public Member Functions

 ConfigurationFile ()
 Create a ConfigurationFile object with all options set to their default values.
 
 ConfigurationFile (const std::string &file_name)
 Parse a file to create this ConfigurationFile object. More...
 
void add_reaction_filename (const std::string &rfile)
 Add a new reaction data file name. More...
 
void clear_reaction_filenames ()
 Clear the list of reaction data files.
 
const std::array< double, 3 > & get_neutrino_direction ()
 Gets a three-vector pointing in the direction of the incident neutrinos.
 
const std::unordered_set
< std::string > & 
get_reaction_filenames () const
 Get the name(s) of the reaction data files that will be used to create the Reaction object(s)
 
uint_fast64_t get_seed () const
 Get the random number seed that will be used to initialize a Generator.
 
std::unique_ptr
< marley::NeutrinoSource > & 
get_source ()
 Get a unique_ptr reference to the NeutrinoSource that will be used to help create a Generator object.
 
std::unique_ptr
< marley::StructureDatabase > & 
get_structure_db ()
 Get a unique_ptr reference to the StructureDatabase that will be used to help create a Generator object.
 
void print_summary (std::ostream &os=std::cout)
 Print a summary of the configuration file settings to a std::ostream.
 
void remove_reaction_filename (const std::string &rfile)
 Remove an existing reaction data file name. More...
 
void set_neutrino_direction (const std::array< double, 3 > &dir_vec)
 Sets the incident neutrino direction. More...
 
void set_seed (uint_fast64_t s)
 Set the random number seed that will be used to initialize a Generator.
 
void set_source (std::unique_ptr< marley::NeutrinoSource > &&new_source)
 Transfers ownership of a NeutrinoSource to this ConfigurationFile, deleting the previous source if one exists.
 
Executable option accessors

Functions that access configuration file options that are only used if MARLEY is being run as an executable

bool check_overwrite_hepevt () const
 Check whether a pre-existing HEPEvt file will be silently overwritten (true) or whether the executable will prompt the user to confirm an overwrite (false)
 
bool check_write_hepevt () const
 Check whether a HEPEvt format file will be written (true) or not (false)
 
std::string get_hepevt_filename () const
 Get the name of the HEPEvt format file that will receive Event output.
 
size_t get_num_events ()
 Get the number of events that should be generated during a single run of the executable.
 

Static Public Member Functions

static std::array< double, 3 > get_default_neutrino_direction ()
 Gets a three-vector pointing in the default incident neutrino direction.
 

Protected Member Functions

void add_decay_schemes (const std::string &file_name, const marley::DecayScheme::FileFormat format, const std::set< int > &nucleus_pdg_codes)
 Helper function to add DecayScheme objects to the structure database. More...
 
bool next_word_from_line (std::string &word, bool enable_exceptions=true, bool make_lowercase=true)
 Helper function for parse() that gets the next word from a parsed line of the configuration file. More...
 
void parse ()
 Helper function for the constructor that handles file parsing.
 
virtual bool process_extra_keywords ()
 Helper function that allows extra configuration file keywords to be processed by derived classes (like RootConfigurationFile) without needing to override parse(). More...
 
virtual bool process_extra_source_types (const std::string &type, int neutrino_pdg)
 Helper function that allows extra NeutrinoSource types to be created by derived classes (like RootConfigurationFile) without needing to override parse(). More...
 

Static Protected Member Functions

static std::string neutrino_pid_to_string (int pdg)
 Convert a neutrino PDG code to a string. More...
 

Protected Attributes

std::array< double, 3 > dir_vec_ = DEFAULT_INCIDENT_NEUTRINO_DIRECTION_
 Three-vector that points in the direction of the incident neutrinos.
 
std::string filename_
 Name of the configuration file to parse.
 
std::unordered_set< std::string > reaction_filenames_
 Reaction data files to parse when creating Reaction objects.
 
uint_fast64_t seed_
 Random number seed to use when creating a Generator.
 
std::unique_ptr
< marley::NeutrinoSource
source_
 A NeutrinoSource object that is created based on the specifications given in the configuration file. More...
 
std::unique_ptr
< marley::StructureDatabase
structure_db_
 StructureDatabase that holds the discrete level data specified in the configuration file.
 
File parsing helper variables
std::ifstream file_in_
 std::ifstream used to read the configuration file
 
std::istringstream iss_
 Stream used to parse each line.
 
std::string keyword_
 String that stores the current keyword read in from the configuration file.
 
std::string line_
 String that stores the current line of the configuration file during parsing.
 
size_t line_num_
 The current line number being processed.
 

Static Protected Attributes

static const std::array
< double, 3 > 
DEFAULT_INCIDENT_NEUTRINO_DIRECTION_ = { 0., 0., 1.}
 Default incident neutrino direction to use for generating events.
 

Executable options

Data members that store configuration file options that are only used if MARLEY is being run as an executable

bool check_hepevt_overwrite_
 Whether to prompt the user (true) or not (false) before overwriting a previously-existing HEPEvt format file.
 
std::string hepevt_filename_
 Name of the HEPEvt format file that will receive Event output.
 
size_t num_events_
 The number of events to generate.
 
bool write_hepevt_
 Whether to create a HEPEvt format output file (true) or not (false)
 
static constexpr size_t DEFAULT_NUM_EVENTS_ = 1000
 The default number of events to generate.
 

Detailed Description

Parser for a MARLEY Generator configuration file.

For details about the format of the configuration file, please see chapter 1 of the MARLEY user manual.

Constructor & Destructor Documentation

marley::ConfigurationFile::ConfigurationFile ( const std::string &  file_name)

Parse a file to create this ConfigurationFile object.

Parameters
file_nameThe name of the file to parse

Member Function Documentation

void marley::ConfigurationFile::add_decay_schemes ( const std::string &  file_name,
const marley::DecayScheme::FileFormat  format,
const std::set< int > &  nucleus_pdg_codes 
)
protected

Helper function to add DecayScheme objects to the structure database.

Parameters
file_nameName of the file containing the discrete level data
formatFormat of the file
nucleus_pdg_codesPDG codes for each nuclide whose discrete level data should be loaded from the file
Todo:
Consider altering the parsing process used here so that all nuclides are loaded from the file in one pass.
void marley::ConfigurationFile::add_reaction_filename ( const std::string &  rfile)
inline

Add a new reaction data file name.

Parameters
rfileName of the file to add
std::string marley::ConfigurationFile::neutrino_pid_to_string ( int  pdg)
staticprotected

Convert a neutrino PDG code to a string.

Parameters
pdgPDG code of the requested neutrino
Returns
Converted string (or "?" if unsuccessful)
bool marley::ConfigurationFile::next_word_from_line ( std::string &  word,
bool  enable_exceptions = true,
bool  make_lowercase = true 
)
protected

Helper function for parse() that gets the next word from a parsed line of the configuration file.

Parameters
[out]wordThe next word from the line
enable_exceptionsWhether to throw exceptions (true) or not (false) if a parsing problem occurs
make_lowercaseWhether to convert the word to all-lowercase (true) or leave it as is (false) before returning it
Returns
true if another word was found on the line, or false if the end of the line has been reached
bool marley::ConfigurationFile::process_extra_keywords ( )
protectedvirtual

Helper function that allows extra configuration file keywords to be processed by derived classes (like RootConfigurationFile) without needing to override parse().

This method is overridden by the derived class RootConfigurationFile to handle keywords specifying details of the ROOT output when MARLEY is run as an executable.

Returns
If an extra keyword was successfully processed, then this function returns true. Otherwise, it returns false.

Reimplemented in marley::RootConfigurationFile.

bool marley::ConfigurationFile::process_extra_source_types ( const std::string &  type,
int  neutrino_pdg 
)
inlineprotectedvirtual

Helper function that allows extra NeutrinoSource types to be created by derived classes (like RootConfigurationFile) without needing to override parse().

This method is overridden by the derived class RootConfigurationFile to allow NeutrinoSource objects to be created that require ROOT libraries to load.

Returns
If a NeutrinoSource was successfully created using one of the extra types, then this function returns true. Otherwise, it returns false.
Parameters
typeString from the configuration file indicating what NeutrinoSource type is being requested
intneutrino_pdg PDG code for the neutrino type produced by the new source

Reimplemented in marley::RootConfigurationFile.

void marley::ConfigurationFile::remove_reaction_filename ( const std::string &  rfile)
inline

Remove an existing reaction data file name.

Parameters
rfileName of the file to remove
void marley::ConfigurationFile::set_neutrino_direction ( const std::array< double, 3 > &  dir_vec)
inline

Sets the incident neutrino direction.

Parameters
dir_vecThree-vector that points in the direction of the incident neutrinos. It does not need to be normalized, but it must be nonzero, or a marley::Error will be thrown by this function

Member Data Documentation

std::unique_ptr<marley::NeutrinoSource> marley::ConfigurationFile::source_
protected

A NeutrinoSource object that is created based on the specifications given in the configuration file.

When a marley::Generator object is constructed using this ConfigurationFile, ownership of the NeutrinoSource will be transferred to the Generator. After this occurs, source_.get() will return nullptr.


The documentation for this class was generated from the following files: