Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LhaID Struct Reference

Represents an identifier of a LHA element, possibly containing several sub-ids. More...

#include <LhaID.h>

Public Member Functions

template<typename... Args>
requires (std::convertible_to<Args, long> && ...)
 LhaID (Args... sub_ids)
 Constructs an LhaID from a list of integral sub-ids.
 
 LhaID (const std::string &parts)
 Constructs an LhaID from a string of underscore-separated integers.
 
 LhaID (const std::vector< long > &sub_ids)
 Constructs an LhaID from an explicit vector of sub-ids.
 
 LhaID (std::vector< long > &&sub_ids)
 
 LhaID (long id)
 Constructs an LhaID with a single identifier.
 
std::string to_string () const
 Returns the canonical string representation of this LhaID.
 
std::vector< long > get_parts () const
 Returns the underlying vector of sub-ids.
 
 operator long () const
 Implicit conversion of a trivial LhaID to a long integer.
 

Public Attributes

std::vector< long > parts
 

Friends

bool operator== (const LhaID &lhs, const LhaID &rhs)
 Equality comparison operator.
 
bool operator!= (const LhaID &lhs, const LhaID &rhs)
 Inequality comparison operator.
 
bool operator< (const LhaID &lhs, const LhaID &rhs)
 Strict weak ordering based on lexicographic comparison of parts.
 
std::ostream & operator<< (std::ostream &, const LhaID &)
 Stream output operator for LhaID.
 

Detailed Description

Represents an identifier of a LHA element, possibly containing several sub-ids.

An LhaID is internally stored as a sequence of integer parts. This allows one to represent both simple one-dimensional identifiers (e.g. a PDG code) and multi-dimensional indices (e.g. block/row/column) in a uniform way.

The canonical string representation is obtained by joining the parts with underscores, for example:

  • parts = { 511 } → "511"
  • parts = { 5, 2 } → "5_2"
  • parts = { 321, 1, 3 } → "321_1_3"

The type also supports:

  • comparison operators (lexicographic on parts),
  • a conversion to long for trivial (single-part) IDs, with a warning if information would be lost.
Examples
examples/dependency_management_example.cpp.

Definition at line 56 of file LhaID.h.

Constructor & Destructor Documentation

◆ LhaID() [1/5]

template<typename... Args>
requires (std::convertible_to<Args, long> && ...)
LhaID::LhaID ( Args...  sub_ids)
inline

Constructs an LhaID from a list of integral sub-ids.

This variadic constructor accepts any number of arguments that are convertible to long and stores them in order in the parts vector.

Examples:

LhaID a(511); // parts = {511}
LhaID b(5, 2); // parts = {5, 2}
LhaID c(321, 1, 3); // parts = {321, 1, 3}
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
Template Parameters
ArgsParameter pack of types convertible to long.
Parameters
sub_idsSub-ids of the element.

Definition at line 77 of file LhaID.h.

◆ LhaID() [2/5]

LhaID::LhaID ( const std::string &  parts)

Constructs an LhaID from a string of underscore-separated integers.

The string is split on the '_' character and each token is converted to a long using std::stol. An empty string corresponds to an empty parts vector.

Examples:

  • "511" → parts = {511}
  • "5_2" → parts = {5, 2}
  • "" → parts = {}
Parameters
partsString encoding the sub-ids of the element, separated by '_'.
Exceptions
std::invalid_argumentor std::out_of_range if a token cannot be converted by std::stol.

Definition at line 8 of file LhaID.cpp.

◆ LhaID() [3/5]

LhaID::LhaID ( const std::vector< long > &  sub_ids)
inline

Constructs an LhaID from an explicit vector of sub-ids.

The content of sub_ids is moved into the internal parts vector.

Parameters
sub_idsSub-identifiers of the element.

Definition at line 105 of file LhaID.h.

◆ LhaID() [4/5]

LhaID::LhaID ( std::vector< long > &&  sub_ids)
inline

Definition at line 106 of file LhaID.h.

◆ LhaID() [5/5]

LhaID::LhaID ( long  id)
inline

Constructs an LhaID with a single identifier.

Equivalent to calling the variadic constructor with a single argument or using an initializer list with one element.

Parameters
idIdentifier of the element.

Definition at line 128 of file LhaID.h.

Member Function Documentation

◆ get_parts()

std::vector< long > LhaID::get_parts ( ) const
inline

Returns the underlying vector of sub-ids.

This is a value-returning accessor; modifications of the returned vector do not affect the original LhaID.

Returns
A copy of the internal parts vector.

Definition at line 148 of file LhaID.h.

◆ operator long()

LhaID::operator long ( ) const

Implicit conversion of a trivial LhaID to a long integer.

This conversion is intended for IDs that contain a single part (e.g. simple PDG codes). If parts contains more than one element, a warning is emitted via LOG_WARN and only the first element is returned, effectively discarding information.

Returns
The first element of parts.
Warning
For multi-part IDs, only the first component is kept.

Definition at line 30 of file LhaID.cpp.

◆ to_string()

std::string LhaID::to_string ( ) const

Returns the canonical string representation of this LhaID.

The parts are joined with underscores in order. If parts is empty, an empty string is returned.

Returns
String representation, e.g. "5_2".

Definition at line 19 of file LhaID.cpp.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const LhaID lhs,
const LhaID rhs 
)
friend

Inequality comparison operator.

Parameters
lhsLeft-hand side.
rhsRight-hand side.
Returns
true if lhs and rhs differ, false otherwise.

Definition at line 183 of file LhaID.h.

◆ operator<

bool operator< ( const LhaID lhs,
const LhaID rhs 
)
friend

Strict weak ordering based on lexicographic comparison of parts.

This operator enables LhaID to be used as a key in ordered containers such as std::map or std::set.

Parameters
lhsLeft-hand side.
rhsRight-hand side.
Returns
true if lhs is lexicographically smaller than rhs.

Definition at line 195 of file LhaID.h.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const LhaID id 
)
friend

Stream output operator for LhaID.

Writes the canonical string representation (as returned by to_string()) to the output stream.

Parameters
osOutput stream.
idIdentifier to print.
Returns
Reference to the output stream.

Definition at line 3 of file LhaID.cpp.

◆ operator==

bool operator== ( const LhaID lhs,
const LhaID rhs 
)
friend

Equality comparison operator.

Two LhaID objects are equal if and only if their parts vectors are equal.

Parameters
lhsLeft-hand side.
rhsRight-hand side.
Returns
true if both identifiers have identical parts, false otherwise.

Definition at line 174 of file LhaID.h.

Member Data Documentation

◆ parts

std::vector<long> LhaID::parts

Collection of sub-ids.

Definition at line 57 of file LhaID.h.


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