Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:41

0001 // -*- C++ -*-
0002 //
0003 // Package:   HLTPhysicsDeclared
0004 // Class:     HLTPhysicsDeclared
0005 //
0006 // Original Author:     Luca Malgeri
0007 // Adapted for HLT by:  Andrea Bocci
0008 
0009 // user include files
0010 #include "FWCore/Framework/interface/Frameworkfwd.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/global/EDFilter.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017 
0018 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
0019 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0020 //
0021 // class declaration
0022 //
0023 
0024 class HLTPhysicsDeclared : public edm::global::EDFilter<> {
0025 public:
0026   explicit HLTPhysicsDeclared(const edm::ParameterSet&);
0027   ~HLTPhysicsDeclared() override;
0028   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0029 
0030 private:
0031   bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0032 
0033   bool m_invert;
0034   edm::InputTag m_gtDigis;
0035   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_gtDigisToken;
0036 };
0037 
0038 // system include files
0039 #include <memory>
0040 
0041 // user include files
0042 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0043 
0044 using namespace edm;
0045 
0046 HLTPhysicsDeclared::HLTPhysicsDeclared(const edm::ParameterSet& config)
0047     : m_invert(config.getParameter<bool>("invert")),
0048       m_gtDigis(config.getParameter<edm::InputTag>("L1GtReadoutRecordTag")) {
0049   m_gtDigisToken = consumes<L1GlobalTriggerReadoutRecord>(m_gtDigis);
0050 }
0051 
0052 HLTPhysicsDeclared::~HLTPhysicsDeclared() = default;
0053 
0054 void HLTPhysicsDeclared::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0055   edm::ParameterSetDescription desc;
0056   desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
0057   desc.add<bool>("invert", false);
0058   descriptions.add("hltPhysicsDeclared", desc);
0059 }
0060 
0061 bool HLTPhysicsDeclared::filter(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const {
0062   bool accept = false;
0063 
0064   if (event.isRealData()) {
0065     // for real data, access the "physics enabled" bit in the L1 GT data
0066     edm::Handle<L1GlobalTriggerReadoutRecord> h_gtDigis;
0067     if (not event.getByToken(m_gtDigisToken, h_gtDigis)) {
0068       edm::LogWarning(h_gtDigis.whyFailed()->category()) << h_gtDigis.whyFailed()->what();
0069       // not enough informations to make a decision - reject the event
0070       return false;
0071     } else {
0072       L1GtFdlWord fdlWord = h_gtDigis->gtFdlWord();
0073       if (fdlWord.physicsDeclared() == 1)
0074         accept = true;
0075     }
0076   } else {
0077     // for MC, assume the "physics enabled" bit to be always set
0078     accept = true;
0079   }
0080 
0081   // if requested, invert the filter decision
0082   if (m_invert)
0083     accept = not accept;
0084 
0085   return accept;
0086 }
0087 
0088 // declare this class as a framework plugin
0089 #include "FWCore/Framework/interface/MakerMacros.h"
0090 DEFINE_FWK_MODULE(HLTPhysicsDeclared);