File indexing completed on 2025-02-05 23:51:00
0001 #ifndef UtilAlgos_PhiRangeSelector_h
0002 #define UtilAlgos_PhiRangeSelector_h
0003 #include "FWCore/Framework/interface/ConsumesCollector.h"
0004 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006
0007 struct PhiRangeSelector {
0008 PhiRangeSelector(double phiMin, double phiMax) : phiMin_(phiMin), phiMax_(phiMax) {}
0009 template <typename T>
0010 bool operator()(const T& t) const {
0011 double phi = t.phi();
0012 return (phi >= phiMin_ && phi <= phiMax_);
0013 }
0014
0015 private:
0016 double phiMin_, phiMax_;
0017 };
0018
0019 namespace reco {
0020 namespace modules {
0021 template <>
0022 struct ParameterAdapter<PhiRangeSelector> {
0023 static PhiRangeSelector make(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) {
0024 return PhiRangeSelector(cfg.getParameter<double>("phiMin"), cfg.getParameter<double>("phiMax"));
0025 }
0026
0027 static void fillPSetDescription(edm::ParameterSetDescription& desc) {
0028 desc.add<double>("phiMin", -3.2);
0029 desc.add<double>("phiMax", 3.2);
0030 }
0031 };
0032 }
0033 }
0034
0035 #endif