CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VariableEventSelector.h
Go to the documentation of this file.
1 #ifndef _VariableEventSelector_H
2 #define _VariableEventSelector_H
3 
6 
8  public:
10  EventSelector(pset)
11  {
12  var_=pset.getParameter<std::string>("var");
13  doMin_=pset.exists("min");
14  if (doMin_) min_=pset.getParameter<double>("min");
15  doMax_=pset.exists("max");
16  if (doMax_) max_=pset.getParameter<double>("max");
17 
18  std::stringstream ss;
19  ss<<"event selector based on VariableHelper variable: "<<var_;
20  description_.push_back(ss.str()); ss.str("");
21  if (doMin_){
22  ss<<"with minimum boundary: "<<min_;
23  description_.push_back(ss.str()); ss.str("");}
24  if (doMax_){
25  ss<<"with maximum boundary: "<<max_;
26  description_.push_back(ss.str()); ss.str("");}
27  }
28  bool select(const edm::Event& e) const{
29  const CachingVariable * var=edm::Service<VariableHelperService>()->get().variable(var_);
30  if (!var->compute(e)) return false;
31 
32  double v=(*var)(e);
33 
34  if (doMin_ && v<min_) return false;
35  else if (doMax_ && v>max_) return false;
36  else return true;
37  }
38 
39  private:
41  bool doMin_;
42  double min_;
43  bool doMax_;
44  double max_;
45 };
46 
47 #endif
T getParameter(std::string const &) const
std::vector< std::string > description_
Definition: EventSelector.h:31
bool exists(std::string const &parameterName) const
checks if a parameter exists
VariableEventSelector(const edm::ParameterSet &pset)
A selector of events.
Definition: EventSelector.h:15
bool compute(const edm::Event &iEvent) const
bool select(const edm::Event &e) const
decision of the selector module