Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTMhtFilter
0002  *
0003  * See header file for documentation
0004  *
0005  *  \author Steven Lowette
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 // Constructor
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()) {  // number of settings to .OR.
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 // Destructor
0034 HLTMhtFilter::~HLTMhtFilter() = default;
0035 
0036 // Fill descriptions
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 // Make filter decision
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   // Take the .OR. of all sets of requirements
0057   for (unsigned int i = 0; i < nOrs_; ++i) {
0058     // Create the reference to the output filter objects
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     // Check if the event passes this cut set
0069     accept = accept || (mht > minMht_[i]);
0070     // In principle we could break if accepted, but in order to save
0071     // for offline analysis all possible decisions we keep looping here
0072     // in term of timing this will not matter much; typically 1 or 2 cut-sets
0073     // will be checked only
0074 
0075     // Store the ref (even if it is not accepted)
0076     mhtref = reco::METRef(hmht, 0);
0077 
0078     filterproduct.addObject(trigger::TriggerMHT, mhtref);  // save as TriggerMHT object
0079   }
0080 
0081   return accept;
0082 }