CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
VariableFormulaEventSelector Class Reference

#include <VariableEventSelector.h>

Inheritance diagram for VariableFormulaEventSelector:
EventSelector

Public Member Functions

bool select (const edm::Event &e) const
 decision of the selector module More...
 
 VariableFormulaEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
 VariableFormulaEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from EventSelector
const std::vector< std::string > & description ()
 
 EventSelector ()
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
const std::string & name () const
 name of the module (from configuration) More...
 
virtual ~EventSelector ()
 

Private Attributes

TFormula * formula_
 
double threshold_
 
std::set< std::string > vars_
 

Additional Inherited Members

- Protected Attributes inherited from EventSelector
std::vector< std::string > description_
 
std::string name_
 

Detailed Description

Definition at line 10 of file VariableEventSelector.h.

Constructor & Destructor Documentation

VariableFormulaEventSelector::VariableFormulaEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
inline
VariableFormulaEventSelector::VariableFormulaEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)
inline

Definition at line 13 of file VariableEventSelector.h.

References formula_, edm::ParameterSet::getParameter(), EventSelector::name_, AlCaHLTBitMon_QueryRunRegistry::string, threshold_, and vars_.

13  :
14  EventSelector(pset, iC)
15  {
16  const std::string name_ = pset.getParameter<std::string>("fname");
17  TString ts(pset.getParameter<std::string>("formula"));
18  //find the variables. register and replace
19  int open = ts.Index("[");
20  int close = ts.Index("]");
21  while (open>0){
22  ++open;
23  TString sub( ts(open,close-open));
24  //std::cout<<"found:"<< sub <<std::endl;
25  vars_.insert( sub.Data() );
26  //vars_.insert( ts(open,close-open));
27  open = ts.Index("[",open);
28  close = ts.Index("]",open);
29  }
30 
31  unsigned int v_i;
32  std::set<std::string>::iterator v_it;
33  for (v_i = 0, v_it=vars_.begin();
34  v_i!=vars_.size(); ++v_i,++v_it)
35  {
36  ts.ReplaceAll(TString::Format("[%s]", v_it->c_str()),TString::Format("[%d]", v_i));
37  }
38 
39  //std::cout<<" formula found:"<< ts <<std::endl;
40  formula_ = new TFormula(name_.c_str(), ts);
41  //vars_ = pset.getParameter<std::vector<std::string>>("variables");
42  threshold_= pset.getParameter<double>("threshold");
43  }
T getParameter(std::string const &) const
std::string name_
Definition: EventSelector.h:33
std::set< std::string > vars_

Member Function Documentation

bool VariableFormulaEventSelector::select ( const edm::Event ) const
inlinevirtual

decision of the selector module

Implements EventSelector.

Definition at line 45 of file VariableEventSelector.h.

References CachingVariable::compute(), alignCSCRings::e, formula_, threshold_, findQualityFiles::v, MetTreeProducer::var(), and vars_.

45  {
46  unsigned int v_i;
47  std::set<std::string>::iterator v_it;
48 
49  for (v_i = 0, v_it=vars_.begin();
50  v_i!=vars_.size(); ++v_i,++v_it)
51  {
52  const CachingVariable * var = edm::Service<VariableHelperService>()->get().variable(*v_it);
53  if (!var->compute(e)) return false;
54  double v=(*var)(e);
55  formula_->SetParameter(v_i, v);
56  }
57 
58  //should be valuated 0. or 1. in double
59  return (formula_->Eval(0.)>=threshold_);
60  }
bool compute(const edm::Event &iEvent) const
std::set< std::string > vars_

Member Data Documentation

TFormula* VariableFormulaEventSelector::formula_
private

Definition at line 63 of file VariableEventSelector.h.

Referenced by select(), and VariableFormulaEventSelector().

double VariableFormulaEventSelector::threshold_
private

Definition at line 65 of file VariableEventSelector.h.

Referenced by select(), and VariableFormulaEventSelector().

std::set<std::string> VariableFormulaEventSelector::vars_
private

Definition at line 64 of file VariableEventSelector.h.

Referenced by select(), and VariableFormulaEventSelector().