Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:08

0001 // -*- C++ -*-
0002 //
0003 // Package:    TMTFilter
0004 // Class:      TMTFilter
0005 //
0006 /**\class TMTFilter TMTFilter.cc EventFilter/L1TRawToDigi/src/TMTFilter.cc
0007 
0008 Description: <one line class summary>
0009 Implementation:
0010 <Notes on implementation>
0011 */
0012 //
0013 // Original Author:  Jim Brooke
0014 //         Created:
0015 //
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 
0021 // user include files
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 
0024 #include "FWCore/Framework/interface/EDFilter.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/Utilities/interface/InputTag.h"
0030 
0031 #include <string>
0032 #include <vector>
0033 #include <iostream>
0034 
0035 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
0036 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0037 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0038 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
0039 
0040 //
0041 // class declaration
0042 //
0043 
0044 class TMTFilter : public edm::EDFilter {
0045 public:
0046   explicit TMTFilter(const edm::ParameterSet&);
0047   ~TMTFilter() override;
0048 
0049 private:
0050   void beginJob() override;
0051   bool filter(edm::Event&, const edm::EventSetup&) override;
0052   void endJob() override;
0053 
0054   // ----------member data ---------------------------
0055   edm::EDGetTokenT<FEDRawDataCollection> fedData_;
0056 
0057   std::vector<int> mpList_;  // list of MPs to select
0058 };
0059 
0060 //
0061 // constructors and destructor
0062 //
0063 TMTFilter::TMTFilter(const edm::ParameterSet& iConfig)
0064     : mpList_(iConfig.getUntrackedParameter<std::vector<int> >("mpList")) {
0065   //now do what ever initialization is needed
0066 
0067   fedData_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("inputTag"));
0068 }
0069 
0070 TMTFilter::~TMTFilter() {
0071   // do anything here that needs to be done at desctruction time
0072   // (e.g. close files, deallocate resources etc.)
0073 }
0074 
0075 //
0076 // member functions
0077 //
0078 
0079 // ------------ method called on each new Event  ------------
0080 bool TMTFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0081   using namespace edm;
0082 
0083   edm::Handle<FEDRawDataCollection> feds;
0084   iEvent.getByToken(fedData_, feds);
0085 
0086   if (!feds.isValid()) {
0087     LogError("L1T") << "Cannot unpack: no FEDRawDataCollection found";
0088     return false;
0089   }
0090 
0091   const FEDRawData& l1tRcd = feds->FEDData(1024);
0092 
0093   const unsigned char* data = l1tRcd.data();
0094   FEDHeader header(data);
0095 
0096   bool mp = false;
0097   for (auto itr : mpList_) {
0098     mp |= (((header.bxID() - 1) % 9) == itr);
0099   }
0100 
0101   return mp;
0102 }
0103 
0104 // ------------ method called once each job just before starting event loop  ------------
0105 void TMTFilter::beginJob() {}
0106 
0107 // ------------ method called once each job just after ending the event loop  ------------
0108 void TMTFilter::endJob() {}
0109 
0110 //define this as a plug-in
0111 DEFINE_FWK_MODULE(TMTFilter);