CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
VarRangeCut< ObjType > Class Template Reference

#include <VarRangeCut.h>

Public Member Functions

bool operator() (const ObjType &obj) const
 
const std::string & varName () const
 
 VarRangeCut (const edm::ParameterSet &config)
 

Static Public Member Functions

static edm::ParameterSetDescription makePSetDescription ()
 

Private Attributes

std::vector< std::pair< float, float > > allowedRanges_
 
std::function< float(const ObjType &)> varFunc_
 
std::string varName_
 

Detailed Description

template<typename ObjType>
class VarRangeCut< ObjType >

Definition at line 30 of file VarRangeCut.h.

Constructor & Destructor Documentation

template<typename ObjType >
VarRangeCut< ObjType >::VarRangeCut ( const edm::ParameterSet config)
explicit

Definition at line 45 of file VarRangeCut.h.

References VarRangeCut< ObjType >::allowedRanges_, edm::ParameterSet::getParameter(), diffTwoXMLs::ranges, split, AlCaHLTBitMon_QueryRunRegistry::string, VarRangeCut< ObjType >::varFunc_, and VarRangeCut< ObjType >::varName_.

46 {
47  varName_ = config.getParameter<std::string>("rangeVar");
48  varFunc_ = hltdqm::getUnaryFuncFloat<ObjType>(varName_);
49  auto ranges = config.getParameter<std::vector<std::string> >("allowedRanges");
50  for(auto range: ranges){
51  std::vector<std::string> splitRange;
52  boost::split(splitRange,range,boost::is_any_of(":"));
53  if(splitRange.size()!=2) throw cms::Exception("ConfigError") <<"in VarRangeCut::VarRangeCut range "<<range<<" is not of format X:Y"<<std::endl;
54  allowedRanges_.push_back({std::stof(splitRange[0]),std::stof(splitRange[1])});
55  }
56 }
T getParameter(std::string const &) const
std::string varName_
Definition: VarRangeCut.h:39
string ranges
Definition: diffTwoXMLs.py:79
std::vector< std::pair< float, float > > allowedRanges_
Definition: VarRangeCut.h:41
std::function< float(const ObjType &)> varFunc_
Definition: VarRangeCut.h:40
double split
Definition: MVATrainer.cc:139

Member Function Documentation

template<typename ObjType >
edm::ParameterSetDescription VarRangeCut< ObjType >::makePSetDescription ( )
static

Definition at line 59 of file VarRangeCut.h.

References edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

60 {
62  desc.add<std::string>("rangeVar","");
63  desc.add<std::vector<std::string> >("allowedRanges",std::vector<std::string>());
64  return desc;
65 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
template<typename ObjType >
bool VarRangeCut< ObjType >::operator() ( const ObjType &  obj) const

Definition at line 68 of file VarRangeCut.h.

References VarRangeCut< ObjType >::allowedRanges_, and VarRangeCut< ObjType >::varFunc_.

69 {
70  if(!varFunc_) return true; //auto pass if we dont specify a variable function
71  else{
72  float varVal = varFunc_(obj);
73  for(auto& range : allowedRanges_){
74  if(varVal>=range.first && varVal<range.second) return true;
75  }
76  return false;
77  }
78 }
std::vector< std::pair< float, float > > allowedRanges_
Definition: VarRangeCut.h:41
std::function< float(const ObjType &)> varFunc_
Definition: VarRangeCut.h:40
template<typename ObjType >
const std::string& VarRangeCut< ObjType >::varName ( ) const
inline

Definition at line 36 of file VarRangeCut.h.

References VarRangeCut< ObjType >::varName_.

36 {return varName_;}
std::string varName_
Definition: VarRangeCut.h:39

Member Data Documentation

template<typename ObjType >
std::vector<std::pair<float,float> > VarRangeCut< ObjType >::allowedRanges_
private
template<typename ObjType >
std::function<float(const ObjType&)> VarRangeCut< ObjType >::varFunc_
private
template<typename ObjType >
std::string VarRangeCut< ObjType >::varName_
private