14 const char* startingFrom = expr.c_str();
16 parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p);
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;
52 if (sel.get() == 0)
return false;
59 if (expr.get() == 0)
return 0;
61 return expr->value(obj);
68 if (exprs_.back().get() == 0) {
69 std::cerr <<
"Failed to parse expression " << expr << std::endl;
80 if (strlen(cut) && !cuts_[0].
get()) {
81 std::cerr <<
"Failed to set cut \"" << cut <<
"\"" << std::endl;
102 if (!cuts_.back().get()) {
103 std::cerr <<
"Failed to add cut \"" << cut <<
"\"" << std::endl;
113 if (icut >= cuts_.size())
return false;
114 if (cuts_[icut].
get() == 0)
return true;
117 return (*cuts_[icut])(
obj);
119 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
128 if (exprs_.size() > iexpr)
return exprs_[iexpr]->
value(obj);
130 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
138 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
139 for (std::vector<reco::parser::ExpressionPtr>::const_iterator it = exprs_.begin(), ed = exprs_.end(); it != ed; ++it) {
140 if (ptr == 0 || it->get() == 0) {
141 printf(
" : %8s",
"#ERR");
144 double val = (*it)->value(obj);
148 int len = sprintf(buff,
" : % 8.6g",val);
152 if (strchr(buff,
'e')) {
153 printf((len == 3+13 ?
" : % .0e" :
" : % .1e"),val);
155 printf(
"%11.11s",buff);
159 printf(
" : %8s",
"EXCEPT");
160 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
164 for (std::vector<reco::parser::SelectorPtr>::const_iterator it = cuts_.begin()+1, ed = cuts_.end(); it != ed; ++it) {
165 if (ptr == 0 || it->get() == 0) {
166 printf(
" : %8s",
"#ERR");
169 int ret = (*it)->operator()(
obj);
170 printf(
" : %8d", ret);
172 printf(
" : %8s",
"EXCEPT");
173 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
185 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
187 if (!exprs_.empty()) hist->Fill(exprs_[0]->value(obj));
189 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
197 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
199 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
201 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
209 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
211 if (exprs_.size() >= 2) graph->SetPoint(graph->GetN(), exprs_[0]->value(obj), exprs_[1]->value(obj));
213 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
222 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
224 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
226 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
void clearExtraCuts()
Clear all extra cuts ;.
boost::shared_ptr< ExpressionBase > ExpressionPtr
TypeWithDict nestedType(char const *) const
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
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