Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-25 01:53:23

0001 #ifndef DQMOFFLINE_LUMI_TRIGGERTOOLS_H
0002 #define DQMOFFLINE_LUMI_TRIGGERTOOLS_H
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Common/interface/TriggerNames.h"
0008 #include "DataFormats/Common/interface/TriggerResults.h"
0009 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0010 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0011 
0012 #include <bitset>
0013 
0014 const unsigned int kNTrigBit = 128;
0015 typedef std::bitset<kNTrigBit> TriggerBits;
0016 const unsigned int kNTrigObjectBit = 256;
0017 typedef std::bitset<kNTrigObjectBit> TriggerObjectBits;
0018 
0019 class TriggerTools {
0020 public:
0021   TriggerTools(){};
0022   ~TriggerTools(){};
0023 
0024   void readEvent(const edm::Event &iEvent);
0025 
0026   void setTriggerResultsToken(edm::EDGetTokenT<edm::TriggerResults> token) { fHLTTag_token = token; }
0027   void setTriggerEventToken(edm::EDGetTokenT<trigger::TriggerEvent> token) { fHLTObjTag_token = token; }
0028   void setDRMAX(const double _drMax) { DRMAX = _drMax; }
0029 
0030   void addTriggerRecord(const std::string &name) {
0031     Record rec;
0032     rec.hltPattern = name;
0033     records.push_back(rec);
0034   }
0035   void addTriggerRecord(const std::string &name, const std::string &objName) {
0036     Record rec;
0037     rec.hltPattern = name;
0038     rec.hltObjName = objName;
0039     records.push_back(rec);
0040   }
0041 
0042   void initHLTObjects(const HLTConfigProvider &hltConfigProvider_);
0043 
0044   bool pass() const;
0045   bool passObj(const double eta, const double phi) const;
0046 
0047 private:
0048   struct Record {
0049     std::string hltPattern;                        // HLT path name/pattern (wildcards allowed: *,?)
0050     std::string hltPathName = "";                  // HLT path name in trigger menu
0051     unsigned int hltPathIndex = (unsigned int)-1;  // HLT path index in trigger menu
0052     std::string hltObjName = "";                   // trigger object name in trigger menu
0053   };
0054   std::vector<Record> records;
0055 
0056   edm::EDGetTokenT<edm::TriggerResults> fHLTTag_token;
0057   edm::EDGetTokenT<trigger::TriggerEvent> fHLTObjTag_token;
0058 
0059   edm::Handle<edm::TriggerResults> hTrgRes;
0060   edm::Handle<trigger::TriggerEvent> hTrgEvt;
0061 
0062   edm::ParameterSetID fTriggerNamesID;
0063 
0064   // initialization from HLT menu; needs to be called on every change in HLT menu
0065   void initPathNames(const std::vector<std::string> &triggerNames);
0066 
0067   TriggerBits triggerBits;
0068 
0069   // Matching parameter
0070   double DRMAX = 0.1;
0071 };
0072 
0073 #endif