flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY

Handles reading and writing of SLHA files. More...

#include <slha_io.hpp>

Collaboration diagram for flexiblesusy::SLHA_io:
Collaboration graph

Classes

struct  CKM_wolfenstein
 
struct  Modsel
 

Public Types

enum  Position { front , back }
 
using Tuple_processor = std::function< void(int, double)>
 

Public Member Functions

bool block_exists (const std::string &) const
 
void clear ()
 
void fill (FlexibleDecay_settings &) const
 
void fill (LToLConversion_settings &) const
 
void fill (Physical_input &) const
 
void fill (softsusy::QedQcd &) const
 
void fill (Spectrum_generator_settings &) const
 
const SLHAea::Collget_data () const
 
const Modselget_modsel () const
 
SLHA_iooperator= (const SLHA_io &)
 
SLHA_iooperator= (SLHA_io &&) noexcept
 
double read_block (const std::string &, const Tuple_processor &) const
 
double read_block (const std::string &, double &) const
 
template<class Derived >
double read_block (const std::string &, Eigen::PlainObjectBase< Derived > &) const
 
double read_entry (const std::string &, int) const
 
void read_from_file (const std::string &)
 opens SLHA input file and reads the content More...
 
void read_from_source (const std::string &)
 reads from source More...
 
void read_from_stream (std::istream &)
 clears stored data and reads SLHA data from a stream More...
 
double read_scale (const std::string &) const
 
void set_block (const std::ostringstream &, Position position=back)
 
template<class Derived >
void set_block (const std::string &, const Eigen::MatrixBase< Derived > &, const std::string &, double scale=0.)
 
void set_block (const std::string &, double, const std::string &, double scale=0.)
 
void set_block (const std::string &, Position position=back)
 
template<class Derived >
void set_block_imag (const std::string &, const Eigen::MatrixBase< Derived > &, const std::string &, double scale=0.)
 
void set_blocks (const std::vector< std::string > &, Position position=back)
 
void set_data (const SLHAea::Coll &)
 
void set_effectivecouplings_block (const std::vector< std::tuple< int, int, int, double, std::string > > &)
 
void set_FlexibleDecay_settings (const FlexibleDecay_settings &)
 
void set_LToLConversion_settings (const LToLConversion_settings &)
 
void set_modsel (const Modsel &)
 
void set_physical_input (const Physical_input &)
 
void set_settings (const Spectrum_generator_settings &)
 
void set_sminputs (const softsusy::QedQcd &)
 
void set_unitarity_infinite_s (Spectrum_generator_settings const &, UnitarityInfiniteS const &)
 
 SLHA_io ()
 
 SLHA_io (const SLHA_io &)
 
 SLHA_io (SLHA_io &&) noexcept
 
void write_to_file (const std::string &) const
 
void write_to_stream () const
 
void write_to_stream (std::ostream &) const
 
 ~SLHA_io ()
 

Private Member Functions

double read_matrix (const std::string &, double *, int, int) const
 
double read_matrix (const std::string &, std::complex< double > *, int, int) const
 
void read_modsel ()
 
double read_vector (const std::string &, double *, int) const
 
double read_vector (const std::string &, std::complex< double > *, int) const
 
void set_matrix (const std::string &, const double *, const std::string &, double, int, int)
 
void set_matrix (const std::string &, const std::complex< double > *, const std::string &, double, int, int)
 
void set_matrix_imag (const std::string &, const double *, const std::string &, double, int, int)
 
void set_matrix_imag (const std::string &, const std::complex< double > *, const std::string &, double, int, int)
 
void set_vector (const std::string &, const double *, const std::string &, double, int)
 
void set_vector (const std::string &, const std::complex< double > *, const std::string &, double, int)
 
void set_vector_imag (const std::string &, const double *, const std::string &, double, int)
 
void set_vector_imag (const std::string &, const std::complex< double > *, const std::string &, double, int)
 

Static Private Member Functions

static std::string block_head (const std::string &name, double scale)
 
static bool read_scale (const SLHAea::Line &line, double &scale)
 

Private Attributes

std::unique_ptr< SLHAea::Colldata
 SHLA data. More...
 
Modsel modsel {}
 data from block MODSEL More...
 

Detailed Description

Handles reading and writing of SLHA files.

Reading: There are two ways to read block entries from SLHA files: a) using the read_block() function with a SLHA_io::Tuple_processor or b) using the read_entry() function for each entry. Note, that a) is much faster than b) (more than 1000 times) because b) needs to search for the block each time read_entry() is called.

Example how to use a tuple processor (fast!):

void process_tuple(double* array, int key, double value) {
array[key] = value;
}
void read_file() {
double array[1000];
SLHA_io reader;
reader.read_from_file("file.slha");
SLHA_io::Tuple_processor processor = [&array] (int key, double value) {
return process_tuple(array, key, value);
};
reader.read_block("MyBlock", processor);
}
Handles reading and writing of SLHA files.
Definition: slha_io.hpp:95
double read_block(const std::string &, const Tuple_processor &) const
Definition: slha_io.cpp:687
void read_from_file(const std::string &)
opens SLHA input file and reads the content
Definition: slha_io.cpp:534
std::function< void(int, double)> Tuple_processor
Definition: slha_io.hpp:97

Example how to use a for loop (slow!):

void read_file() {
double array[1000];
SLHA_io reader;
reader.read_from_file("file.slha");
for (int i = 0; i < 1000; i++) {
array[i] = reader.read_entry("MyBlock", i);
}
}
double read_entry(const std::string &, int) const
Definition: slha_io.cpp:739

Definition at line 95 of file slha_io.hpp.

Member Typedef Documentation

◆ Tuple_processor

using flexiblesusy::SLHA_io::Tuple_processor = std::function<void(int, double)>

Definition at line 97 of file slha_io.hpp.

Member Enumeration Documentation

◆ Position

Enumerator
front 
back 

Definition at line 98 of file slha_io.hpp.

Constructor & Destructor Documentation

◆ SLHA_io() [1/3]

flexiblesusy::SLHA_io::SLHA_io ( )

Definition at line 437 of file slha_io.cpp.

Referenced by operator=().

◆ SLHA_io() [2/3]

flexiblesusy::SLHA_io::SLHA_io ( const SLHA_io other)

Definition at line 443 of file slha_io.cpp.

◆ SLHA_io() [3/3]

flexiblesusy::SLHA_io::SLHA_io ( SLHA_io &&  other)
noexcept

Definition at line 450 of file slha_io.cpp.

◆ ~SLHA_io()

flexiblesusy::SLHA_io::~SLHA_io ( )
default

Member Function Documentation

◆ block_exists()

bool flexiblesusy::SLHA_io::block_exists ( const std::string &  block_name) const

Definition at line 508 of file slha_io.cpp.

References data.

◆ block_head()

std::string flexiblesusy::SLHA_io::block_head ( const std::string &  name,
double  scale 
)
staticprivate

◆ clear()

void flexiblesusy::SLHA_io::clear ( )

Definition at line 474 of file slha_io.cpp.

References flexiblesusy::SLHA_io::Modsel::clear(), data, and modsel.

◆ fill() [1/5]

void flexiblesusy::SLHA_io::fill ( FlexibleDecay_settings settings) const

Fill struct of decay settings from SLHA object (FlexibleDecay block)

Parameters
settingsstruct of decay settings

Definition at line 654 of file slha_io.cpp.

References flexiblesusy::anonymous_namespace{slha_io.cpp}::process_flexibledecay_tuple(), read_block(), and settings.

◆ fill() [2/5]

void flexiblesusy::SLHA_io::fill ( LToLConversion_settings settings) const

Fill struct of decay settings from SLHA object (LToLConversion block)

Parameters
settingsstruct of decay settings

Definition at line 639 of file slha_io.cpp.

References flexiblesusy::anonymous_namespace{slha_io.cpp}::process_ltolconversion_tuple(), read_block(), and settings.

◆ fill() [3/5]

void flexiblesusy::SLHA_io::fill ( Physical_input input) const

Fill struct of extra physical input parameters from SLHA object (FlexibleSUSYInput block)

Parameters
inputstruct of physical input parameters

Definition at line 624 of file slha_io.cpp.

References flexiblesusy::anonymous_namespace{slha_io.cpp}::process_flexiblesusyinput_tuple(), and read_block().

◆ fill() [4/5]

◆ fill() [5/5]

void flexiblesusy::SLHA_io::fill ( Spectrum_generator_settings settings) const

Fill struct of spectrum generator settings from SLHA object (FlexibleSUSY block)

Parameters
settingsstruct of spectrum generator settings

Definition at line 669 of file slha_io.cpp.

References flexiblesusy::anonymous_namespace{slha_io.cpp}::process_flexiblesusy_tuple(), read_block(), and settings.

◆ get_data()

const SLHAea::Coll & flexiblesusy::SLHA_io::get_data ( ) const

Definition at line 481 of file slha_io.cpp.

References data.

◆ get_modsel()

const Modsel & flexiblesusy::SLHA_io::get_modsel ( ) const
inline

Definition at line 128 of file slha_io.hpp.

References modsel.

◆ operator=() [1/2]

SLHA_io & flexiblesusy::SLHA_io::operator= ( const SLHA_io other)

Definition at line 460 of file slha_io.cpp.

References SLHA_io().

◆ operator=() [2/2]

SLHA_io & flexiblesusy::SLHA_io::operator= ( SLHA_io &&  other)
noexcept

Definition at line 466 of file slha_io.cpp.

References data.

◆ read_block() [1/3]

double flexiblesusy::SLHA_io::read_block ( const std::string &  block_name,
const Tuple_processor processor 
) const

Applies processor to each (key, value) pair of a SLHA block. Non-data lines are ignored.

Parameters
block_nameblock name
processortuple processor to be applied
Returns
scale (or 0 if no scale is defined)

Definition at line 687 of file slha_io.cpp.

References data, SLHAea::Coll::find(), read_scale(), flexiblesusy::to_double(), and flexiblesusy::to_int().

Referenced by fill(), and read_modsel().

◆ read_block() [2/3]

double flexiblesusy::SLHA_io::read_block ( const std::string &  block_name,
double &  entry 
) const

Fills an entry from a SLHA block

Parameters
block_nameblock name
entryentry to be filled
Returns
scale (or 0 if no scale is defined)

Definition at line 718 of file slha_io.cpp.

References data, SLHAea::Coll::find(), read_scale(), and flexiblesusy::to_double().

◆ read_block() [3/3]

template<class Derived >
double flexiblesusy::SLHA_io::read_block ( const std::string &  block_name,
Eigen::PlainObjectBase< Derived > &  dense 
) const

Fills a matrix or vector from a SLHA block

Parameters
block_nameblock name
densematrix or vector to be filled
Returns
scale (or 0 if no scale is defined)

Definition at line 195 of file slha_io.hpp.

References read_matrix(), and read_vector().

◆ read_entry()

double flexiblesusy::SLHA_io::read_entry ( const std::string &  block_name,
int  key 
) const

◆ read_from_file()

void flexiblesusy::SLHA_io::read_from_file ( const std::string &  file_name)

opens SLHA input file and reads the content

Parameters
file_nameSLHA input file name

Definition at line 534 of file slha_io.cpp.

References read_from_stream().

Referenced by read_from_source().

◆ read_from_source()

void flexiblesusy::SLHA_io::read_from_source ( const std::string &  source)

reads from source

If source is "-", then read_from_stream() is called. Otherwise, read_from_file() is called.

Parameters
sourcestring that specifies the source

Definition at line 521 of file slha_io.cpp.

References read_from_file(), and read_from_stream().

◆ read_from_stream()

void flexiblesusy::SLHA_io::read_from_stream ( std::istream &  istr)

clears stored data and reads SLHA data from a stream

Parameters
istrinput stream

Definition at line 548 of file slha_io.cpp.

References data, and read_modsel().

Referenced by read_from_file(), and read_from_source().

◆ read_matrix() [1/2]

double flexiblesusy::SLHA_io::read_matrix ( const std::string &  block_name,
double *  a,
int  rows,
int  cols 
) const
private

Definition at line 969 of file slha_io.cpp.

References data, and flexiblesusy::detail::read_matrix_().

Referenced by read_block().

◆ read_matrix() [2/2]

double flexiblesusy::SLHA_io::read_matrix ( const std::string &  block_name,
std::complex< double > *  a,
int  rows,
int  cols 
) const
private

Definition at line 975 of file slha_io.cpp.

References data, and flexiblesusy::detail::read_matrix_().

◆ read_modsel()

void flexiblesusy::SLHA_io::read_modsel ( )
private

◆ read_scale() [1/2]

bool flexiblesusy::SLHA_io::read_scale ( const SLHAea::Line line,
double &  scale 
)
staticprivate

Reads the scale from the line, if the line is a block head and contains a scale definition. Otherwise, the scale is not read.

Parameters
linethe line
scalethe scale to write the value to
Returns
true if scale has been read; false otherwise

Definition at line 564 of file slha_io.cpp.

References flexiblesusy::detail::read_scale().

◆ read_scale() [2/2]

double flexiblesusy::SLHA_io::read_scale ( const std::string &  block_name) const

Reads scale definition from SLHA block.

Parameters
block_nameblock name
Returns
scale (or 0 if no scale is defined)

Definition at line 771 of file slha_io.cpp.

References data, SLHAea::Coll::find(), and read_scale().

Referenced by read_block(), and read_scale().

◆ read_vector() [1/2]

double flexiblesusy::SLHA_io::read_vector ( const std::string &  block_name,
double *  a,
int  len 
) const
private

Definition at line 957 of file slha_io.cpp.

References data, and flexiblesusy::detail::read_vector_().

Referenced by read_block().

◆ read_vector() [2/2]

double flexiblesusy::SLHA_io::read_vector ( const std::string &  block_name,
std::complex< double > *  a,
int  len 
) const
private

Definition at line 963 of file slha_io.cpp.

References data, and flexiblesusy::detail::read_vector_().

◆ set_block() [1/4]

◆ set_block() [2/4]

template<class Derived >
void flexiblesusy::SLHA_io::set_block ( const std::string &  name,
const Eigen::MatrixBase< Derived > &  dense,
const std::string &  symbol,
double  scale = 0. 
)

Writes real part of a matrix or vector to SLHA object

Parameters
namebloch name
densematrix ox vector
symbolsymbol name
scalerenormalization scale

Definition at line 211 of file slha_io.hpp.

References set_matrix(), and set_vector().

◆ set_block() [3/4]

void flexiblesusy::SLHA_io::set_block ( const std::string &  name,
double  value,
const std::string &  symbol,
double  scale = 0. 
)

This function treats a given scalar as 1x1 matrix. Such a case is not defined in the SLHA standard, but we still handle it to avoid problems.

Definition at line 819 of file slha_io.cpp.

References block_head(), FORMAT_MIXING_MATRIX, and set_block().

◆ set_block() [4/4]

void flexiblesusy::SLHA_io::set_block ( const std::string &  lines,
Position  position = back 
)

Definition at line 793 of file slha_io.cpp.

References data, front, SLHAea::Block::name(), and SLHAea::Block::str().

◆ set_block_imag()

template<class Derived >
void flexiblesusy::SLHA_io::set_block_imag ( const std::string &  name,
const Eigen::MatrixBase< Derived > &  dense,
const std::string &  symbol,
double  scale = 0. 
)

Writes imaginary part of a matrix or vector to SLHA object

Parameters
namebloch name
densematrix ox vector
symbolsymbol name
scalerenormalization scale

Definition at line 229 of file slha_io.hpp.

References set_matrix_imag(), and set_vector_imag().

◆ set_blocks()

void flexiblesusy::SLHA_io::set_blocks ( const std::vector< std::string > &  blocks,
Position  position = back 
)

Definition at line 807 of file slha_io.cpp.

References set_block().

◆ set_data()

void flexiblesusy::SLHA_io::set_data ( const SLHAea::Coll data_)

Definition at line 487 of file slha_io.cpp.

References data.

◆ set_effectivecouplings_block()

void flexiblesusy::SLHA_io::set_effectivecouplings_block ( const std::vector< std::tuple< int, int, int, double, std::string > > &  effCouplings)

Definition at line 1028 of file slha_io.cpp.

References set_block().

◆ set_FlexibleDecay_settings()

void flexiblesusy::SLHA_io::set_FlexibleDecay_settings ( const FlexibleDecay_settings settings)

◆ set_LToLConversion_settings()

void flexiblesusy::SLHA_io::set_LToLConversion_settings ( const LToLConversion_settings settings)

◆ set_matrix() [1/2]

void flexiblesusy::SLHA_io::set_matrix ( const std::string &  name,
const double *  a,
const std::string &  symbol,
double  scale,
int  rows,
int  cols 
)
private

Definition at line 993 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_matrix(), and set_block().

Referenced by set_block().

◆ set_matrix() [2/2]

void flexiblesusy::SLHA_io::set_matrix ( const std::string &  name,
const std::complex< double > *  a,
const std::string &  symbol,
double  scale,
int  rows,
int  cols 
)
private

Definition at line 999 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_matrix(), and set_block().

◆ set_matrix_imag() [1/2]

void flexiblesusy::SLHA_io::set_matrix_imag ( const std::string &  name,
const double *  a,
const std::string &  symbol,
double  scale,
int  rows,
int  cols 
)
private

Definition at line 1017 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_matrix_imag(), and set_block().

Referenced by set_block_imag().

◆ set_matrix_imag() [2/2]

void flexiblesusy::SLHA_io::set_matrix_imag ( const std::string &  name,
const std::complex< double > *  a,
const std::string &  symbol,
double  scale,
int  rows,
int  cols 
)
private

◆ set_modsel()

◆ set_physical_input()

void flexiblesusy::SLHA_io::set_physical_input ( const Physical_input input)

◆ set_settings()

void flexiblesusy::SLHA_io::set_settings ( const Spectrum_generator_settings settings)

◆ set_sminputs()

◆ set_unitarity_infinite_s()

◆ set_vector() [1/2]

void flexiblesusy::SLHA_io::set_vector ( const std::string &  name,
const double *  a,
const std::string &  symbol,
double  scale,
int  rows 
)
private

Definition at line 981 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_vector(), and set_block().

Referenced by set_block().

◆ set_vector() [2/2]

void flexiblesusy::SLHA_io::set_vector ( const std::string &  name,
const std::complex< double > *  a,
const std::string &  symbol,
double  scale,
int  rows 
)
private

Definition at line 987 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_vector(), and set_block().

◆ set_vector_imag() [1/2]

void flexiblesusy::SLHA_io::set_vector_imag ( const std::string &  name,
const double *  a,
const std::string &  symbol,
double  scale,
int  rows 
)
private

Definition at line 1005 of file slha_io.cpp.

References block_head(), flexiblesusy::detail::format_vector_imag(), and set_block().

Referenced by set_block_imag().

◆ set_vector_imag() [2/2]

void flexiblesusy::SLHA_io::set_vector_imag ( const std::string &  name,
const std::complex< double > *  a,
const std::string &  symbol,
double  scale,
int  rows 
)
private

◆ write_to_file()

void flexiblesusy::SLHA_io::write_to_file ( const std::string &  file_name) const

Definition at line 935 of file slha_io.cpp.

References write_to_stream().

◆ write_to_stream() [1/2]

void flexiblesusy::SLHA_io::write_to_stream ( ) const

Definition at line 951 of file slha_io.cpp.

References write_to_stream().

Referenced by write_to_file(), and write_to_stream().

◆ write_to_stream() [2/2]

void flexiblesusy::SLHA_io::write_to_stream ( std::ostream &  ostr) const

Definition at line 941 of file slha_io.cpp.

References data, and ERROR.

Member Data Documentation

◆ data

std::unique_ptr<SLHAea::Coll> flexiblesusy::SLHA_io::data
private

◆ modsel

Modsel flexiblesusy::SLHA_io::modsel {}
private

data from block MODSEL

Definition at line 164 of file slha_io.hpp.

Referenced by clear(), fill(), get_modsel(), read_modsel(), and set_modsel().


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