cepgen is hosted by Hepforge, IPPP Durham
CepGen N/A
Central exclusive processes event generator
cepgen::utils Namespace Reference

Collection of utilities.

Namespaces

namespace  env
 All environment variable-related utilities.
 
namespace  kt
 

Classes

class  AbortHandler
 Object handling a 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
 
struct  EnumHash
 A hasher table for an enumeration. More...
 
class  EventBrowser
 A user-friendly browser for the Event content. More...
 
class  Functional
 A string-to-functional parser. More...
 
class  FunctionWrapper
 Wrapper to a 1-dimensional function with optional parameters. 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  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 container for binned distributions. More...
 
class  Logger
 General purpose message logger. More...
 
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  StreamCollector
 
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...
 

Typedefs

using DrawableColl = std::vector<const Drawable*>
 Collection of drawable objects A generic drawing utility.
 

Enumerations

enum struct  Normalise { no = 0 , yes = 1 }
 
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 xBj (double q2, double mp2, double mx2)
 Compute Bjorken x from virtuality/diffractive mass.
 
double q2 (double xbj, double mp2, double mx2)
 Compute the virtuality from Bjorken x/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.
 
Event generateLPAIREvent ()
 Generate a standard single-dissociative \(pp \to p^\ast (\gamma\gamma \to \mu^+\mu^-) p\) LPAIR event.
 
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.
 
bool isWriteable (const std::string &)
 Check if path can be accessed for writing.
 
template<typename T >
bool positive (const T &val)
 Check if a number is positive and finite.
 
template<typename T >
short sign (const T &val)
 Type-safe C++ sign function.
 
double fastHypot (double, double)
 Compute the square root of the squared sum (sqrt(a^2+b^2))
 
double fastHypot (double, double, double)
 Compute the square root of the squared sum (sqrt(a^2+b^2+c^2))
 
double fastSqrtSqDiff (double, double, Normalise normalise=Normalise::no)
 Compute the square root of the squared difference (sqrt(a^2-b^2))
 
double fastSqrtSqDiff (double, double, double, Normalise normalise=Normalise::no)
 Compute the square root of the squared difference (sqrt(a^2-b^2-c^2))
 
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 double &)
 
template<>
std::string toString (const std::wstring &)
 Convert a wide characters to a standard characters string.
 
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.
 
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.
 
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.
 
std::string demangle (const char *)
 Demangle a type id if possible.
 
std::string timeAs (const std::string &fmt)
 Return the formatted date/time now.
 
std::string yesno (bool test)
 Human-readable boolean printout Boldify a string for TTY-type output streams.
 
template<typename T >
std::string boldify (T str)
 
std::ostream & operator<< (std::ostream &, const Colour &)
 
std::ostream & operator<< (std::ostream &, const Modifier &)
 
Modifier operator| (const Modifier &, const Modifier &)
 
std::string colourise (const std::string &, const Colour &, const Modifier &=Modifier::none)
 Colourise a string for TTY-type output streams.
 
std::string sanitise (const std::string &)
 Replace all unsafe characters to build a computer-readable (and filename-safe) string.
 
std::string parseSpecialChars (const std::string &)
 Transform all emoji-like special characters into their LaTeX representation.
 
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.
 
std::vector< std::string > split (const std::string &, char, bool trim_parts=false)
 Split a string according to a separation character.
 
template<typename T >
std::string merge (const T &val, const std::string &)
 Merge a printable type in a single string.
 
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<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<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.
 
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.
 
std::string toUpper (const std::string &)
 Capitalise a string.
 
std::string toLower (const std::string &)
 Lowercase version of a string.
 
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.
 
std::string s (const std::string &, float, bool=true)
 Add a trailing "s" when needed.
 
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.
 
template<class T >
std::string repr (const std::set< T > &vec, const std::string &sep=",")
 Helper to print a set of values.
 
std::string randomString (size_t size)
 Generate a random string of a given size.
 
std::string ltrim (const std::string &str)
 Trim leading spaces.
 
std::string rtrim (const std::string &str)
 Trim trailing spaces.
 
std::string trim (const std::string &str)
 Trim leading and trailing spaces.
 
std::string strip (const std::string &)
 Strip all special characters from string.
 
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 error_number)
 Describe an error code.
 

Variables

std::atomic< int > gSignal
 

Typedef Documentation

◆ DrawableColl

using DrawableColl = std::vector<const Drawable*>

Definition at line 32 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 83 of file String.h.

◆ Modifier

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

Definition at line 96 of file String.h.

◆ Normalise

enum struct Normalise
strong
Enumerator
no 
yes 

Definition at line 36 of file Math.h.

Function Documentation

◆ between()

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

◆ boldify()

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

◆ colourise()

std::string colourise ( const std::string & ,
const Colour & ,
const Modifier & = Modifier::none )

◆ contains() [1/3]

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

Definition at line 51 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 56 of file Collections.h.

◆ contains() [3/3]

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

Definition at line 46 of file Collections.h.

◆ demangle()

std::string demangle ( const char * )

◆ describeError()

std::string describeError ( int error_number)

◆ endsWith()

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

◆ energyFromW()

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

◆ fastHypot() [1/2]

double fastHypot ( double ,
double  )

◆ fastHypot() [2/2]

double fastHypot ( double ,
double ,
double  )

◆ fastSqrtSqDiff() [1/2]

double fastSqrtSqDiff ( double ,
double ,
double ,
Normalise normalise = Normalise::no )

◆ fastSqrtSqDiff() [2/2]

double fastSqrtSqDiff ( double ,
double ,
Normalise normalise = Normalise::no )

◆ fileExists()

bool fileExists ( const std::string & )

◆ fileExtension()

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

◆ format() [1/2]

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

Definition at line 61 of file String.h.

◆ format() [2/2]

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

Definition at line 72 of file String.h.

◆ generateLPAIREvent()

Event generateLPAIREvent ( )

Definition at line 27 of file EventUtils.h.

◆ isFloat()

bool isFloat ( const std::string & )

◆ isInt()

bool isInt ( const std::string & )

◆ isWriteable()

bool isWriteable ( const std::string & )

◆ keys() [1/2]

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

Definition at line 32 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 39 of file Collections.h.

◆ ltrim()

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

◆ merge() [1/7]

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

◆ merge() [2/7]

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

◆ 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 135 of file String.h.

◆ merge() [4/7]

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

Definition at line 139 of file String.h.

◆ merge() [5/7]

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

◆ merge() [6/7]

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

◆ merge() [7/7]

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

Definition at line 124 of file String.h.

◆ mX2()

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

◆ normalise()

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

Definition at line 61 of file Collections.h.

◆ operator<<() [1/2]

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

◆ operator<<() [2/2]

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

◆ operator|()

Modifier operator| ( const Modifier & ,
const Modifier &  )

◆ parseSpecialChars()

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

◆ positive()

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

◆ q2()

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

◆ randomString()

std::string randomString ( size_t size)

◆ readFile()

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

◆ replaceAll() [1/3]

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

◆ replaceAll() [2/3]

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

◆ replaceAll() [3/3]

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

◆ repr() [1/3]

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

Definition at line 174 of file String.h.

◆ repr() [2/3]

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 157 of file String.h.

◆ repr() [3/3]

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

Definition at line 169 of file String.h.

◆ rtrim()

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

◆ s()

std::string s ( const std::string & ,
float ,
bool = true )

◆ sanitise()

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

◆ sign()

template<typename T >
short sign ( const T & val)

Definition at line 28 of file Math.h.

◆ split()

std::vector< std::string > split ( const std::string & ,
char ,
bool trim_parts = false )

◆ startsWith()

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

◆ strip()

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

◆ timeAs()

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

◆ toCamelCase()

std::string toCamelCase ( const std::string & ,
bool lower = true )

◆ toLower()

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

◆ toString() [1/6]

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

◆ toString() [2/6]

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

◆ toString() [3/6]

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

◆ toString() [4/6]

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

Definition at line 47 of file String.h.

◆ toString() [5/6]

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

◆ toString() [6/6]

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

Definition at line 36 of file String.h.

◆ toUpper()

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

◆ toWstring()

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

◆ trim()

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

Definition at line 180 of file String.h.

◆ uniform()

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

Definition at line 70 of file Collections.h.

◆ xBj()

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

◆ yesno()

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

Variable Documentation

◆ gSignal

std::atomic<int> gSignal
extern