12 using namespace boost::spirit::classic;
14 const char* startingFrom = expr.c_str();
16 parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p).full;
27 using namespace boost::spirit::classic;
29 const char* startingFrom = expr.c_str();
31 parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p).full;
41 while (collection.IsTypedef()) collection = collection.ToType();
43 for (
size_t i = 0;
i < collection.SubTypeSize(); ++
i) {
45 if (objtype.Name() ==
"value_type") {
46 while (objtype.IsTypedef()) objtype = objtype.ToType();
50 std::cerr <<
"Can't get a type out of " << wrapperType.Name(Reflex::SCOPED) << std::endl;
56 if (sel.get() == 0)
return false;Reflex::Object
obj(type, const_cast<void *>(ptr));
62 if (expr.get() == 0)
return 0;
63 Reflex::Object
obj(type, const_cast<void *>(ptr));
64 return expr->value(obj);
71 if (exprs_.back().get() == 0) {
72 std::cerr <<
"Failed to parse expression " << expr << std::endl;
83 if (strlen(cut) && !cuts_[0].
get()) {
84 std::cerr <<
"Failed to set cut \"" << cut <<
"\"" << std::endl;
105 if (!cuts_.back().get()) {
106 std::cerr <<
"Failed to add cut \"" << cut <<
"\"" << std::endl;
116 if (icut >= cuts_.size())
return false;
117 if (cuts_[icut].
get() == 0)
return true;
119 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
120 return (*cuts_[icut])(
obj);
122 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
130 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
131 if (exprs_.size() > iexpr)
return exprs_[iexpr]->
value(obj);
133 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
140 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
141 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
142 for (std::vector<reco::parser::ExpressionPtr>::const_iterator it = exprs_.begin(), ed = exprs_.end(); it != ed; ++it) {
143 if (ptr == 0 || it->get() == 0) {
144 printf(
" : %8s",
"#ERR");
147 double val = (*it)->value(obj);
151 int len = sprintf(buff,
" : % 8.6g",val);
155 if (strchr(buff,
'e')) {
156 printf((len == 3+13 ?
" : % .0e" :
" : % .1e"),val);
158 printf(
"%11.11s",buff);
162 printf(
" : %8s",
"EXCEPT");
163 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
167 for (std::vector<reco::parser::SelectorPtr>::const_iterator it = cuts_.begin()+1, ed = cuts_.end(); it != ed; ++it) {
168 if (ptr == 0 || it->get() == 0) {
169 printf(
" : %8s",
"#ERR");
172 int ret = (*it)->operator()(
obj);
173 printf(
" : %8d", ret);
175 printf(
" : %8s",
"EXCEPT");
176 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
187 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
188 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
190 if (!exprs_.empty()) hist->Fill(exprs_[0]->value(obj));
192 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
199 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
200 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
202 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
204 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
211 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
212 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
214 if (exprs_.size() >= 2) graph->SetPoint(graph->GetN(), exprs_[0]->value(obj), exprs_[1]->value(obj));
216 if (!ignoreExceptions_)
std::cerr <<
"Caught exception " << ex.what() << std::endl;
224 Reflex::Object
obj(objType_, const_cast<void *>(ptr));
225 if ((cuts_[0].
get() == 0) || (*cuts_[0])(obj)) {
227 if (exprs_.size() >= 2) hist->Fill(exprs_[0]->value(obj), exprs_[1]->value(obj));
229 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 ;.
static reco::parser::SelectorPtr makeSelector(const std::string &expr, const Reflex::Type &type)
Parse an expression for a given object type (using lazy parsing when resolving methods) ...
boost::shared_ptr< ExpressionBase > ExpressionPtr
static bool test(const reco::parser::SelectorPtr &sel, const Reflex::Type type, const void *obj)
Make a Reflex::Object(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)
static double eval(const reco::parser::ExpressionPtr &sel, const Reflex::Type type, const void *obj)
Make a Reflex::Object(type, obj) and pass it to the expression.
bool test(const void *obj, size_t icut=0) const
double eval(const void *obj, size_t iexpr=0) const
static Reflex::Type elementType(const Reflex::Type &wrapperType)
Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs.
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
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 Reflex::Type &type)
Parse an expression for a given object type (using lazy parsing when resolving methods) ...
void fillProf(const void *obj, TProfile *prof) const
void fillGraph(const void *obj, TGraph *graph) const