Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTHtMhtFilter
0002  *
0003  * See header file for documentation
0004  *
0005  *  \author Steven Lowette
0006  *
0007  */
0008 
0009 #include "HLTrigger/JetMET/interface/HLTHtMhtFilter.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 HLTHtMhtFilter::HLTHtMhtFilter(const edm::ParameterSet& iConfig)
0019     : HLTFilter(iConfig),
0020       minHt_(iConfig.getParameter<std::vector<double> >("minHt")),
0021       minMht_(iConfig.getParameter<std::vector<double> >("minMht")),
0022       minMeff_(iConfig.getParameter<std::vector<double> >("minMeff")),
0023       meffSlope_(iConfig.getParameter<std::vector<double> >("meffSlope")),
0024       htLabels_(iConfig.getParameter<std::vector<edm::InputTag> >("htLabels")),
0025       mhtLabels_(iConfig.getParameter<std::vector<edm::InputTag> >("mhtLabels")),
0026       nOrs_(htLabels_.size()) {  // number of settings to .OR.
0027   if (!(htLabels_.size() == minHt_.size() && htLabels_.size() == minMht_.size() &&
0028         htLabels_.size() == minMeff_.size() && htLabels_.size() == meffSlope_.size() &&
0029         htLabels_.size() == mhtLabels_.size()) ||
0030       htLabels_.empty()) {
0031     nOrs_ = (minHt_.size() < nOrs_ ? minHt_.size() : nOrs_);
0032     nOrs_ = (minMht_.size() < nOrs_ ? minMht_.size() : nOrs_);
0033     nOrs_ = (minMeff_.size() < nOrs_ ? minMeff_.size() : nOrs_);
0034     nOrs_ = (meffSlope_.size() < nOrs_ ? meffSlope_.size() : nOrs_);
0035     nOrs_ = (mhtLabels_.size() < nOrs_ ? mhtLabels_.size() : nOrs_);
0036     edm::LogError("HLTHtMhtFilter") << "inconsistent module configuration!";
0037   }
0038 
0039   for (unsigned int i = 0; i < nOrs_; ++i) {
0040     m_theHtToken.push_back(consumes<reco::METCollection>(htLabels_[i]));
0041     m_theMhtToken.push_back(consumes<reco::METCollection>(mhtLabels_[i]));
0042   }
0043 }
0044 
0045 // Destructor
0046 HLTHtMhtFilter::~HLTHtMhtFilter() = default;
0047 
0048 // Fill descriptions
0049 void HLTHtMhtFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0050   std::vector<edm::InputTag> tmp1(1, edm::InputTag("hltHtMhtProducer"));
0051   std::vector<double> tmp2(1, 0.);
0052   edm::ParameterSetDescription desc;
0053   makeHLTFilterDescription(desc);
0054   desc.add<std::vector<edm::InputTag> >("htLabels", tmp1);
0055   desc.add<std::vector<edm::InputTag> >("mhtLabels", tmp1);
0056   tmp2[0] = 250;
0057   desc.add<std::vector<double> >("minHt", tmp2);
0058   tmp2[0] = 70;
0059   desc.add<std::vector<double> >("minMht", tmp2);
0060   tmp2[0] = 0;
0061   desc.add<std::vector<double> >("minMeff", tmp2);
0062   tmp2[0] = 1;
0063   desc.add<std::vector<double> >("meffSlope", tmp2);
0064   descriptions.add("hltHtMhtFilter", desc);
0065 }
0066 
0067 // Make filter decision
0068 bool HLTHtMhtFilter::hltFilter(edm::Event& iEvent,
0069                                const edm::EventSetup& iSetup,
0070                                trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0071   bool accept = false;
0072 
0073   // Take the .OR. of all sets of requirements
0074   for (unsigned int i = 0; i < nOrs_; ++i) {
0075     // Create the reference to the output filter objects
0076     if (saveTags()) {
0077       filterproduct.addCollectionTag(htLabels_[i]);
0078       filterproduct.addCollectionTag(mhtLabels_[i]);
0079     }
0080 
0081     edm::Handle<reco::METCollection> hht;
0082     iEvent.getByToken(m_theHtToken[i], hht);
0083     double ht = 0;
0084     if (!hht->empty())
0085       ht = hht->front().sumEt();
0086 
0087     edm::Handle<reco::METCollection> hmht;
0088     iEvent.getByToken(m_theMhtToken[i], hmht);
0089     double mht = 0;
0090     if (!hmht->empty())
0091       mht = hmht->front().pt();
0092 
0093     // Check if the event passes this cut set
0094     accept = accept || (ht > minHt_[i] && mht > minMht_[i] && sqrt(mht + meffSlope_[i] * ht) > minMeff_[i]);
0095     // In principle we could break if accepted, but in order to save
0096     // for offline analysis all possible decisions we keep looping here
0097     // in term of timing this will not matter much; typically 1 or 2 cut-sets
0098     // will be checked only
0099 
0100     // Store the object that was cut on and the ref to it
0101     // (even if it is not accepted)
0102     edm::Ref<reco::METCollection> htref(hht, 0);
0103     edm::Ref<reco::METCollection> mhtref(hmht, 0);
0104     filterproduct.addObject(trigger::TriggerTHT, htref);   // save as TriggerTHT object
0105     filterproduct.addObject(trigger::TriggerMHT, mhtref);  // save as TriggerMHT object
0106   }
0107 
0108   return accept;
0109 }