Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:52

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   explicit VarRangeCutColl(const std::vector<edm::ParameterSet>& configs) {
0028     for (const auto& cutConfig : configs)
0029       rangeCuts_.emplace_back(VarRangeCut<ObjType>(cutConfig));
0030   }
0031 
0032   //if no cuts are defined, it returns true
0033   bool operator()(const ObjType& obj) const {
0034     for (auto& cut : rangeCuts_) {
0035       if (!cut(obj))
0036         return false;
0037     }
0038     return true;
0039   }
0040 
0041   //this version allows us to skip a range check for a specificed variable
0042   //okay this feature requirement was missed in the initial (very rushed) design phase
0043   //and thats why its now hacked in
0044   //basically if you're applying an Et cut, you want to automatically turn it of
0045   //when you're making a turn on curve...
0046   //if no cuts are defined, it returns true
0047   bool operator()(const ObjType& obj, const std::string& varToSkip) const {
0048     for (auto& cut : rangeCuts_) {
0049       if (cut.varName() == varToSkip)
0050         continue;
0051       if (!cut(obj))
0052         return false;
0053     }
0054     return true;
0055   }
0056   //for multiple cuts to skip
0057   bool operator()(const ObjType& obj, const std::vector<std::string>& varsToSkip) const {
0058     for (auto& cut : rangeCuts_) {
0059       if (std::find(varsToSkip.begin(), varsToSkip.end(), cut.varName()) != varsToSkip.end())
0060         continue;
0061       if (!cut(obj))
0062         return false;
0063     }
0064     return true;
0065   }
0066 
0067 private:
0068   std::vector<VarRangeCut<ObjType> > rangeCuts_;
0069 };
0070 
0071 #endif