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

◆ VarRangeCut()

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

Definition at line 44 of file VarRangeCut.h.

References FastTimerService_cff::range, diffTwoXMLs::ranges, submitPVValidationJobs::split(), and AlCaHLTBitMon_QueryRunRegistry::string.

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::pair< float, float > > allowedRanges_
Definition: VarRangeCut.h:40
Definition: config.py:1
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

◆ makePSetDescription()

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

Definition at line 59 of file VarRangeCut.h.

References submitPVResolutionJobs::desc, 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 }

◆ operator()()

template<typename ObjType >
bool VarRangeCut< ObjType >::operator() ( const ObjType &  obj) const

Definition at line 67 of file VarRangeCut.h.

References getGTfromDQMFile::obj, and FastTimerService_cff::range.

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

◆ varName()

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

◆ allowedRanges_

template<typename ObjType >
std::vector<std::pair<float, float> > VarRangeCut< ObjType >::allowedRanges_
private

Definition at line 40 of file VarRangeCut.h.

◆ varFunc_

template<typename ObjType >
std::function<float(const ObjType&)> VarRangeCut< ObjType >::varFunc_
private

Definition at line 39 of file VarRangeCut.h.

◆ varName_

template<typename ObjType >
std::string VarRangeCut< ObjType >::varName_
private

Definition at line 38 of file VarRangeCut.h.

Referenced by VarRangeCut< ObjType >::varName().