Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1TValidationEventFilter
0004 // Class:      L1TValidationEventFilter
0005 //
0006 /**\class L1TValidationEventFilter L1TValidationEventFilter.cc EventFilter/L1TRawToDigi/src/L1TValidationEventFilter.cc
0007 
0008 Description: <one line class summary>
0009 Implementation:
0010 nn<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 #include "DataFormats/L1TCalorimeter/interface/CaloTower.h"
0041 
0042 //
0043 // class declaration
0044 //
0045 
0046 namespace l1t {
0047 
0048   class L1TCaloTowersFilter : public edm::EDFilter {
0049   public:
0050     explicit L1TCaloTowersFilter(const edm::ParameterSet&);
0051     ~L1TCaloTowersFilter() override;
0052 
0053   private:
0054     void beginJob() override;
0055     bool filter(edm::Event&, const edm::EventSetup&) override;
0056     void endJob() override;
0057 
0058     // ----------member data ---------------------------
0059     edm::EDGetTokenT<FEDRawDataCollection> fedData_;
0060     edm::EDGetToken m_towerToken;
0061 
0062     int period_;  // validation event period
0063   };
0064 
0065   //
0066   // constructors and destructor
0067   //
0068   L1TCaloTowersFilter::L1TCaloTowersFilter(const edm::ParameterSet& iConfig)
0069       : period_(iConfig.getUntrackedParameter<int>("period", 107)) {
0070     //now do what ever initialization is needed
0071 
0072     // fedData_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("inputTag"));
0073     edm::InputTag towerTag = iConfig.getParameter<edm::InputTag>("towerToken");
0074     m_towerToken = consumes<l1t::CaloTowerBxCollection>(towerTag);
0075   }
0076 
0077   L1TCaloTowersFilter::~L1TCaloTowersFilter() {
0078     // do anything here that needs to be done at desctruction time
0079     // (e.g. close files, deallocate resources etc.)
0080   }
0081 
0082   //
0083   // member functions
0084   //
0085 
0086   // ------------ method called on each new Event  ------------
0087   bool L1TCaloTowersFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0088     using namespace edm;
0089 
0090     Handle<BXVector<l1t::CaloTower> > towers;
0091     iEvent.getByToken(m_towerToken, towers);
0092 
0093     // edm::Handle<FEDRawDataCollection> feds;
0094     // iEvent.getByToken(fedData_, feds);
0095 
0096     if (towers->size() == 0) {
0097       LogDebug("L1TCaloTowersFilter") << "Event does not contain towers." << std::endl;
0098       return false;
0099     }
0100 
0101     LogDebug("L1TCaloTowersFilter") << "Event does contains towers." << std::endl;
0102     return true;
0103 
0104     /*
0105   if (!feds.isValid()) {
0106     LogError("L1T") << "Cannot unpack: no FEDRawDataCollection found";
0107     return false;
0108   }
0109 
0110   const FEDRawData& l1tRcd = feds->FEDData(1024);
0111 
0112   const unsigned char *data = l1tRcd.data();
0113   FEDHeader header(data);
0114 
0115   bool fatEvent = (header.lvl1ID() % period_ == 0 );
0116 
0117   return fatEvent;
0118   */
0119   }
0120 
0121   // ------------ method called once each job just before starting event loop  ------------
0122   void L1TCaloTowersFilter::beginJob() {}
0123 
0124   // ------------ method called once each job just after ending the event loop  ------------
0125   void L1TCaloTowersFilter::endJob() {}
0126 
0127 }  // namespace l1t
0128 
0129 using namespace l1t;
0130 //define this as a plug-in
0131 DEFINE_FWK_MODULE(L1TCaloTowersFilter);