12 using namespace boost::spirit::classic;
14 const char* startingFrom = expr.c_str();
16 parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p);
27 using namespace boost::spirit::classic;
29 const char* startingFrom = expr.c_str();
31 parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p);
46 std::cerr <<
"Can't get a type out of " << wrapperType.
name() << std::endl;
58 if (expr.get() == 0)
return 0;
60 return expr->value(obj);
67 if (exprs_.back().get() == 0) {
68 std::cerr <<
"Failed to parse expression " << expr << std::endl;
79 if (strlen(cut) && !cuts_[0].
get()) {
80 std::cerr <<
"Failed to set cut \"" << cut <<
"\"" << std::endl;
101 if (!cuts_.back().get()) {
102 std::cerr <<
"Failed to add cut \"" << cut <<
"\"" << std::endl;
112 if (icut >= cuts_.size())
return false;
113 if (cuts_[icut].
get() == 0)
return true;
116 return (*cuts_[icut])(
obj);
118 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
127 if (exprs_.size() > iexpr)
return exprs_[iexpr]->
value(obj);
129 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
137 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
138 for (std::vector<reco::parser::ExpressionPtr>::const_iterator it = exprs_.begin(), ed = exprs_.end(); it != ed; ++it) {
139 if (ptr == 0 || it->get() == 0) {
140 printf(
" : %8s",
"#ERR");
143 double val = (*it)->value(obj);
147 int len = sprintf(buff,
" : % 8.6g",val);
151 if (strchr(buff,
'e')) {
152 printf((len == 3+13 ?
" : % .0e" :
" : % .1e"),val);
154 printf(
"%11.11s",buff);
158 printf(
" : %8s",
"EXCEPT");
159 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
163 for (std::vector<reco::parser::SelectorPtr>::const_iterator it = cuts_.begin()+1, ed = cuts_.end(); it != ed; ++it) {
164 if (ptr == 0 || it->get() == 0) {
165 printf(
" : %8s",
"#ERR");
168 int ret = (*it)->operator()(
obj);
169 printf(
" : %8d", ret);
171 printf(
" : %8s",
"EXCEPT");
172 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
184 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
186 if (!exprs_.empty()) hist->Fill(exprs_[0]->value(obj));
188 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
196 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
198 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
200 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
208 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
210 if (exprs_.size() >= 2) graph->SetPoint(graph->GetN(), exprs_[0]->value(obj), exprs_[1]->value(obj));
212 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
221 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
223 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
225 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
void print(const void *obj) const
void fill2D(const void *obj, TH2 *hist2d) const
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Evaluator * parse(const T &text)
void clearExtraCuts()
Clear all extra cuts ;.
boost::shared_ptr< ExpressionBase > ExpressionPtr
static bool test(const reco::parser::SelectorPtr &sel, const edm::TypeWithDict type, const void *obj)
Make a edm::ObjectWithDict(type, obj) and pass it to the selector.
bool addExtraCut(const char *cut)
Add one extra cut that can be evaluated separately (as if it was an expression)
TypeWithDict templateArgumentAt(size_t index) const
TypeWithDict nestedType(char const *name) const
bool test(const void *obj, size_t icut=0) const
double eval(const void *obj, size_t iexpr=0) const
void fill1D(const void *obj, TH1 *hist) const
void clearCut()
Clear the default cut.
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate 'what' message for the exception
bool addExpression(const char *expr)
boost::shared_ptr< SelectorBase > SelectorPtr
static edm::TypeWithDict elementType(const edm::TypeWithDict &wrapperType)
Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs.
bool setCut(const char *cut)
Set the default cut that is applied to the events.
static reco::parser::ExpressionPtr makeExpression(const std::string &expr, const edm::TypeWithDict &type)
Parse an expression for a given object type (using lazy parsing when resolving methods) ...
static double eval(const reco::parser::ExpressionPtr &sel, const edm::TypeWithDict type, const void *obj)
Make a edm::ObjectWithDict(type, obj) and pass it to the expression.
void fillProf(const void *obj, TProfile *prof) const
static reco::parser::SelectorPtr makeSelector(const std::string &expr, const edm::TypeWithDict &type)
Parse an expression for a given object type (using lazy parsing when resolving methods) ...
void fillGraph(const void *obj, TGraph *graph) const