Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-13 02:58:09

0001 #ifndef DQMOffline_Trigger_VarRangeCutColl_h
0002 #define DQMOffline_Trigger_VarRangeCutColl_h
0003 
0004 //********************************************************************************
0005 //
0006 // Description:
0007 //   A collection cut minimal selection cuts.
0008 //   These selection cuts are intended to be simple selections on kinematic variables.
0009 //   The cuts are ANDed together
0010 //   intended use case cuts on et and eta
0011 //   However individual cuts can be skipped, so you can disable say only the Et cut
0012 //   when  you're doing a turn on
0013 //
0014 // Implimentation:
0015 //   Basically a vector of VarRangeCuts which a nice operator() function to make it
0016 //   easy to use
0017 //
0018 // Author : Sam Harper , RAL, May 2017
0019 //
0020 //***********************************************************************************
0021 
0022 #include "DQMOffline/Trigger/interface/VarRangeCut.h"
0023 
0024 template <typename ObjType>
0025 class VarRangeCutColl {
0026 public:
0027   VarRangeCutColl() {}
0028   explicit VarRangeCutColl(const std::vector<edm::ParameterSet>& configs) {
0029     for (const auto& cutConfig : configs)
0030       rangeCuts_.emplace_back(VarRangeCut<ObjType>(cutConfig));
0031   }
0032 
0033   //if no cuts are defined, it returns true
0034   bool operator()(const ObjType& obj) const {
0035     for (auto& cut : rangeCuts_) {
0036       if (!cut(obj))
0037         return false;
0038     }
0039     return true;
0040   }
0041 
0042   //this version allows us to skip a range check for a specificed variable
0043   //okay this feature requirement was missed in the initial (very rushed) design phase
0044   //and thats why its now hacked in
0045   //basically if you're applying an Et cut, you want to automatically turn it of
0046   //when you're making a turn on curve...
0047   //if no cuts are defined, it returns true
0048   bool operator()(const ObjType& obj, const std::string& varToSkip) const {
0049     for (auto& cut : rangeCuts_) {
0050       if (cut.varName() == varToSkip)
0051         continue;
0052       if (!cut(obj))
0053         return false;
0054     }
0055     return true;
0056   }
0057   //for multiple cuts to skip
0058   bool operator()(const ObjType& obj, const std::vector<std::string>& varsToSkip) const {
0059     for (auto& cut : rangeCuts_) {
0060       if (std::find(varsToSkip.begin(), varsToSkip.end(), cut.varName()) != varsToSkip.end())
0061         continue;
0062       if (!cut(obj))
0063         return false;
0064     }
0065     return true;
0066   }
0067 
0068 private:
0069   std::vector<VarRangeCut<ObjType> > rangeCuts_;
0070 };
0071 
0072 #endif