File indexing completed on 2024-04-06 12:21:41
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002
0003 #include "FWCore/Framework/interface/global/EDFilter.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010
0011 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
0012 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
0013
0014 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0015 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0016
0017 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0018 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
0019
0020 #include <iostream>
0021 #include <string>
0022
0023 class L1Filter : public edm::global::EDFilter<> {
0024 public:
0025 explicit L1Filter(edm::ParameterSet const &);
0026
0027 bool filter(edm::StreamID, edm::Event &e, edm::EventSetup const &c) const override;
0028
0029 private:
0030 edm::EDGetTokenT<L1GlobalTriggerRecord> triggerToken_;
0031 edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> triggerReadoutToken_;
0032 const edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> menuToken_;
0033 const bool useAODRecord_;
0034 const bool useFinalDecision_;
0035 const std::vector<std::string> algos_;
0036 };
0037
0038 L1Filter::L1Filter(const edm::ParameterSet &ps)
0039 : menuToken_(esConsumes()),
0040 useAODRecord_(ps.getParameter<bool>("useAODRecord")),
0041 useFinalDecision_(ps.getParameter<bool>("useFinalDecision")),
0042 algos_(ps.getParameter<std::vector<std::string>>("algorithms")) {
0043 auto inputTag = ps.getParameter<edm::InputTag>("inputTag");
0044
0045 if (useAODRecord_) {
0046 triggerToken_ = consumes(inputTag);
0047 } else {
0048 triggerReadoutToken_ = consumes(inputTag);
0049 }
0050 }
0051
0052 bool L1Filter::filter(edm::StreamID, edm::Event &iEvent, edm::EventSetup const &evSetup) const {
0053
0054 const L1GtTriggerMenu &menu = evSetup.getData(menuToken_);
0055
0056 bool passed = false;
0057 std::vector<std::string>::const_iterator algo;
0058
0059 if (useAODRecord_) {
0060 L1GlobalTriggerRecord const >Record = iEvent.get(triggerToken_);
0061
0062 if (useFinalDecision_)
0063 passed = gtRecord.decision();
0064 else {
0065 const DecisionWord dWord = gtRecord.decisionWord();
0066 for (algo = algos_.begin(); algo != algos_.end(); ++algo) {
0067 passed |= menu.gtAlgorithmResult((*algo), dWord);
0068 }
0069 }
0070 } else {
0071 L1GlobalTriggerReadoutRecord const >Record = iEvent.get(triggerReadoutToken_);
0072
0073 if (useFinalDecision_)
0074 passed = gtRecord.decision();
0075 else {
0076 const DecisionWord &dWord = gtRecord.decisionWord();
0077 for (algo = algos_.begin(); algo != algos_.end(); ++algo) {
0078 passed |= menu.gtAlgorithmResult((*algo), dWord);
0079 }
0080 }
0081 }
0082
0083 return passed;
0084 }
0085
0086 #include "FWCore/Framework/interface/MakerMacros.h"
0087
0088 DEFINE_FWK_MODULE(L1Filter);