~mbogomilov/maus/devel3

« back to all changes in this revision

Viewing changes to src/common_cpp/Utils/MAUSEvaluator.cc

  • Committer: Durga Rajaram
  • Date: 2014-01-14 07:07:02 UTC
  • mfrom: (659.1.80 relcand)
  • Revision ID: durga@fnal.gov-20140114070702-2l1fuj1w6rraw7xe
Tags: MAUS-v0.7.6
MAUS-v0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include <iostream>
19
19
 
20
 
#include "src/legacy/Interface/Squeal.hh"
 
20
#include "Utils/Exception.hh"
21
21
 
22
22
#include "src/common_cpp/Utils/MAUSEvaluator.hh"
23
23
 
41
41
    py_arg = Py_BuildValue("(sd)", name.c_str(), value);
42
42
    if (py_arg == NULL) {
43
43
        PyErr_Clear();
44
 
        throw(Squeal(Squeal::recoverable,
 
44
        throw(Exception(Exception::recoverable,
45
45
              "Failed to resolve arguments to set_variable",
46
46
              "MAUSEvaluator::evaluate"));
47
47
    }
53
53
    if (py_value == NULL) {
54
54
        PyErr_Clear();
55
55
        Py_DECREF(py_arg);
56
 
        throw(Squeal(Squeal::recoverable,
 
56
        throw(Exception(Exception::recoverable,
57
57
                     "Failed to parse variable "+name,
58
58
                     "MAUSEvaluator::evaluate"));
59
59
    }
68
68
    py_arg = Py_BuildValue("(s)", function.c_str());
69
69
    if (py_arg == NULL) {
70
70
        PyErr_Clear();
71
 
        throw(Squeal(Squeal::recoverable,
 
71
        throw(Exception(Exception::recoverable,
72
72
                   "Failed to build function "+function,
73
73
                   "MAUSEvaluator::evaluate"));
74
74
    }
79
79
    if (py_value == NULL) {
80
80
        PyErr_Clear();
81
81
        Py_DECREF(py_arg);
82
 
        throw(Squeal(Squeal::recoverable,
 
82
        throw(Exception(Exception::recoverable,
83
83
                   "Failed to evaluate expression \""+function+"\"",
84
84
                   "MAUSEvaluator::evaluate"));
85
85
    }
87
87
    // now put transform py_value into C++ double
88
88
    double value = 0.;
89
89
    if (!PyArg_Parse(py_value, "d", &value)) {
90
 
        throw(Squeal(Squeal::recoverable,
 
90
        throw(MAUS::Exception(MAUS::Exception::recoverable,
91
91
                   "Failed to evaluate expression \""+function+"\"",
92
92
                   "MAUSEvaluator::evaluate"));
93
93
    }
121
121
void MAUSEvaluator::reset() {
122
122
  // check that we don't have anything allocated already
123
123
  clear();
124
 
  // NOTE: I don't throw Squeals here because I'm nervous about
 
124
  // NOTE: I don't throw MAUS::Exceptions here because I'm nervous about
125
125
  // set up/tear down order
126
126
  // initialise evaluator module
127
127
  _evaluator_mod = PyImport_ImportModule("evaluator");