File indexing completed on 2024-04-06 12:20:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtBeamModeFilter.h"
0015
0016
0017 #include <vector>
0018 #include <iostream>
0019
0020
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 #include "FWCore/Framework/interface/Run.h"
0024
0025 #include "DataFormats/Common/interface/Handle.h"
0026
0027 #include "DataFormats/Common/interface/ConditionsInEdm.h"
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 #include <cstdint>
0035
0036
0037 L1GtBeamModeFilter::L1GtBeamModeFilter(const edm::ParameterSet& parSet)
0038 :
0039
0040 m_condInEdmInputTag(parSet.getParameter<edm::InputTag>("CondInEdmInputTag")),
0041 m_l1GtEvmReadoutRecordTag(parSet.getParameter<edm::InputTag>("L1GtEvmReadoutRecordTag")),
0042 m_allowedBeamMode(parSet.getParameter<std::vector<unsigned int> >("AllowedBeamMode")),
0043 m_invertResult(parSet.getParameter<bool>("InvertResult")),
0044 m_isDebugEnabled(edm::isDebugEnabled()) {
0045 if (m_isDebugEnabled) {
0046 LogDebug("L1GtBeamModeFilter") << std::endl;
0047
0048 LogTrace("L1GtBeamModeFilter") << "\nInput tag for ConditionsInEdm product: " << m_condInEdmInputTag
0049 << "\nInput tag for L1 GT EVM record: " << m_l1GtEvmReadoutRecordTag
0050 << "\nAllowed beam modes:" << std::endl;
0051
0052 for (std::vector<unsigned int>::const_iterator itMode = m_allowedBeamMode.begin();
0053 itMode != m_allowedBeamMode.end();
0054 ++itMode) {
0055 LogTrace("L1GtBeamModeFilter") << " " << (*itMode) << std::endl;
0056 }
0057
0058 LogTrace("L1GtBeamModeFilter") << "\nInvert result (use as NOT filter): " << m_invertResult << std::endl;
0059
0060 LogTrace("L1GtBeamModeFilter") << std::endl;
0061 }
0062 }
0063
0064
0065 L1GtBeamModeFilter::~L1GtBeamModeFilter() {
0066
0067 }
0068
0069
0070
0071 bool L1GtBeamModeFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& evSetup) const {
0072
0073 bool filterResult = false;
0074
0075
0076
0077
0078 if (!(iEvent.isRealData())) {
0079
0080
0081
0082
0083 if (m_invertResult) {
0084 return false;
0085 } else {
0086 return true;
0087 }
0088 }
0089
0090
0091
0092
0093 uint16_t beamModeValue = 0;
0094
0095
0096
0097 const edm::Run& iRun = iEvent.getRun();
0098
0099
0100 edm::Handle<edm::ConditionsInRunBlock> condInRunBlock;
0101 iRun.getByLabel(m_condInEdmInputTag, condInRunBlock);
0102
0103
0104 bool condInRunBlockValid = true;
0105
0106 if (!condInRunBlock.isValid()) {
0107 LogDebug("L1GtBeamModeFilter") << "\nConditionsInRunBlock with \n " << m_condInEdmInputTag
0108 << "\nrequested in configuration, but not found in the event."
0109 << "\n"
0110 << std::endl;
0111
0112 condInRunBlockValid = false;
0113
0114 } else {
0115 beamModeValue = condInRunBlock->beamMode;
0116 }
0117
0118
0119
0120 if (!condInRunBlockValid) {
0121
0122 edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
0123 iEvent.getByLabel(m_l1GtEvmReadoutRecordTag, gtEvmReadoutRecord);
0124
0125 if (!gtEvmReadoutRecord.isValid()) {
0126 LogDebug("L1GtBeamModeFilter") << "\nL1GlobalTriggerEvmReadoutRecord with input tag " << m_l1GtEvmReadoutRecordTag
0127 << "\nrequested in configuration, but not found in the event." << std::endl;
0128
0129
0130 return false;
0131
0132 } else {
0133 beamModeValue = (gtEvmReadoutRecord->gtfeWord()).beamMode();
0134 }
0135 }
0136
0137 LogDebug("L1GtBeamModeFilter") << "\nBeam mode: " << beamModeValue << std::endl;
0138
0139 for (std::vector<unsigned int>::const_iterator itMode = m_allowedBeamMode.begin(); itMode != m_allowedBeamMode.end();
0140 ++itMode) {
0141 if (beamModeValue == (*itMode)) {
0142 filterResult = true;
0143
0144
0145
0146
0147 break;
0148 }
0149 }
0150
0151
0152
0153 if (m_invertResult) {
0154 filterResult = !filterResult;
0155 }
0156
0157 return filterResult;
0158 }