File indexing completed on 2024-10-08 05:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0018
0019
0020 #include <bitset>
0021 #include <iomanip>
0022 #include <iostream>
0023
0024
0025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0028
0029 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCand.h"
0030
0031 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
0032 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0033 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0034 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
0035 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0036 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
0037
0038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0039
0040 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0041 #include "FWCore/Utilities/interface/Exception.h"
0042
0043 #include "FWCore/Framework/interface/Event.h"
0044 #include "FWCore/Utilities/interface/InputTag.h"
0045
0046
0047
0048
0049 L1GlobalTriggerPSB::L1GlobalTriggerPSB(const edm::InputTag &m_caloGctInputTag,
0050 const std::vector<edm::InputTag> &m_technicalTriggersInputTags,
0051 edm::ConsumesCollector &&iC)
0052 : m_candL1NoIsoEG(new std::vector<const L1GctCand *>),
0053 m_candL1IsoEG(new std::vector<const L1GctCand *>),
0054 m_candL1CenJet(new std::vector<const L1GctCand *>),
0055 m_candL1ForJet(new std::vector<const L1GctCand *>),
0056 m_candL1TauJet(new std::vector<const L1GctCand *>),
0057 m_candETM(nullptr),
0058 m_candETT(nullptr),
0059 m_candHTT(nullptr),
0060 m_candHTM(nullptr),
0061 m_candJetCounts(nullptr),
0062 m_candHfBitCounts(nullptr),
0063 m_candHfRingEtSums(nullptr),
0064 m_isDebugEnabled(edm::isDebugEnabled())
0065
0066 {
0067 iC.consumes<L1GctEmCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "nonIsoEm", ""));
0068 iC.consumes<L1GctEmCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "isoEm", ""));
0069 iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "cenJets", ""));
0070 iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "forJets", ""));
0071 iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "tauJets", ""));
0072 iC.consumes<L1GctEtMissCollection>(m_caloGctInputTag);
0073 iC.consumes<L1GctEtTotalCollection>(m_caloGctInputTag);
0074 iC.consumes<L1GctEtHadCollection>(m_caloGctInputTag);
0075 iC.consumes<L1GctHtMissCollection>(m_caloGctInputTag);
0076 iC.consumes<L1GctJetCountsCollection>(m_caloGctInputTag);
0077 iC.consumes<L1GctHFBitCountsCollection>(m_caloGctInputTag);
0078 iC.consumes<L1GctHFRingEtSumsCollection>(m_caloGctInputTag);
0079
0080 for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin();
0081 it != m_technicalTriggersInputTags.end();
0082 it++) {
0083 iC.consumes<L1GtTechnicalTriggerRecord>((*it));
0084 }
0085
0086 }
0087
0088
0089 L1GlobalTriggerPSB::~L1GlobalTriggerPSB() {
0090 reset();
0091
0092 delete m_candL1NoIsoEG;
0093 delete m_candL1IsoEG;
0094 delete m_candL1CenJet;
0095 delete m_candL1ForJet;
0096 delete m_candL1TauJet;
0097 }
0098
0099
0100 void L1GlobalTriggerPSB::init(const int nrL1NoIsoEG,
0101 const int nrL1IsoEG,
0102 const int nrL1CenJet,
0103 const int nrL1ForJet,
0104 const int nrL1TauJet,
0105 const int numberTechnicalTriggers) {
0106 m_candL1NoIsoEG->reserve(nrL1NoIsoEG);
0107 m_candL1IsoEG->reserve(nrL1IsoEG);
0108 m_candL1CenJet->reserve(nrL1CenJet);
0109 m_candL1ForJet->reserve(nrL1ForJet);
0110 m_candL1TauJet->reserve(nrL1TauJet);
0111
0112 m_gtTechnicalTriggers.reserve(numberTechnicalTriggers);
0113 m_gtTechnicalTriggers.assign(numberTechnicalTriggers, false);
0114 }
0115
0116
0117
0118 void L1GlobalTriggerPSB::receiveGctObjectData(edm::Event &iEvent,
0119 const edm::InputTag &caloGctInputTag,
0120 const int iBxInEvent,
0121 const bool receiveNoIsoEG,
0122 const int nrL1NoIsoEG,
0123 const bool receiveIsoEG,
0124 const int nrL1IsoEG,
0125 const bool receiveCenJet,
0126 const int nrL1CenJet,
0127 const bool receiveForJet,
0128 const int nrL1ForJet,
0129 const bool receiveTauJet,
0130 const int nrL1TauJet,
0131 const bool receiveETM,
0132 const bool receiveETT,
0133 const bool receiveHTT,
0134 const bool receiveHTM,
0135 const bool receiveJetCounts,
0136 const bool receiveHfBitCounts,
0137 const bool receiveHfRingEtSums) {
0138
0139
0140
0141
0142
0143
0144 reset();
0145
0146 std::ostringstream warningsStream;
0147 bool warningEnabled = edm::isWarningEnabled();
0148
0149 if (receiveNoIsoEG) {
0150
0151 edm::Handle<L1GctEmCandCollection> emCands;
0152 iEvent.getByLabel(caloGctInputTag.label(), "nonIsoEm", emCands);
0153
0154 if (!emCands.isValid()) {
0155 if (warningEnabled) {
0156 warningsStream << "\nWarning: L1GctEmCandCollection with input label " << caloGctInputTag.label()
0157 << " and instance \"nonIsoEm\" \n"
0158 << "requested in configuration, but not found in the event.\n"
0159 << std::endl;
0160 }
0161 } else {
0162 for (L1GctEmCandCollection::const_iterator it = emCands->begin(); it != emCands->end(); it++) {
0163 if ((*it).bx() == iBxInEvent) {
0164 (*m_candL1NoIsoEG).push_back(&(*it));
0165
0166 }
0167 }
0168 }
0169 }
0170
0171 if (receiveIsoEG) {
0172
0173 edm::Handle<L1GctEmCandCollection> isoEmCands;
0174 iEvent.getByLabel(caloGctInputTag.label(), "isoEm", isoEmCands);
0175
0176 if (!isoEmCands.isValid()) {
0177 if (warningEnabled) {
0178 warningsStream << "\nWarning: L1GctEmCandCollection with input label " << caloGctInputTag.label()
0179 << " and instance \"isoEm\" \n"
0180 << "requested in configuration, but not found in the event.\n"
0181 << std::endl;
0182 }
0183 } else {
0184 for (L1GctEmCandCollection::const_iterator it = isoEmCands->begin(); it != isoEmCands->end(); it++) {
0185 if ((*it).bx() == iBxInEvent) {
0186 (*m_candL1IsoEG).push_back(&(*it));
0187
0188 }
0189 }
0190 }
0191 }
0192
0193 if (receiveCenJet) {
0194
0195 edm::Handle<L1GctJetCandCollection> cenJets;
0196 iEvent.getByLabel(caloGctInputTag.label(), "cenJets", cenJets);
0197
0198 if (!cenJets.isValid()) {
0199 if (warningEnabled) {
0200 warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0201 << " and instance \"cenJets\" \n"
0202 << "requested in configuration, but not found in the event.\n"
0203 << std::endl;
0204 }
0205 } else {
0206 for (L1GctJetCandCollection::const_iterator it = cenJets->begin(); it != cenJets->end(); it++) {
0207 if ((*it).bx() == iBxInEvent) {
0208 (*m_candL1CenJet).push_back(&(*it));
0209
0210 }
0211 }
0212 }
0213 }
0214
0215 if (receiveForJet) {
0216
0217 edm::Handle<L1GctJetCandCollection> forJets;
0218 iEvent.getByLabel(caloGctInputTag.label(), "forJets", forJets);
0219
0220 if (!forJets.isValid()) {
0221 if (warningEnabled) {
0222 warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0223 << " and instance \"forJets\" \n"
0224 << "requested in configuration, but not found in the event.\n"
0225 << std::endl;
0226 }
0227 } else {
0228 for (L1GctJetCandCollection::const_iterator it = forJets->begin(); it != forJets->end(); it++) {
0229 if ((*it).bx() == iBxInEvent) {
0230 (*m_candL1ForJet).push_back(&(*it));
0231
0232 }
0233 }
0234 }
0235 }
0236
0237 if (receiveTauJet) {
0238
0239 edm::Handle<L1GctJetCandCollection> tauJets;
0240 iEvent.getByLabel(caloGctInputTag.label(), "tauJets", tauJets);
0241
0242 if (!tauJets.isValid()) {
0243 if (warningEnabled) {
0244 warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0245 << " and instance \"tauJets\" \n"
0246 << "requested in configuration, but not found in the event.\n"
0247 << std::endl;
0248 }
0249 } else {
0250 for (L1GctJetCandCollection::const_iterator it = tauJets->begin(); it != tauJets->end(); it++) {
0251 if ((*it).bx() == iBxInEvent) {
0252 (*m_candL1TauJet).push_back(&(*it));
0253
0254 }
0255 }
0256 }
0257 }
0258
0259
0260 if (receiveETM) {
0261 edm::Handle<L1GctEtMissCollection> missEtColl;
0262 iEvent.getByLabel(caloGctInputTag, missEtColl);
0263
0264 if (!missEtColl.isValid()) {
0265 if (warningEnabled) {
0266 warningsStream << "\nWarning: L1GctEtMissCollection with input tag " << caloGctInputTag
0267 << "\nrequested in configuration, but not found in the event.\n"
0268 << std::endl;
0269 }
0270 } else {
0271 for (L1GctEtMissCollection::const_iterator it = missEtColl->begin(); it != missEtColl->end(); it++) {
0272 if ((*it).bx() == iBxInEvent) {
0273 m_candETM = &(*it);
0274
0275 }
0276 }
0277 }
0278 }
0279
0280
0281 if (receiveETT) {
0282 edm::Handle<L1GctEtTotalCollection> sumEtColl;
0283 iEvent.getByLabel(caloGctInputTag, sumEtColl);
0284
0285 if (!sumEtColl.isValid()) {
0286 if (warningEnabled) {
0287 warningsStream << "\nWarning: L1GctEtTotalCollection with input tag " << caloGctInputTag
0288 << "\nrequested in configuration, but not found in the event.\n"
0289 << std::endl;
0290 }
0291 } else {
0292 for (L1GctEtTotalCollection::const_iterator it = sumEtColl->begin(); it != sumEtColl->end(); it++) {
0293 if ((*it).bx() == iBxInEvent) {
0294 m_candETT = &(*it);
0295
0296 }
0297 }
0298 }
0299 }
0300
0301
0302 if (receiveHTT) {
0303 edm::Handle<L1GctEtHadCollection> sumHtColl;
0304 iEvent.getByLabel(caloGctInputTag, sumHtColl);
0305
0306 if (!sumHtColl.isValid()) {
0307 if (warningEnabled) {
0308 warningsStream << "\nWarning: L1GctEtHadCollection with input tag " << caloGctInputTag
0309 << "\nrequested in configuration, but not found in the event.\n"
0310 << std::endl;
0311 }
0312 } else {
0313 for (L1GctEtHadCollection::const_iterator it = sumHtColl->begin(); it != sumHtColl->end(); it++) {
0314 if ((*it).bx() == iBxInEvent) {
0315 m_candHTT = &(*it);
0316
0317 }
0318 }
0319 }
0320 }
0321
0322
0323 if (receiveHTM) {
0324 edm::Handle<L1GctHtMissCollection> missHtColl;
0325 iEvent.getByLabel(caloGctInputTag, missHtColl);
0326
0327 if (!missHtColl.isValid()) {
0328 if (warningEnabled) {
0329 warningsStream << "\nWarning: L1GctHtMissCollection with input tag " << caloGctInputTag
0330 << "\nrequested in configuration, but not found in the event.\n"
0331 << std::endl;
0332 }
0333 } else {
0334 for (L1GctHtMissCollection::const_iterator it = missHtColl->begin(); it != missHtColl->end(); it++) {
0335 if ((*it).bx() == iBxInEvent) {
0336 m_candHTM = &(*it);
0337
0338 }
0339 }
0340 }
0341 }
0342
0343
0344 if (receiveJetCounts) {
0345 edm::Handle<L1GctJetCountsCollection> jetCountColl;
0346 iEvent.getByLabel(caloGctInputTag, jetCountColl);
0347
0348 if (!jetCountColl.isValid()) {
0349 if (warningEnabled) {
0350 warningsStream << "\nWarning: L1GctJetCountsCollection with input tag " << caloGctInputTag
0351 << "\nrequested in configuration, but not found in the event.\n"
0352 << std::endl;
0353 }
0354 } else {
0355 for (L1GctJetCountsCollection::const_iterator it = jetCountColl->begin(); it != jetCountColl->end(); it++) {
0356 if ((*it).bx() == iBxInEvent) {
0357 m_candJetCounts = &(*it);
0358
0359 }
0360 }
0361 }
0362 }
0363
0364
0365 if (receiveHfBitCounts) {
0366 edm::Handle<L1GctHFBitCountsCollection> hfBitCountsColl;
0367 iEvent.getByLabel(caloGctInputTag, hfBitCountsColl);
0368
0369 if (!hfBitCountsColl.isValid()) {
0370 if (warningEnabled) {
0371 warningsStream << "\nWarning: L1GctHFBitCountsCollection with input tag " << caloGctInputTag
0372 << "\nrequested in configuration, but not found in the event.\n"
0373 << std::endl;
0374 }
0375 } else {
0376 for (L1GctHFBitCountsCollection::const_iterator it = hfBitCountsColl->begin(); it != hfBitCountsColl->end();
0377 it++) {
0378 if ((*it).bx() == iBxInEvent) {
0379 m_candHfBitCounts = &(*it);
0380
0381
0382 }
0383 }
0384 }
0385 }
0386
0387
0388 if (receiveHfRingEtSums) {
0389 edm::Handle<L1GctHFRingEtSumsCollection> hfRingEtSums;
0390 iEvent.getByLabel(caloGctInputTag, hfRingEtSums);
0391
0392 if (!hfRingEtSums.isValid()) {
0393 if (warningEnabled) {
0394 warningsStream << "\nWarning: L1GctHFRingEtSumsCollection with input tag " << caloGctInputTag
0395 << "\nrequested in configuration, but not found in the event.\n"
0396 << std::endl;
0397 }
0398 } else {
0399 for (L1GctHFRingEtSumsCollection::const_iterator it = hfRingEtSums->begin(); it != hfRingEtSums->end(); it++) {
0400 if ((*it).bx() == iBxInEvent) {
0401 m_candHfRingEtSums = &(*it);
0402
0403
0404 }
0405 }
0406 }
0407 }
0408
0409 if (m_verbosity && warningEnabled) {
0410 if (warningsStream.tellp() > 0) {
0411 edm::LogWarning("L1GlobalTrigger") << warningsStream.str();
0412 }
0413 }
0414
0415 if (m_verbosity && m_isDebugEnabled) {
0416 LogDebug("L1GlobalTrigger") << "\n**** L1GlobalTriggerPSB receiving calorimeter data for BxInEvent "
0417 "= "
0418 << iBxInEvent << "\n from " << caloGctInputTag << "\n"
0419 << std::endl;
0420
0421 printGctObjectData(iBxInEvent);
0422 }
0423 }
0424
0425
0426 void L1GlobalTriggerPSB::receiveCastorData(edm::Event &iEvent,
0427 const edm::InputTag &castorInputTag,
0428 const int iBxInEvent,
0429 const bool receiveCastor,
0430 const bool readFromPsb) {
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466 }
0467
0468
0469
0470
0471 void L1GlobalTriggerPSB::receiveBptxData(edm::Event &iEvent,
0472 const edm::InputTag &bptxInputTag,
0473 const int iBxInEvent,
0474 const bool receiveBptx,
0475 const bool readFromPsb) {}
0476
0477
0478
0479
0480 void L1GlobalTriggerPSB::receiveExternalData(edm::Event &iEvent,
0481 const std::vector<edm::InputTag> &externalInputTags,
0482 const int iBxInEvent,
0483 const bool receiveExternal,
0484 const bool readFromPsb) {}
0485
0486
0487
0488
0489 void L1GlobalTriggerPSB::receiveTechnicalTriggers(edm::Event &iEvent,
0490 const std::vector<edm::InputTag> &technicalTriggersInputTags,
0491 const int iBxInEvent,
0492 const bool receiveTechTr,
0493 const int nrL1TechTr) {
0494 std::ostringstream warningsStream;
0495 bool warningEnabled = edm::isWarningEnabled();
0496
0497
0498 m_gtTechnicalTriggers = std::vector<bool>(nrL1TechTr, false);
0499
0500 if (receiveTechTr) {
0501
0502
0503
0504
0505 for (std::vector<edm::InputTag>::const_iterator it = technicalTriggersInputTags.begin();
0506 it != technicalTriggersInputTags.end();
0507 it++) {
0508 edm::Handle<L1GtTechnicalTriggerRecord> techTrigRecord;
0509 iEvent.getByLabel((*it), techTrigRecord);
0510
0511 if (!techTrigRecord.isValid()) {
0512 if (warningEnabled) {
0513 warningsStream << "\nWarning: L1GtTechnicalTriggerRecord with input tag " << (*it)
0514 << "\nrequested in configuration, but not found in the event.\n"
0515 << std::endl;
0516 }
0517 } else {
0518 const std::vector<L1GtTechnicalTrigger> &ttVec = techTrigRecord->gtTechnicalTrigger();
0519 size_t ttVecSize = ttVec.size();
0520
0521 for (size_t iTT = 0; iTT < ttVecSize; ++iTT) {
0522 const L1GtTechnicalTrigger &ttBxRecord = ttVec[iTT];
0523 int ttBxInEvent = ttBxRecord.bxInEvent();
0524
0525 if (ttBxInEvent == iBxInEvent) {
0526 int ttBitNumber = ttBxRecord.gtTechnicalTriggerBitNumber();
0527 bool ttResult = ttBxRecord.gtTechnicalTriggerResult();
0528
0529 m_gtTechnicalTriggers.at(ttBitNumber) = ttResult;
0530
0531 if (m_verbosity) {
0532 LogTrace("L1GlobalTrigger") << "Add for BxInEvent " << iBxInEvent << " the technical trigger produced by "
0533 << (*it) << " : name " << (ttBxRecord.gtTechnicalTriggerName())
0534 << " , bit number " << ttBitNumber << " and result " << ttResult << std::endl;
0535 }
0536 }
0537 }
0538 }
0539 }
0540 }
0541
0542 if (m_verbosity && warningEnabled) {
0543 if (warningsStream.tellp() > 0) {
0544 edm::LogWarning("L1GlobalTrigger") << warningsStream.str();
0545 }
0546 }
0547
0548 if (m_verbosity && m_isDebugEnabled) {
0549 LogDebug("L1GlobalTrigger") << "\n**** L1GlobalTriggerPSB receiving technical triggers: " << std::endl;
0550
0551 int sizeW64 = 64;
0552 int iBit = 0;
0553
0554 std::ostringstream myCout;
0555
0556 for (std::vector<bool>::reverse_iterator ritBit = m_gtTechnicalTriggers.rbegin();
0557 ritBit != m_gtTechnicalTriggers.rend();
0558 ++ritBit) {
0559 myCout << (*ritBit ? '1' : '0');
0560
0561 if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0562 myCout << " ";
0563 }
0564
0565 iBit++;
0566 }
0567
0568 LogTrace("L1GlobalTrigger") << myCout.str() << "\n" << std::endl;
0569 }
0570 }
0571
0572
0573 void L1GlobalTriggerPSB::fillPsbBlock(edm::Event &iEvent,
0574 const uint16_t &activeBoardsGtDaq,
0575 const int recordLength0,
0576 const int recordLength1,
0577 const unsigned int altNrBxBoardDaq,
0578 const std::vector<L1GtBoard> &boardMaps,
0579 const int iBxInEvent,
0580 L1GlobalTriggerReadoutRecord *gtDaqReadoutRecord) {
0581
0582
0583 int bxCross = iEvent.bunchCrossing();
0584 uint16_t bxCrossHw = 0;
0585 if ((bxCross & 0xFFF) == bxCross) {
0586 bxCrossHw = static_cast<uint16_t>(bxCross);
0587 } else {
0588 bxCrossHw = 0;
0589 if (m_verbosity) {
0590 LogDebug("L1GlobalTrigger") << "\nBunch cross number [hex] = " << std::hex << bxCross
0591 << "\n larger than 12 bits. Set to 0! \n"
0592 << std::dec << std::endl;
0593 }
0594 }
0595
0596 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
0597
0598
0599
0600
0601 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
0602 int iPosition = itBoard->gtPositionDaqRecord();
0603 if (iPosition > 0) {
0604 int iActiveBit = itBoard->gtBitDaqActiveBoards();
0605 bool activeBoard = false;
0606 bool writeBoard = false;
0607
0608 int recLength = -1;
0609
0610 if (iActiveBit >= 0) {
0611 activeBoard = activeBoardsGtDaq & (1 << iActiveBit);
0612
0613 int altNrBxBoard = (altNrBxBoardDaq & (1 << iActiveBit)) >> iActiveBit;
0614
0615 if (altNrBxBoard == 1) {
0616 recLength = recordLength1;
0617 } else {
0618 recLength = recordLength0;
0619 }
0620
0621 int lowBxInEvent = (recLength + 1) / 2 - recLength;
0622 int uppBxInEvent = (recLength + 1) / 2 - 1;
0623
0624 if ((iBxInEvent >= lowBxInEvent) && (iBxInEvent <= uppBxInEvent)) {
0625 writeBoard = true;
0626 }
0627
0628
0629
0630
0631
0632
0633
0634
0635 }
0636
0637
0638
0639
0640
0641
0642
0643
0644 if (activeBoard && writeBoard && (itBoard->gtBoardType() == PSB)) {
0645 L1GtPsbWord psbWordValue;
0646
0647
0648 psbWordValue.setBoardId(itBoard->gtBoardId());
0649
0650
0651 psbWordValue.setBxInEvent(iBxInEvent);
0652
0653
0654 uint16_t bxNrValue = bxCrossHw;
0655 psbWordValue.setBxNr(bxNrValue);
0656
0657
0658 psbWordValue.setEventNr(static_cast<uint32_t>(iEvent.id().event()));
0659
0660
0661
0662 uint16_t localBxNrValue = bxCrossHw;
0663 psbWordValue.setLocalBxNr(localBxNrValue);
0664
0665
0666
0667
0668 int nrObjRow = 2;
0669
0670 std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
0671 int nrCables = quadInPsb.size();
0672
0673 uint16_t aDataVal = 0;
0674 uint16_t bDataVal = 0;
0675
0676 int iCable = -1;
0677 for (std::vector<L1GtPsbQuad>::const_iterator itQuad = quadInPsb.begin(); itQuad != quadInPsb.end(); ++itQuad) {
0678 iCable++;
0679
0680 int iAB = (nrCables - iCable - 1) * nrObjRow;
0681
0682 switch (*itQuad) {
0683 case TechTr: {
0684
0685
0686
0687
0688
0689
0690
0691
0692 int bitsPerWord = 16;
0693
0694
0695 int iPair = 0;
0696 aDataVal = 0;
0697
0698 int iBit = 0;
0699 uint16_t bitVal = 0;
0700
0701 for (int i = 0; i < bitsPerWord; ++i) {
0702 if (m_gtTechnicalTriggers[iBit]) {
0703 bitVal = 1;
0704 } else {
0705 bitVal = 0;
0706 }
0707
0708 aDataVal = aDataVal | (bitVal << i);
0709 iBit++;
0710 }
0711 psbWordValue.setAData(aDataVal, iAB + iPair);
0712
0713
0714 bDataVal = 0;
0715
0716 for (int i = 0; i < bitsPerWord; ++i) {
0717 if (m_gtTechnicalTriggers[iBit]) {
0718 bitVal = 1;
0719 } else {
0720 bitVal = 0;
0721 }
0722
0723 bDataVal = bDataVal | (bitVal << i);
0724 iBit++;
0725 }
0726 psbWordValue.setBData(bDataVal, iAB + iPair);
0727
0728
0729 iPair = 1;
0730 aDataVal = 0;
0731
0732 for (int i = 0; i < bitsPerWord; ++i) {
0733 if (m_gtTechnicalTriggers[iBit]) {
0734 bitVal = 1;
0735 } else {
0736 bitVal = 0;
0737 }
0738
0739 aDataVal = aDataVal | (bitVal << i);
0740 iBit++;
0741 }
0742 psbWordValue.setAData(aDataVal, iAB + iPair);
0743
0744 bDataVal = 0;
0745
0746 for (int i = 0; i < bitsPerWord; ++i) {
0747 if (m_gtTechnicalTriggers[iBit]) {
0748 bitVal = 1;
0749 } else {
0750 bitVal = 0;
0751 }
0752
0753 bDataVal = bDataVal | (bitVal << i);
0754 iBit++;
0755 }
0756 psbWordValue.setBData(bDataVal, iAB + iPair);
0757 }
0758
0759 break;
0760 case NoIsoEGQ: {
0761
0762
0763
0764
0765
0766
0767
0768 int recL1NoIsoEG = m_candL1NoIsoEG->size();
0769 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0770 if (iPair < recL1NoIsoEG) {
0771 aDataVal = (static_cast<const L1GctEmCand *>((*m_candL1NoIsoEG)[iPair]))->raw();
0772 } else {
0773 aDataVal = 0;
0774 }
0775 psbWordValue.setAData(aDataVal, iAB + iPair);
0776
0777 if ((iPair + nrObjRow) < recL1NoIsoEG) {
0778 bDataVal = (static_cast<const L1GctEmCand *>((*m_candL1NoIsoEG)[iPair + nrObjRow]))->raw();
0779 } else {
0780 bDataVal = 0;
0781 }
0782 psbWordValue.setBData(bDataVal, iAB + iPair);
0783 }
0784 }
0785
0786 break;
0787 case IsoEGQ: {
0788
0789
0790
0791
0792
0793
0794
0795 int recL1IsoEG = m_candL1IsoEG->size();
0796 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0797 if (iPair < recL1IsoEG) {
0798 aDataVal = (static_cast<const L1GctEmCand *>((*m_candL1IsoEG)[iPair]))->raw();
0799 } else {
0800 aDataVal = 0;
0801 }
0802 psbWordValue.setAData(aDataVal, iAB + iPair);
0803
0804 if ((iPair + nrObjRow) < recL1IsoEG) {
0805 bDataVal = (static_cast<const L1GctEmCand *>((*m_candL1IsoEG)[iPair + nrObjRow]))->raw();
0806 } else {
0807 bDataVal = 0;
0808 }
0809 psbWordValue.setBData(bDataVal, iAB + iPair);
0810 }
0811
0812 }
0813
0814 break;
0815 case CenJetQ: {
0816
0817
0818
0819
0820
0821
0822
0823 int recL1CenJet = m_candL1CenJet->size();
0824 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0825 if (iPair < recL1CenJet) {
0826 aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1CenJet)[iPair]))->raw();
0827 } else {
0828 aDataVal = 0;
0829 }
0830 psbWordValue.setAData(aDataVal, iAB + iPair);
0831
0832 if ((iPair + nrObjRow) < recL1CenJet) {
0833 bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1CenJet)[iPair + nrObjRow]))->raw();
0834 } else {
0835 bDataVal = 0;
0836 }
0837 psbWordValue.setBData(bDataVal, iAB + iPair);
0838 }
0839 }
0840
0841 break;
0842 case ForJetQ: {
0843
0844
0845
0846
0847
0848
0849
0850 int recL1ForJet = m_candL1ForJet->size();
0851 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0852 if (iPair < recL1ForJet) {
0853 aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1ForJet)[iPair]))->raw();
0854 } else {
0855 aDataVal = 0;
0856 }
0857 psbWordValue.setAData(aDataVal, iAB + iPair);
0858
0859 if ((iPair + nrObjRow) < recL1ForJet) {
0860 bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1ForJet)[iPair + nrObjRow]))->raw();
0861 } else {
0862 bDataVal = 0;
0863 }
0864 psbWordValue.setBData(bDataVal, iAB + iPair);
0865 }
0866
0867 }
0868
0869 break;
0870 case TauJetQ: {
0871
0872
0873
0874
0875
0876
0877
0878 int recL1TauJet = m_candL1TauJet->size();
0879 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0880 if (iPair < recL1TauJet) {
0881 aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1TauJet)[iPair]))->raw();
0882 } else {
0883 aDataVal = 0;
0884 }
0885 psbWordValue.setAData(aDataVal, iAB + iPair);
0886
0887 if ((iPair + nrObjRow) < recL1TauJet) {
0888 bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1TauJet)[iPair + nrObjRow]))->raw();
0889 } else {
0890 bDataVal = 0;
0891 }
0892 psbWordValue.setBData(bDataVal, iAB + iPair);
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902 }
0903
0904 }
0905
0906 break;
0907 case ESumsQ: {
0908
0909
0910
0911
0912
0913
0914
0915
0916 int iPair = 0;
0917
0918 if (m_candETT) {
0919 aDataVal = m_candETT->raw();
0920 } else {
0921 aDataVal = 0;
0922 }
0923 psbWordValue.setAData(aDataVal, iAB + iPair);
0924
0925 if (m_candHTT) {
0926 bDataVal = m_candHTT->raw();
0927 } else {
0928 bDataVal = 0;
0929 }
0930 psbWordValue.setBData(bDataVal, iAB + iPair);
0931
0932
0933
0934
0935
0936
0937
0938
0939 iPair = 1;
0940 if (m_candETM) {
0941
0942 aDataVal = m_candETM->raw() & 0x0000FFFF;
0943
0944
0945
0946
0947
0948
0949
0950 } else {
0951 aDataVal = 0;
0952 }
0953 psbWordValue.setAData(aDataVal, iAB + iPair);
0954
0955 if (m_candETM) {
0956
0957 bDataVal = (m_candETM->raw() & 0xFFFF0000) >> 16;
0958
0959
0960
0961
0962
0963 } else {
0964 bDataVal = 0;
0965 }
0966 psbWordValue.setBData(bDataVal, iAB + iPair);
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977 }
0978
0979 break;
0980 case JetCountsQ: {
0981
0982
0983
0984
0985
0986
0987
0988
0989 int jetCountsBits = 5;
0990 int countsPerWord = 3;
0991
0992
0993 int iPair = 0;
0994 aDataVal = 0;
0995 bDataVal = 0;
0996
0997 int iCount = 0;
0998
0999 if (m_candJetCounts) {
1000 for (int i = 0; i < countsPerWord; ++i) {
1001 aDataVal = aDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1002 iCount++;
1003 }
1004
1005
1006
1007 for (int i = 0; i < countsPerWord; ++i) {
1008 bDataVal = bDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1009 iCount++;
1010 }
1011 }
1012
1013 psbWordValue.setAData(aDataVal, iAB + iPair);
1014 psbWordValue.setBData(bDataVal, iAB + iPair);
1015
1016
1017 iPair = 1;
1018 aDataVal = 0;
1019 bDataVal = 0;
1020
1021 if (m_candJetCounts) {
1022 for (int i = 0; i < countsPerWord; ++i) {
1023 aDataVal = aDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1024 iCount++;
1025 }
1026
1027
1028
1029 for (int i = 0; i < countsPerWord; ++i) {
1030 bDataVal = bDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1031 iCount++;
1032 }
1033 }
1034
1035 psbWordValue.setAData(aDataVal, iAB + iPair);
1036 psbWordValue.setBData(bDataVal, iAB + iPair);
1037 }
1038
1039 break;
1040
1041 case HfQ: {
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053 int hfBits = 3;
1054
1055 L1GctHFBitCounts hfBitCounts;
1056 int nHfBitCounts = hfBitCounts.nCounts();
1057
1058 L1GctHFRingEtSums hfRingEtSums;
1059 int nHfRingEtSums = hfRingEtSums.nSums();
1060
1061
1062 int iPair = 0;
1063 aDataVal = 0;
1064 bDataVal = 0;
1065
1066
1067 int hfPerWord = sizeof(aDataVal) * 8 / hfBits;
1068
1069
1070
1071
1072
1073
1074 int iHf = 0;
1075 bool aDataFlag = true;
1076 bool bDataFlag = false;
1077
1078 if (m_candHfBitCounts) {
1079 for (int i = 0; i < nHfBitCounts; ++i) {
1080 if (aDataFlag) {
1081 if (iHf < hfPerWord) {
1082
1083 aDataVal = aDataVal | ((m_candHfBitCounts->bitCount(i)) << (hfBits * iHf));
1084 iHf++;
1085
1086
1087
1088
1089 } else {
1090 aDataFlag = false;
1091 bDataFlag = true;
1092 iHf = 0;
1093 }
1094 }
1095
1096 if (bDataFlag) {
1097 if (iHf < hfPerWord) {
1098
1099 bDataVal = bDataVal | ((m_candHfBitCounts->bitCount(i)) << (hfBits * iHf));
1100 iHf++;
1101
1102
1103
1104
1105 } else {
1106 aDataFlag = false;
1107 bDataFlag = false;
1108 iHf = 0;
1109 }
1110 }
1111 }
1112 } else {
1113
1114
1115
1116
1117
1118 }
1119
1120 if (aDataFlag && bDataFlag) {
1121 LogTrace("L1GlobalTrigger")
1122 << "\n HfBitCounts collection filled aData and bData [" << (iAB + iPair) << "]"
1123 << "\n HfRingEtSums collection has no space to be written" << std::endl;
1124 }
1125
1126 if (m_candHfRingEtSums) {
1127 for (int i = 0; i < nHfRingEtSums; ++i) {
1128 if (aDataFlag) {
1129 if (iHf < hfPerWord) {
1130
1131 aDataVal = aDataVal | ((m_candHfRingEtSums->etSum(i)) << (hfBits * iHf));
1132 iHf++;
1133
1134
1135
1136
1137 } else {
1138 aDataFlag = false;
1139 bDataFlag = true;
1140 iHf = 0;
1141 }
1142 }
1143
1144 if (bDataFlag) {
1145 if (iHf < hfPerWord) {
1146
1147 bDataVal = bDataVal | ((m_candHfRingEtSums->etSum(i)) << (hfBits * iHf));
1148 iHf++;
1149
1150
1151
1152
1153 } else {
1154 aDataFlag = false;
1155 bDataFlag = false;
1156 iHf = 0;
1157 }
1158 }
1159 }
1160 } else {
1161 iHf = nHfRingEtSums % hfPerWord;
1162
1163
1164
1165
1166 }
1167
1168 psbWordValue.setAData(aDataVal, iAB + iPair);
1169 psbWordValue.setBData(bDataVal, iAB + iPair);
1170
1171
1172
1173
1174
1175
1176
1177
1178 if (aDataFlag && bDataFlag) {
1179 LogTrace("L1GlobalTrigger") << "\n aData and bData [" << (iAB + iPair) << "] full"
1180 << "\n HfRingEtSums collection has not enough space to be "
1181 "written"
1182 << std::endl;
1183 }
1184
1185 }
1186
1187 break;
1188 default: {
1189
1190 }
1191
1192 break;
1193 }
1194
1195 }
1196
1197
1198
1199
1200
1201
1202
1203 gtDaqReadoutRecord->setGtPsbWord(psbWordValue);
1204
1205 }
1206
1207 }
1208
1209 }
1210 }
1211
1212
1213
1214 void L1GlobalTriggerPSB::reset() {
1215 m_candL1NoIsoEG->clear();
1216 m_candL1IsoEG->clear();
1217 m_candL1CenJet->clear();
1218 m_candL1ForJet->clear();
1219 m_candL1TauJet->clear();
1220
1221
1222 m_candETM = nullptr;
1223 m_candETT = nullptr;
1224 m_candHTT = nullptr;
1225 m_candHTM = nullptr;
1226
1227 m_candJetCounts = nullptr;
1228
1229 m_candHfBitCounts = nullptr;
1230 m_candHfRingEtSums = nullptr;
1231 }
1232
1233
1234
1235 void L1GlobalTriggerPSB::printGctObjectData(const int iBxInEvent) const {
1236 LogTrace("L1GlobalTrigger") << "\nL1GlobalTrigger: GCT data [hex] received by PSBs for BxInEvent = " << iBxInEvent
1237 << "\n"
1238 << std::endl;
1239
1240 std::vector<const L1GctCand *>::const_iterator iterConst;
1241
1242 LogTrace("L1GlobalTrigger") << " GCT NoIsoEG " << std::endl;
1243 for (iterConst = m_candL1NoIsoEG->begin(); iterConst != m_candL1NoIsoEG->end(); iterConst++) {
1244 LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1245 << " Eta index = " << (*iterConst)->etaIndex()
1246 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1247 }
1248
1249 LogTrace("L1GlobalTrigger") << " GCT IsoEG " << std::endl;
1250 for (iterConst = m_candL1IsoEG->begin(); iterConst != m_candL1IsoEG->end(); iterConst++) {
1251 LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1252 << " Eta index = " << (*iterConst)->etaIndex()
1253 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1254 }
1255
1256 LogTrace("L1GlobalTrigger") << " GCT CenJet " << std::endl;
1257 for (iterConst = m_candL1CenJet->begin(); iterConst != m_candL1CenJet->end(); iterConst++) {
1258 LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1259 << " Eta index = " << (*iterConst)->etaIndex()
1260 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1261 }
1262
1263 LogTrace("L1GlobalTrigger") << " GCT ForJet " << std::endl;
1264 for (iterConst = m_candL1ForJet->begin(); iterConst != m_candL1ForJet->end(); iterConst++) {
1265 LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1266 << " Eta index = " << (*iterConst)->etaIndex()
1267 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1268 }
1269
1270 LogTrace("L1GlobalTrigger") << " GCT TauJet " << std::endl;
1271 for (iterConst = m_candL1TauJet->begin(); iterConst != m_candL1TauJet->end(); iterConst++) {
1272 LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1273 << " Eta index = " << (*iterConst)->etaIndex()
1274 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1275 }
1276
1277 LogTrace("L1GlobalTrigger") << " GCT ETM " << std::endl;
1278 if (m_candETM) {
1279 LogTrace("L1GlobalTrigger") << std::hex << "ET = " << m_candETM->et() << std::dec << std::endl;
1280
1281 LogTrace("L1GlobalTrigger") << std::hex << "phi = " << m_candETM->phi() << std::dec << std::endl;
1282 }
1283
1284 LogTrace("L1GlobalTrigger") << " GCT ETT " << std::endl;
1285 if (m_candETT) {
1286 LogTrace("L1GlobalTrigger") << std::hex << "ET = " << m_candETT->et() << std::dec << std::endl;
1287 }
1288
1289 LogTrace("L1GlobalTrigger") << " GCT HTT " << std::endl;
1290 if (m_candHTT) {
1291 LogTrace("L1GlobalTrigger") << std::hex << "ET = " << m_candHTT->et() << std::dec << std::endl;
1292 }
1293
1294 LogTrace("L1GlobalTrigger") << " GCT HTM " << std::endl;
1295 if (m_candHTM) {
1296 LogTrace("L1GlobalTrigger") << std::hex << "ET = " << m_candHTM->et() << std::dec << std::endl;
1297
1298 LogTrace("L1GlobalTrigger") << std::hex << "phi = " << m_candHTM->phi() << std::dec << std::endl;
1299 }
1300
1301 LogTrace("L1GlobalTrigger") << " GCT JetCounts " << std::endl;
1302 if (m_candJetCounts) {
1303 LogTrace("L1GlobalTrigger") << (*m_candJetCounts) << std::endl;
1304 }
1305
1306 LogTrace("L1GlobalTrigger") << " GCT HfBitCounts " << std::endl;
1307 if (m_candHfBitCounts) {
1308 LogTrace("L1GlobalTrigger") << (*m_candHfBitCounts) << std::endl;
1309 }
1310
1311 LogTrace("L1GlobalTrigger") << " GCT HfRingEtSums " << std::endl;
1312 if (m_candHfRingEtSums) {
1313 LogTrace("L1GlobalTrigger") << (*m_candHfRingEtSums) << std::endl;
1314 }
1315 }
1316
1317