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 
7 
9  public:
11  VariableEventSelector(pset, iC) {}
13  EventSelector(pset, iC)
14  {
15  var_=pset.getParameter<std::string>("var");
16  doMin_=pset.exists("min");
17  if (doMin_) min_=pset.getParameter<double>("min");
18  doMax_=pset.exists("max");
19  if (doMax_) max_=pset.getParameter<double>("max");
20 
21  std::stringstream ss;
22  ss<<"event selector based on VariableHelper variable: "<<var_;
23  description_.push_back(ss.str()); ss.str("");
24  if (doMin_){
25  ss<<"with minimum boundary: "<<min_;
26  description_.push_back(ss.str()); ss.str("");}
27  if (doMax_){
28  ss<<"with maximum boundary: "<<max_;
29  description_.push_back(ss.str()); ss.str("");}
30  }
31  bool select(const edm::Event& e) const{
32  const CachingVariable * var=edm::Service<VariableHelperService>()->get().variable(var_);
33  if (!var->compute(e)) return false;
34 
35  double v=(*var)(e);
36 
37  if (doMin_ && v<min_) return false;
38  else if (doMax_ && v>max_) return false;
39  else return true;
40  }
41 
42  private:
44  bool doMin_;
45  double min_;
46  bool doMax_;
47  double max_;
48 };
49 
50 #endif
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
VariableEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
A selector of events.
Definition: EventSelector.h:16
bool compute(const edm::Event &iEvent) const
std::vector< std::string > description_
Definition: EventSelector.h:34
VariableEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
bool select(const edm::Event &e) const
decision of the selector module