CMS 3D CMS Logo

StringObjectFunction.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_StringObjectFunction_h
2 #define CommonTools_Utils_StringObjectFunction_h
3 /* \class StringCutObjectSelector
4  *
5  * \author Luca Lista, INFN
6  *
7  * $Id: StringObjectFunction.h,v 1.4 2012/06/26 21:09:37 wmtan Exp $
8  */
14 
15 template<typename T, bool DefaultLazyness=false>
17  StringObjectFunction(const std::string & expr, bool lazy=DefaultLazyness) :
18  type_(typeid(T)) {
19  if(! reco::parser::expressionParser<T>(expr, expr_, lazy)) {
21  "failed to parse \"" + expr + "\"");
22  }
23  }
25  expr_(expr),
26  type_(typeid(T)) {
27  }
28  double operator()(const T & t) const {
29  edm::ObjectWithDict o(type_, const_cast<T *>(& t));
30  return expr_->value(o);
31  }
32 
33 private:
36 };
37 
38 template <typename Object> class sortByStringFunction {
39  public:
42 
43  bool operator() (const Object * o1, const Object * o2) {
44  return (*f_)(*o1) > (*f_)(*o2);
45  }
46  private:
48 };
49 
50 #endif
boost::shared_ptr< ExpressionBase > ExpressionPtr
StringObjectFunction(const reco::parser::ExpressionPtr &expr)
double f[11][100]
StringObjectFunction(const std::string &expr, bool lazy=DefaultLazyness)
edm::TypeWithDict type_
reco::parser::ExpressionPtr expr_
StringObjectFunction< Object > * f_
long double T
double operator()(const T &t) const
sortByStringFunction(StringObjectFunction< Object > *f)