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 29 of file VarRangeCut.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file VarRangeCut.h.

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

44  {
45  varName_ = config.getParameter<std::string>("rangeVar");
46  varFunc_ = hltdqm::getUnaryFuncFloat<ObjType>(varName_);
47  auto ranges = config.getParameter<std::vector<std::string> >("allowedRanges");
48  for (auto range : ranges) {
49  std::vector<std::string> splitRange;
50  boost::split(splitRange, range, boost::is_any_of(":"));
51  if (splitRange.size() != 2)
52  throw cms::Exception("ConfigError")
53  << "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 }
std::vector< std::string_view > split(std::string_view, const char *)
T getParameter(std::string const &) const
std::vector< std::pair< float, float > > allowedRanges_
Definition: VarRangeCut.h:40
std::string varName_
Definition: VarRangeCut.h:38
string ranges
Definition: diffTwoXMLs.py:79
std::function< float(const ObjType &)> varFunc_
Definition: VarRangeCut.h:39

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.

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

Definition at line 67 of file VarRangeCut.h.

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

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

Definition at line 35 of file VarRangeCut.h.

References VarRangeCut< ObjType >::varName_.

35 { return varName_; }
std::string varName_
Definition: VarRangeCut.h:38

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