File indexing completed on 2024-04-06 12:04:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0017
0018
0019 #include <iomanip>
0020
0021
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024
0025
0026 L1GlobalTriggerReadoutRecord::L1GlobalTriggerReadoutRecord() {
0027
0028 m_gtfeWord = L1GtfeWord();
0029
0030
0031 }
0032
0033 L1GlobalTriggerReadoutRecord::L1GlobalTriggerReadoutRecord(int numberBxInEvent) {
0034 m_gtfeWord = L1GtfeWord();
0035
0036 m_gtFdlWord.reserve(numberBxInEvent);
0037 m_gtFdlWord.assign(numberBxInEvent, L1GtFdlWord());
0038
0039
0040 int minBxInEvent = (numberBxInEvent + 1) / 2 - numberBxInEvent;
0041
0042
0043
0044
0045 for (int iFdl = 0; iFdl < numberBxInEvent; ++iFdl) {
0046 int iBxInEvent = minBxInEvent + iFdl;
0047 m_gtFdlWord[iFdl].setBxInEvent(iBxInEvent);
0048 }
0049
0050
0051 int numberPsb = L1GlobalTriggerReadoutSetup::NumberPsbBoards;
0052 int totalNumberPsb = numberPsb * numberBxInEvent;
0053
0054 m_gtPsbWord.reserve(totalNumberPsb);
0055 m_gtPsbWord.assign(totalNumberPsb, L1GtPsbWord());
0056 }
0057
0058 L1GlobalTriggerReadoutRecord::L1GlobalTriggerReadoutRecord(const int numberBxInEvent,
0059 const int numberFdlBoards,
0060 const int numberPsbBoards) {
0061
0062 m_gtfeWord = L1GtfeWord();
0063
0064
0065 if (numberFdlBoards > 0) {
0066 m_gtFdlWord.reserve(numberBxInEvent);
0067 }
0068
0069
0070 if (numberPsbBoards > 0) {
0071 m_gtPsbWord.reserve(numberPsbBoards * numberBxInEvent);
0072 }
0073 }
0074
0075
0076 L1GlobalTriggerReadoutRecord::L1GlobalTriggerReadoutRecord(const L1GlobalTriggerReadoutRecord& result) {
0077 m_gtfeWord = result.m_gtfeWord;
0078 m_gtFdlWord = result.m_gtFdlWord;
0079 m_gtPsbWord = result.m_gtPsbWord;
0080
0081 m_muCollRefProd = result.m_muCollRefProd;
0082 }
0083
0084
0085 L1GlobalTriggerReadoutRecord::~L1GlobalTriggerReadoutRecord() {
0086
0087 }
0088
0089
0090 L1GlobalTriggerReadoutRecord& L1GlobalTriggerReadoutRecord::operator=(const L1GlobalTriggerReadoutRecord& result) {
0091 if (this != &result) {
0092 m_gtfeWord = result.m_gtfeWord;
0093 m_gtFdlWord = result.m_gtFdlWord;
0094 m_gtPsbWord = result.m_gtPsbWord;
0095
0096 m_muCollRefProd = result.m_muCollRefProd;
0097 }
0098
0099 return *this;
0100 }
0101
0102
0103 bool L1GlobalTriggerReadoutRecord::operator==(const L1GlobalTriggerReadoutRecord& result) const {
0104 if (m_gtfeWord != result.m_gtfeWord) {
0105 return false;
0106 }
0107
0108 if (m_gtFdlWord != result.m_gtFdlWord) {
0109 return false;
0110 }
0111
0112 if (m_gtPsbWord != result.m_gtPsbWord) {
0113 return false;
0114 }
0115
0116 if (m_muCollRefProd != result.m_muCollRefProd) {
0117 return false;
0118 }
0119
0120
0121 return true;
0122 }
0123
0124
0125 bool L1GlobalTriggerReadoutRecord::operator!=(const L1GlobalTriggerReadoutRecord& result) const {
0126 return !(result == *this);
0127 }
0128
0129
0130
0131
0132 const bool L1GlobalTriggerReadoutRecord::decision(int bxInEventValue) const {
0133 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0134 if ((*itBx).bxInEvent() == bxInEventValue) {
0135 return (*itBx).finalOR();
0136 }
0137 }
0138
0139
0140
0141
0142
0143 LogTrace("L1GlobalTriggerReadoutRecord")
0144 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0145 << "Can not return global decision for this bx!\n"
0146 << std::endl;
0147
0148 return false;
0149 }
0150
0151
0152 const bool L1GlobalTriggerReadoutRecord::decision() const {
0153 int bxInEventL1Accept = 0;
0154 return decision(bxInEventL1Accept);
0155 }
0156
0157
0158
0159 const cms_uint16_t L1GlobalTriggerReadoutRecord::finalOR(int bxInEventValue) const {
0160 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0161 if ((*itBx).bxInEvent() == bxInEventValue) {
0162 return (*itBx).finalOR();
0163 }
0164 }
0165
0166
0167
0168
0169
0170 LogTrace("L1GlobalTriggerReadoutRecord")
0171 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0172 << "Can not return finalOR for this bx!\n"
0173 << std::endl;
0174
0175 return 0;
0176 }
0177
0178
0179 const cms_uint16_t L1GlobalTriggerReadoutRecord::finalOR() const {
0180 int bxInEventL1Accept = 0;
0181 return finalOR(bxInEventL1Accept);
0182 }
0183
0184
0185
0186 const DecisionWord& L1GlobalTriggerReadoutRecord::decisionWord(int bxInEventValue) const {
0187 const static DecisionWord emptyDecisionWord;
0188
0189 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0190 if ((*itBx).bxInEvent() == bxInEventValue) {
0191 return (*itBx).gtDecisionWord();
0192 }
0193 }
0194
0195
0196
0197
0198
0199 LogTrace("L1GlobalTriggerReadoutRecord")
0200 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0201 << "Can not return decision word for this bx!\n"
0202 << std::endl;
0203
0204 return emptyDecisionWord;
0205 }
0206
0207 const DecisionWord& L1GlobalTriggerReadoutRecord::decisionWord() const {
0208 int bxInEventL1Accept = 0;
0209 return decisionWord(bxInEventL1Accept);
0210 }
0211
0212 const TechnicalTriggerWord& L1GlobalTriggerReadoutRecord::technicalTriggerWord(int bxInEventValue) const {
0213 const static TechnicalTriggerWord emptyTechnicalTriggerWord;
0214
0215 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0216 if ((*itBx).bxInEvent() == bxInEventValue) {
0217 return (*itBx).gtTechnicalTriggerWord();
0218 }
0219 }
0220
0221
0222
0223
0224
0225 LogTrace("L1GlobalTriggerReadoutRecord")
0226 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0227 << "Can not return technical trigger word for this bx!\n"
0228 << std::endl;
0229
0230 return emptyTechnicalTriggerWord;
0231 }
0232
0233 const TechnicalTriggerWord& L1GlobalTriggerReadoutRecord::technicalTriggerWord() const {
0234 int bxInEventL1Accept = 0;
0235 return technicalTriggerWord(bxInEventL1Accept);
0236 }
0237
0238
0239
0240 void L1GlobalTriggerReadoutRecord::setDecision(const bool& t, int bxInEventValue) {
0241 for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0242 if ((*itBx).bxInEvent() == bxInEventValue) {
0243
0244 (*itBx).setFinalOR(static_cast<uint16_t>(t));
0245 return;
0246 }
0247 }
0248
0249
0250
0251
0252 LogTrace("L1GlobalTriggerReadoutRecord")
0253 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0254 << "Can not set global decision for this bx!\n"
0255 << std::endl;
0256 }
0257
0258
0259 void L1GlobalTriggerReadoutRecord::setDecision(const bool& t) {
0260 int bxInEventL1Accept = 0;
0261 setDecision(t, bxInEventL1Accept);
0262 }
0263
0264
0265 void L1GlobalTriggerReadoutRecord::setDecisionWord(const DecisionWord& decisionWordValue, int bxInEventValue) {
0266 for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0267 if ((*itBx).bxInEvent() == bxInEventValue) {
0268 (*itBx).setGtDecisionWord(decisionWordValue);
0269 return;
0270 }
0271 }
0272
0273
0274
0275
0276 LogTrace("L1GlobalTriggerReadoutRecord")
0277 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0278 << "Can not set decision word for this bx!\n"
0279 << std::endl;
0280 }
0281
0282 void L1GlobalTriggerReadoutRecord::setDecisionWord(const DecisionWord& decisionWordValue) {
0283 int bxInEventL1Accept = 0;
0284 setDecisionWord(decisionWordValue, bxInEventL1Accept);
0285 }
0286
0287 void L1GlobalTriggerReadoutRecord::setTechnicalTriggerWord(const TechnicalTriggerWord& ttWordValue,
0288 int bxInEventValue) {
0289 for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0290 if ((*itBx).bxInEvent() == bxInEventValue) {
0291 (*itBx).setGtTechnicalTriggerWord(ttWordValue);
0292 return;
0293 }
0294 }
0295
0296
0297
0298
0299 LogTrace("L1GlobalTriggerReadoutRecord")
0300 << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0301 << "Can not set technical trigger word for this bx!\n"
0302 << std::endl;
0303 }
0304
0305 void L1GlobalTriggerReadoutRecord::setTechnicalTriggerWord(const TechnicalTriggerWord& ttWordValue) {
0306 int bxInEventL1Accept = 0;
0307 setTechnicalTriggerWord(ttWordValue, bxInEventL1Accept);
0308 }
0309
0310
0311 void L1GlobalTriggerReadoutRecord::printGtDecision(std::ostream& myCout, int bxInEventValue) const {
0312 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0313 if ((*itBx).bxInEvent() == bxInEventValue) {
0314 myCout << "\nL1 Global Trigger Record: " << std::endl;
0315
0316 myCout << " Bunch cross " << bxInEventValue << std::endl
0317 << " Global Decision = " << std::setw(5) << (*itBx).globalDecision() << std::endl;
0318
0319 (*itBx).printGtDecisionWord(myCout);
0320 }
0321 }
0322
0323 myCout << std::endl;
0324 }
0325
0326 void L1GlobalTriggerReadoutRecord::printGtDecision(std::ostream& myCout) const {
0327 int bxInEventL1Accept = 0;
0328 printGtDecision(myCout, bxInEventL1Accept);
0329 }
0330
0331
0332 void L1GlobalTriggerReadoutRecord::printTechnicalTrigger(std::ostream& myCout, int bxInEventValue) const {
0333 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0334 if ((*itBx).bxInEvent() == bxInEventValue) {
0335 myCout << "\nL1 Global Trigger Record: " << std::endl;
0336
0337 myCout << " Bunch cross " << bxInEventValue << std::endl;
0338
0339 (*itBx).printGtTechnicalTriggerWord(myCout);
0340 }
0341 }
0342
0343 myCout << std::endl;
0344 }
0345
0346 void L1GlobalTriggerReadoutRecord::printTechnicalTrigger(std::ostream& myCout) const {
0347 int bxInEventL1Accept = 0;
0348 printTechnicalTrigger(myCout, bxInEventL1Accept);
0349 }
0350
0351
0352 const edm::RefProd<L1MuGMTReadoutCollection> L1GlobalTriggerReadoutRecord::muCollectionRefProd() const {
0353 return m_muCollRefProd;
0354 }
0355
0356 void L1GlobalTriggerReadoutRecord::setMuCollectionRefProd(edm::Handle<L1MuGMTReadoutCollection>& muHandle) {
0357 m_muCollRefProd = edm::RefProd<L1MuGMTReadoutCollection>(muHandle);
0358 }
0359
0360 void L1GlobalTriggerReadoutRecord::setMuCollectionRefProd(const edm::RefProd<L1MuGMTReadoutCollection>& refProdMuGMT) {
0361 m_muCollRefProd = refProdMuGMT;
0362 }
0363
0364
0365
0366
0367 const L1GtfeWord L1GlobalTriggerReadoutRecord::gtfeWord() const { return m_gtfeWord; }
0368
0369 void L1GlobalTriggerReadoutRecord::setGtfeWord(const L1GtfeWord& gtfeWordValue) { m_gtfeWord = gtfeWordValue; }
0370
0371
0372 const L1GtFdlWord L1GlobalTriggerReadoutRecord::gtFdlWord(int bxInEventValue) const {
0373 for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0374 if ((*itBx).bxInEvent() == bxInEventValue) {
0375 return (*itBx);
0376 }
0377 }
0378
0379
0380
0381
0382 LogTrace("L1GlobalTriggerReadoutRecord")
0383 << "\nError: requested L1GtFdlWord for bxInEvent = " << bxInEventValue << " does not exist.\n"
0384 << std::endl;
0385
0386
0387 return L1GtFdlWord();
0388 }
0389
0390 const L1GtFdlWord L1GlobalTriggerReadoutRecord::gtFdlWord() const {
0391 int bxInEventL1Accept = 0;
0392 return gtFdlWord(bxInEventL1Accept);
0393 }
0394
0395 void L1GlobalTriggerReadoutRecord::setGtFdlWord(const L1GtFdlWord& gtFdlWordValue, int bxInEventValue) {
0396
0397 for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin(); itBx != m_gtFdlWord.end(); ++itBx) {
0398 if ((*itBx).bxInEvent() == bxInEventValue) {
0399 *itBx = gtFdlWordValue;
0400 LogTrace("L1GlobalTriggerReadoutRecord")
0401 << "L1GlobalTriggerReadoutRecord: replacing L1GtFdlWord for bxInEvent = " << bxInEventValue << "\n"
0402 << std::endl;
0403 return;
0404 }
0405 }
0406
0407
0408
0409
0410
0411 LogTrace("L1GlobalTriggerReadoutRecord")
0412 << "\nError: Cannot set L1GtFdlWord for bxInEvent = " << bxInEventValue << std::endl;
0413 }
0414
0415 void L1GlobalTriggerReadoutRecord::setGtFdlWord(const L1GtFdlWord& gtFdlWordValue) {
0416
0417 m_gtFdlWord.push_back(gtFdlWordValue);
0418 }
0419
0420
0421 const L1GtPsbWord L1GlobalTriggerReadoutRecord::gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const {
0422 for (std::vector<L1GtPsbWord>::const_iterator itBx = m_gtPsbWord.begin(); itBx != m_gtPsbWord.end(); ++itBx) {
0423 if (((*itBx).bxInEvent() == bxInEventValue) && ((*itBx).boardId() == boardIdValue)) {
0424 return (*itBx);
0425 }
0426 }
0427
0428
0429
0430
0431 LogTrace("L1GlobalTriggerReadoutRecord")
0432 << "\nError: requested L1GtPsbWord for boardId = " << std::hex << boardIdValue << std::dec
0433 << " and bxInEvent = " << bxInEventValue << " does not exist.\n"
0434 << std::endl;
0435
0436
0437 return L1GtPsbWord();
0438 }
0439
0440 const L1GtPsbWord L1GlobalTriggerReadoutRecord::gtPsbWord(cms_uint16_t boardIdValue) const {
0441 int bxInEventL1Accept = 0;
0442 return gtPsbWord(boardIdValue, bxInEventL1Accept);
0443 }
0444
0445 void L1GlobalTriggerReadoutRecord::setGtPsbWord(const L1GtPsbWord& gtPsbWordValue,
0446 cms_uint16_t boardIdValue,
0447 int bxInEventValue) {
0448
0449 for (std::vector<L1GtPsbWord>::iterator itBx = m_gtPsbWord.begin(); itBx != m_gtPsbWord.end(); ++itBx) {
0450 if (((*itBx).bxInEvent() == bxInEventValue) && ((*itBx).boardId() == boardIdValue)) {
0451 *itBx = gtPsbWordValue;
0452
0453 LogTrace("L1GlobalTriggerReadoutRecord")
0454 << "\nL1GlobalTriggerReadoutRecord: replacing L1GtPsbWord with boardId = " << std::hex << boardIdValue
0455 << std::dec << " and bxInEvent = " << bxInEventValue << "\n"
0456 << std::endl;
0457 return;
0458 }
0459 }
0460
0461
0462
0463
0464 for (std::vector<L1GtPsbWord>::iterator itBx = m_gtPsbWord.begin(); itBx != m_gtPsbWord.end(); ++itBx) {
0465 if (((*itBx).bxInEvent() == 0) && ((*itBx).boardId() == 0)) {
0466 *itBx = gtPsbWordValue;
0467
0468 LogTrace("L1GlobalTriggerReadoutRecord") << "\nL1GlobalTriggerReadoutRecord: filling an empty L1GtPsbWord"
0469 << " for PSB with boardId = " << std::hex << boardIdValue << std::dec
0470 << " and bxInEvent = " << bxInEventValue << "\n"
0471 << std::endl;
0472 return;
0473 }
0474 }
0475
0476
0477
0478
0479
0480 LogTrace("L1GlobalTriggerReadoutRecord")
0481 << "\nError: Cannot set L1GtPsbWord for PSB with boardId = " << std::hex << boardIdValue << std::dec
0482 << " and bxInEvent = " << bxInEventValue << "\n No PSB to replace and no empty PSB found!\n"
0483 << std::endl;
0484 }
0485
0486 void L1GlobalTriggerReadoutRecord::setGtPsbWord(const L1GtPsbWord& gtPsbWordValue, cms_uint16_t boardIdValue) {
0487 int bxInEventL1Accept = 0;
0488 setGtPsbWord(gtPsbWordValue, boardIdValue, bxInEventL1Accept);
0489 }
0490
0491 void L1GlobalTriggerReadoutRecord::setGtPsbWord(const L1GtPsbWord& gtPsbWordValue) {
0492
0493 m_gtPsbWord.push_back(gtPsbWordValue);
0494 }
0495
0496
0497
0498
0499
0500 void L1GlobalTriggerReadoutRecord::reset() {
0501 m_gtfeWord.reset();
0502
0503 for (std::vector<L1GtFdlWord>::iterator itFdl = m_gtFdlWord.begin(); itFdl != m_gtFdlWord.end(); ++itFdl) {
0504 itFdl->reset();
0505 }
0506
0507 for (std::vector<L1GtPsbWord>::iterator itPsb = m_gtPsbWord.begin(); itPsb != m_gtPsbWord.end(); ++itPsb) {
0508 itPsb->reset();
0509 }
0510
0511
0512 }
0513
0514
0515 void L1GlobalTriggerReadoutRecord::print(std::ostream& myCout) const {
0516 myCout << "\n L1GlobalTriggerReadoutRecord::print \n" << std::endl;
0517
0518 m_gtfeWord.print(myCout);
0519
0520 for (std::vector<L1GtFdlWord>::const_iterator itFdl = m_gtFdlWord.begin(); itFdl != m_gtFdlWord.end(); ++itFdl) {
0521 itFdl->print(myCout);
0522 }
0523
0524 for (std::vector<L1GtPsbWord>::const_iterator itPsb = m_gtPsbWord.begin(); itPsb != m_gtPsbWord.end(); ++itPsb) {
0525 itPsb->print(myCout);
0526 }
0527
0528
0529
0530 }
0531
0532
0533 std::ostream& operator<<(std::ostream& s, const L1GlobalTriggerReadoutRecord& result) {
0534
0535 s << "Not available yet - sorry";
0536
0537 return s;
0538 }