cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.3
A generic central exclusive processes event generator
Loading...
Searching...
No Matches
cepgen::utils Namespace Reference

Collection of utilities.

Namespaces

namespace  env
 All environment variable-related utilities.
 
namespace  kt
 

Classes

class  AbortHandler
 Object handling an user-driven process abortion. More...
 
class  Caller
 External command piping utility. More...
 
class  Derivator
 
class  DocumentationGenerator
 Documentation generator object. More...
 
class  Drawable
 A generic object which can be drawn in the standard output. More...
 
class  Drawer
 A generic drawing utility. More...
 
struct  EnumHash
 A hasher table for an enumeration. More...
 
class  EventBrowser
 A user-friendly browser for the Event content. More...
 
class  Function1D
 Wrapper to a 1-dimensional function with optional parameters. More...
 
class  Functional
 A string-to-functional parser. More...
 
class  FunctionalExprTk
 
class  FunctionalLibmatheval
 
class  FunctionalMuParser
 
class  FunctionalTinyExpr
 
class  GnuplotDrawer
 Gnuplot drawable objects drawing utility. More...
 
class  Graph1D
 A one-dimensional graph object. More...
 
class  Graph2D
 A two-dimensional graph object. More...
 
class  GridDrawer
 Utility object to draw a grid values mapping. More...
 
class  GSLDerivator
 
class  GSLFunctionWrapper
 GSL wrapper to define a functor as a GSL-digestible functional. More...
 
class  GSLMonteFunctionWrapper
 GSL wrapper to define a functor as an integrable functional. More...
 
struct  Hasher
 A hasher table for a given structure. More...
 
struct  Hasher< T, true >
 A hasher table for a given structure. More...
 
class  Hist1D
 1D histogram container More...
 
class  Hist2D
 2D histogram container More...
 
class  Histogram
 Generic text-based plotting utility. More...
 
class  Logger
 General purposes logger. More...
 
class  MatplotlibDrawer
 
class  Piper
 External command piping utility. More...
 
class  ProcessVariablesAnalyser
 
class  ProgressBar
 A simple progress indicator. More...
 
class  RandomGenerator
 A random number generator. More...
 
struct  RunAbortedException
 Exception raised when the user terminates the process. More...
 
class  TextDocumentationGenerator
 Text documentation generator object. More...
 
class  TextDrawer
 
class  TimeKeeper
 Collection of clocks to benchmark execution blocks. More...
 
class  Timer
 A generic timer to extract the processing time between two steps in this software's flow. More...
 
class  TopdrawerDrawer
 
class  YODADrawer
 

Typedefs

typedef std::vector< const Drawable * > DrawableColl
 A collection of drawable objects.
 

Enumerations

enum class  Colour {
  none = -1 , reset = 0 , black = 30 , red = 31 ,
  green = 32 , yellow = 33 , blue = 34 , magenta = 35 ,
  cyan = 36 , white = 37
}
 TTY-type enumeration of colours. More...
 
enum struct  Modifier : int16_t {
  none = -1 , reset = 0 , bold = 1 , dimmed = 1 << 1 ,
  italic = 1 << 2 , underline = 1 << 3 , blink = 1 << 4 , reverse = 1 << 6
}
 

Functions

double mX2 (double xbj, double q2, double mp2)
 Compute the diffractive mass from virtuality/Bjorken x.
 
double q2 (double xbj, double mp2, double mx2)
 Compute the virtuality from Bjorken x/diffractive mass.
 
double xBj (double q2, double mp2, double mx2)
 Compute Bjorken x from virtuality/diffractive mass.
 
double energyFromW (double w, double mp2, double m2)
 Compute energy from mass and emitted mass.
 
template<typename K , typename T >
std::vector< K > keys (const std::map< K, T > &coll)
 Retrieve all keys from a map.
 
template<typename K , typename T >
std::vector< K > keys (const std::unordered_map< K, T > &coll)
 Retrieve all keys from an unordered map.
 
template<typename T >
bool contains (const std::vector< T > &coll, const T &item)
 Check if a vector contains an item.
 
template<typename T >
bool contains (const std::set< T > &coll, const T &item)
 Check if a set contains an item.
 
template<typename K , typename T >
bool contains (const std::unordered_map< K, T > &coll, const T &item)
 Check if an unordered map contains an item.
 
template<typename T >
void normalise (std::vector< T > &coll)
 Remove duplicates and sort a collection.
 
template<typename T >
bool uniform (const std::vector< T > &coll)
 Check if all elements of a collection are uniform.
 
bool operator& (const Drawer::Mode &lhs, const Drawer::Mode::value_t &rhs)
 
Drawer::Mode operator| (const Drawer::Mode &lhs, const Drawer::Mode::value_t &rhs)
 
std::ostream & operator<< (std::ostream &os, const Drawer::Mode &mode)
 
bool fileExists (const std::string &)
 Check if the file exists.
 
std::string fileExtension (const std::string &file)
 Small utility to retrieve the extension of a filename.
 
std::string readFile (const std::string &)
 Read the content of a file into a string buffer.
 
Hist2D::contents_t operator* (double scaling, const Hist2D::contents_t &oth)
 
std::ostream & operator<< (std::ostream &os, const Hist2D::contents_t &cnt)
 
template<typename T >
bool positive (const T &val)
 Check if a number is positive and finite.
 
template bool positive< double > (const double &)
 
template bool positive< float > (const float &)
 
template bool positive< int > (const int &)
 
double fastHypot (double x, double y)
 
double fastHypot (double x, double y, double z)
 
double fastSqrtSqDiff (double, double)
 Compute the square root of the squared difference (sqrt(a^2-b^2))
 
std::regex kFloatRegex ("[+-]?[0-9]*\\.?[0-9]+([eEdD][+-]?[0-9]+)?", std::regex_constants::extended)
 
std::string yesno (bool test)
 Human-readable boolean printout Boldify a string for TTY-type output streams.
 
template<>
std::string boldify (std::string str)
 String implementation of the boldification procedure.
 
template<>
std::string boldify (const char *str)
 C-style character array implementation of the boldification procedure.
 
template<>
std::string boldify (unsigned long ui)
 Unsigned long integer implementation of the boldification procedure.
 
Modifier operator| (const Modifier &lhs, const Modifier &rhs)
 
std::string colourise (const std::string &, const Colour &, const Modifier &=Modifier::none)
 Colourise a string for TTY-type output streams.
 
std::string parseSpecialChars (const std::string &)
 Transform all emoji-like special characters into their LaTeX representation.
 
std::string sanitise (const std::string &)
 Replace all unsafe characters to build a computer-readable (and filename-safe) string.
 
std::string timeAs (const std::string &fmt)
 Return the formatted date/time now.
 
size_t replaceAll (std::string &str, const std::string &from, const std::string &to)
 Replace all occurrences of a text by another.
 
std::string replaceAll (const std::string &str, const std::string &from, const std::string &to)
 Replace all occurrences of a text by another.
 
std::string replaceAll (const std::string &str, const std::vector< std::pair< std::string, std::string > > &keys)
 Replace all occurrences of multiple texts by others.
 
template<>
std::string toString (const std::wstring &str)
 Convert a wide characters to a standard characters string.
 
template<>
std::string toString (const ParametersList &params)
 Specialisation of string conversion of parameters list.
 
template<>
std::string toString (const Limits &lim)
 Specialisation of string conversion of limits.
 
std::wstring toWstring (const std::string &str)
 Convert a standard characters to a wide characters string.
 
std::string toCamelCase (const std::string &, bool lower=true)
 Convert any case into a camelCase string.
 
std::string randomString (size_t size)
 Generate a random string of a given size.
 
std::string s (const std::string &, float, bool=true)
 Add a trailing "s" when needed.
 
std::vector< std::string > split (const std::string &, char, bool trim=false)
 Split a string according to a separation character.
 
template<typename T >
std::string merge (const std::vector< T > &, const std::string &)
 Merge a collection of a printable type in a single string.
 
template std::string merge< std::string > (const std::vector< std::string > &, const std::string &)
 
template std::string merge< Limits > (const std::vector< Limits > &, const std::string &)
 
template std::string merge< unsigned short > (const std::vector< unsigned short > &, const std::string &)
 
template std::string merge< int > (const std::vector< int > &, const std::string &)
 
template std::string merge< unsigned long long > (const std::vector< unsigned long long > &, const std::string &)
 
template std::string merge< double > (const std::vector< double > &, const std::string &)
 
template std::string merge< ParametersList > (const std::vector< ParametersList > &, const std::string &)
 
template<typename T >
std::string merge (const std::vector< std::vector< T > > &, const std::string &)
 Merge a collection of collections of a printable type in a single string.
 
template std::string merge< double > (const std::vector< std::vector< double > > &, const std::string &)
 
std::string merge (const ParametersList &, const std::string &)
 Trivial dimension-1 "merger" for parameters list input.
 
std::string merge (const Limits &, const std::string &)
 Trivial dimension-1 "merger" for limits input.
 
bool isInt (const std::string &)
 Check if a string is also an integer.
 
bool isFloat (const std::string &)
 Check if a string is also a floating point number.
 
std::string toUpper (const std::string &)
 Capitalise a string.
 
std::string toLower (const std::string &)
 Lowercase version of a string.
 
template void normalise (std::vector< std::string > &)
 
std::string ltrim (const std::string &str)
 Trim leading spaces.
 
std::string rtrim (const std::string &str)
 Trim trailing spaces.
 
std::string strip (const std::string &)
 Strip all special characters from string.
 
std::string demangle (const char *)
 Demangle a type id if possible.
 
std::vector< std::string > between (const std::string &str, const std::string &beg, const std::string &end)
 Get a (list of) substring(s) between two characters chains.
 
bool startsWith (const std::string &, const std::string &)
 Check if a string starts with a given token.
 
bool endsWith (const std::string &, const std::string &)
 Check if a string ends with a given token.
 
std::string describeError (int errnum)
 Describe an error code.
 
std::ostream & operator<< (std::ostream &os, const Colour &col)
 
std::ostream & operator<< (std::ostream &os, const Modifier &mod)
 
template<typename T >
std::string toString (const T &obj)
 Transform any type into a string.
 
template<>
std::string toString (const Limits &)
 Specialisation of string conversion of limits.
 
template<>
std::string toString (const ParametersList &)
 Specialisation of string conversion of parameters list.
 
template<>
std::string toString (const std::string &obj)
 Trivial specialisation of string conversion of string.
 
template<>
std::string toString (const std::wstring &)
 Convert a wide characters to a standard characters string.
 
template<typename... Args>
std::string format (const std::string &fmt, Args... args)
 Format a string using a printf style format descriptor.
 
template<typename... Args>
std::string format (const std::wstring &fmt, Args... args)
 Format a wide string using a printf style format descriptor.
 
template<typename T >
std::string boldify (T str)
 
template<typename T >
std::string merge (const T &val, const std::string &)
 Merge a a printable type in a single string.
 
template<typename T , size_t N>
std::string merge (const std::array< T, N > &arr, const std::string &delim)
 Merge a collection of a printable type in a single string.
 
std::string merge (const std::string &val, const std::string &)
 Trivial dimension-1 "merger" for string input.
 
template<class T >
std::string repr (const std::vector< T > &vec, const std::function< std::string(const T &)> &printer, const std::string &sep=",")
 Helper to print a vector.
 
template<class T >
std::string repr (const std::vector< T > &vec, const std::string &sep=",")
 Helper to print a vector.
 
std::string trim (const std::string &str)
 Trim leading and trailing spaces.
 
Event generateLPAIREvent ()
 Generate a standard single-dissociative \(pp \to p^\ast (\gamma\gamma \to \mu^+\mu^-) p\) LPAIR event.
 

Variables

std::atomic< int > gSignal
 Abort signal handler.
 
static const Limits x_limits {0., 1.}
 

Typedef Documentation

◆ DrawableColl

typedef std::vector<const Drawable*> DrawableColl

Definition at line 34 of file Drawer.h.

Enumeration Type Documentation

◆ Colour

enum class Colour
strong
Enumerator
none 
reset 
black 
red 
green 
yellow 
blue 
magenta 
cyan 
white 

Definition at line 81 of file String.h.

◆ Modifier

enum struct Modifier : int16_t
strong
Enumerator
none 
reset 
bold 
dimmed 
italic 
underline 
blink 
reverse 

Definition at line 94 of file String.h.

Function Documentation

◆ between()

std::vector< std::string > between ( const std::string &  str,
const std::string &  beg,
const std::string &  end 
)
Parameters
[in]begStart delimiter of the substring(s)
[in]endEnd delimiter of the substring(s)

Definition at line 342 of file String.cpp.

◆ boldify() [1/4]

template<>
std::string boldify ( const char *  str)

Definition at line 55 of file String.cpp.

◆ boldify() [2/4]

template<>
std::string boldify ( std::string  str)

Definition at line 49 of file String.cpp.

◆ boldify() [3/4]

template<typename T >
std::string boldify ( str)

◆ boldify() [4/4]

template<>
std::string boldify ( unsigned long  ui)

Definition at line 61 of file String.cpp.

◆ colourise()

std::string colourise ( const std::string &  str,
const Colour col,
const Modifier mod 
)

Definition at line 70 of file String.cpp.

◆ contains() [1/3]

template<typename T >
bool contains ( const std::set< T > &  coll,
const T &  item 
)

Definition at line 52 of file Collections.h.

◆ contains() [2/3]

template<typename K , typename T >
bool contains ( const std::unordered_map< K, T > &  coll,
const T &  item 
)

Definition at line 57 of file Collections.h.

◆ contains() [3/3]

template<typename T >
bool contains ( const std::vector< T > &  coll,
const T &  item 
)

Definition at line 47 of file Collections.h.

◆ demangle()

std::string demangle ( const char *  name)

Definition at line 332 of file String.cpp.

◆ describeError()

std::string describeError ( int  errnum)

Definition at line 364 of file String.cpp.

◆ endsWith()

bool endsWith ( const std::string &  str,
const std::string &  end 
)

Definition at line 358 of file String.cpp.

◆ energyFromW()

double energyFromW ( double  w,
double  mp2,
double  m2 
)

Definition at line 47 of file Utils.cpp.

◆ fastHypot() [1/2]

double fastHypot ( double  x,
double  y 
)

Definition at line 33 of file Math.cpp.

◆ fastHypot() [2/2]

double fastHypot ( double  x,
double  y,
double  z 
)

Definition at line 38 of file Math.cpp.

◆ fastSqrtSqDiff()

double fastSqrtSqDiff ( double  x,
double  y 
)

Definition at line 43 of file Math.cpp.

◆ fileExists()

bool fileExists ( const std::string &  path)

Definition at line 27 of file Filesystem.cpp.

◆ fileExtension()

std::string fileExtension ( const std::string &  file)

Definition at line 29 of file Filesystem.cpp.

◆ format() [1/2]

template<typename... Args>
std::string format ( const std::string &  fmt,
Args...  args 
)

Definition at line 59 of file String.h.

◆ format() [2/2]

template<typename... Args>
std::string format ( const std::wstring &  fmt,
Args...  args 
)

Definition at line 70 of file String.h.

◆ generateLPAIREvent()

Event generateLPAIREvent ( )

Definition at line 30 of file EventUtils.h.

◆ isFloat()

bool isFloat ( const std::string &  str)

Definition at line 286 of file String.cpp.

◆ isInt()

bool isInt ( const std::string &  str)

Definition at line 281 of file String.cpp.

◆ keys() [1/2]

template<typename K , typename T >
std::vector< K > keys ( const std::map< K, T > &  coll)

Definition at line 33 of file Collections.h.

◆ keys() [2/2]

template<typename K , typename T >
std::vector< K > keys ( const std::unordered_map< K, T > &  coll)

Definition at line 40 of file Collections.h.

◆ kFloatRegex()

std::regex kFloatRegex ( "?*\\.?+([eEdD][+-]?[0-9]+)?"  [+-][0-9][0-9],
std::regex_constants::extended   
)

◆ ltrim()

std::string ltrim ( const std::string &  str)

Definition at line 312 of file String.cpp.

◆ merge() [1/7]

std::string merge ( const Limits lim,
const std::string &   
)

Definition at line 275 of file String.cpp.

◆ merge() [2/7]

std::string merge ( const ParametersList plist,
const std::string &   
)

Definition at line 273 of file String.cpp.

◆ merge() [3/7]

template<typename T , size_t N>
std::string merge ( const std::array< T, N > &  arr,
const std::string &  delim 
)

Definition at line 133 of file String.h.

◆ merge() [4/7]

std::string merge ( const std::string &  val,
const std::string &   
)

Definition at line 137 of file String.h.

◆ merge() [5/7]

template<typename T >
std::string merge ( const std::vector< std::vector< T > > &  vec,
const std::string &  delim 
)

Definition at line 259 of file String.cpp.

◆ merge() [6/7]

template<typename T >
std::string merge ( const std::vector< T > &  vec,
const std::string &  delim 
)

Definition at line 239 of file String.cpp.

◆ merge() [7/7]

template<typename T >
std::string merge ( const T &  val,
const std::string &   
)

Definition at line 122 of file String.h.

◆ merge< double >() [1/2]

template std::string merge< double > ( const std::vector< double > &  ,
const std::string &   
)

◆ merge< double >() [2/2]

template std::string merge< double > ( const std::vector< std::vector< double > > &  ,
const std::string &   
)

◆ merge< int >()

template std::string merge< int > ( const std::vector< int > &  ,
const std::string &   
)

◆ merge< Limits >()

template std::string merge< Limits > ( const std::vector< Limits > &  ,
const std::string &   
)

◆ merge< ParametersList >()

template std::string merge< ParametersList > ( const std::vector< ParametersList > &  ,
const std::string &   
)

◆ merge< std::string >()

template std::string merge< std::string > ( const std::vector< std::string > &  ,
const std::string &   
)

◆ merge< unsigned long long >()

template std::string merge< unsigned long long > ( const std::vector< unsigned long long > &  ,
const std::string &   
)

◆ merge< unsigned short >()

template std::string merge< unsigned short > ( const std::vector< unsigned short > &  ,
const std::string &   
)

◆ mX2()

double mX2 ( double  xbj,
double  q2,
double  mp2 
)

Definition at line 29 of file Utils.cpp.

◆ normalise() [1/2]

template void normalise ( std::vector< std::string > &  )

◆ normalise() [2/2]

template<typename T >
void normalise ( std::vector< T > &  coll)

Definition at line 63 of file Collections.h.

◆ operator&()

bool operator& ( const Drawer::Mode lhs,
const Drawer::Mode::value_t rhs 
)

Definition at line 30 of file Drawer.cpp.

◆ operator*()

Hist2D::contents_t operator* ( double  scaling,
const Hist2D::contents_t oth 
)

Definition at line 283 of file Hist2D.cpp.

◆ operator<<() [1/4]

std::ostream & operator<< ( std::ostream &  os,
const Colour col 
)

Definition at line 382 of file String.cpp.

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream &  os,
const Drawer::Mode mode 
)

Definition at line 37 of file Drawer.cpp.

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream &  os,
const Hist2D::contents_t cnt 
)

Definition at line 295 of file Hist2D.cpp.

◆ operator<<() [4/4]

std::ostream & operator<< ( std::ostream &  os,
const Modifier mod 
)

Definition at line 398 of file String.cpp.

◆ operator|() [1/2]

Drawer::Mode operator| ( const Drawer::Mode lhs,
const Drawer::Mode::value_t rhs 
)

Definition at line 32 of file Drawer.cpp.

◆ operator|() [2/2]

Modifier operator| ( const Modifier lhs,
const Modifier rhs 
)

Definition at line 65 of file String.cpp.

◆ parseSpecialChars()

std::string parseSpecialChars ( const std::string &  str)

Definition at line 90 of file String.cpp.

◆ positive()

template<typename T >
bool positive ( const T &  val)

Definition at line 26 of file Math.cpp.

◆ positive< double >()

template bool positive< double > ( const double &  )

◆ positive< float >()

template bool positive< float > ( const float &  )

◆ positive< int >()

template bool positive< int > ( const int &  )

◆ q2()

double q2 ( double  xbj,
double  mp2,
double  mx2 
)

Definition at line 35 of file Utils.cpp.

◆ randomString()

std::string randomString ( size_t  size)

Definition at line 212 of file String.cpp.

◆ readFile()

std::string readFile ( const std::string &  filename)

Definition at line 31 of file Filesystem.cpp.

◆ replaceAll() [1/3]

std::string replaceAll ( const std::string &  str,
const std::string &  from,
const std::string &  to 
)

Definition at line 128 of file String.cpp.

◆ replaceAll() [2/3]

std::string replaceAll ( const std::string &  str,
const std::vector< std::pair< std::string, std::string > > &  keys 
)

Definition at line 137 of file String.cpp.

◆ replaceAll() [3/3]

size_t replaceAll ( std::string &  str,
const std::string &  from,
const std::string &  to 
)

Definition at line 118 of file String.cpp.

◆ repr() [1/2]

template<class T >
std::string repr ( const std::vector< T > &  vec,
const std::function< std::string(const T &)> &  printer,
const std::string &  sep = "," 
)

Definition at line 154 of file String.h.

◆ repr() [2/2]

template<class T >
std::string repr ( const std::vector< T > &  vec,
const std::string &  sep = "," 
)

Definition at line 166 of file String.h.

◆ rtrim()

std::string rtrim ( const std::string &  str)

Definition at line 318 of file String.cpp.

◆ s()

std::string s ( const std::string &  word,
float  num,
bool  show_number 
)

Definition at line 219 of file String.cpp.

◆ sanitise()

std::string sanitise ( const std::string &  str)

Definition at line 105 of file String.cpp.

◆ split()

std::vector< std::string > split ( const std::string &  str,
char  delim,
bool  trim 
)

Definition at line 224 of file String.cpp.

◆ startsWith()

bool startsWith ( const std::string &  str,
const std::string &  beg 
)

Definition at line 356 of file String.cpp.

◆ strip()

std::string strip ( const std::string &  str)

Definition at line 325 of file String.cpp.

◆ timeAs()

std::string timeAs ( const std::string &  fmt)

Definition at line 110 of file String.cpp.

◆ toCamelCase()

std::string toCamelCase ( const std::string &  in,
bool  lower 
)

Definition at line 177 of file String.cpp.

◆ toLower()

std::string toLower ( const std::string &  str)

Definition at line 295 of file String.cpp.

◆ toString() [1/8]

template<>
std::string toString ( const Limits lim)

Definition at line 165 of file String.cpp.

◆ toString() [2/8]

template<>
std::string toString ( const Limits lim)

Definition at line 165 of file String.cpp.

◆ toString() [3/8]

template<>
std::string toString ( const ParametersList params)

Definition at line 158 of file String.cpp.

◆ toString() [4/8]

template<>
std::string toString ( const ParametersList params)

Definition at line 158 of file String.cpp.

◆ toString() [5/8]

template<>
std::string toString ( const std::string &  obj)

Definition at line 47 of file String.h.

◆ toString() [6/8]

template<>
std::string toString ( const std::wstring &  str)

Definition at line 151 of file String.cpp.

◆ toString() [7/8]

template<>
std::string toString ( const std::wstring &  str)

Definition at line 151 of file String.cpp.

◆ toString() [8/8]

template<typename T >
std::string toString ( const T &  obj)

Definition at line 36 of file String.h.

◆ toUpper()

std::string toUpper ( const std::string &  str)

Definition at line 288 of file String.cpp.

◆ toWstring()

std::wstring toWstring ( const std::string &  str)

Definition at line 171 of file String.cpp.

◆ trim()

std::string trim ( const std::string &  str)

Definition at line 173 of file String.h.

◆ uniform()

template<typename T >
bool uniform ( const std::vector< T > &  coll)

Definition at line 72 of file Collections.h.

◆ xBj()

double xBj ( double  q2,
double  mp2,
double  mx2 
)

Definition at line 41 of file Utils.cpp.

◆ yesno()

std::string yesno ( bool  test)
Template Parameters
Ttype of variable to be boldified

Definition at line 45 of file String.cpp.

Variable Documentation

◆ gSignal

std::atomic< int > gSignal

Definition at line 39 of file GlobalFunctions.cpp.

◆ x_limits

const Limits x_limits {0., 1.}
static

Definition at line 27 of file Utils.cpp.