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) rangeCuts_.emplace_back(VarRangeCut<ObjType>(cutConfig));
29  }
30 
31  //if no cuts are defined, it returns true
32  bool operator()(const ObjType& obj)const{
33  for(auto& cut : rangeCuts_){
34  if(!cut(obj)) return false;
35  }
36  return true;
37  }
38 
39  //this version allows us to skip a range check for a specificed variable
40  //okay this feature requirement was missed in the initial (very rushed) design phase
41  //and thats why its now hacked in
42  //basically if you're applying an Et cut, you want to automatically turn it of
43  //when you're making a turn on curve...
44  //if no cuts are defined, it returns true
45  bool operator()(const ObjType& obj,const std::string& varToSkip)const{
46  for(auto& cut : rangeCuts_){
47  if(cut.varName()==varToSkip) continue;
48  if(!cut(obj)) return false;
49  }
50  return true;
51  }
52  //for multiple cuts to skip
53  bool operator()(const ObjType& obj,const std::vector<std::string>& varsToSkip)const{
54  for(auto& cut : rangeCuts_){
55  if(std::find(varsToSkip.begin(),varsToSkip.end(),cut.varName())!=varsToSkip.end()) continue;
56  if(!cut(obj)) return false;
57  }
58  return true;
59  }
60 private:
61  std::vector<VarRangeCut<ObjType> > rangeCuts_;
62 };
63 
64 #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:20
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_