Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:41

0001 // Author:  Alfredo Gurrola
0002 //(20/11/08 make MET and JET logic independent   /Grigory Safronov)
0003 
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 
0007 #include "HLTHcalNoiseFilter.h"
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "DataFormats/Math/interface/deltaR.h"
0011 
0012 HLTHcalNoiseFilter::HLTHcalNoiseFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0013   JetSource_ = iConfig.getParameter<edm::InputTag>("JetSource");
0014   MetSource_ = iConfig.getParameter<edm::InputTag>("MetSource");
0015   TowerSource_ = iConfig.getParameter<edm::InputTag>("TowerSource");
0016   useMet_ = iConfig.getParameter<bool>("UseMET");
0017   useJet_ = iConfig.getParameter<bool>("UseJet");
0018   MetCut_ = iConfig.getParameter<double>("MetCut");
0019   JetMinE_ = iConfig.getParameter<double>("JetMinE");
0020   JetHCALminEnergyFraction_ = iConfig.getParameter<double>("JetHCALminEnergyFraction");
0021 
0022   if (useMet_) {
0023     MetSourceToken_ = consumes<reco::CaloMETCollection>(MetSource_);
0024   }
0025   if (useJet_) {
0026     JetSourceToken_ = consumes<reco::CaloJetCollection>(JetSource_);
0027     TowerSourceToken_ = consumes<CaloTowerCollection>(TowerSource_);
0028   }
0029 }
0030 
0031 HLTHcalNoiseFilter::~HLTHcalNoiseFilter() = default;
0032 
0033 void HLTHcalNoiseFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0034   edm::ParameterSetDescription desc;
0035   makeHLTFilterDescription(desc);
0036   desc.add<edm::InputTag>("JetSource", edm::InputTag("iterativeCone5CaloJets"));
0037   desc.add<edm::InputTag>("MetSource", edm::InputTag("met"));
0038   desc.add<edm::InputTag>("TowerSource", edm::InputTag("towerMaker"));
0039   desc.add<bool>("UseJet", true);
0040   desc.add<bool>("UseMET", false);
0041   desc.add<double>("MetCut", 0.);
0042   desc.add<double>("JetMinE", 20.);
0043   desc.add<double>("JetHCALminEnergyFraction", 0.98);
0044   descriptions.add("hltHcalNoiseFilter", desc);
0045 }
0046 
0047 //
0048 // member functions
0049 //
0050 
0051 bool HLTHcalNoiseFilter::hltFilter(edm::Event& iEvent,
0052                                    const edm::EventSetup& iSetup,
0053                                    trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0054   using namespace edm;
0055   using namespace reco;
0056 
0057   bool isAnomalous_BasedOnMET = false;
0058   bool isAnomalous_BasedOnEnergyFraction = false;
0059 
0060   if (useMet_) {
0061     Handle<CaloMETCollection> metHandle;
0062     iEvent.getByToken(MetSourceToken_, metHandle);
0063     const CaloMETCollection* metCol = metHandle.product();
0064     const CaloMET met = metCol->front();
0065 
0066     if (met.pt() > MetCut_)
0067       isAnomalous_BasedOnMET = true;
0068   }
0069 
0070   if (useJet_) {
0071     Handle<CaloJetCollection> calojetHandle;
0072     iEvent.getByToken(JetSourceToken_, calojetHandle);
0073 
0074     Handle<CaloTowerCollection> towerHandle;
0075     iEvent.getByToken(TowerSourceToken_, towerHandle);
0076 
0077     std::vector<CaloTower> TowerContainer;
0078     std::vector<CaloJet> JetContainer;
0079     TowerContainer.clear();
0080     JetContainer.clear();
0081     CaloTower seedTower;
0082     for (auto const& calojetIter : *calojetHandle) {
0083       if (((calojetIter.et()) * cosh(calojetIter.eta()) > JetMinE_) and
0084           (calojetIter.energyFractionHadronic() > JetHCALminEnergyFraction_)) {
0085         JetContainer.push_back(calojetIter);
0086         double maxTowerE = 0.0;
0087         for (auto const& kal : *towerHandle) {
0088           double dR = deltaR(calojetIter.eta(), calojetIter.phi(), kal.eta(), kal.phi());
0089           if ((dR < 0.50) and (kal.p() > maxTowerE)) {
0090             maxTowerE = kal.p();
0091             seedTower = kal;
0092           }
0093         }
0094         TowerContainer.push_back(seedTower);
0095       }
0096     }
0097     if (!JetContainer.empty()) {
0098       isAnomalous_BasedOnEnergyFraction = true;
0099     }
0100   }
0101 
0102   return ((useMet_ and isAnomalous_BasedOnMET) or (useJet_ and isAnomalous_BasedOnEnergyFraction));
0103 }
0104 
0105 // declare this class as a framework plugin
0106 #include "FWCore/Framework/interface/MakerMacros.h"
0107 DEFINE_FWK_MODULE(HLTHcalNoiseFilter);