Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:12

0001 #ifndef UtilAlgos_StringCutObjectSelector_h
0002 #define UtilAlgos_StringCutObjectSelector_h
0003 #include "FWCore/Framework/interface/ConsumesCollector.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
0006 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0007 
0008 namespace reco {
0009   namespace modules {
0010 
0011     template <typename T, bool Lazy>
0012     struct ParameterAdapter<StringCutObjectSelector<T, Lazy> > {
0013       static StringCutObjectSelector<T, Lazy> make(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) {
0014         return StringCutObjectSelector<T, Lazy>(cfg.template getParameter<std::string>("cut"));
0015       }
0016 
0017       static void fillPSetDescription(edm::ParameterSetDescription& desc) { desc.add<std::string>("cut", ""); }
0018     };
0019 
0020   }  // namespace modules
0021 }  // namespace reco
0022 
0023 // Introducing a simpler way to use a string object selector outside of the
0024 // heavily-templated infrastructure above. This simply translates the cfg
0025 // into the string that the functor expects.
0026 namespace reco {
0027   template <typename T, bool Lazy>
0028   class StringCutObjectSelectorHandler : public StringCutObjectSelector<T, Lazy> {
0029   public:
0030     explicit StringCutObjectSelectorHandler(const edm::ParameterSet& cfg)
0031         : StringCutObjectSelector<T, Lazy>(cfg.getParameter<std::string>("cut")) {}
0032   };
0033 }  // namespace reco
0034 
0035 #endif