Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:44

0001 
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/global/EDFilter.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0007 
0008 class EENoiseFilter : public edm::global::EDFilter<> {
0009 public:
0010   explicit EENoiseFilter(const edm::ParameterSet& iConfig);
0011 
0012 private:
0013   bool filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
0014 
0015   edm::EDGetTokenT<EcalRecHitCollection> ebRHSrcToken_;
0016   edm::EDGetTokenT<EcalRecHitCollection> eeRHSrcToken_;
0017   const double slope_, intercept_;
0018 
0019   const bool taggingMode_, debug_;
0020 };
0021 
0022 EENoiseFilter::EENoiseFilter(const edm::ParameterSet& iConfig)
0023     : ebRHSrcToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EBRecHitSource"))),
0024       eeRHSrcToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHitSource"))),
0025       slope_(iConfig.getParameter<double>("Slope")),
0026       intercept_(iConfig.getParameter<double>("Intercept")),
0027       taggingMode_(iConfig.getParameter<bool>("taggingMode")),
0028       debug_(iConfig.getParameter<bool>("debug")) {
0029   produces<bool>();
0030 }
0031 
0032 bool EENoiseFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0033   edm::Handle<EcalRecHitCollection> ebRHs, eeRHs;
0034   iEvent.getByToken(ebRHSrcToken_, ebRHs);
0035   iEvent.getByToken(eeRHSrcToken_, eeRHs);
0036 
0037   const bool pass = eeRHs->size() < slope_ * ebRHs->size() + intercept_;
0038 
0039   iEvent.put(std::make_unique<bool>(pass));
0040 
0041   return taggingMode_ || pass;
0042 }
0043 
0044 #include "FWCore/Framework/interface/MakerMacros.h"
0045 
0046 DEFINE_FWK_MODULE(EENoiseFilter);