Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Utilities.hpp File Reference
#include "Acts/Utilities/TypeTraits.hpp"
#include <string>
#include <unordered_map>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <pybind11/pybind11.h>
+ Include dependency graph for Utilities.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Acts::Python::Context
 

Namespaces

namespace  Acts::Python
 

Macros

#define ACTS_PYTHON_MEMBER(name)   _binding_instance.def_readwrite(#name, &_struct_type::name)
 
#define ACTS_PYTHON_STRUCT_BEGIN(obj, cls)
 
#define ACTS_PYTHON_STRUCT_END()
 
#define ACTS_PYTHON_MEMBER_LOOP(r, data, elem)   ACTS_PYTHON_MEMBER(elem);
 This macro is needed to use the BOOST_PP_SEQ_FOR_EACH loop macro.
 
#define ACTS_PYTHON_DECLARE_ALGORITHM(algorithm, mod, name,...)
 
#define ACTS_PYTHON_DECLARE_WRITER(writer, mod, name,...)
 Similar as above for writers.
 
#define ACTS_PYTHON_DECLARE_READER(reader, mod, name,...)
 Similar as above for readers.
 

Functions

template<typename T , typename Ur , typename Ut >
void Acts::Python::pythonRangeProperty (T &obj, const std::string &name, Ur Ut::*begin, Ur Ut::*end)
 
void Acts::Python::patchClassesWithConfig (pybind11::module_ &m)
 
template<typename T >
void Acts::Python::patchKwargsConstructor (T &c)
 
 Acts::Python::METHOD_TRAIT (write_method_trait_t, write)
 

Macro Definition Documentation

#define ACTS_PYTHON_DECLARE_ALGORITHM (   algorithm,
  mod,
  name,
  ... 
)
Value:
do { \
using Alg = algorithm; \
using Config = Alg::Config; \
auto alg = \
py::class_<Alg, ActsExamples::IAlgorithm, std::shared_ptr<Alg>>(mod, \
name) \
.def(py::init<const Config&, Acts::Logging::Level>(), \
py::arg("config"), py::arg("level")) \
.def_property_readonly("config", &Alg::config); \
\
auto c = py::class_<Config>(alg, "Config").def(py::init<>()); \
ACTS_PYTHON_STRUCT_BEGIN(c, Config); \
BOOST_PP_SEQ_FOR_EACH(ACTS_PYTHON_MEMBER_LOOP, _, \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
ACTS_PYTHON_STRUCT_END(); \
} while (0)

A macro that uses Boost.Preprocessor to create the python binding for and algorithm and the additional config struct.

Definition at line 80 of file Utilities.hpp.

View newest version in sPHENIX GitHub at line 80 of file Utilities.hpp

Referenced by Acts::Python::addAmbiguityResolution(), Acts::Python::addExampleAlgorithms(), Acts::Python::addExaTrkXTrackFinding(), Acts::Python::addExperimentalGeometry(), Acts::Python::addGeant4HepMC3(), Acts::Python::addHepMC3(), Acts::Python::addOnnx(), Acts::Python::addOnnxMlpack(), Acts::Python::addPropagation(), Acts::Python::addTrackFinding(), Acts::Python::addTrackFitting(), Acts::Python::addTruthTracking(), and Acts::Python::addVertexing().

#define ACTS_PYTHON_DECLARE_READER (   reader,
  mod,
  name,
  ... 
)
Value:
do { \
using Reader = reader; \
auto r = \
py::class_<Reader, ActsExamples::IReader, std::shared_ptr<Reader>>( \
mod, name) \
.def(py::init<const Config&, Acts::Logging::Level>(), \
py::arg("config"), py::arg("level")) \
.def_property_readonly("config", &Reader::config); \
\
auto c = py::class_<Config>(r, "Config").def(py::init<>()); \
ACTS_PYTHON_STRUCT_BEGIN(c, Config); \
BOOST_PP_SEQ_FOR_EACH(ACTS_PYTHON_MEMBER_LOOP, _, \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
ACTS_PYTHON_STRUCT_END(); \
} while (0)

Similar as above for readers.

Definition at line 127 of file Utilities.hpp.

View newest version in sPHENIX GitHub at line 127 of file Utilities.hpp

Referenced by Acts::Python::addEDM4hep(), Acts::Python::addHepMC3(), and Acts::Python::addInput().

#define ACTS_PYTHON_DECLARE_WRITER (   writer,
  mod,
  name,
  ... 
)
Value:
do { \
using Writer = writer; \
auto w = \
py::class_<Writer, ActsExamples::IWriter, std::shared_ptr<Writer>>( \
mod, name) \
.def(py::init<const Config&, Acts::Logging::Level>(), \
py::arg("config"), py::arg("level")) \
.def_property_readonly("config", &Writer::config); \
\
constexpr bool has_write_method = \
Acts::Python::write_method_trait_t, \
\
if constexpr (has_write_method) { \
w.def("write", &Writer::write); \
} \
\
auto c = py::class_<Config>(w, "Config").def(py::init<>()); \
ACTS_PYTHON_STRUCT_BEGIN(c, Config); \
BOOST_PP_SEQ_FOR_EACH(ACTS_PYTHON_MEMBER_LOOP, _, \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
ACTS_PYTHON_STRUCT_END(); \
} while (0)

Similar as above for writers.

Definition at line 99 of file Utilities.hpp.

View newest version in sPHENIX GitHub at line 99 of file Utilities.hpp

Referenced by Acts::Python::addEDM4hep(), Acts::Python::addHepMC3(), and Acts::Python::addOutput().

#define ACTS_PYTHON_MEMBER_LOOP (   r,
  data,
  elem 
)    ACTS_PYTHON_MEMBER(elem);

This macro is needed to use the BOOST_PP_SEQ_FOR_EACH loop macro.

Definition at line 76 of file Utilities.hpp.

View newest version in sPHENIX GitHub at line 76 of file Utilities.hpp

#define ACTS_PYTHON_STRUCT_BEGIN (   obj,
  cls 
)