Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:53

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/global/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/L1TCalorimeter/interface/CaloTower.h"
0036 
0037 //
0038 // class declaration
0039 //
0040 
0041 namespace l1t {
0042 
0043   class L1TCaloTowersFilter : public edm::global::EDFilter<> {
0044   public:
0045     explicit L1TCaloTowersFilter(const edm::ParameterSet&);
0046 
0047   private:
0048     bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0049 
0050     // ----------member data ---------------------------
0051     edm::EDGetTokenT<l1t::CaloTowerBxCollection> m_towerToken;
0052 
0053     int period_;  // validation event period
0054   };
0055 
0056   //
0057   // constructors and destructor
0058   //
0059   L1TCaloTowersFilter::L1TCaloTowersFilter(const edm::ParameterSet& iConfig)
0060       : period_(iConfig.getUntrackedParameter<int>("period", 107)) {
0061     //now do what ever initialization is needed
0062 
0063     edm::InputTag towerTag = iConfig.getParameter<edm::InputTag>("towerToken");
0064     m_towerToken = consumes<l1t::CaloTowerBxCollection>(towerTag);
0065   }
0066 
0067   //
0068   // member functions
0069   //
0070 
0071   // ------------ method called on each new Event  ------------
0072   bool L1TCaloTowersFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0073     using namespace edm;
0074 
0075     Handle<BXVector<l1t::CaloTower> > towers;
0076     iEvent.getByToken(m_towerToken, towers);
0077 
0078     if (towers->size() == 0) {
0079       LogDebug("L1TCaloTowersFilter") << "Event does not contain towers." << std::endl;
0080       return false;
0081     }
0082 
0083     LogDebug("L1TCaloTowersFilter") << "Event does contains towers." << std::endl;
0084     return true;
0085   }
0086 
0087 }  // namespace l1t
0088 
0089 using namespace l1t;
0090 //define this as a plug-in
0091 DEFINE_FWK_MODULE(L1TCaloTowersFilter);