CMS 3D CMS Logo

VarRangeCutColl.h
Go to the documentation of this file.
1 #ifndef DQMOffline_Trigger_VarRangeCutColl_h
2 #define DQMOffline_Trigger_VarRangeCutColl_h
3 
4 //********************************************************************************
5 //
6 // Description:
7 // A collection cut minimal selection cuts.
8 // These selection cuts are intended to be simple selections on kinematic variables.
9 // The cuts are ANDed together
10 // intended use case cuts on et and eta
11 // However individual cuts can be skipped, so you can disable say only the Et cut
12 // when you're doing a turn on
13 //
14 // Implimentation:
15 // Basically a vector of VarRangeCuts which a nice operator() function to make it
16 // easy to use
17 //
18 // Author : Sam Harper , RAL, May 2017
19 //
20 //***********************************************************************************
21 
23 
24 template <typename ObjType>
26 public:
27  explicit VarRangeCutColl(const std::vector<edm::ParameterSet>& configs) {
28  for (const auto& cutConfig : configs)
29  rangeCuts_.emplace_back(VarRangeCut<ObjType>(cutConfig));
30  }
31 
32  //if no cuts are defined, it returns true
33  bool operator()(const ObjType& obj) const {
34  for (auto& cut : rangeCuts_) {
35  if (!cut(obj))
36  return false;
37  }
38  return true;
39  }
40 
41  //this version allows us to skip a range check for a specificed variable
42  //okay this feature requirement was missed in the initial (very rushed) design phase
43  //and thats why its now hacked in
44  //basically if you're applying an Et cut, you want to automatically turn it of
45  //when you're making a turn on curve...
46  //if no cuts are defined, it returns true
47  bool operator()(const ObjType& obj, const std::string& varToSkip) const {
48  for (auto& cut : rangeCuts_) {
49  if (cut.varName() == varToSkip)
50  continue;
51  if (!cut(obj))
52  return false;
53  }
54  return true;
55  }
56  //for multiple cuts to skip
57  bool operator()(const ObjType& obj, const std::vector<std::string>& varsToSkip) const {
58  for (auto& cut : rangeCuts_) {
59  if (std::find(varsToSkip.begin(), varsToSkip.end(), cut.varName()) != varsToSkip.end())
60  continue;
61  if (!cut(obj))
62  return false;
63  }
64  return true;
65  }
66 
67 private:
68  std::vector<VarRangeCut<ObjType> > rangeCuts_;
69 };
70 
71 #endif
VarRangeCutColl(const std::vector< edm::ParameterSet > &configs)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool operator()(const ObjType &obj, const std::string &varToSkip) const
bool operator()(const ObjType &obj, const std::vector< std::string > &varsToSkip) const
bool operator()(const ObjType &obj) const
std::vector< VarRangeCut< ObjType > > rangeCuts_