Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:35

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripTools
0004 // Class:      EventWithHistoryEDFilter
0005 //
0006 /**\class EventWithHistoryEDFilter EventWithHistoryEDFilter.cc DPGAnalysis/SiStripTools/plugins/EventWithHistoryEDFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Tue Dec  9 18:33:42 CET 2008
0016 // $Id: EventWithHistoryEDFilter.cc,v 1.3 2010/01/12 09:13:04 venturia Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 #include <vector>
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/global/EDFilter.h"
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/Run.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/Framework/interface/EventSetup.h"
0032 #include "FWCore/Framework/interface/ESHandle.h"
0033 
0034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0036 
0037 #include "DPGAnalysis/SiStripTools/interface/EventWithHistoryFilter.h"
0038 
0039 //
0040 // class declaration
0041 //
0042 
0043 class EventWithHistoryEDFilter : public edm::global::EDFilter<> {
0044 public:
0045   explicit EventWithHistoryEDFilter(const edm::ParameterSet&);
0046 
0047 private:
0048   bool filter(edm::StreamID streamId, edm::Event&, const edm::EventSetup&) const override;
0049 
0050   // ----------member data ---------------------------
0051 
0052   std::vector<EventWithHistoryFilter> ehfilters_;
0053   const bool debu_;
0054 };
0055 
0056 //
0057 // constants, enums and typedefs
0058 //
0059 
0060 //
0061 // static data member definitions
0062 //
0063 
0064 //
0065 // constructors and destructor
0066 //
0067 EventWithHistoryEDFilter::EventWithHistoryEDFilter(const edm::ParameterSet& iConfig)
0068     : ehfilters_(), debu_(iConfig.getUntrackedParameter<bool>("debugPrint", false)) {
0069   //now do what ever initialization is needed
0070 
0071   std::vector<edm::ParameterSet> filterconfigs(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(
0072       "filterConfigurations", std::vector<edm::ParameterSet>()));
0073 
0074   for (auto& ps : filterconfigs) {
0075     ps.augment(iConfig.getUntrackedParameter<edm::ParameterSet>("commonConfiguration", edm::ParameterSet()));
0076 
0077     ehfilters_.emplace_back(ps, consumesCollector());
0078   }
0079 }
0080 
0081 //
0082 // member functions
0083 //
0084 
0085 // ------------ method called on each new Event  ------------
0086 bool EventWithHistoryEDFilter::filter(edm::StreamID streamId, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0087   bool selected = false;
0088 
0089   for (const auto& filter : ehfilters_) {
0090     selected = selected || filter.selected(iEvent, iSetup);
0091   }
0092 
0093   if (debu_ && selected)
0094     edm::LogInfo("SELECTED") << "selected event";
0095 
0096   return selected;
0097 }
0098 
0099 //define this as a plug-in
0100 DEFINE_FWK_MODULE(EventWithHistoryEDFilter);