Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:00

0001 #include "DQMOffline/Lumi/interface/TriggerTools.h"
0002 #include "FWCore/Utilities/interface/InputTag.h"
0003 #include "DataFormats/Math/interface/deltaR.h"
0004 #include <string>
0005 
0006 using namespace ZCountingTrigger;
0007 
0008 //--------------------------------------------------------------------------------------------------
0009 TriggerObjects TriggerTools::matchHLT(const double eta,
0010                                       const double phi,
0011                                       const std::vector<TriggerRecord>& triggerRecords,
0012                                       const trigger::TriggerEvent& triggerEvent) {
0013   const double dRMax = 0.2;
0014 
0015   TriggerObjects matchBits;
0016   for (unsigned int irec = 0; irec < triggerRecords.size(); irec++) {
0017     for (unsigned int iobj = 0; iobj < triggerRecords[irec].objectMap.size(); iobj++) {
0018       const std::string& filterName = triggerRecords[irec].objectMap[iobj].first;
0019       const unsigned int filterBit = triggerRecords[irec].objectMap[iobj].second;
0020 
0021       edm::InputTag filterTag(filterName, "", "HLT");
0022       // filterIndex must be less than the size of trgEvent or you get a CMSException: _M_range_check
0023       if (triggerEvent.filterIndex(filterTag) < triggerEvent.sizeFilters()) {
0024         const trigger::TriggerObjectCollection& toc(triggerEvent.getObjects());
0025         const trigger::Keys& keys(triggerEvent.filterKeys(triggerEvent.filterIndex(filterTag)));
0026 
0027         for (unsigned int hlto = 0; hlto < keys.size(); hlto++) {
0028           trigger::size_type hltf = keys[hlto];
0029           const trigger::TriggerObject& tobj(toc[hltf]);
0030           if (reco::deltaR(eta, phi, tobj.eta(), tobj.phi()) < dRMax) {
0031             matchBits[filterBit] = true;
0032           }
0033         }
0034       }
0035     }
0036   }
0037 
0038   return matchBits;
0039 }