File indexing completed on 2024-04-06 12:18:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "HLTrigger/JetMET/interface/HLTMhtFilter.h"
0010
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0014 #include "DataFormats/Common/interface/Handle.h"
0015 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0016
0017
0018 HLTMhtFilter::HLTMhtFilter(const edm::ParameterSet& iConfig)
0019 : HLTFilter(iConfig),
0020 minMht_(iConfig.getParameter<std::vector<double> >("minMht")),
0021 mhtLabels_(iConfig.getParameter<std::vector<edm::InputTag> >("mhtLabels")),
0022 nOrs_(mhtLabels_.size()) {
0023 if (!(mhtLabels_.size() == minMht_.size()) || mhtLabels_.empty()) {
0024 nOrs_ = (minMht_.size() < nOrs_ ? minMht_.size() : nOrs_);
0025 edm::LogError("HLTMhtFilter") << "inconsistent module configuration!";
0026 }
0027
0028 for (unsigned int i = 0; i < nOrs_; ++i) {
0029 m_theMhtToken.push_back(consumes<reco::METCollection>(mhtLabels_[i]));
0030 }
0031 }
0032
0033
0034 HLTMhtFilter::~HLTMhtFilter() = default;
0035
0036
0037 void HLTMhtFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0038 std::vector<edm::InputTag> tmp1(1, edm::InputTag("hltMhtProducer"));
0039 std::vector<double> tmp2(1, 0.);
0040 edm::ParameterSetDescription desc;
0041 makeHLTFilterDescription(desc);
0042 desc.add<std::vector<edm::InputTag> >("mhtLabels", tmp1);
0043 tmp2[0] = 70;
0044 desc.add<std::vector<double> >("minMht", tmp2);
0045 descriptions.add("hltMhtFilter", desc);
0046 }
0047
0048
0049 bool HLTMhtFilter::hltFilter(edm::Event& iEvent,
0050 const edm::EventSetup& iSetup,
0051 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0052 reco::METRef mhtref;
0053
0054 bool accept = false;
0055
0056
0057 for (unsigned int i = 0; i < nOrs_; ++i) {
0058
0059 if (saveTags())
0060 filterproduct.addCollectionTag(mhtLabels_[i]);
0061
0062 edm::Handle<reco::METCollection> hmht;
0063 iEvent.getByToken(m_theMhtToken[i], hmht);
0064 double mht = 0;
0065 if (!hmht->empty())
0066 mht = hmht->front().pt();
0067
0068
0069 accept = accept || (mht > minMht_[i]);
0070
0071
0072
0073
0074
0075
0076 mhtref = reco::METRef(hmht, 0);
0077
0078 filterproduct.addObject(trigger::TriggerMHT, mhtref);
0079 }
0080
0081 return accept;
0082 }