File indexing completed on 2024-04-06 12:06:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <memory>
0010 #include <vector>
0011 #include <map>
0012 #include <set>
0013
0014
0015 #include "DPGAnalysis/Skims/interface/PhysDecl.h"
0016
0017 #include "FWCore/Utilities/interface/InputTag.h"
0018 #include "FWCore/Framework/interface/Frameworkfwd.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 #include "FWCore/Framework/interface/ESHandle.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
0025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0026 #include "DataFormats/Common/interface/TriggerResults.h"
0027 #include "FWCore/Common/interface/TriggerNames.h"
0028
0029 using namespace edm;
0030 using namespace std;
0031
0032 PhysDecl::PhysDecl(const edm::ParameterSet& iConfig) {
0033 applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter", true);
0034 debugOn = iConfig.getUntrackedParameter<bool>("debugOn", false);
0035 hlTriggerResults_ = consumes<TriggerResults>(iConfig.getParameter<edm::InputTag>("HLTriggerResults"));
0036 gtDigis_ = consumes<L1GlobalTriggerReadoutRecord>(
0037 iConfig.getUntrackedParameter<edm::InputTag>("gtDigis", edm::InputTag("gtDigis")));
0038 init_ = false;
0039 }
0040
0041 PhysDecl::~PhysDecl() {}
0042
0043 bool PhysDecl::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0044 bool accepted = false;
0045
0046 int ievt = iEvent.id().event();
0047 int irun = iEvent.id().run();
0048 int ils = iEvent.luminosityBlock();
0049 int bx = iEvent.bunchCrossing();
0050
0051
0052 edm::Handle<TriggerResults> HLTR;
0053 iEvent.getByToken(hlTriggerResults_, HLTR);
0054
0055 if (HLTR.isValid()) {
0056 if (!init_) {
0057 init_ = true;
0058 const edm::TriggerNames& triggerNames = iEvent.triggerNames(*HLTR);
0059 hlNames_ = triggerNames.triggerNames();
0060 }
0061 if (debugOn) {
0062 std::cout << "HLT_debug: Run " << irun << " Ev " << ievt << " LB " << ils << " BX " << bx << " Acc: ";
0063 const unsigned int n(hlNames_.size());
0064 for (unsigned int i = 0; i != n; ++i) {
0065 if (HLTR->accept(i)) {
0066 std::cout << hlNames_[i] << ",";
0067 }
0068 }
0069 std::cout << std::endl;
0070 }
0071 }
0072
0073
0074
0075 edm::Handle<L1GlobalTriggerReadoutRecord> gtrr_handle;
0076 iEvent.getByToken(gtDigis_, gtrr_handle);
0077 L1GlobalTriggerReadoutRecord const* gtrr = gtrr_handle.product();
0078
0079 L1GtFdlWord fdlWord = gtrr->gtFdlWord();
0080
0081 if (fdlWord.physicsDeclared() == 1)
0082 accepted = true;
0083
0084 if (debugOn) {
0085 std::cout << "PhysDecl_debug: Run " << irun << " Event " << ievt << " Lumi Block " << ils << " Bunch Crossing "
0086 << bx << " Accepted " << accepted << std::endl;
0087 }
0088
0089 if (applyfilter)
0090 return accepted;
0091 else
0092 return true;
0093 }
0094
0095
0096 DEFINE_FWK_MODULE(PhysDecl);