Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:48

0001 // -*- C++ -*-
0002 //
0003 // Package:    RecHitEnergyFilter
0004 // Class:      RecHitEnergyFilter
0005 //
0006 /**\class RecHitEnergyFilter RecHitEnergyFilter.cc JacksonJ/RecHitEnergyFilter/src/RecHitEnergyFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  James Jackson
0015 //         Created:  Mon Jan 11 09:57:58 CET 2010
0016 // $Id: RecHitEnergyFilter.cc,v 1.1 2010/03/06 22:12:30 malgeri Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/stream/EDFilter.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0030 
0031 //
0032 // class declaration
0033 //
0034 
0035 class RecHitEnergyFilter : public edm::stream::EDFilter<> {
0036 public:
0037   explicit RecHitEnergyFilter(const edm::ParameterSet&);
0038   ~RecHitEnergyFilter() override;
0039 
0040 private:
0041   bool filter(edm::Event&, const edm::EventSetup&) override;
0042 
0043   // RecHit input tags
0044   edm::InputTag ebRecHitsTag_;
0045   edm::InputTag eeRecHitsTag_;
0046 
0047   // RecHit handles
0048   edm::Handle<EcalRecHitCollection> ebRecHitsH_;
0049   edm::Handle<EcalRecHitCollection> eeRecHitsH_;
0050   const EcalRecHitCollection* ebRecHits_;
0051   const EcalRecHitCollection* eeRecHits_;
0052 
0053   // Procesing control
0054   bool doEb_;
0055   bool doEe_;
0056   double ebThresh_;
0057   double eeThresh_;
0058 };
0059 
0060 //
0061 // constructors and destructor
0062 //
0063 RecHitEnergyFilter::RecHitEnergyFilter(const edm::ParameterSet& iConfig) {
0064   doEb_ = iConfig.getParameter<bool>("DoEB");
0065   doEe_ = iConfig.getParameter<bool>("DoEE");
0066   ebRecHitsTag_ = iConfig.getParameter<edm::InputTag>("EBRecHits");
0067   eeRecHitsTag_ = iConfig.getParameter<edm::InputTag>("EERecHits");
0068   ebThresh_ = iConfig.getParameter<double>("EBThresh");
0069   eeThresh_ = iConfig.getParameter<double>("EEThresh");
0070 }
0071 
0072 RecHitEnergyFilter::~RecHitEnergyFilter() {}
0073 
0074 //
0075 // member functions
0076 //
0077 
0078 // ------------ method called on each new Event  ------------
0079 bool RecHitEnergyFilter::filter(edm::Event& evt, const edm::EventSetup& iSetup) {
0080   if (doEb_) {
0081     evt.getByLabel(ebRecHitsTag_, ebRecHitsH_);
0082     ebRecHits_ = ebRecHitsH_.product();
0083     for (EcalRecHitCollection::const_iterator it = ebRecHits_->begin(); it != ebRecHits_->end(); ++it) {
0084       double hitE = it->energy();
0085       if (hitE > ebThresh_) {
0086         return true;
0087       }
0088     }
0089   }
0090   if (doEe_) {
0091     evt.getByLabel(eeRecHitsTag_, eeRecHitsH_);
0092     eeRecHits_ = eeRecHitsH_.product();
0093     for (EcalRecHitCollection::const_iterator it = eeRecHits_->begin(); it != eeRecHits_->end(); ++it) {
0094       double hitE = it->energy();
0095       if (hitE > eeThresh_) {
0096         return true;
0097       }
0098     }
0099   }
0100 
0101   return false;
0102 }
0103 
0104 //define this as a plug-in
0105 DEFINE_FWK_MODULE(RecHitEnergyFilter);