13 const char *startingFrom = expr.c_str();
16 grammar.use_parser<1>() >> end_p,
30 const char *startingFrom = expr.c_str();
33 grammar.use_parser<0>() >> end_p,
49 std::cerr <<
"Can't get a type out of " << wrapperType.
name() << std::endl;
54 if (
sel.get() ==
nullptr)
61 if (expr.get() ==
nullptr)
64 return expr->value(
obj);
70 if (exprs_.back().get() ==
nullptr) {
71 std::cerr <<
"Failed to parse expression " << expr << std::endl;
81 if (strlen(
cut) && !cuts_[0].
get()) {
82 std::cerr <<
"Failed to set cut \"" <<
cut <<
"\"" << std::endl;
95 if (!cuts_.back().get()) {
96 std::cerr <<
"Failed to add cut \"" <<
cut <<
"\"" << std::endl;
104 if (icut >= cuts_.size())
106 if (cuts_[icut].
get() ==
nullptr)
110 return (*cuts_[icut])(
obj);
112 if (!ignoreExceptions_)
113 std::cerr <<
"Caught exception " << ex.what() << std::endl;
121 if (exprs_.size() > iexpr)
124 if (!ignoreExceptions_)
125 std::cerr <<
"Caught exception " << ex.what() << std::endl;
132 if ((cuts_[0].
get() ==
nullptr) || (*cuts_[0])(
obj)) {
133 for (std::vector<reco::parser::ExpressionPtr>::const_iterator it = exprs_.begin(), ed = exprs_.end(); it != ed;
135 if (ptr ==
nullptr || it->get() ==
nullptr) {
136 printf(
" : %8s",
"#ERR");
139 double val = (*it)->value(
obj);
143 int len = sprintf(buff,
" : % 8.6g",
val);
147 if (strchr(buff,
'e')) {
148 printf((len == 3 + 13 ?
" : % .0e" :
" : % .1e"),
val);
150 printf(
"%11.11s", buff);
154 printf(
" : %8s",
"EXCEPT");
155 if (!ignoreExceptions_)
156 std::cerr <<
"Caught exception " << ex.what() << std::endl;
160 for (std::vector<reco::parser::SelectorPtr>::const_iterator it = cuts_.begin() + 1, ed = cuts_.end(); it != ed;
162 if (ptr ==
nullptr || it->get() ==
nullptr) {
163 printf(
" : %8s",
"#ERR");
166 int ret = (*it)->operator()(
obj);
167 printf(
" : %8d",
ret);
169 printf(
" : %8s",
"EXCEPT");
170 if (!ignoreExceptions_)
171 std::cerr <<
"Caught exception " << ex.what() << std::endl;
181 if ((cuts_[0].
get() ==
nullptr) || (*cuts_[0])(
obj)) {
184 hist->Fill(exprs_[0]->value(
obj));
186 if (!ignoreExceptions_)
187 std::cerr <<
"Caught exception " << ex.what() << std::endl;
194 if ((cuts_[0].
get() ==
nullptr) || (*cuts_[0])(
obj)) {
196 if (exprs_.size() >= 2)
197 hist->Fill(exprs_[0]->value(
obj), exprs_[1]->value(
obj));
199 if (!ignoreExceptions_)
200 std::cerr <<
"Caught exception " << ex.what() << std::endl;
207 if ((cuts_[0].
get() ==
nullptr) || (*cuts_[0])(
obj)) {
209 if (exprs_.size() >= 2)
210 graph->SetPoint(graph->GetN(), exprs_[0]->value(
obj), exprs_[1]->value(
obj));
212 if (!ignoreExceptions_)
213 std::cerr <<
"Caught exception " << ex.what() << std::endl;
220 if ((cuts_[0].
get() ==
nullptr) || (*cuts_[0])(
obj)) {
222 if (exprs_.size() >= 2)
223 hist->Fill(exprs_[0]->value(
obj), exprs_[1]->value(
obj));
225 if (!ignoreExceptions_)
226 std::cerr <<
"Caught exception " << ex.what() << std::endl;
void fill2D(const void *obj, TH2 *hist2d) const
vector< string > parse(string line, const string &delimiter)
void fillGraph(const void *obj, TGraph *graph) const
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
ret
prodAgent to be discontinued
void clearExtraCuts()
Clear all extra cuts ;.
std::shared_ptr< ExpressionBase > ExpressionPtr
bool test(const void *obj, size_t icut=0) 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)
double eval(const void *obj, size_t iexpr=0) const
void fill1D(const void *obj, TH1 *hist) const
void fillProf(const void *obj, TProfile *prof) const
void clearCut()
Clear the default cut.
TypeWithDict templateArgumentAt(size_t index) const
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate 'what' message for the exception
bool addExpression(const char *expr)
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 print(const void *obj) 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) ...
std::shared_ptr< SelectorBase > SelectorPtr