64
std::string Str_DocString =
65
std::string("str(is_mc)\n\n")+
66
std::string("Get a string describing the fields in MAUS.\n\n")+
67
std::string("- is_mc: set to True to print the MC fields; set to False to\n")+
68
std::string(" to print the Recon fields\n")+
69
std::string("Returns a multiline string, each line describing the\n")+
70
std::string("position, rotation, scale factor and field.\n");
72
PyObject* Str(PyObject *dummy, PyObject *args) {
74
if (!PyArg_ParseTuple(args, "O", &py_is_mc)) {
75
PyErr_SetString(PyExc_TypeError,
76
"Failed to interpret str arguments as bool");
79
int is_mc = PyObject_IsTrue(py_is_mc);
82
BTFieldConstructor* maus_field = NULL;
84
maus_field = Globals::GetInstance()->GetMCFieldConstructor();
86
maus_field = Globals::GetInstance()->GetReconFieldConstructor();
87
if (maus_field == NULL) {
88
PyErr_SetString(PyExc_RuntimeError,
89
"Error - somehow MAUS library was initialised but fields are not.");
92
std::stringstream str_out;
93
maus_field->Print(str_out);
94
PyObject* py_str = PyString_FromString(str_out.str().c_str());
96
} catch (std::exception& exc) {
97
PyErr_SetString(PyExc_RuntimeError, (&exc)->what());
63
102
static PyMethodDef methods[] = {
103
{"str", (PyCFunction)Str, METH_VARARGS, Str_DocString.c_str()},
64
104
{"get_field_value", (PyCFunction)GetFieldValue,
65
METH_VARARGS, GetFieldValue_DocString.c_str()},
105
METH_VARARGS, GetFieldValue_DocString.c_str()},
66
106
{NULL, NULL, 0, NULL}