File indexing completed on 2024-04-06 12:10:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "EventFilter/L1GlobalTriggerRawToDigi/interface/L1GlobalTriggerRecordProducer.h"
0017
0018
0019 #include <iostream>
0020
0021
0022 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
0023
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/Utilities/interface/InputTag.h"
0026
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/ESHandle.h"
0029
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0032
0033
0034 L1GlobalTriggerRecordProducer::L1GlobalTriggerRecordProducer(const edm::ParameterSet& parSet) {
0035 produces<L1GlobalTriggerRecord>();
0036
0037
0038 m_l1GtReadoutRecordTag =
0039 consumes<L1GlobalTriggerReadoutRecord>(parSet.getParameter<edm::InputTag>("L1GtReadoutRecordTag"));
0040
0041 LogDebug("L1GlobalTriggerRecordProducer").log([&parSet](auto& l) {
0042 l << "\nInput tag for L1 GT DAQ record: " << parSet.getParameter<edm::InputTag>("L1GtReadoutRecordTag");
0043 });
0044
0045 m_l1GtTmAlgoToken = esConsumes<L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd>();
0046
0047
0048 m_l1GtTmTechToken = esConsumes<L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd>();
0049
0050
0051
0052 m_l1GtTmAlgoCacheID = 0ULL;
0053 m_l1GtTmTechCacheID = 0ULL;
0054 }
0055
0056
0057 L1GlobalTriggerRecordProducer::~L1GlobalTriggerRecordProducer() {
0058
0059 }
0060
0061
0062
0063
0064 void L1GlobalTriggerRecordProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSetup) {
0065
0066 std::unique_ptr<L1GlobalTriggerRecord> gtRecord(new L1GlobalTriggerRecord());
0067
0068
0069 edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
0070 iEvent.getByToken(m_l1GtReadoutRecordTag, gtReadoutRecord);
0071
0072 if (!gtReadoutRecord.isValid()) {
0073 LogDebug("L1GlobalTriggerRecordProducer").log([this](auto& l) {
0074 l << "\n\n Error: no L1GlobalTriggerReadoutRecord found with input tag ";
0075 edm::ProductLabels labels;
0076 labelsForToken(m_l1GtReadoutRecordTag, labels);
0077 l << labels.module << " " << labels.productInstance << " " << labels.process
0078 << "\n Returning empty L1GlobalTriggerRecord.\n\n";
0079 });
0080 iEvent.put(std::move(gtRecord));
0081 return;
0082 }
0083
0084
0085 cms_uint16_t gtFinalOR = gtReadoutRecord->finalOR();
0086 int physicsDaqPartition = 0;
0087 bool gtDecision = static_cast<bool>(gtFinalOR & (1 << physicsDaqPartition));
0088
0089 DecisionWord algoDecisionWord = gtReadoutRecord->decisionWord();
0090 TechnicalTriggerWord techDecisionWord = gtReadoutRecord->technicalTriggerWord();
0091
0092
0093
0094
0095 unsigned long long l1GtTmAlgoCacheID = evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
0096
0097 if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
0098 edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo = evSetup.getHandle(m_l1GtTmAlgoToken);
0099 m_l1GtTmAlgo = l1GtTmAlgo.product();
0100
0101 m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
0102
0103 m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
0104 }
0105
0106 unsigned long long l1GtTmTechCacheID = evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
0107
0108 if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
0109 edm::ESHandle<L1GtTriggerMask> l1GtTmTech = evSetup.getHandle(m_l1GtTmTechToken);
0110 m_l1GtTmTech = l1GtTmTech.product();
0111
0112 m_triggerMaskTechTrig = m_l1GtTmTech->gtTriggerMask();
0113
0114 m_l1GtTmTechCacheID = l1GtTmTechCacheID;
0115 }
0116
0117
0118
0119 gtRecord->setDecisionWordBeforeMask(algoDecisionWord);
0120 gtRecord->setTechnicalTriggerWordBeforeMask(techDecisionWord);
0121
0122
0123
0124 int iDaq = 0;
0125
0126
0127
0128 int iBit = -1;
0129
0130 for (std::vector<bool>::iterator itBit = algoDecisionWord.begin(); itBit != algoDecisionWord.end(); ++itBit) {
0131 iBit++;
0132
0133 int triggerMaskAlgoTrigBit = m_triggerMaskAlgoTrig[iBit] & (1 << iDaq);
0134
0135
0136
0137
0138
0139
0140 if (triggerMaskAlgoTrigBit) {
0141 *itBit = false;
0142
0143
0144
0145
0146 }
0147 }
0148
0149
0150
0151 iBit = -1;
0152
0153 for (std::vector<bool>::iterator itBit = techDecisionWord.begin(); itBit != techDecisionWord.end(); ++itBit) {
0154 iBit++;
0155
0156 int triggerMaskTechTrigBit = m_triggerMaskTechTrig[iBit] & (1 << iDaq);
0157
0158
0159
0160
0161
0162
0163 if (triggerMaskTechTrigBit) {
0164 *itBit = false;
0165
0166
0167
0168
0169 }
0170 }
0171
0172
0173
0174 gtRecord->setDecision(gtDecision);
0175 gtRecord->setDecisionWord(algoDecisionWord);
0176 gtRecord->setTechnicalTriggerWord(techDecisionWord);
0177
0178
0179 unsigned int pfIndexTech = static_cast<unsigned int>((gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech());
0180 unsigned int pfIndexAlgo = static_cast<unsigned int>((gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo());
0181
0182 gtRecord->setGtPrescaleFactorIndexTech(pfIndexTech);
0183 gtRecord->setGtPrescaleFactorIndexAlgo(pfIndexAlgo);
0184
0185 if (edm::isDebugEnabled()) {
0186 std::ostringstream myCoutStream;
0187 gtRecord->print(myCoutStream);
0188 LogTrace("L1GlobalTriggerRecordProducer") << "\n The following L1 GT record was produced.\n"
0189 << myCoutStream.str() << "\n"
0190 << std::endl;
0191 }
0192
0193
0194 iEvent.put(std::move(gtRecord));
0195 }
0196
0197