CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ScannerHelpers.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_FWLite_ScannerHelpers_h
2 #define PhysicsTools_FWLite_ScannerHelpers_h
3 
4 #include <string>
5 #include <Reflex/Type.h>
6 #include <TH1.h>
7 #include <TH2.h>
8 #include <TProfile.h>
9 #include <TGraph.h>
10 
11 
12 // AFAIK These includes are needed to build the dictionary
13 // but must be kept hidden if CINT sees this class
14 #if !defined(__CINT__) && !defined(__MAKECINT__)
19 #endif
20 
21 namespace helper {
24  class Parser {
25  public:
27  Parser() {}
29  static reco::parser::ExpressionPtr makeExpression(const std::string &expr, const Reflex::Type &type) ;
31  static reco::parser::SelectorPtr makeSelector(const std::string &expr, const Reflex::Type &type) ;
33  static Reflex::Type elementType(const Reflex::Type &wrapperType) ;
34 
35  //--- we define also dictionaries for these two trivial functions that should be callable even by CINT
36  // because otherwise sometimes CINT crashes even on the creation and destruction of Reflex::Object
38  static bool test(const reco::parser::SelectorPtr &sel, const Reflex::Type type, const void * obj);
40  static double eval(const reco::parser::ExpressionPtr &sel, const Reflex::Type type, const void * obj);
41  };
42 
45  class ScannerBase {
46  public:
50  ScannerBase(const Reflex::Type &objType) : objType_(objType), cuts_(1), ignoreExceptions_(false) {}
51 
54  bool addExpression(const char *expr) ;
56  void clearExpressions() { exprs_.clear(); }
58  size_t numberOfExpressions() const { return exprs_.size(); }
59 
61  bool setCut(const char *cut) ;
63  void clearCut() ;
65  bool addExtraCut(const char *cut) ;
67  void clearExtraCuts();
69  size_t numberOfExtraCuts() const { return cuts_.size()-1; }
70 
73  bool test(const void *obj, size_t icut = 0) const ;
74 
77  double eval(const void *obj, size_t iexpr = 0) const;
78 
81  void print(const void *obj) const ;
82 
85  void fill1D(const void *obj, TH1 *hist) const ;
86 
89  void fill2D(const void *obj, TH2 *hist2d) const ;
90 
93  void fillGraph(const void *obj, TGraph *graph) const ;
94 
97  void fillProf(const void *obj, TProfile *prof) const ;
98 
101  void setIgnoreExceptions(bool ignoreThem) { ignoreExceptions_ = ignoreThem; }
102  private:
104  std::vector<reco::parser::ExpressionPtr> exprs_;
105 
107  std::vector<reco::parser::SelectorPtr> cuts_;
108 
111  };
112 }
113 
114 #endif
void print(const void *obj) const
type
Definition: HCALResponse.h:22
void fill2D(const void *obj, TH2 *hist2d) const
void clearExtraCuts()
Clear all extra cuts ;.
void setIgnoreExceptions(bool ignoreThem)
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) ...
void clearExpressions()
Clear all the expressions.
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)
std::vector< reco::parser::SelectorPtr > cuts_
The first one is the default cut, the others are the extra ones.
std::vector< reco::parser::ExpressionPtr > exprs_
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.
ScannerBase()
Empty constructor, necessary for Reflex, DO NOT USE.
bool test(const void *obj, size_t icut=0) const
ScannerBase(const Reflex::Type &objType)
Constructor taking as argument the type of the individual object passed to the scanner.
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&lt;C&gt; to C::value_type and resolves typedefs.
void fill1D(const void *obj, TH1 *hist) const
void clearCut()
Clear the default cut.
bool addExpression(const char *expr)
Reflex::Type objType_
Definition: adjgraph.h:12
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
bool ignoreExceptions_
See setIgnoreExceptions to find out what this means.
size_t numberOfExtraCuts() const
Number of extra cuts.
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
Parser()
Empty constructor, necessary for Reflex, useless.
size_t numberOfExpressions() const
Number of valid expressions.