![]() |
|
|||
File indexing completed on 2025-01-12 23:42:02
0001 #ifndef PhysicsTools_UtilAlgos_interface_EDFilterWrapper_h 0002 #define PhysicsTools_UtilAlgos_interface_EDFilterWrapper_h 0003 0004 /** 0005 \class EDFilterWrapper EDFilterWrapper.h "PhysicsTools/UtilAlgos/interface/EDFilterWrapper.h" 0006 \brief Wrapper class for a class of type BasicFilter to "convert" it into a full EDFilter 0007 0008 This template class is a wrapper around classes of type BasicFilter as defined in the 0009 BasicFilter.h file of this package. From this class the wrapper expects the following 0010 member functions: 0011 0012 + a constructor with a const edm::ParameterSet& as input. 0013 + a filter function with an const edm::EventBase& as input 0014 0015 the function is called within the wrapper. The wrapper translates the common class into 0016 a basic EDFilter as shown below: 0017 0018 #include "PhysicsTools/UtilAlgos/interface/EDFilterWrapper.h" 0019 #include "PhysicsTools/SelectorUtils/interface/PVSelector.h" 0020 0021 typedef edm::FilterWrapper<PVSelector> PrimaryVertexFilter; 0022 0023 #include "FWCore/Framework/interface/MakerMacros.h" 0024 DEFINE_FWK_MODULE(PrimaryVertexFilter); 0025 0026 You can find this example in the plugins directory of this package. With this wrapper class 0027 we have the use case in mind that you keep classes, which easily can be used both within the 0028 full framework and within FWLite. 0029 0030 NOTE: in the current implementation this wrapper class does not support use of the EventSetup. 0031 If you want to make use of this feature we recommend you to start from an EDFilter from the 0032 very beginning and just to stay within the full framework. 0033 */ 0034 0035 #include "FWCore/Framework/interface/global/EDFilter.h" 0036 #include "FWCore/ServiceRegistry/interface/Service.h" 0037 #include "CommonTools/UtilAlgos/interface/TFileService.h" 0038 #include "FWCore/Common/interface/EventBase.h" 0039 #include "FWCore/Framework/interface/Event.h" 0040 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" 0041 #include "FWCore/ParameterSet/interface/ParameterSet.h" 0042 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" 0043 0044 namespace edm { 0045 0046 template <class T> 0047 class FilterWrapper : public edm::global::EDFilter<> { 0048 public: 0049 /// default contructor 0050 FilterWrapper(const edm::ParameterSet& cfg) { filter_ = std::shared_ptr<T>(new T(cfg, consumesCollector())); } 0051 /// default destructor 0052 ~FilterWrapper() override {} 0053 /// everything which has to be done during the event loop. NOTE: We can't use the eventSetup in FWLite so ignore it 0054 bool filter(edm::StreamID, edm::Event& event, const edm::EventSetup& eventSetup) const override { 0055 edm::EventBase& eventBase = dynamic_cast<edm::EventBase&>(event); 0056 edm::EventBase const& eventBaseConst = const_cast<edm::EventBase const&>(eventBase); 0057 return (*filter_)(eventBaseConst); 0058 } 0059 0060 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { 0061 edm::ParameterSetDescription desc = T::getDescription(); 0062 descriptions.addWithDefaultLabel(desc); 0063 } 0064 0065 protected: 0066 /// shared pointer to analysis class of type BasicAnalyzer 0067 std::shared_ptr<T> filter_; 0068 }; 0069 0070 } // namespace edm 0071 0072 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |