File indexing completed on 2024-09-24 22:51:28
0001
0002
0003
0004
0005
0006 #include "L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h"
0007
0008
0009 #include <memory>
0010 #include <iostream>
0011 #include <iomanip>
0012 #include <algorithm>
0013
0014 #include "FWCore/Utilities/interface/typedefs.h"
0015 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0022 #include "FWCore/Utilities/interface/InputTag.h"
0023 #include "DataFormats/Common/interface/RefProd.h"
0024
0025 #include "L1Trigger/L1TGlobal/interface/GlobalParamsHelper.h"
0026
0027 #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
0028 #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
0029 #include "DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h"
0030 #include "DataFormats/L1TGlobal/interface/AXOL1TLScore.h"
0031
0032 #include "L1Trigger/L1TGlobal/interface/TriggerMenu.h"
0033
0034 #include "TriggerMenuParser.h"
0035
0036 using namespace l1t;
0037
0038 void L1TGlobalProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0039 edm::ParameterSetDescription desc;
0040
0041 desc.add<edm::InputTag>("MuonInputTag", edm::InputTag(""))
0042 ->setComment("InputTag for Global Muon Trigger (required parameter: default value is invalid)");
0043 desc.add<edm::InputTag>("MuonShowerInputTag", edm::InputTag(""))
0044 ->setComment("InputTag for Global Muon Shower Trigger (required parameter: default value is invalid)");
0045 desc.add<edm::InputTag>("EGammaInputTag", edm::InputTag(""))
0046 ->setComment("InputTag for Calo Trigger EGamma (required parameter: default value is invalid)");
0047 desc.add<edm::InputTag>("TauInputTag", edm::InputTag(""))
0048 ->setComment("InputTag for Calo Trigger Tau (required parameter: default value is invalid)");
0049 desc.add<edm::InputTag>("JetInputTag", edm::InputTag(""))
0050 ->setComment("InputTag for Calo Trigger Jet (required parameter: default value is invalid)");
0051 desc.add<edm::InputTag>("EtSumInputTag", edm::InputTag(""))
0052 ->setComment("InputTag for Calo Trigger EtSum (required parameter: default value is invalid)");
0053 desc.add<edm::InputTag>("EtSumZdcInputTag", edm::InputTag(""))
0054 ->setComment("InputTag for ZDC EtSums Plus and Minus (required parameter: default value is invalid)");
0055 desc.add<edm::InputTag>("CICADAInputTag", edm::InputTag(""))
0056 ->setComment("InputTag for CICADA Anomaly Detection (required parameter: default value is invalid)");
0057 desc.add<edm::InputTag>("ExtInputTag", edm::InputTag(""))
0058 ->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)");
0059 desc.add<edm::InputTag>("AlgoBlkInputTag", edm::InputTag("hltGtStage2Digis"))
0060 ->setComment(
0061 "InputTag for unpacked Algblk (required only if GetPrescaleColumnFromData orRequireMenuToMatchAlgoBlkInput "
0062 "set to true)");
0063 desc.add<bool>("GetPrescaleColumnFromData", false)
0064 ->setComment("Get prescale column from unpacked GlobalAlgBck. Otherwise use value specified in PrescaleSet");
0065 desc.add<bool>("AlgorithmTriggersUnprescaled", false)
0066 ->setComment("not required, but recommend to specify explicitly in config");
0067 desc.add<bool>("RequireMenuToMatchAlgoBlkInput", true)
0068 ->setComment(
0069 "This requires that the L1 menu record to match the menu used to produce the inputed L1 results, should be "
0070 "true when used by the HLT to produce the object map");
0071 desc.add<bool>("AlgorithmTriggersUnmasked", false)
0072 ->setComment("not required, but recommend to specify explicitly in config");
0073
0074
0075 desc.add<bool>("useMuonShowers", false);
0076
0077
0078 desc.add<bool>("produceAXOL1TLScore", false);
0079
0080
0081
0082
0083
0084 desc.add<bool>("resetPSCountersEachLumiSec", false);
0085
0086
0087
0088 desc.add<bool>("semiRandomInitialPSCounters", false);
0089
0090
0091
0092 desc.add<bool>("ProduceL1GtDaqRecord", true);
0093 desc.add<bool>("ProduceL1GtObjectMapRecord", true);
0094 desc.add<int>("EmulateBxInEvent", 1);
0095 desc.add<int>("L1DataBxInEvent", 5);
0096 desc.add<unsigned int>("AlternativeNrBxBoardDaq", 0);
0097 desc.add<int>("BstLengthBytes", -1);
0098 desc.add<unsigned int>("PrescaleSet", 1);
0099 desc.addUntracked<int>("Verbosity", 0);
0100 desc.addUntracked<bool>("PrintL1Menu", false);
0101 desc.add<std::string>("TriggerMenuLuminosity", "startup");
0102 descriptions.add("L1TGlobalProducer", desc);
0103 }
0104
0105
0106
0107 L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet)
0108 : m_muInputTag(parSet.getParameter<edm::InputTag>("MuonInputTag")),
0109 m_muShowerInputTag(parSet.getParameter<edm::InputTag>("MuonShowerInputTag")),
0110 m_egInputTag(parSet.getParameter<edm::InputTag>("EGammaInputTag")),
0111 m_tauInputTag(parSet.getParameter<edm::InputTag>("TauInputTag")),
0112 m_jetInputTag(parSet.getParameter<edm::InputTag>("JetInputTag")),
0113 m_sumInputTag(parSet.getParameter<edm::InputTag>("EtSumInputTag")),
0114 m_sumZdcInputTag(parSet.getParameter<edm::InputTag>("EtSumZdcInputTag")),
0115 m_CICADAInputTag(parSet.getParameter<edm::InputTag>("CICADAInputTag")),
0116 m_extInputTag(parSet.getParameter<edm::InputTag>("ExtInputTag")),
0117
0118 m_produceL1GtDaqRecord(parSet.getParameter<bool>("ProduceL1GtDaqRecord")),
0119 m_produceL1GtObjectMapRecord(parSet.getParameter<bool>("ProduceL1GtObjectMapRecord")),
0120
0121 m_emulateBxInEvent(parSet.getParameter<int>("EmulateBxInEvent")),
0122 m_L1DataBxInEvent(parSet.getParameter<int>("L1DataBxInEvent")),
0123
0124 m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int>("AlternativeNrBxBoardDaq")),
0125 m_psBstLengthBytes(parSet.getParameter<int>("BstLengthBytes")),
0126
0127 m_prescaleSet(parSet.getParameter<unsigned int>("PrescaleSet")),
0128
0129 m_algorithmTriggersUnprescaled(parSet.getParameter<bool>("AlgorithmTriggersUnprescaled")),
0130 m_algorithmTriggersUnmasked(parSet.getParameter<bool>("AlgorithmTriggersUnmasked")),
0131
0132 m_verbosity(parSet.getUntrackedParameter<int>("Verbosity")),
0133 m_printL1Menu(parSet.getUntrackedParameter<bool>("PrintL1Menu")),
0134 m_isDebugEnabled(edm::isDebugEnabled()),
0135 m_getPrescaleColumnFromData(parSet.getParameter<bool>("GetPrescaleColumnFromData")),
0136 m_requireMenuToMatchAlgoBlkInput(parSet.getParameter<bool>("RequireMenuToMatchAlgoBlkInput")),
0137 m_algoblkInputTag(parSet.getParameter<edm::InputTag>("AlgoBlkInputTag")),
0138 m_resetPSCountersEachLumiSec(parSet.getParameter<bool>("resetPSCountersEachLumiSec")),
0139 m_semiRandomInitialPSCounters(parSet.getParameter<bool>("semiRandomInitialPSCounters")),
0140 m_useMuonShowers(parSet.getParameter<bool>("useMuonShowers")),
0141 m_produceAXOL1TLScore(parSet.getParameter<bool>("produceAXOL1TLScore")) {
0142 m_egInputToken = consumes<BXVector<EGamma>>(m_egInputTag);
0143 m_tauInputToken = consumes<BXVector<Tau>>(m_tauInputTag);
0144 m_jetInputToken = consumes<BXVector<Jet>>(m_jetInputTag);
0145 m_sumInputToken = consumes<BXVector<EtSum>>(m_sumInputTag);
0146 m_sumZdcInputToken = consumes<BXVector<EtSum>>(m_sumZdcInputTag);
0147 m_CICADAInputToken = consumes<BXVector<float>>(m_CICADAInputTag);
0148 m_muInputToken = consumes<BXVector<Muon>>(m_muInputTag);
0149 if (m_useMuonShowers)
0150 m_muShowerInputToken = consumes<BXVector<MuonShower>>(m_muShowerInputTag);
0151 m_extInputToken = consumes<BXVector<GlobalExtBlk>>(m_extInputTag);
0152 m_l1GtStableParToken = esConsumes<L1TGlobalParameters, L1TGlobalParametersRcd>();
0153 m_l1GtMenuToken = esConsumes<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>();
0154 if (!(m_algorithmTriggersUnprescaled && m_algorithmTriggersUnmasked)) {
0155 m_l1GtPrescaleVetosToken = esConsumes<L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd>();
0156 }
0157 if (m_getPrescaleColumnFromData || m_requireMenuToMatchAlgoBlkInput) {
0158 m_algoblkInputToken = consumes<BXVector<GlobalAlgBlk>>(m_algoblkInputTag);
0159 }
0160
0161 if (m_verbosity) {
0162 LogTrace("L1TGlobalProducer") << "\nInput tag for muon collection from uGMT: " << m_muInputTag
0163 << "\nInput tag for calorimeter jet collections from Cal: " << m_jetInputTag
0164 << "\nInput tag for external conditions : " << m_extInputTag << std::endl;
0165
0166 LogTrace("L1TGlobalProducer") << "\nProduce the L1 uGT DAQ readout record: " << m_produceL1GtDaqRecord
0167 << "\nProduce the L1 uGT Object Map record: "
0168 << m_produceL1GtObjectMapRecord << " \n"
0169 << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent << " \n"
0170 << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
0171 << m_alternativeNrBxBoardDaq << " \n"
0172 << "\nRun algorithm triggers unprescaled: "
0173 << m_algorithmTriggersUnprescaled
0174 << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked
0175 << "\n"
0176 << std::endl;
0177 }
0178
0179 if ((m_emulateBxInEvent > 0) && ((m_emulateBxInEvent % 2) == 0)) {
0180 m_emulateBxInEvent = m_emulateBxInEvent - 1;
0181
0182 if (m_verbosity) {
0183 edm::LogWarning("L1TGlobalProducer")
0184 << "\nWARNING: Number of bunch crossing to be emulated rounded to: " << m_emulateBxInEvent
0185 << "\n The number must be an odd number!\n"
0186 << std::endl;
0187 }
0188 }
0189
0190 if ((m_L1DataBxInEvent > 0) && ((m_L1DataBxInEvent % 2) == 0)) {
0191 m_L1DataBxInEvent = m_L1DataBxInEvent - 1;
0192
0193 if (m_verbosity) {
0194 edm::LogWarning("L1TGlobalProducer")
0195 << "\nWARNING: Number of bunch crossing for incoming L1 Data rounded to: " << m_L1DataBxInEvent
0196 << "\n The number must be an odd number!\n"
0197 << std::endl;
0198 }
0199 } else if (m_L1DataBxInEvent < 0) {
0200 m_L1DataBxInEvent = 1;
0201
0202 if (m_verbosity) {
0203 edm::LogWarning("L1TGlobalProducer")
0204 << "\nWARNING: Number of bunch crossing for incoming L1 Data was changed to: " << m_L1DataBxInEvent
0205 << "\n The number must be an odd positive number!\n"
0206 << std::endl;
0207 }
0208 }
0209
0210
0211 if (m_produceL1GtDaqRecord) {
0212 produces<GlobalAlgBlkBxCollection>();
0213
0214 }
0215
0216 if (m_produceL1GtObjectMapRecord) {
0217 produces<GlobalObjectMapRecord>();
0218 }
0219
0220 if (m_produceAXOL1TLScore) {
0221 produces<AXOL1TLScoreBxCollection>("AXOScore");
0222 }
0223
0224
0225 m_uGtBrd = std::make_unique<GlobalBoard>();
0226 m_uGtBrd->setVerbosity(m_verbosity);
0227 m_uGtBrd->setResetPSCountersEachLumiSec(m_resetPSCountersEachLumiSec);
0228 m_uGtBrd->setSemiRandomInitialPSCounters(m_semiRandomInitialPSCounters);
0229
0230
0231
0232
0233 m_l1GtParCacheID = 0ULL;
0234 m_l1GtMenuCacheID = 0ULL;
0235
0236 m_numberPhysTriggers = 0;
0237 m_numberDaqPartitions = 0;
0238
0239 m_nrL1Mu = 0;
0240 m_nrL1MuShower = 0;
0241 m_nrL1EG = 0;
0242 m_nrL1Tau = 0;
0243
0244 m_nrL1Jet = 0;
0245
0246 m_ifMuEtaNumberBits = 0;
0247 m_ifCaloEtaNumberBits = 0;
0248
0249
0250 m_l1GtParCacheID = 0ULL;
0251
0252 m_totalBxInEvent = 0;
0253
0254 m_activeBoardsGtDaq = 0;
0255 m_bstLengthBytes = 0;
0256
0257
0258 m_l1GtBMCacheID = 0ULL;
0259
0260
0261 m_l1GtPfAlgoCacheID = 0ULL;
0262
0263 m_l1GtTmAlgoCacheID = 0ULL;
0264
0265 m_l1GtTmVetoAlgoCacheID = 0ULL;
0266
0267 m_currentLumi = 0;
0268
0269
0270 std::vector<l1t::Muon> muonVec_bxm2;
0271 std::vector<l1t::Muon> muonVec_bxm1;
0272
0273
0274 std::vector<std::vector<double>> temp_prescaleTable;
0275
0276 temp_prescaleTable.push_back(std::vector<double>());
0277 m_initialPrescaleFactorsAlgoTrig = temp_prescaleTable;
0278 }
0279
0280
0281 L1TGlobalProducer::~L1TGlobalProducer() {}
0282
0283
0284
0285
0286 void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSetup) {
0287
0288
0289
0290
0291 unsigned long long l1GtParCacheID = evSetup.get<L1TGlobalParametersRcd>().cacheIdentifier();
0292
0293 if (m_l1GtParCacheID != l1GtParCacheID) {
0294 edm::ESHandle<L1TGlobalParameters> l1GtStablePar = evSetup.getHandle(m_l1GtStableParToken);
0295 m_l1GtStablePar = l1GtStablePar.product();
0296 const GlobalParamsHelper* data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
0297
0298
0299 m_totalBxInEvent = data->totalBxInEvent();
0300
0301
0302 m_numberPhysTriggers = data->numberPhysTriggers();
0303
0304
0305 m_nrL1Mu = data->numberL1Mu();
0306
0307
0308
0309
0310 if (m_useMuonShowers)
0311 m_nrL1MuShower = 1;
0312
0313
0314 m_nrL1EG = data->numberL1EG();
0315
0316
0317 m_nrL1Jet = data->numberL1Jet();
0318
0319
0320 m_nrL1Tau = data->numberL1Tau();
0321
0322 if (m_L1DataBxInEvent < 1)
0323 m_L1DataBxInEvent = 1;
0324 int minL1DataBxInEvent = (m_L1DataBxInEvent + 1) / 2 - m_L1DataBxInEvent;
0325 int maxL1DataBxInEvent = (m_L1DataBxInEvent + 1) / 2 - 1;
0326
0327
0328 m_uGtBrd->init(m_numberPhysTriggers,
0329 m_nrL1Mu,
0330 m_nrL1MuShower,
0331 m_nrL1EG,
0332 m_nrL1Tau,
0333 m_nrL1Jet,
0334 minL1DataBxInEvent,
0335 maxL1DataBxInEvent);
0336
0337
0338 m_l1GtParCacheID = l1GtParCacheID;
0339 }
0340
0341 if (m_emulateBxInEvent < 0) {
0342 m_emulateBxInEvent = m_totalBxInEvent;
0343 }
0344
0345 if (m_emulateBxInEvent < 1)
0346 m_emulateBxInEvent = 1;
0347 int minEmulBxInEvent = (m_emulateBxInEvent + 1) / 2 - m_emulateBxInEvent;
0348 int maxEmulBxInEvent = (m_emulateBxInEvent + 1) / 2 - 1;
0349
0350
0351
0352 unsigned long long l1GtMenuCacheID = evSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
0353
0354 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
0355 const GlobalParamsHelper* data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
0356
0357 edm::ESHandle<L1TUtmTriggerMenu> l1GtMenu = evSetup.getHandle(m_l1GtMenuToken);
0358 const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
0359
0360 if (m_requireMenuToMatchAlgoBlkInput) {
0361 edm::Handle<BXVector<GlobalAlgBlk>> m_uGtAlgBlk;
0362 iEvent.getByToken(m_algoblkInputToken, m_uGtAlgBlk);
0363 if (m_uGtAlgBlk->size() >= 1) {
0364 if ((*m_uGtAlgBlk)[0].getL1FirmwareUUID() != static_cast<int>(utml1GtMenu->getFirmwareUuidHashed())) {
0365 throw cms::Exception("ConditionsError")
0366 << " Error L1 menu loaded in via conditions does not match the L1 actually run "
0367 << (*m_uGtAlgBlk)[0].getL1FirmwareUUID() << " vs " << utml1GtMenu->getFirmwareUuidHashed()
0368 << ". This means that the mapping of the names to the bits may be incorrect. Please check the "
0369 "L1TUtmTriggerMenuRcd record supplied. Unless you know what you are doing, do not simply disable this "
0370 "check via the config as this a major error and the indication of something very wrong";
0371 }
0372 }
0373 }
0374
0375
0376 TriggerMenuParser gtParser = TriggerMenuParser();
0377
0378 gtParser.setGtNumberConditionChips(data->numberChips());
0379 gtParser.setGtPinsOnConditionChip(data->pinsOnChip());
0380 gtParser.setGtOrderConditionChip(data->orderOfChip());
0381 gtParser.setGtNumberPhysTriggers(data->numberPhysTriggers());
0382
0383
0384 gtParser.parseCondFormats(utml1GtMenu);
0385
0386
0387 m_l1GtMenu = std::make_unique<TriggerMenu>(gtParser.gtTriggerMenuName(),
0388 data->numberChips(),
0389 gtParser.vecMuonTemplate(),
0390 gtParser.vecMuonShowerTemplate(),
0391 gtParser.vecCaloTemplate(),
0392 gtParser.vecEnergySumTemplate(),
0393 gtParser.vecEnergySumZdcTemplate(),
0394 gtParser.vecAXOL1TLTemplate(),
0395 gtParser.vecCICADATemplate(),
0396 gtParser.vecExternalTemplate(),
0397 gtParser.vecCorrelationTemplate(),
0398 gtParser.vecCorrelationThreeBodyTemplate(),
0399 gtParser.vecCorrelationWithOverlapRemovalTemplate(),
0400 gtParser.corMuonTemplate(),
0401 gtParser.corCaloTemplate(),
0402 gtParser.corEnergySumTemplate());
0403
0404 m_l1GtMenu->setGtTriggerMenuInterface(gtParser.gtTriggerMenuInterface());
0405 m_l1GtMenu->setGtTriggerMenuImplementation(gtParser.gtTriggerMenuImplementation());
0406 m_l1GtMenu->setGtScaleDbKey(gtParser.gtScaleDbKey());
0407 m_l1GtMenu->setGtScales(gtParser.gtScales());
0408 m_l1GtMenu->setGtTriggerMenuUUID(gtParser.gtTriggerMenuUUID());
0409
0410 m_l1GtMenu->setGtAlgorithmMap(gtParser.gtAlgorithmMap());
0411 m_l1GtMenu->setGtAlgorithmAliasMap(gtParser.gtAlgorithmAliasMap());
0412
0413 m_l1GtMenu->buildGtConditionMap();
0414
0415 int printV = 2;
0416 if (m_printL1Menu)
0417 m_l1GtMenu->print(std::cout, printV);
0418
0419 m_l1GtMenuCacheID = l1GtMenuCacheID;
0420 }
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450 if (!(m_algorithmTriggersUnprescaled && m_algorithmTriggersUnmasked)) {
0451 unsigned long long l1GtPfAlgoCacheID = evSetup.get<L1TGlobalPrescalesVetosFractRcd>().cacheIdentifier();
0452
0453 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
0454 edm::ESHandle<L1TGlobalPrescalesVetosFract> l1GtPrescalesFractVetoes =
0455 evSetup.getHandle(m_l1GtPrescaleVetosToken);
0456 const L1TGlobalPrescalesVetosFract* es = l1GtPrescalesFractVetoes.product();
0457 m_l1GtPrescalesVetosFract = PrescalesVetosFractHelper::readFromEventSetup(es);
0458
0459 m_prescaleFactorsAlgoTrig = &(m_l1GtPrescalesVetosFract->prescaleTable());
0460 m_triggerMaskVetoAlgoTrig = &(m_l1GtPrescalesVetosFract->triggerMaskVeto());
0461
0462 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
0463 }
0464 if (m_getPrescaleColumnFromData &&
0465 (m_currentLumi != iEvent.luminosityBlock())) {
0466
0467 m_currentLumi = iEvent.luminosityBlock();
0468
0469 edm::Handle<BXVector<GlobalAlgBlk>> m_uGtAlgBlk;
0470 iEvent.getByToken(m_algoblkInputToken, m_uGtAlgBlk);
0471
0472 if (m_uGtAlgBlk.isValid() && !m_uGtAlgBlk->isEmpty(0)) {
0473 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
0474 m_prescaleSet = static_cast<unsigned int>(algBlk->getPreScColumn());
0475 } else {
0476 m_prescaleSet = 1;
0477 edm::LogError("L1TGlobalProduce")
0478 << "Could not find valid algo block. Setting prescale column to 1" << std::endl;
0479 }
0480 }
0481 } else {
0482
0483 m_prescaleSet = 0;
0484 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
0485 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
0486 m_triggerMaskVetoAlgoTrig = &m_initialTriggerMaskVetoAlgoTrig;
0487 }
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534 bool receiveMu = true;
0535 bool receiveMuShower = true;
0536 bool receiveEG = true;
0537 bool receiveTau = true;
0538 bool receiveJet = true;
0539 bool receiveEtSums = true;
0540 bool receiveEtSumsZdc = true;
0541 bool receiveCICADA = true;
0542 bool receiveExt = true;
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572 std::unique_ptr<GlobalAlgBlkBxCollection> uGtAlgRecord(
0573 new GlobalAlgBlkBxCollection(0, minEmulBxInEvent, maxEmulBxInEvent));
0574
0575
0576 std::unique_ptr<GlobalObjectMapRecord> gtObjectMapRecord(new GlobalObjectMapRecord());
0577
0578 std::unique_ptr<AXOL1TLScoreBxCollection> uGtAXOScoreRecord(nullptr);
0579 if (m_produceAXOL1TLScore) {
0580 uGtAXOScoreRecord = std::make_unique<AXOL1TLScoreBxCollection>();
0581 }
0582
0583
0584
0585
0586
0587
0588 int bxCross = iEvent.bunchCrossing();
0589 uint16_t bxCrossHw = 0;
0590 if ((bxCross & 0xFFF) == bxCross) {
0591 bxCrossHw = static_cast<uint16_t>(bxCross);
0592 } else {
0593 bxCrossHw = 0;
0594 if (m_verbosity) {
0595 LogDebug("L1TGlobalProducer") << "\nBunch cross number [hex] = " << std::hex << bxCross
0596 << "\n larger than 12 bits. Set to 0! \n"
0597 << std::dec << std::endl;
0598 }
0599 }
0600 LogDebug("L1TGlobalProducer") << "HW BxCross " << bxCrossHw << std::endl;
0601
0602
0603
0604 unsigned int pfAlgoSetIndex = m_prescaleSet;
0605
0606 auto max = (*m_prescaleFactorsAlgoTrig).size() - 1;
0607 if (pfAlgoSetIndex > max) {
0608 edm::LogWarning("L1TGlobalProducer") << "\nAttempting to access prescale algo set: " << m_prescaleSet
0609 << "\nNumber of prescale algo sets available: 0.." << max
0610 << "Setting former to latter." << std::endl;
0611 pfAlgoSetIndex = max;
0612 }
0613
0614 const std::vector<double>& prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
0615
0616
0617 m_initialTriggerMaskAlgoTrig.clear();
0618 for (unsigned int iAlgo = 0; iAlgo < prescaleFactorsAlgoTrig.size(); iAlgo++) {
0619 unsigned int value = prescaleFactorsAlgoTrig[iAlgo];
0620 value = (value == 0) ? 0 : 1;
0621 m_initialTriggerMaskAlgoTrig.push_back(value);
0622 }
0623 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
0624
0625 const std::vector<unsigned int>& triggerMaskAlgoTrig = *m_triggerMaskAlgoTrig;
0626 const std::vector<int>& triggerMaskVetoAlgoTrig = *m_triggerMaskVetoAlgoTrig;
0627
0628 LogDebug("L1TGlobalProducer") << "Size of prescale vector" << prescaleFactorsAlgoTrig.size() << std::endl;
0629
0630
0631 m_uGtBrd->receiveCaloObjectData(iEvent,
0632 m_egInputToken,
0633 m_tauInputToken,
0634 m_jetInputToken,
0635 m_sumInputToken,
0636 m_sumZdcInputToken,
0637 m_CICADAInputToken,
0638 receiveEG,
0639 m_nrL1EG,
0640 receiveTau,
0641 m_nrL1Tau,
0642 receiveJet,
0643 m_nrL1Jet,
0644 receiveEtSums,
0645 receiveEtSumsZdc,
0646 receiveCICADA);
0647
0648 m_uGtBrd->receiveMuonObjectData(iEvent, m_muInputToken, receiveMu, m_nrL1Mu, &muonVec_bxm2, &muonVec_bxm1);
0649
0650 if (m_useMuonShowers)
0651 m_uGtBrd->receiveMuonShowerObjectData(iEvent, m_muShowerInputToken, receiveMuShower, m_nrL1MuShower);
0652
0653
0654 m_uGtBrd->enableAXOScoreSaving(m_produceAXOL1TLScore);
0655
0656 m_uGtBrd->receiveExternalData(iEvent, m_extInputToken, receiveExt);
0657
0658
0659 for (int iBxInEvent = minEmulBxInEvent; iBxInEvent <= maxEmulBxInEvent; ++iBxInEvent) {
0660
0661 LogDebug("L1TGlobalProducer") << "\nL1TGlobalProducer : running GTL for bx = " << iBxInEvent << "\n" << std::endl;
0662
0663
0664 m_uGtBrd->runGTL(iEvent,
0665 evSetup,
0666 m_l1GtMenu.get(),
0667 m_produceL1GtObjectMapRecord,
0668 iBxInEvent,
0669 gtObjectMapRecord,
0670 m_numberPhysTriggers,
0671 m_nrL1Mu,
0672 m_nrL1MuShower,
0673 m_nrL1EG,
0674 m_nrL1Tau,
0675 m_nrL1Jet);
0676
0677
0678 LogDebug("L1TGlobalProducer") << "\nL1TGlobalProducer : running FDL for bx = " << iBxInEvent << "\n" << std::endl;
0679
0680
0681 m_uGtBrd->runFDL(iEvent,
0682 iBxInEvent,
0683 m_totalBxInEvent,
0684 m_numberPhysTriggers,
0685 prescaleFactorsAlgoTrig,
0686 triggerMaskAlgoTrig,
0687 triggerMaskVetoAlgoTrig,
0688 m_algorithmTriggersUnprescaled,
0689 m_algorithmTriggersUnmasked);
0690
0691
0692 if (m_produceL1GtDaqRecord) {
0693 m_uGtBrd->fillAlgRecord(iBxInEvent,
0694 uGtAlgRecord,
0695 m_prescaleSet,
0696 m_l1GtMenu->gtTriggerMenuUUID(),
0697 m_l1GtMenu->gtTriggerMenuImplementation());
0698 }
0699
0700
0701 if (m_produceAXOL1TLScore) {
0702 m_uGtBrd->fillAXOScore(iBxInEvent, uGtAXOScoreRecord);
0703 }
0704
0705 }
0706
0707 muonVec_bxm2 = muonVec_bxm1;
0708 muonVec_bxm1.clear();
0709 for (std::vector<const l1t::Muon*>::const_iterator iMu = (*(m_uGtBrd->getCandL1Mu())).begin(0);
0710 iMu != (*(m_uGtBrd->getCandL1Mu())).end(0);
0711 ++iMu) {
0712 muonVec_bxm1.push_back(**iMu);
0713 }
0714
0715 m_uGtBrd->reset();
0716
0717 if (m_verbosity && m_isDebugEnabled) {
0718 std::ostringstream myCoutStream;
0719
0720 for (int bx = minEmulBxInEvent; bx < maxEmulBxInEvent; bx++) {
0721
0722 (uGtAlgRecord->at(bx, 0)).print(myCoutStream);
0723 }
0724
0725 LogTrace("L1TGlobalProducer") << "\n The following L1 GT DAQ readout record was produced:\n"
0726 << myCoutStream.str() << "\n"
0727 << std::endl;
0728
0729 myCoutStream.str("");
0730 myCoutStream.clear();
0731
0732 const std::vector<GlobalObjectMap> objMapVec = gtObjectMapRecord->gtObjectMap();
0733
0734 for (std::vector<GlobalObjectMap>::const_iterator it = objMapVec.begin(); it != objMapVec.end(); ++it) {
0735 (*it).print(myCoutStream);
0736 }
0737
0738 LogDebug("L1TGlobalProducer") << "Test gtObjectMapRecord in L1TGlobalProducer \n\n"
0739 << myCoutStream.str() << "\n\n"
0740 << std::endl;
0741
0742 myCoutStream.str("");
0743 myCoutStream.clear();
0744 }
0745
0746
0747 if (m_produceL1GtDaqRecord) {
0748 iEvent.put(std::move(uGtAlgRecord));
0749 }
0750
0751 if (m_produceL1GtObjectMapRecord) {
0752 iEvent.put(std::move(gtObjectMapRecord));
0753 }
0754
0755 if (m_produceAXOL1TLScore) {
0756 iEvent.put(std::move(uGtAXOScoreRecord), "AXOScore");
0757 }
0758 }
0759
0760
0761 #include "FWCore/PluginManager/interface/ModuleDef.h"
0762 #include "FWCore/Framework/interface/MakerMacros.h"
0763 #include <cstdint>
0764 DEFINE_FWK_MODULE(L1TGlobalProducer);