File indexing completed on 2024-04-06 12:18:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "HLTBeamModeFilter.h"
0015
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017
0018
0019 #include <vector>
0020 #include <iostream>
0021
0022
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025
0026 #include "DataFormats/Common/interface/Handle.h"
0027
0028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0029
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0034
0035
0036 HLTBeamModeFilter::HLTBeamModeFilter(const edm::ParameterSet& parSet)
0037 : HLTFilter(parSet),
0038
0039 m_l1GtEvmReadoutRecordTag(parSet.getParameter<edm::InputTag>("L1GtEvmReadoutRecordTag")),
0040 m_l1GtEvmReadoutRecordToken(consumes<L1GlobalTriggerEvmReadoutRecord>(m_l1GtEvmReadoutRecordTag)),
0041 m_allowedBeamMode(parSet.getParameter<std::vector<unsigned int> >("AllowedBeamMode")),
0042 m_isDebugEnabled(edm::isDebugEnabled()) {
0043 if (m_isDebugEnabled) {
0044 LogDebug("HLTBeamModeFilter") << std::endl;
0045
0046 LogTrace("HLTBeamModeFilter") << "Input tag for L1 GT EVM record: " << m_l1GtEvmReadoutRecordTag
0047 << "\nAllowed beam modes:" << std::endl;
0048
0049 for (std::vector<unsigned int>::const_iterator itMode = m_allowedBeamMode.begin();
0050 itMode != m_allowedBeamMode.end();
0051 ++itMode) {
0052 LogTrace("HLTBeamModeFilter") << " " << (*itMode) << std::endl;
0053 }
0054
0055 LogTrace("HLTBeamModeFilter") << std::endl;
0056 }
0057 }
0058
0059
0060 HLTBeamModeFilter::~HLTBeamModeFilter() {
0061
0062 }
0063
0064
0065 void HLTBeamModeFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0066 edm::ParameterSetDescription desc;
0067 makeHLTFilterDescription(desc);
0068
0069
0070
0071
0072
0073
0074
0075 desc.add<edm::InputTag>("L1GtEvmReadoutRecordTag", edm::InputTag("gtEvmDigis"));
0076
0077
0078
0079 std::vector<unsigned int> allowedBeamMode(1, 11);
0080 desc.add<std::vector<unsigned int> >("AllowedBeamMode", allowedBeamMode);
0081 descriptions.add("hltBeamModeFilter", desc);
0082 }
0083
0084 bool HLTBeamModeFilter::hltFilter(edm::Event& iEvent,
0085 const edm::EventSetup& evSetup,
0086 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0087
0088
0089
0090 if (!(iEvent.isRealData())) {
0091
0092
0093
0094 return true;
0095 }
0096
0097
0098
0099
0100 bool filterResult = false;
0101
0102
0103 edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
0104 iEvent.getByToken(m_l1GtEvmReadoutRecordToken, gtEvmReadoutRecord);
0105
0106 if (!gtEvmReadoutRecord.isValid()) {
0107 edm::LogWarning("HLTBeamModeFilter") << "\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag "
0108 << m_l1GtEvmReadoutRecordTag
0109 << "\nrequested in configuration, but not found in the event." << std::endl;
0110
0111 return false;
0112 }
0113
0114 const uint16_t beamModeValue = (gtEvmReadoutRecord->gtfeWord()).beamMode();
0115
0116 edm::LogInfo("HLTBeamModeFilter") << "Beam mode: " << beamModeValue;
0117
0118 for (unsigned int itMode : m_allowedBeamMode) {
0119 if (beamModeValue == itMode) {
0120 filterResult = true;
0121
0122
0123
0124
0125 break;
0126 }
0127 }
0128
0129
0130 return filterResult;
0131 }
0132
0133
0134 #include "FWCore/Framework/interface/MakerMacros.h"
0135 #include <cstdint>
0136 DEFINE_FWK_MODULE(HLTBeamModeFilter);