File indexing completed on 2024-04-06 12:06:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022
0023
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
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
0044 edm::InputTag ebRecHitsTag_;
0045 edm::InputTag eeRecHitsTag_;
0046
0047
0048 edm::Handle<EcalRecHitCollection> ebRecHitsH_;
0049 edm::Handle<EcalRecHitCollection> eeRecHitsH_;
0050 const EcalRecHitCollection* ebRecHits_;
0051 const EcalRecHitCollection* eeRecHits_;
0052
0053
0054 bool doEb_;
0055 bool doEe_;
0056 double ebThresh_;
0057 double eeThresh_;
0058 };
0059
0060
0061
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
0076
0077
0078
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
0105 DEFINE_FWK_MODULE(RecHitEnergyFilter);