File indexing completed on 2024-04-06 12:19:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1GlobalTrigger.h"
0017
0018
0019 #include <algorithm>
0020 #include <iomanip>
0021 #include <iostream>
0022 #include <memory>
0023
0024
0025
0026
0027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
0029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0030
0031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
0032
0033 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
0034 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
0035 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
0036
0037 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
0038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0039 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0040 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
0041 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0042 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
0043
0044 #include "FWCore/Framework/interface/ESHandle.h"
0045 #include "FWCore/Framework/interface/Event.h"
0046 #include "FWCore/Framework/interface/EventSetup.h"
0047 #include "FWCore/Framework/interface/MakerMacros.h"
0048
0049 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFDL.h"
0050 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
0051 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0052
0053 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeExtWord.h"
0054 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeWord.h"
0055 #include "DataFormats/L1GlobalTrigger/interface/L1TcsWord.h"
0056
0057 #include "DataFormats/Common/interface/RefProd.h"
0058 #include "FWCore/Utilities/interface/InputTag.h"
0059
0060 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0061 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0062 #include <cstdint>
0063
0064
0065
0066 L1GlobalTrigger::L1GlobalTrigger(const edm::ParameterSet &parSet)
0067 : m_muGmtInputTag(parSet.getParameter<edm::InputTag>("GmtInputTag")),
0068 m_caloGctInputTag(parSet.getParameter<edm::InputTag>("GctInputTag")),
0069 m_castorInputTag(parSet.getParameter<edm::InputTag>("CastorInputTag")),
0070 m_technicalTriggersInputTags(parSet.getParameter<std::vector<edm::InputTag>>("TechnicalTriggersInputTags")),
0071 m_produceL1GtDaqRecord(parSet.getParameter<bool>("ProduceL1GtDaqRecord")),
0072 m_produceL1GtEvmRecord(parSet.getParameter<bool>("ProduceL1GtEvmRecord")),
0073 m_produceL1GtObjectMapRecord(parSet.getParameter<bool>("ProduceL1GtObjectMapRecord")),
0074 m_writePsbL1GtDaqRecord(parSet.getParameter<bool>("WritePsbL1GtDaqRecord")),
0075 m_readTechnicalTriggerRecords(parSet.getParameter<bool>("ReadTechnicalTriggerRecords")),
0076 m_emulateBxInEvent(parSet.getParameter<int>("EmulateBxInEvent")),
0077 m_recordLength(parSet.getParameter<std::vector<int>>("RecordLength")),
0078 m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int>("AlternativeNrBxBoardDaq")),
0079 m_alternativeNrBxBoardEvm(parSet.getParameter<unsigned int>("AlternativeNrBxBoardEvm")),
0080 m_psBstLengthBytes(parSet.getParameter<int>("BstLengthBytes")),
0081 m_algorithmTriggersUnprescaled(parSet.getParameter<bool>("AlgorithmTriggersUnprescaled")),
0082 m_algorithmTriggersUnmasked(parSet.getParameter<bool>("AlgorithmTriggersUnmasked")),
0083 m_technicalTriggersUnprescaled(parSet.getParameter<bool>("TechnicalTriggersUnprescaled")),
0084 m_technicalTriggersUnmasked(parSet.getParameter<bool>("TechnicalTriggersUnmasked")),
0085 m_technicalTriggersVetoUnmasked(parSet.getParameter<bool>("TechnicalTriggersVetoUnmasked")),
0086 m_verbosity(parSet.getUntrackedParameter<int>("Verbosity", 0)),
0087 m_isDebugEnabled(edm::isDebugEnabled()),
0088 m_l1GtStableParToken(esConsumes<L1GtStableParameters, L1GtStableParametersRcd>()),
0089 m_l1GtParToken(esConsumes<L1GtParameters, L1GtParametersRcd>()),
0090 m_l1GtBMToken(esConsumes<L1GtBoardMaps, L1GtBoardMapsRcd>()),
0091 m_l1GtPfAlgoToken(esConsumes<L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd>()),
0092 m_l1GtPfTechToken(esConsumes<L1GtPrescaleFactors, L1GtPrescaleFactorsTechTrigRcd>()),
0093 m_l1GtTmAlgoToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd>()),
0094 m_l1GtTmTechToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd>()),
0095 m_l1GtTmVetoAlgoToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskVetoAlgoTrigRcd>()),
0096 m_l1GtTmVetoTechToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskVetoTechTrigRcd>()) {
0097 if (m_verbosity) {
0098 LogDebug("L1GlobalTrigger") << std::endl;
0099
0100 LogTrace("L1GlobalTrigger") << "\nInput tag for muon collection from GMT: " << m_muGmtInputTag
0101 << "\nInput tag for calorimeter collections from GCT: " << m_caloGctInputTag
0102 << "\nInput tag for CASTOR record: " << m_castorInputTag
0103 << "\nInput tag for technical triggers: " << std::endl;
0104
0105
0106 for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin();
0107 it != m_technicalTriggersInputTags.end();
0108 it++) {
0109 LogTrace("L1GlobalTrigger") << "\n " << (*it) << std::endl;
0110 }
0111
0112 LogTrace("L1GlobalTrigger")
0113 << "\nProduce the L1 GT DAQ readout record: " << m_produceL1GtDaqRecord
0114 << "\nProduce the L1 GT EVM readout record: " << m_produceL1GtEvmRecord
0115 << "\nProduce the L1 GT Object Map record: " << m_produceL1GtObjectMapRecord << " \n"
0116 << "\nWrite Psb content to L1 GT DAQ Record: " << m_writePsbL1GtDaqRecord << " \n"
0117 << "\nRead technical trigger records: " << m_readTechnicalTriggerRecords << " \n"
0118 << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
0119 << "\nNumber of BXs corresponding to alternative 0: " << m_recordLength.at(0)
0120 << "\nNumber of BXs corresponding to alternative 1: " << m_recordLength.at(1) << " \n"
0121 << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex << m_alternativeNrBxBoardDaq
0122 << "\nAlternative for number of BX in GT EVM record: 0x" << std::hex << m_alternativeNrBxBoardEvm << std::dec
0123 << " \n"
0124 << "\nLength of BST message [bytes]: " << m_psBstLengthBytes << "\n"
0125 << "\nRun algorithm triggers unprescaled: " << m_algorithmTriggersUnprescaled
0126 << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked << "\n"
0127 << "\nRun technical triggers unprescaled: " << m_technicalTriggersUnprescaled
0128 << "\nRun technical triggers unmasked (all enabled): " << m_technicalTriggersUnmasked
0129 << "\nRun technical triggers veto unmasked (no veto): " << m_technicalTriggersUnmasked << "\n"
0130 << std::endl;
0131 }
0132
0133 if ((m_emulateBxInEvent > 0) && ((m_emulateBxInEvent % 2) == 0)) {
0134 m_emulateBxInEvent = m_emulateBxInEvent - 1;
0135
0136 if (m_verbosity) {
0137 edm::LogWarning("L1GlobalTrigger") << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
0138 << m_emulateBxInEvent << "\n The number must be an odd number!\n"
0139 << std::endl;
0140 }
0141 }
0142
0143 int requiredRecordLength = std::max(m_recordLength.at(0), m_recordLength.at(1));
0144 if ((m_emulateBxInEvent >= 0) && (m_emulateBxInEvent < requiredRecordLength)) {
0145 m_emulateBxInEvent = requiredRecordLength;
0146
0147 if (m_verbosity) {
0148 edm::LogWarning("L1GlobalTrigger") << "\nWARNING: Number of bunch crossing required to be emulated ( "
0149 << m_emulateBxInEvent << " BX) smaller as required in RecordLength:"
0150 << "\n Number of BXs corresponding to alternative 0: "
0151 << m_recordLength.at(0)
0152 << "\n Number of BXs corresponding to alternative 1: "
0153 << m_recordLength.at(1) << "\nEmulating " << requiredRecordLength << " BX!"
0154 << "\n"
0155 << std::endl;
0156 }
0157 }
0158
0159
0160 if (m_produceL1GtDaqRecord) {
0161 produces<L1GlobalTriggerReadoutRecord>();
0162 }
0163
0164 if (m_produceL1GtEvmRecord) {
0165 produces<L1GlobalTriggerEvmReadoutRecord>();
0166 }
0167
0168 if (m_produceL1GtObjectMapRecord) {
0169 produces<L1GlobalTriggerObjectMapRecord>();
0170 }
0171
0172
0173 m_gtPSB = new L1GlobalTriggerPSB(m_caloGctInputTag, m_technicalTriggersInputTags, consumesCollector());
0174 m_gtPSB->setVerbosity(m_verbosity);
0175
0176
0177 m_gtGTL = new L1GlobalTriggerGTL(m_muGmtInputTag, consumesCollector());
0178 m_gtGTL->setVerbosity(m_verbosity);
0179
0180
0181 m_gtFDL = new L1GlobalTriggerFDL();
0182 m_gtFDL->setVerbosity(m_verbosity);
0183
0184
0185
0186
0187 m_l1GtStableParCacheID = 0ULL;
0188
0189 m_numberPhysTriggers = 0;
0190 m_numberTechnicalTriggers = 0;
0191 m_numberDaqPartitions = 0;
0192
0193 m_nrL1Mu = 0;
0194
0195 m_nrL1NoIsoEG = 0;
0196 m_nrL1IsoEG = 0;
0197
0198 m_nrL1CenJet = 0;
0199 m_nrL1ForJet = 0;
0200 m_nrL1TauJet = 0;
0201
0202 m_nrL1JetCounts = 0;
0203
0204 m_ifMuEtaNumberBits = 0;
0205 m_ifCaloEtaNumberBits = 0;
0206
0207
0208 m_l1GtParCacheID = 0ULL;
0209
0210 m_totalBxInEvent = 0;
0211
0212 m_activeBoardsGtDaq = 0;
0213 m_activeBoardsGtEvm = 0;
0214 m_bstLengthBytes = 0;
0215
0216
0217 m_l1GtBMCacheID = 0ULL;
0218
0219
0220 m_l1GtPfAlgoCacheID = 0ULL;
0221 m_l1GtPfTechCacheID = 0ULL;
0222
0223 m_l1GtTmAlgoCacheID = 0ULL;
0224 m_l1GtTmTechCacheID = 0ULL;
0225
0226 m_l1GtTmVetoAlgoCacheID = 0ULL;
0227 m_l1GtTmVetoTechCacheID = 0ULL;
0228
0229 consumes<L1MuGMTReadoutCollection>(m_muGmtInputTag);
0230 }
0231
0232
0233 L1GlobalTrigger::~L1GlobalTrigger() {
0234 delete m_gtPSB;
0235 delete m_gtGTL;
0236 delete m_gtFDL;
0237 }
0238
0239
0240
0241
0242 void L1GlobalTrigger::produce(edm::Event &iEvent, const edm::EventSetup &evSetup) {
0243
0244
0245
0246
0247
0248 unsigned long long l1GtStableParCacheID = evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
0249
0250 if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
0251 edm::ESHandle<L1GtStableParameters> l1GtStablePar = evSetup.getHandle(m_l1GtStableParToken);
0252 m_l1GtStablePar = l1GtStablePar.product();
0253
0254
0255 m_numberPhysTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
0256
0257
0258 m_numberTechnicalTriggers = m_l1GtStablePar->gtNumberTechnicalTriggers();
0259
0260
0261 m_numberDaqPartitions = 8;
0262
0263
0264 m_nrL1Mu = static_cast<int>(m_l1GtStablePar->gtNumberL1Mu());
0265
0266 m_nrL1NoIsoEG = static_cast<int>(m_l1GtStablePar->gtNumberL1NoIsoEG());
0267 m_nrL1IsoEG = static_cast<int>(m_l1GtStablePar->gtNumberL1IsoEG());
0268
0269 m_nrL1CenJet = static_cast<int>(m_l1GtStablePar->gtNumberL1CenJet());
0270 m_nrL1ForJet = static_cast<int>(m_l1GtStablePar->gtNumberL1ForJet());
0271 m_nrL1TauJet = static_cast<int>(m_l1GtStablePar->gtNumberL1TauJet());
0272
0273 m_nrL1JetCounts = static_cast<int>(m_l1GtStablePar->gtNumberL1JetCounts());
0274
0275
0276
0277 m_ifMuEtaNumberBits = static_cast<int>(m_l1GtStablePar->gtIfMuEtaNumberBits());
0278 m_ifCaloEtaNumberBits = static_cast<int>(m_l1GtStablePar->gtIfCaloEtaNumberBits());
0279
0280
0281 m_gtGTL->init(m_nrL1Mu, m_numberPhysTriggers);
0282
0283
0284 m_gtPSB->init(m_nrL1NoIsoEG, m_nrL1IsoEG, m_nrL1CenJet, m_nrL1ForJet, m_nrL1TauJet, m_numberTechnicalTriggers);
0285
0286
0287 m_l1GtStableParCacheID = l1GtStableParCacheID;
0288 }
0289
0290
0291
0292
0293 unsigned long long l1GtParCacheID = evSetup.get<L1GtParametersRcd>().cacheIdentifier();
0294
0295 if (m_l1GtParCacheID != l1GtParCacheID) {
0296 edm::ESHandle<L1GtParameters> l1GtPar = evSetup.getHandle(m_l1GtParToken);
0297 m_l1GtPar = l1GtPar.product();
0298
0299
0300 m_totalBxInEvent = m_l1GtPar->gtTotalBxInEvent();
0301
0302
0303 m_activeBoardsGtDaq = m_l1GtPar->gtDaqActiveBoards();
0304 m_activeBoardsGtEvm = m_l1GtPar->gtEvmActiveBoards();
0305
0306
0307 m_bstLengthBytes = m_l1GtPar->gtBstLengthBytes();
0308
0309 m_l1GtParCacheID = l1GtParCacheID;
0310 }
0311
0312
0313 if (m_emulateBxInEvent < 0) {
0314 m_emulateBxInEvent = m_totalBxInEvent;
0315 }
0316
0317 int minBxInEvent = (m_emulateBxInEvent + 1) / 2 - m_emulateBxInEvent;
0318 int maxBxInEvent = (m_emulateBxInEvent + 1) / 2 - 1;
0319
0320 int recordLength0 = m_recordLength.at(0);
0321 int recordLength1 = m_recordLength.at(1);
0322
0323 if ((recordLength0 < 0) || (recordLength1 < 0)) {
0324
0325
0326
0327 recordLength0 = m_emulateBxInEvent;
0328 recordLength1 = m_emulateBxInEvent;
0329 }
0330
0331 if (m_verbosity) {
0332 LogDebug("L1GlobalTrigger") << "\nTotal number of BX to emulate in the GT readout record: " << m_emulateBxInEvent
0333 << " = "
0334 << "[" << minBxInEvent << ", " << maxBxInEvent << "] BX\n"
0335 << "\nNumber of BX for alternative 0: " << recordLength0
0336 << "\nNumber of BX for alternative 1: " << recordLength1
0337 << "\nActive boards in L1 GT DAQ record (hex format) = " << std::hex
0338 << std::setw(sizeof(m_activeBoardsGtDaq) * 2) << std::setfill('0')
0339 << m_activeBoardsGtDaq << std::dec << std::setfill(' ')
0340 << "\nActive boards in L1 GT EVM record (hex format) = " << std::hex
0341 << std::setw(sizeof(m_activeBoardsGtEvm) * 2) << std::setfill('0')
0342 << m_activeBoardsGtEvm << std::dec << std::setfill(' ') << "\n"
0343 << std::endl;
0344 }
0345
0346
0347
0348
0349 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
0350
0351 unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
0352
0353 if (m_l1GtBMCacheID != l1GtBMCacheID) {
0354 edm::ESHandle<L1GtBoardMaps> l1GtBM = evSetup.getHandle(m_l1GtBMToken);
0355 m_l1GtBM = l1GtBM.product();
0356
0357 m_l1GtBMCacheID = l1GtBMCacheID;
0358 }
0359
0360
0361 const std::vector<L1GtBoard> &boardMaps = m_l1GtBM->gtBoardMaps();
0362
0363
0364
0365
0366 unsigned long long l1GtPfAlgoCacheID = evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
0367
0368 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
0369 edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo = evSetup.getHandle(m_l1GtPfAlgoToken);
0370 m_l1GtPfAlgo = l1GtPfAlgo.product();
0371
0372 m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
0373
0374 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
0375 }
0376
0377 unsigned long long l1GtPfTechCacheID = evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
0378
0379 if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
0380 edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech = evSetup.getHandle(m_l1GtPfTechToken);
0381 m_l1GtPfTech = l1GtPfTech.product();
0382
0383 m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
0384
0385 m_l1GtPfTechCacheID = l1GtPfTechCacheID;
0386 }
0387
0388
0389
0390
0391 unsigned long long l1GtTmAlgoCacheID = evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
0392
0393 if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
0394 edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo = evSetup.getHandle(m_l1GtTmAlgoToken);
0395 m_l1GtTmAlgo = l1GtTmAlgo.product();
0396
0397 m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
0398
0399 m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
0400 }
0401
0402 unsigned long long l1GtTmTechCacheID = evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
0403
0404 if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
0405 edm::ESHandle<L1GtTriggerMask> l1GtTmTech = evSetup.getHandle(m_l1GtTmTechToken);
0406 m_l1GtTmTech = l1GtTmTech.product();
0407
0408 m_triggerMaskTechTrig = m_l1GtTmTech->gtTriggerMask();
0409
0410 m_l1GtTmTechCacheID = l1GtTmTechCacheID;
0411 }
0412
0413 unsigned long long l1GtTmVetoAlgoCacheID = evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
0414
0415 if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
0416 edm::ESHandle<L1GtTriggerMask> l1GtTmVetoAlgo = evSetup.getHandle(m_l1GtTmVetoAlgoToken);
0417 m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
0418
0419 m_triggerMaskVetoAlgoTrig = m_l1GtTmVetoAlgo->gtTriggerMask();
0420
0421 m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
0422 }
0423
0424 unsigned long long l1GtTmVetoTechCacheID = evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
0425
0426 if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
0427 edm::ESHandle<L1GtTriggerMask> l1GtTmVetoTech = evSetup.getHandle(m_l1GtTmVetoTechToken);
0428 m_l1GtTmVetoTech = l1GtTmVetoTech.product();
0429
0430 m_triggerMaskVetoTechTrig = m_l1GtTmVetoTech->gtTriggerMask();
0431
0432 m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
0433 }
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443 int daqNrFdlBoards = 0;
0444 int daqNrPsbBoards = 0;
0445
0446
0447 bool receiveMu = false;
0448 bool receiveNoIsoEG = false;
0449 bool receiveIsoEG = false;
0450 bool receiveCenJet = false;
0451 bool receiveForJet = false;
0452 bool receiveTauJet = false;
0453 bool receiveETM = false;
0454 bool receiveETT = false;
0455 bool receiveHTT = false;
0456 bool receiveHTM = false;
0457 bool receiveJetCounts = false;
0458 bool receiveHfBitCounts = false;
0459 bool receiveHfRingEtSums = false;
0460
0461 bool receiveExternal = false;
0462
0463 bool receiveTechTr = false;
0464
0465 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
0466 int iPosition = itBoard->gtPositionDaqRecord();
0467 if (iPosition > 0) {
0468 int iActiveBit = itBoard->gtBitDaqActiveBoards();
0469 bool activeBoard = false;
0470
0471 if (iActiveBit >= 0) {
0472 activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
0473 }
0474
0475
0476
0477
0478 if ((iActiveBit < 0) || activeBoard) {
0479 switch (itBoard->gtBoardType()) {
0480 case FDL: {
0481 daqNrFdlBoards++;
0482 }
0483
0484 break;
0485 case PSB: {
0486 daqNrPsbBoards++;
0487
0488
0489 std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
0490 for (std::vector<L1GtPsbQuad>::const_iterator itQuad = quadInPsb.begin(); itQuad != quadInPsb.end();
0491 ++itQuad) {
0492 switch (*itQuad) {
0493 case TechTr: {
0494 receiveTechTr = true;
0495 }
0496
0497 break;
0498 case NoIsoEGQ: {
0499 receiveNoIsoEG = true;
0500 }
0501
0502 break;
0503 case IsoEGQ: {
0504 receiveIsoEG = true;
0505 }
0506
0507 break;
0508 case CenJetQ: {
0509 receiveCenJet = true;
0510 }
0511
0512 break;
0513 case ForJetQ: {
0514 receiveForJet = true;
0515 }
0516
0517 break;
0518 case TauJetQ: {
0519 receiveTauJet = true;
0520 }
0521
0522 break;
0523 case ESumsQ: {
0524 receiveETM = true;
0525 receiveETT = true;
0526 receiveHTT = true;
0527 receiveHTM = true;
0528 }
0529
0530 break;
0531 case JetCountsQ: {
0532 receiveJetCounts = true;
0533 }
0534
0535 break;
0536 case CastorQ: {
0537
0538 }
0539
0540 break;
0541 case BptxQ: {
0542
0543 }
0544
0545 break;
0546 case GtExternalQ: {
0547 receiveExternal = true;
0548 }
0549
0550 break;
0551 case HfQ: {
0552 receiveHfBitCounts = true;
0553 receiveHfRingEtSums = true;
0554 }
0555
0556 break;
0557
0558 default: {
0559
0560 }
0561
0562 break;
0563 }
0564 }
0565
0566 }
0567
0568 break;
0569 default: {
0570
0571 }
0572
0573 break;
0574 }
0575 }
0576 }
0577 }
0578
0579
0580
0581 std::unique_ptr<L1GlobalTriggerReadoutRecord> gtDaqReadoutRecord(
0582 new L1GlobalTriggerReadoutRecord(m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards));
0583
0584
0585 std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord(
0586 new L1GlobalTriggerEvmReadoutRecord(m_emulateBxInEvent, daqNrFdlBoards));
0587
0588
0589
0590 std::unique_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(new L1GlobalTriggerObjectMapRecord());
0591
0592
0593
0594
0595
0596
0597 int bxCross = iEvent.bunchCrossing();
0598 uint16_t bxCrossHw = 0;
0599 if ((bxCross & 0xFFF) == bxCross) {
0600 bxCrossHw = static_cast<uint16_t>(bxCross);
0601 } else {
0602 bxCrossHw = 0;
0603 if (m_verbosity) {
0604 LogDebug("L1GlobalTrigger") << "\nBunch cross number [hex] = " << std::hex << bxCross
0605 << "\n larger than 12 bits. Set to 0! \n"
0606 << std::dec << std::endl;
0607 }
0608 }
0609
0610 if (m_produceL1GtDaqRecord) {
0611 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
0612 int iPosition = itBoard->gtPositionDaqRecord();
0613 if (iPosition > 0) {
0614 int iActiveBit = itBoard->gtBitDaqActiveBoards();
0615 bool activeBoard = false;
0616
0617 if (iActiveBit >= 0) {
0618 activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
0619 }
0620
0621
0622
0623
0624 if ((iActiveBit < 0) || activeBoard) {
0625 switch (itBoard->gtBoardType()) {
0626 case GTFE: {
0627 L1GtfeWord gtfeWordValue;
0628
0629 gtfeWordValue.setBoardId(itBoard->gtBoardId());
0630
0631
0632
0633 gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
0634
0635 gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
0636
0637
0638 gtfeWordValue.setBxNr(bxCrossHw);
0639
0640
0641 gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
0642
0643
0644 gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardDaq));
0645
0646
0647
0648
0649 gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
0650
0651
0652
0653 gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
0654 }
0655
0656 break;
0657 case TCS: {
0658
0659 }
0660
0661 break;
0662 case TIM: {
0663
0664 }
0665
0666 break;
0667 default: {
0668
0669 }
0670
0671 break;
0672 }
0673 }
0674 }
0675 }
0676 }
0677
0678
0679
0680 int evmNrFdlBoards = 0;
0681
0682 if (m_produceL1GtEvmRecord) {
0683
0684
0685 int bstLengthBytes = 0;
0686
0687 if (m_psBstLengthBytes < 0) {
0688
0689 bstLengthBytes = static_cast<int>(m_bstLengthBytes);
0690
0691 } else {
0692
0693 bstLengthBytes = m_psBstLengthBytes;
0694 }
0695
0696 if (m_verbosity) {
0697 LogTrace("L1GlobalTrigger") << "\n Length of BST message (in bytes): " << bstLengthBytes << "\n" << std::endl;
0698 }
0699
0700 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
0701 int iPosition = itBoard->gtPositionEvmRecord();
0702 if (iPosition > 0) {
0703 int iActiveBit = itBoard->gtBitEvmActiveBoards();
0704 bool activeBoard = false;
0705
0706 if (iActiveBit >= 0) {
0707 activeBoard = m_activeBoardsGtEvm & (1 << iActiveBit);
0708 }
0709
0710
0711
0712
0713 if ((iActiveBit < 0) || activeBoard) {
0714 switch (itBoard->gtBoardType()) {
0715 case GTFE: {
0716 L1GtfeExtWord gtfeWordValue(bstLengthBytes);
0717
0718 gtfeWordValue.setBoardId(itBoard->gtBoardId());
0719
0720
0721
0722 gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
0723
0724 gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
0725
0726
0727 gtfeWordValue.setBxNr(bxCrossHw);
0728
0729
0730 gtfeWordValue.setActiveBoards(m_activeBoardsGtEvm);
0731
0732
0733 gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardEvm));
0734
0735
0736
0737
0738 gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
0739
0740
0741 edm::TimeValue_t evTime = iEvent.time().value();
0742
0743 gtfeWordValue.setGpsTime(evTime);
0744
0745
0746
0747
0748
0749
0750
0751 uint16_t bstSourceVal = 0xDDDD;
0752 gtfeWordValue.setBstSource(bstSourceVal);
0753
0754
0755
0756 gtEvmReadoutRecord->setGtfeWord(gtfeWordValue);
0757 }
0758
0759 break;
0760 case FDL: {
0761 evmNrFdlBoards++;
0762 }
0763
0764 break;
0765 case TCS: {
0766 L1TcsWord tcsWordValue;
0767
0768 tcsWordValue.setBoardId(itBoard->gtBoardId());
0769
0770
0771 tcsWordValue.setBxNr(bxCrossHw);
0772
0773 uint16_t trigType = 0x5;
0774 tcsWordValue.setTriggerType(trigType);
0775
0776
0777 tcsWordValue.setLuminositySegmentNr(static_cast<uint16_t>(iEvent.luminosityBlock()));
0778
0779
0780 tcsWordValue.setEventNr(static_cast<uint32_t>(iEvent.id().event()));
0781
0782
0783 tcsWordValue.setOrbitNr(static_cast<uint64_t>(iEvent.orbitNumber()));
0784
0785
0786
0787 gtEvmReadoutRecord->setTcsWord(tcsWordValue);
0788
0789 }
0790
0791 break;
0792 case TIM: {
0793
0794 }
0795
0796 break;
0797 default: {
0798
0799 }
0800
0801 break;
0802 }
0803 }
0804 }
0805 }
0806 }
0807
0808
0809 int pfAlgoSetIndex = 0;
0810 const std::vector<int> &prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
0811
0812 int pfTechSetIndex = 0;
0813 const std::vector<int> &prescaleFactorsTechTrig = (*m_prescaleFactorsTechTrig).at(pfTechSetIndex);
0814
0815
0816
0817
0818 for (int iBxInEvent = minBxInEvent; iBxInEvent <= maxBxInEvent; ++iBxInEvent) {
0819
0820
0821
0822
0823
0824
0825 m_gtPSB->receiveGctObjectData(iEvent,
0826 m_caloGctInputTag,
0827 iBxInEvent,
0828 receiveNoIsoEG,
0829 m_nrL1NoIsoEG,
0830 receiveIsoEG,
0831 m_nrL1IsoEG,
0832 receiveCenJet,
0833 m_nrL1CenJet,
0834 receiveForJet,
0835 m_nrL1ForJet,
0836 receiveTauJet,
0837 m_nrL1TauJet,
0838 receiveETM,
0839 receiveETT,
0840 receiveHTT,
0841 receiveHTM,
0842 receiveJetCounts,
0843 receiveHfBitCounts,
0844 receiveHfRingEtSums);
0845
0846
0847 if (m_readTechnicalTriggerRecords) {
0848 m_gtPSB->receiveTechnicalTriggers(
0849 iEvent, m_technicalTriggersInputTags, iBxInEvent, receiveTechTr, m_numberTechnicalTriggers);
0850 }
0851
0852 if (receiveExternal) {
0853
0854 }
0855
0856 if (m_produceL1GtDaqRecord && m_writePsbL1GtDaqRecord) {
0857 m_gtPSB->fillPsbBlock(iEvent,
0858 m_activeBoardsGtDaq,
0859 recordLength0,
0860 recordLength1,
0861 m_alternativeNrBxBoardDaq,
0862 boardMaps,
0863 iBxInEvent,
0864 gtDaqReadoutRecord.get());
0865 }
0866
0867
0868
0869
0870
0871
0872
0873 m_gtGTL->receiveGmtObjectData(iEvent, m_muGmtInputTag, iBxInEvent, receiveMu, m_nrL1Mu);
0874
0875
0876
0877
0878
0879
0880 m_gtGTL->run(iEvent,
0881 evSetup,
0882 m_gtPSB,
0883 m_produceL1GtObjectMapRecord,
0884 iBxInEvent,
0885 gtObjectMapRecord.get(),
0886 m_numberPhysTriggers,
0887 m_nrL1Mu,
0888 m_nrL1NoIsoEG,
0889 m_nrL1IsoEG,
0890 m_nrL1CenJet,
0891 m_nrL1ForJet,
0892 m_nrL1TauJet,
0893 m_nrL1JetCounts,
0894 m_ifMuEtaNumberBits,
0895 m_ifCaloEtaNumberBits);
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906 m_gtFDL->run(iEvent,
0907 prescaleFactorsAlgoTrig,
0908 prescaleFactorsTechTrig,
0909 m_triggerMaskAlgoTrig,
0910 m_triggerMaskTechTrig,
0911 m_triggerMaskVetoAlgoTrig,
0912 m_triggerMaskVetoTechTrig,
0913 boardMaps,
0914 m_emulateBxInEvent,
0915 iBxInEvent,
0916 m_numberPhysTriggers,
0917 m_numberTechnicalTriggers,
0918 m_numberDaqPartitions,
0919 m_gtGTL,
0920 m_gtPSB,
0921 pfAlgoSetIndex,
0922 pfTechSetIndex,
0923 m_algorithmTriggersUnprescaled,
0924 m_algorithmTriggersUnmasked,
0925 m_technicalTriggersUnprescaled,
0926 m_technicalTriggersUnmasked,
0927 m_technicalTriggersVetoUnmasked);
0928
0929 if (m_produceL1GtDaqRecord && (daqNrFdlBoards > 0)) {
0930 m_gtFDL->fillDaqFdlBlock(iBxInEvent,
0931 m_activeBoardsGtDaq,
0932 recordLength0,
0933 recordLength1,
0934 m_alternativeNrBxBoardDaq,
0935 boardMaps,
0936 gtDaqReadoutRecord.get());
0937 }
0938
0939 if (m_produceL1GtEvmRecord && (evmNrFdlBoards > 0)) {
0940 m_gtFDL->fillEvmFdlBlock(iBxInEvent,
0941 m_activeBoardsGtEvm,
0942 recordLength0,
0943 recordLength1,
0944 m_alternativeNrBxBoardEvm,
0945 boardMaps,
0946 gtEvmReadoutRecord.get());
0947 }
0948
0949
0950 m_gtPSB->reset();
0951 m_gtGTL->reset();
0952 m_gtFDL->reset();
0953
0954
0955 }
0956
0957 if (receiveMu) {
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968 edm::Handle<L1MuGMTReadoutCollection> gmtRcHandle;
0969 iEvent.getByLabel(m_muGmtInputTag, gmtRcHandle);
0970
0971 if (!gmtRcHandle.isValid()) {
0972 if (m_verbosity) {
0973 edm::LogWarning("L1GlobalTrigger") << "\nWarning: L1MuGMTReadoutCollection with input tag " << m_muGmtInputTag
0974 << "\nrequested in configuration, but not found in the event.\n"
0975 << std::endl;
0976 }
0977 } else {
0978 gtDaqReadoutRecord->setMuCollectionRefProd(gmtRcHandle);
0979 }
0980 }
0981
0982 if (m_verbosity && m_isDebugEnabled) {
0983 std::ostringstream myCoutStream;
0984 gtDaqReadoutRecord->print(myCoutStream);
0985 LogTrace("L1GlobalTrigger") << "\n The following L1 GT DAQ readout record was produced:\n"
0986 << myCoutStream.str() << "\n"
0987 << std::endl;
0988
0989 myCoutStream.str("");
0990 myCoutStream.clear();
0991
0992 gtEvmReadoutRecord->print(myCoutStream);
0993 LogTrace("L1GlobalTrigger") << "\n The following L1 GT EVM readout record was produced:\n"
0994 << myCoutStream.str() << "\n"
0995 << std::endl;
0996
0997 myCoutStream.str("");
0998 myCoutStream.clear();
0999
1000 const std::vector<L1GlobalTriggerObjectMap> objMapVec = gtObjectMapRecord->gtObjectMap();
1001
1002 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator it = objMapVec.begin(); it != objMapVec.end(); ++it) {
1003 (*it).print(myCoutStream);
1004 }
1005
1006 LogDebug("L1GlobalTrigger") << "Test gtObjectMapRecord in L1GlobalTrigger \n\n"
1007 << myCoutStream.str() << "\n\n"
1008 << std::endl;
1009
1010 myCoutStream.str("");
1011 myCoutStream.clear();
1012 }
1013
1014
1015
1016 if (m_produceL1GtDaqRecord) {
1017 iEvent.put(std::move(gtDaqReadoutRecord));
1018 }
1019
1020 if (m_produceL1GtEvmRecord) {
1021 iEvent.put(std::move(gtEvmReadoutRecord));
1022 }
1023
1024 if (m_produceL1GtObjectMapRecord) {
1025 iEvent.put(std::move(gtObjectMapRecord));
1026 }
1027 }
1028
1029
1030
1031 DEFINE_FWK_MODULE(L1GlobalTrigger);