Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:33

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDFilter.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/METReco/interface/BeamHaloSummary.h"
0006 #include "DataFormats/METReco/interface/HcalHaloData.h"
0007 
0008 class HcalStripHaloFilter : public edm::global::EDFilter<> {
0009 public:
0010   explicit HcalStripHaloFilter(const edm::ParameterSet& iConfig);
0011   ~HcalStripHaloFilter() override {}
0012 
0013 private:
0014   bool filter(edm::StreamID iID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
0015 
0016   const bool taggingMode_;
0017   const int maxWeightedStripLength_;
0018   const double maxEnergyRatio_;
0019   const double minHadEt_;
0020   edm::EDGetTokenT<reco::BeamHaloSummary> beamHaloSummaryToken_;
0021 };
0022 
0023 HcalStripHaloFilter::HcalStripHaloFilter(const edm::ParameterSet& iConfig)
0024     : taggingMode_(iConfig.getParameter<bool>("taggingMode")),
0025       maxWeightedStripLength_(iConfig.getParameter<int>("maxWeightedStripLength")),
0026       maxEnergyRatio_(iConfig.getParameter<double>("maxEnergyRatio")),
0027       minHadEt_(iConfig.getParameter<double>("minHadEt")),
0028       beamHaloSummaryToken_(consumes<reco::BeamHaloSummary>(edm::InputTag("BeamHaloSummary"))) {
0029   produces<bool>();
0030 }
0031 
0032 bool HcalStripHaloFilter::filter(edm::StreamID iID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0033   edm::Handle<reco::BeamHaloSummary> beamHaloSummary;
0034   iEvent.getByToken(beamHaloSummaryToken_, beamHaloSummary);
0035 
0036   bool pass = true;
0037   auto const& problematicStrips = beamHaloSummary->getProblematicStrips();
0038   for (unsigned int iStrip = 0; iStrip < problematicStrips.size(); iStrip++) {
0039     int numContiguousCells = 0;
0040     auto const& problematicStrip = problematicStrips[iStrip];
0041     for (unsigned int iTower = 0; iTower < problematicStrip.cellTowerIds.size(); iTower++) {
0042       numContiguousCells += (int)problematicStrip.cellTowerIds[iTower].first;
0043     }
0044     if (numContiguousCells > maxWeightedStripLength_ && problematicStrip.energyRatio < maxEnergyRatio_ &&
0045         problematicStrip.hadEt > minHadEt_) {
0046       pass = false;
0047       break;
0048     }
0049   }
0050 
0051   iEvent.put(std::make_unique<bool>(pass));
0052 
0053   return taggingMode_ || pass;  // return false if it is a beamhalo event
0054 }
0055 
0056 #include "FWCore/Framework/interface/MakerMacros.h"
0057 DEFINE_FWK_MODULE(HcalStripHaloFilter);