Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripCommissioningRunTypeFilter
0004 // Class:      SiStripCommissioningRunTypeFilter
0005 //
0006 /**\class SiStripCommissioningRunTypeFilter SiStripCommissioningRunTypeFilter.cc myTestArea/SiStripCommissioningRunTypeFilter/src/SiStripCommissioningRunTypeFilter.cc
0007 
0008  Description: simply filter acording to the run type
0009 
0010  Implementation:
0011      Uses information from SiStripEventSummary, so it has to be called after Raw2Digi.
0012 */
0013 //
0014 // Original Author:  Christophe DELAERE
0015 //         Created:  Fri Jan 18 12:17:46 CET 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <algorithm>
0022 #include <vector>
0023 
0024 // user include files
0025 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0026 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
0027 #include "FWCore/Framework/interface/stream/EDFilter.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/Frameworkfwd.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "FWCore/Utilities/interface/EDGetToken.h"
0033 #include "FWCore/Utilities/interface/InputTag.h"
0034 
0035 //
0036 // class declaration
0037 //
0038 class SiStripEventSummary;
0039 
0040 class SiStripCommissioningRunTypeFilter : public edm::stream::EDFilter<> {
0041 public:
0042   explicit SiStripCommissioningRunTypeFilter(const edm::ParameterSet&);
0043   ~SiStripCommissioningRunTypeFilter() override = default;
0044 
0045 private:
0046   bool filter(edm::Event&, const edm::EventSetup&) override;
0047 
0048   // ----------member data ---------------------------
0049   //      edm::InputTag inputModuleLabel_;
0050   edm::EDGetTokenT<SiStripEventSummary> summaryToken_;
0051   std::vector<sistrip::RunType> runTypes_;
0052 };
0053 
0054 //
0055 // constructors and destructor
0056 //
0057 SiStripCommissioningRunTypeFilter::SiStripCommissioningRunTypeFilter(const edm::ParameterSet& iConfig) {
0058   //now do what ever initialization is needed
0059   summaryToken_ = consumes<SiStripEventSummary>(iConfig.getParameter<edm::InputTag>("InputModuleLabel"));
0060   //   inputModuleLabel_ = iConfig.getParameter<edm::InputTag>( "InputModuleLabel" ) ;
0061   std::vector<std::string> runTypes = iConfig.getParameter<std::vector<std::string> >("runTypes");
0062   for (std::vector<std::string>::const_iterator run = runTypes.begin(); run != runTypes.end(); ++run) {
0063     runTypes_.push_back(SiStripEnumsAndStrings::runType(*run));
0064   }
0065 }
0066 
0067 //
0068 // member functions
0069 //
0070 
0071 // ------------ method called on each new Event  ------------
0072 bool SiStripCommissioningRunTypeFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0073   using namespace edm;
0074   // Retrieve commissioning information from "event summary"
0075   edm::Handle<SiStripEventSummary> summary;
0076   iEvent.getByToken(summaryToken_, summary);
0077   return (std::find(runTypes_.begin(), runTypes_.end(), summary->runType()) != runTypes_.end());
0078 }
0079 
0080 #include "FWCore/Framework/interface/MakerMacros.h"
0081 DEFINE_FWK_MODULE(SiStripCommissioningRunTypeFilter);