00001
00018
00019 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00020
00021
00022 #include <bitset>
00023 #include <iostream>
00024 #include <iomanip>
00025
00026
00027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00030
00031 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCand.h"
00032
00033 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
00034 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00035 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
00036 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
00037 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
00038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
00039
00040 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00041
00042 #include "FWCore/Utilities/interface/Exception.h"
00043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00044
00045 #include "FWCore/Framework/interface/Event.h"
00046 #include "FWCore/ParameterSet/interface/InputTag.h"
00047
00048
00049
00050
00051 L1GlobalTriggerPSB::L1GlobalTriggerPSB()
00052 :
00053 m_candL1NoIsoEG ( new std::vector<const L1GctCand*>),
00054 m_candL1IsoEG ( new std::vector<const L1GctCand*>),
00055 m_candL1CenJet ( new std::vector<const L1GctCand*>),
00056 m_candL1ForJet ( new std::vector<const L1GctCand*>),
00057 m_candL1TauJet ( new std::vector<const L1GctCand*>),
00058 m_candETM(0),
00059 m_candETT(0),
00060 m_candHTT(0),
00061 m_candJetCounts(0),
00062 m_candHfBitCounts(0),
00063 m_candHfRingEtSums(0)
00064 {
00065
00066
00067
00068 }
00069
00070
00071
00072 L1GlobalTriggerPSB::~L1GlobalTriggerPSB()
00073 {
00074
00075 reset();
00076
00077 delete m_candL1NoIsoEG;
00078 delete m_candL1IsoEG;
00079 delete m_candL1CenJet;
00080 delete m_candL1ForJet;
00081 delete m_candL1TauJet;
00082
00083 }
00084
00085
00086 void L1GlobalTriggerPSB::init(const int nrL1NoIsoEG, const int nrL1IsoEG,
00087 const int nrL1CenJet, const int nrL1ForJet, const int nrL1TauJet,
00088 const int numberTechnicalTriggers)
00089 {
00090
00091 m_candL1NoIsoEG->reserve(nrL1NoIsoEG);
00092 m_candL1IsoEG->reserve(nrL1IsoEG);
00093 m_candL1CenJet->reserve(nrL1CenJet);
00094 m_candL1ForJet->reserve(nrL1ForJet);
00095 m_candL1TauJet->reserve(nrL1TauJet);
00096
00097 m_gtTechnicalTriggers.reserve(numberTechnicalTriggers);
00098 m_gtTechnicalTriggers.assign(numberTechnicalTriggers, false);
00099
00100 }
00101
00102
00103
00104 void L1GlobalTriggerPSB::receiveGctObjectData(
00105 edm::Event& iEvent,
00106 const edm::InputTag& caloGctInputTag, const int iBxInEvent,
00107 const bool receiveNoIsoEG, const int nrL1NoIsoEG,
00108 const bool receiveIsoEG, const int nrL1IsoEG,
00109 const bool receiveCenJet, const int nrL1CenJet,
00110 const bool receiveForJet, const int nrL1ForJet,
00111 const bool receiveTauJet, const int nrL1TauJet,
00112 const bool receiveETM, const bool receiveETT, const bool receiveHTT,
00113 const bool receiveJetCounts,
00114 const bool receiveHfBitCounts,
00115 const bool receiveHfRingEtSums)
00116 {
00117
00118
00119
00120
00121
00122
00123 reset();
00124
00125 std::ostringstream warningsStream;
00126 bool warningEnabled = edm::isWarningEnabled();
00127
00128 if (receiveNoIsoEG) {
00129
00130
00131 edm::Handle<L1GctEmCandCollection> emCands;
00132 iEvent.getByLabel(caloGctInputTag.label(), "nonIsoEm", emCands);
00133
00134 if (!emCands.isValid()) {
00135 if (warningEnabled) {
00136 warningsStream
00137 << "\nWarning: L1GctEmCandCollection with input label " << caloGctInputTag.label()
00138 << " and instance \"nonIsoEm\" \n"
00139 << "requested in configuration, but not found in the event.\n"
00140 << std::endl;
00141 }
00142 }
00143 else {
00144
00145 for (L1GctEmCandCollection::const_iterator it = emCands->begin(); it
00146 != emCands->end(); it++) {
00147
00148 if ((*it).bx() == iBxInEvent) {
00149
00150 (*m_candL1NoIsoEG).push_back(&(*it));
00151
00152
00153 }
00154 }
00155 }
00156
00157 }
00158
00159 if (receiveIsoEG) {
00160
00161
00162 edm::Handle<L1GctEmCandCollection> isoEmCands;
00163 iEvent.getByLabel(caloGctInputTag.label(), "isoEm", isoEmCands);
00164
00165 if (!isoEmCands.isValid()) {
00166 if (warningEnabled) {
00167 warningsStream
00168 << "\nWarning: L1GctEmCandCollection with input label "
00169 << caloGctInputTag.label()
00170 << " and instance \"isoEm\" \n"
00171 << "requested in configuration, but not found in the event.\n"
00172 << std::endl;
00173 }
00174 }
00175 else {
00176
00177 for (L1GctEmCandCollection::const_iterator it = isoEmCands->begin(); it
00178 != isoEmCands->end(); it++) {
00179
00180 if ((*it).bx() == iBxInEvent) {
00181
00182 (*m_candL1IsoEG).push_back(&(*it));
00183
00184
00185 }
00186 }
00187 }
00188
00189 }
00190
00191
00192 if (receiveCenJet) {
00193
00194
00195 edm::Handle<L1GctJetCandCollection> cenJets;
00196 iEvent.getByLabel(caloGctInputTag.label(), "cenJets", cenJets);
00197
00198 if (!cenJets.isValid()) {
00199 if (warningEnabled) {
00200 warningsStream
00201 << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
00202 << " and instance \"cenJets\" \n"
00203 << "requested in configuration, but not found in the event.\n"
00204 << std::endl;
00205 }
00206 }
00207 else {
00208
00209 for (L1GctJetCandCollection::const_iterator it = cenJets->begin(); it
00210 != cenJets->end(); it++) {
00211
00212 if ((*it).bx() == iBxInEvent) {
00213
00214 (*m_candL1CenJet).push_back(&(*it));
00215
00216
00217 }
00218 }
00219 }
00220
00221 }
00222
00223 if (receiveForJet) {
00224
00225
00226 edm::Handle<L1GctJetCandCollection> forJets;
00227 iEvent.getByLabel(caloGctInputTag.label(), "forJets", forJets);
00228
00229 if (!forJets.isValid()) {
00230 if (warningEnabled) {
00231 warningsStream
00232 << "\nWarning: L1GctJetCandCollection with input label "
00233 << caloGctInputTag.label()
00234 << " and instance \"forJets\" \n"
00235 << "requested in configuration, but not found in the event.\n"
00236 << std::endl;
00237 }
00238 }
00239 else {
00240
00241 for (L1GctJetCandCollection::const_iterator it = forJets->begin(); it
00242 != forJets->end(); it++) {
00243
00244 if ((*it).bx() == iBxInEvent) {
00245
00246 (*m_candL1ForJet).push_back(&(*it));
00247
00248
00249 }
00250 }
00251 }
00252
00253 }
00254
00255 if (receiveTauJet) {
00256
00257
00258 edm::Handle<L1GctJetCandCollection> tauJets;
00259 iEvent.getByLabel(caloGctInputTag.label(), "tauJets", tauJets);
00260
00261 if (!tauJets.isValid()) {
00262 if (warningEnabled) {
00263 warningsStream
00264 << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
00265 << " and instance \"tauJets\" \n"
00266 << "requested in configuration, but not found in the event.\n"
00267 << std::endl;
00268 }
00269 }
00270 else {
00271
00272 for (L1GctJetCandCollection::const_iterator it = tauJets->begin(); it
00273 != tauJets->end(); it++) {
00274
00275 if ((*it).bx() == iBxInEvent) {
00276
00277 (*m_candL1TauJet).push_back(&(*it));
00278
00279
00280 }
00281 }
00282 }
00283
00284 }
00285
00286
00287 if (receiveETM) {
00288
00289 edm::Handle<L1GctEtMissCollection> missEtColl;
00290 iEvent.getByLabel(caloGctInputTag, missEtColl) ;
00291
00292 if (!missEtColl.isValid()) {
00293 if (warningEnabled) {
00294 warningsStream
00295 << "\nWarning: L1GctEtMissCollection with input tag " << caloGctInputTag
00296 << "\nrequested in configuration, but not found in the event.\n"
00297 << std::endl;
00298 }
00299 }
00300 else {
00301
00302 for (L1GctEtMissCollection::const_iterator it = missEtColl->begin(); it
00303 != missEtColl->end(); it++) {
00304
00305 if ((*it).bx() == iBxInEvent) {
00306
00307 m_candETM = &(*it);
00308
00309
00310 }
00311 }
00312 }
00313
00314 }
00315
00316
00317 if (receiveETT) {
00318
00319 edm::Handle<L1GctEtTotalCollection> sumEtColl;
00320 iEvent.getByLabel(caloGctInputTag, sumEtColl) ;
00321
00322 if (!sumEtColl.isValid()) {
00323 if (warningEnabled) {
00324 warningsStream
00325 << "\nWarning: L1GctEtTotalCollection with input tag " << caloGctInputTag
00326 << "\nrequested in configuration, but not found in the event.\n"
00327 << std::endl;
00328 }
00329 }
00330 else {
00331
00332 for (L1GctEtTotalCollection::const_iterator it = sumEtColl->begin(); it
00333 != sumEtColl->end(); it++) {
00334
00335 if ((*it).bx() == iBxInEvent) {
00336
00337 m_candETT = &(*it);
00338
00339
00340 }
00341 }
00342 }
00343
00344 }
00345
00346
00347 if (receiveHTT) {
00348
00349 edm::Handle<L1GctEtHadCollection> sumHtColl;
00350 iEvent.getByLabel(caloGctInputTag, sumHtColl) ;
00351
00352 if (!sumHtColl.isValid()) {
00353 if (warningEnabled) {
00354 warningsStream
00355 << "\nWarning: L1GctEtHadCollection with input tag " << caloGctInputTag
00356 << "\nrequested in configuration, but not found in the event.\n"
00357 << std::endl;
00358 }
00359 }
00360 else {
00361
00362 for (L1GctEtHadCollection::const_iterator it = sumHtColl->begin(); it
00363 != sumHtColl->end(); it++) {
00364
00365 if ((*it).bx() == iBxInEvent) {
00366
00367 m_candHTT = &(*it);
00368
00369
00370 }
00371 }
00372 }
00373
00374 }
00375
00376
00377 if (receiveJetCounts) {
00378
00379 edm::Handle<L1GctJetCountsCollection> jetCountColl;
00380 iEvent.getByLabel(caloGctInputTag, jetCountColl) ;
00381
00382 if (!jetCountColl.isValid()) {
00383 if (warningEnabled) {
00384 warningsStream
00385 << "\nWarning: L1GctJetCountsCollection with input tag " << caloGctInputTag
00386 << "\nrequested in configuration, but not found in the event.\n"
00387 << std::endl;
00388 }
00389 }
00390 else {
00391
00392 for (L1GctJetCountsCollection::const_iterator it =
00393 jetCountColl->begin(); it != jetCountColl->end(); it++) {
00394
00395 if ((*it).bx() == iBxInEvent) {
00396
00397 m_candJetCounts = &(*it);
00398
00399
00400 }
00401 }
00402 }
00403
00404 }
00405
00406
00407
00408 if (receiveHfBitCounts) {
00409
00410 edm::Handle<L1GctHFBitCountsCollection> hfBitCountsColl;
00411 iEvent.getByLabel(caloGctInputTag, hfBitCountsColl) ;
00412
00413 if (!hfBitCountsColl.isValid()) {
00414 if (warningEnabled) {
00415 warningsStream
00416 << "\nWarning: L1GctHFBitCountsCollection with input tag " << caloGctInputTag
00417 << "\nrequested in configuration, but not found in the event.\n"
00418 << std::endl;
00419 }
00420 }
00421 else {
00422
00423 for (L1GctHFBitCountsCollection::const_iterator it =
00424 hfBitCountsColl->begin(); it != hfBitCountsColl->end(); it++) {
00425
00426 if ((*it).bx() == iBxInEvent) {
00427
00428 m_candHfBitCounts = &(*it);
00429
00430
00431
00432 }
00433 }
00434 }
00435
00436 }
00437
00438
00439 if (receiveHfRingEtSums) {
00440
00441 edm::Handle<L1GctHFRingEtSumsCollection> hfRingEtSums;
00442 iEvent.getByLabel(caloGctInputTag, hfRingEtSums) ;
00443
00444 if (!hfRingEtSums.isValid()) {
00445 if (warningEnabled) {
00446 warningsStream
00447 << "\nWarning: L1GctHFRingEtSumsCollection with input tag " << caloGctInputTag
00448 << "\nrequested in configuration, but not found in the event.\n"
00449 << std::endl;
00450 }
00451 }
00452 else {
00453
00454 for (L1GctHFRingEtSumsCollection::const_iterator it =
00455 hfRingEtSums->begin(); it != hfRingEtSums->end(); it++) {
00456
00457 if ((*it).bx() == iBxInEvent) {
00458
00459 m_candHfRingEtSums = &(*it);
00460
00461
00462
00463 }
00464 }
00465 }
00466
00467 }
00468
00469 if (warningEnabled) {
00470 if (warningsStream.tellp() > 0) {
00471 edm::LogWarning("L1GlobalTriggerPSB")
00472 << warningsStream.str();
00473 }
00474 }
00475
00476 if ( edm::isDebugEnabled() ) {
00477
00478 LogDebug("L1GlobalTriggerPSB")
00479 << "\n**** L1GlobalTriggerPSB receiving calorimeter data for BxInEvent = "
00480 << iBxInEvent << "\n from " << caloGctInputTag << "\n"
00481 << std::endl;
00482
00483 printGctObjectData(iBxInEvent);
00484 }
00485
00486
00487 }
00488
00489
00490
00491
00492 void L1GlobalTriggerPSB::receiveTechnicalTriggers(
00493 edm::Event& iEvent, const std::vector<edm::InputTag>& technicalTriggersInputTags,
00494 const int iBxInEvent, const bool receiveTechTr, const int nrL1TechTr) {
00495
00496 std::ostringstream warningsStream;
00497 bool warningEnabled = edm::isWarningEnabled();
00498
00499
00500 m_gtTechnicalTriggers = std::vector<bool>(nrL1TechTr, false);
00501
00502 if (receiveTechTr) {
00503
00504
00505
00506
00507
00508 for (std::vector<edm::InputTag>::const_iterator it = technicalTriggersInputTags.begin(); it
00509 != technicalTriggersInputTags.end(); it++) {
00510
00511 edm::Handle<L1GtTechnicalTriggerRecord> techTrigRecord;
00512 iEvent.getByLabel( ( *it ), techTrigRecord);
00513
00514 if (!techTrigRecord.isValid()) {
00515 if (warningEnabled) {
00516 warningsStream << "\nWarning: L1GtTechnicalTriggerRecord with input tag "
00517 << ( *it )
00518 << "\nrequested in configuration, but not found in the event.\n"
00519 << std::endl;
00520 }
00521 } else {
00522
00523 const std::vector<L1GtTechnicalTrigger>& ttVec =
00524 techTrigRecord->gtTechnicalTrigger();
00525 size_t ttVecSize = ttVec.size();
00526
00527 for (size_t iTT = 0; iTT < ttVecSize; ++iTT) {
00528
00529 const L1GtTechnicalTrigger& ttBxRecord = ttVec[iTT];
00530 int ttBxInEvent = ttBxRecord.bxInEvent();
00531
00532 if (ttBxInEvent == iBxInEvent) {
00533 int ttBitNumber = ttBxRecord.gtTechnicalTriggerBitNumber();
00534 bool ttResult = ttBxRecord.gtTechnicalTriggerResult();
00535
00536 m_gtTechnicalTriggers.at(ttBitNumber) = ttResult;
00537
00538 LogTrace("L1GlobalTriggerPSB") << "Add for BxInEvent " << iBxInEvent
00539 << " the technical trigger produced by " << (*it) << " : name "
00540 << ( ttBxRecord.gtTechnicalTriggerName() ) << " , bit number "
00541 << ttBitNumber << " and result " << ttResult << std::endl;
00542
00543 }
00544
00545 }
00546
00547 }
00548
00549 }
00550
00551 }
00552
00553 if (warningEnabled) {
00554 if (warningsStream.tellp() > 0) {
00555 edm::LogWarning("L1GlobalTriggerPSB")
00556 << warningsStream.str();
00557 }
00558 }
00559
00560 if (edm::isDebugEnabled()) {
00561 LogDebug("L1GlobalTriggerPSB")
00562 << "\n**** L1GlobalTriggerPSB receiving technical triggers: "
00563 << std::endl;
00564
00565 int sizeW64 = 64;
00566 int iBit = 0;
00567
00568 std::ostringstream myCout;
00569
00570 for (std::vector<bool>::reverse_iterator ritBit = m_gtTechnicalTriggers.rbegin(); ritBit
00571 != m_gtTechnicalTriggers.rend(); ++ritBit) {
00572
00573 myCout << ( *ritBit ? '1' : '0' );
00574
00575 if ( ( ( ( iBit + 1 ) % 16 ) == ( sizeW64 % 16 ) ) && ( iBit != 63 )) {
00576 myCout << " ";
00577 }
00578
00579 iBit++;
00580 }
00581
00582 LogTrace("L1GlobalTriggerPSB") << myCout.str() << "\n" << std::endl;
00583
00584 }
00585
00586 }
00587
00588
00589
00590 void L1GlobalTriggerPSB::fillPsbBlock(
00591 edm::Event& iEvent,
00592 const boost::uint16_t& activeBoardsGtDaq,
00593 const std::vector<L1GtBoard>& boardMaps,
00594 const int iBxInEvent,
00595 std::auto_ptr<L1GlobalTriggerReadoutRecord>& gtDaqReadoutRecord)
00596 {
00597
00598 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
00599
00600
00601
00602
00603 for (CItBoardMaps
00604 itBoard = boardMaps.begin();
00605 itBoard != boardMaps.end(); ++itBoard) {
00606
00607 int iPosition = itBoard->gtPositionDaqRecord();
00608 if (iPosition > 0) {
00609
00610 int iActiveBit = itBoard->gtBitDaqActiveBoards();
00611 bool activeBoard = false;
00612
00613 if (iActiveBit >= 0) {
00614 activeBoard = activeBoardsGtDaq & (1 << iActiveBit);
00615 }
00616
00617 if (activeBoard && (itBoard->gtBoardType() == PSB)) {
00618
00619 L1GtPsbWord psbWordValue;
00620
00621
00622 psbWordValue.setBoardId(itBoard->gtBoardId());
00623
00624
00625 psbWordValue.setBxInEvent(iBxInEvent);
00626
00627
00628 boost::uint16_t bxNrValue = 0;
00629 psbWordValue.setBxNr(bxNrValue);
00630
00631
00632
00633 psbWordValue.setEventNr(
00634 static_cast<boost::uint32_t>(iEvent.id().event()) );
00635
00636
00637 boost::uint16_t localBxNrValue = 0;
00638 psbWordValue.setLocalBxNr(localBxNrValue);
00639
00640
00641
00642
00643 int nrObjRow = 2;
00644
00645 std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
00646 int nrCables = quadInPsb.size();
00647
00648 boost::uint16_t aDataVal = 0;
00649 boost::uint16_t bDataVal = 0;
00650
00651 int iCable = -1;
00652 for (std::vector<L1GtPsbQuad>::const_iterator
00653 itQuad = quadInPsb.begin();
00654 itQuad != quadInPsb.end(); ++itQuad) {
00655
00656 iCable++;
00657
00658 int iAB = (nrCables - iCable - 1)*nrObjRow;
00659
00660 switch (*itQuad) {
00661
00662 case TechTr: {
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672 int bitsPerWord = 16;
00673
00674
00675 int iPair = 0;
00676 aDataVal = 0;
00677
00678 int iBit = 0;
00679 boost::uint16_t bitVal = 0;
00680
00681 for (int i = 0; i < bitsPerWord; ++i) {
00682 if (m_gtTechnicalTriggers[iBit]) {
00683 bitVal = 1;
00684 }
00685 else {
00686 bitVal = 0;
00687 }
00688
00689 aDataVal = aDataVal | (bitVal << i);
00690 iBit++;
00691 }
00692 psbWordValue.setAData(aDataVal, iAB + iPair);
00693
00694
00695 bDataVal = 0;
00696
00697 for (int i = 0; i < bitsPerWord; ++i) {
00698 if (m_gtTechnicalTriggers[iBit]) {
00699 bitVal = 1;
00700 }
00701 else {
00702 bitVal = 0;
00703 }
00704
00705 bDataVal = bDataVal | (bitVal << i);
00706 iBit++;
00707 }
00708 psbWordValue.setBData(bDataVal, iAB + iPair);
00709
00710
00711 iPair = 1;
00712 aDataVal = 0;
00713
00714 for (int i = 0; i < bitsPerWord; ++i) {
00715 if (m_gtTechnicalTriggers[iBit]) {
00716 bitVal = 1;
00717 }
00718 else {
00719 bitVal = 0;
00720 }
00721
00722 aDataVal = aDataVal | (bitVal << i);
00723 iBit++;
00724 }
00725 psbWordValue.setAData(aDataVal, iAB + iPair);
00726
00727 bDataVal = 0;
00728
00729 for (int i = 0; i < bitsPerWord; ++i) {
00730 if (m_gtTechnicalTriggers[iBit]) {
00731 bitVal = 1;
00732 }
00733 else {
00734 bitVal = 0;
00735 }
00736
00737 bDataVal = bDataVal | (bitVal << i);
00738 iBit++;
00739 }
00740 psbWordValue.setBData(bDataVal, iAB + iPair);
00741 }
00742
00743 break;
00744 case NoIsoEGQ: {
00745
00746
00747
00748
00749
00750
00751
00752
00753 int recL1NoIsoEG = m_candL1NoIsoEG->size();
00754 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
00755 if (iPair < recL1NoIsoEG) {
00756 aDataVal =
00757 (static_cast<const L1GctEmCand*> ((*m_candL1NoIsoEG)[iPair]))->raw();
00758 }
00759 else {
00760 aDataVal = 0;
00761 }
00762 psbWordValue.setAData(aDataVal, iAB + iPair);
00763
00764 if ((iPair + nrObjRow) < recL1NoIsoEG) {
00765 bDataVal =
00766 (static_cast<const L1GctEmCand*> ((*m_candL1NoIsoEG)[iPair + nrObjRow]))->raw();
00767 }
00768 else {
00769 bDataVal = 0;
00770 }
00771 psbWordValue.setBData(bDataVal, iAB + iPair);
00772
00773 }
00774 }
00775
00776 break;
00777 case IsoEGQ: {
00778
00779
00780
00781
00782
00783
00784
00785
00786 int recL1IsoEG = m_candL1IsoEG->size();
00787 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
00788 if (iPair < recL1IsoEG) {
00789 aDataVal =
00790 (static_cast<const L1GctEmCand*> ((*m_candL1IsoEG)[iPair]))->raw();
00791 }
00792 else {
00793 aDataVal = 0;
00794 }
00795 psbWordValue.setAData(aDataVal, iAB + iPair);
00796
00797 if ((iPair + nrObjRow) < recL1IsoEG) {
00798 bDataVal =
00799 (static_cast<const L1GctEmCand*> ((*m_candL1IsoEG)[iPair + nrObjRow]))->raw();
00800 }
00801 else {
00802 bDataVal = 0;
00803 }
00804 psbWordValue.setBData(bDataVal, iAB + iPair);
00805
00806 }
00807
00808 }
00809
00810 break;
00811 case CenJetQ: {
00812
00813
00814
00815
00816
00817
00818
00819
00820 int recL1CenJet = m_candL1CenJet->size();
00821 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
00822 if (iPair < recL1CenJet) {
00823 aDataVal =
00824 (static_cast<const L1GctJetCand*> ((*m_candL1CenJet)[iPair]))->raw();
00825 }
00826 else {
00827 aDataVal = 0;
00828 }
00829 psbWordValue.setAData(aDataVal, iAB + iPair);
00830
00831 if ((iPair + nrObjRow) < recL1CenJet) {
00832 bDataVal =
00833 (static_cast<const L1GctJetCand*> ((*m_candL1CenJet)[iPair + nrObjRow]))->raw();
00834 }
00835 else {
00836 bDataVal = 0;
00837 }
00838 psbWordValue.setBData(bDataVal, iAB + iPair);
00839
00840 }
00841 }
00842
00843 break;
00844 case ForJetQ: {
00845
00846
00847
00848
00849
00850
00851
00852
00853 int recL1ForJet = m_candL1ForJet->size();
00854 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
00855 if (iPair < recL1ForJet) {
00856 aDataVal =
00857 (static_cast<const L1GctJetCand*> ((*m_candL1ForJet)[iPair]))->raw();
00858 }
00859 else {
00860 aDataVal = 0;
00861 }
00862 psbWordValue.setAData(aDataVal, iAB + iPair);
00863
00864 if ((iPair + nrObjRow) < recL1ForJet) {
00865 bDataVal =
00866 (static_cast<const L1GctJetCand*> ((*m_candL1ForJet)[iPair + nrObjRow]))->raw();
00867 }
00868 else {
00869 bDataVal = 0;
00870 }
00871 psbWordValue.setBData(bDataVal, iAB + iPair);
00872
00873 }
00874
00875 }
00876
00877 break;
00878 case TauJetQ: {
00879
00880
00881
00882
00883
00884
00885
00886
00887 int recL1TauJet = m_candL1TauJet->size();
00888 for (int iPair = 0; iPair < nrObjRow; ++iPair) {
00889 if (iPair < recL1TauJet) {
00890 aDataVal =
00891 (static_cast<const L1GctJetCand*> ((*m_candL1TauJet)[iPair]))->raw();
00892 }
00893 else {
00894 aDataVal = 0;
00895 }
00896 psbWordValue.setAData(aDataVal, iAB + iPair);
00897
00898 if ((iPair + nrObjRow) < recL1TauJet) {
00899 bDataVal =
00900 (static_cast<const L1GctJetCand*> ((*m_candL1TauJet)[iPair + nrObjRow]))->raw();
00901 }
00902 else {
00903 bDataVal = 0;
00904 }
00905 psbWordValue.setBData(bDataVal, iAB + iPair);
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916 }
00917
00918 }
00919
00920 break;
00921 case ESumsQ: {
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931 int iPair = 0;
00932
00933 if (m_candETT) {
00934 aDataVal = m_candETT->raw();
00935 }
00936 else {
00937 aDataVal = 0;
00938 }
00939 psbWordValue.setAData(aDataVal, iAB + iPair);
00940
00941 if (m_candHTT) {
00942 bDataVal = m_candHTT->raw();
00943 }
00944 else {
00945 bDataVal = 0;
00946 }
00947 psbWordValue.setBData(bDataVal, iAB + iPair);
00948
00949
00950
00951
00952
00953
00954
00955
00956 iPair = 1;
00957 if (m_candETM) {
00958
00959 aDataVal = m_candETM->raw() & 0x0000FFFF;
00960
00961
00962
00963
00964
00965
00966
00967 }
00968 else {
00969 aDataVal = 0;
00970 }
00971 psbWordValue.setAData(aDataVal, iAB + iPair);
00972
00973 if (m_candETM) {
00974
00975
00976 bDataVal = (m_candETM->raw() & 0xFFFF0000) >> 16;
00977
00978
00979
00980
00981
00982 }
00983 else {
00984 bDataVal = 0;
00985 }
00986 psbWordValue.setBData(bDataVal, iAB + iPair);
00987
00988
00989
00990
00991
00992
00993
00994
00995 }
00996
00997 break;
00998 case JetCountsQ: {
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008 int jetCountsBits = 5;
01009 int countsPerWord = 3;
01010
01011
01012 int iPair = 0;
01013 aDataVal = 0;
01014 bDataVal = 0;
01015
01016 int iCount = 0;
01017
01018 if (m_candJetCounts) {
01019
01020 for (int i = 0; i < countsPerWord; ++i) {
01021 aDataVal = aDataVal
01022 | ((m_candJetCounts->count(iCount))
01023 << (jetCountsBits*i));
01024 iCount++;
01025 }
01026
01027
01028
01029 for (int i = 0; i < countsPerWord; ++i) {
01030 bDataVal = bDataVal
01031 | ((m_candJetCounts->count(iCount))
01032 << (jetCountsBits*i));
01033 iCount++;
01034 }
01035
01036 }
01037
01038 psbWordValue.setAData(aDataVal, iAB + iPair);
01039 psbWordValue.setBData(bDataVal, iAB + iPair);
01040
01041
01042 iPair = 1;
01043 aDataVal = 0;
01044 bDataVal = 0;
01045
01046 if (m_candJetCounts) {
01047 for (int i = 0; i < countsPerWord; ++i) {
01048 aDataVal = aDataVal
01049 | ((m_candJetCounts->count(iCount))
01050 << (jetCountsBits*i));
01051 iCount++;
01052 }
01053
01054
01055
01056 for (int i = 0; i < countsPerWord; ++i) {
01057 bDataVal = bDataVal
01058 | ((m_candJetCounts->count(iCount))
01059 << (jetCountsBits*i));
01060 iCount++;
01061 }
01062
01063 }
01064
01065 psbWordValue.setAData(aDataVal, iAB + iPair);
01066 psbWordValue.setBData(bDataVal, iAB + iPair);
01067 }
01068
01069 break;
01070
01071 case HfQ: {
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084 int hfBits = 3;
01085
01086 L1GctHFBitCounts hfBitCounts;
01087 int nHfBitCounts = hfBitCounts.nCounts();
01088
01089 L1GctHFRingEtSums hfRingEtSums;
01090 int nHfRingEtSums = hfRingEtSums.nSums();
01091
01092
01093 int iPair = 0;
01094 aDataVal = 0;
01095 bDataVal = 0;
01096
01097
01098 int hfPerWord = sizeof(aDataVal)*8/hfBits;
01099
01100
01101
01102
01103
01104
01105 int iHf = 0;
01106 bool aDataFlag = true;
01107 bool bDataFlag = false;
01108
01109 if (m_candHfBitCounts) {
01110
01111 for (int i = 0; i < nHfBitCounts; ++i) {
01112
01113 if (aDataFlag) {
01114 if (iHf < hfPerWord) {
01115
01116 aDataVal = aDataVal
01117 | ((m_candHfBitCounts->bitCount(i))
01118 << (hfBits*iHf));
01119 iHf++;
01120
01121
01122
01123
01124 } else {
01125 aDataFlag = false;
01126 bDataFlag = true;
01127 iHf = 0;
01128 }
01129 }
01130
01131 if (bDataFlag) {
01132 if (iHf < hfPerWord) {
01133
01134 bDataVal = bDataVal
01135 | ((m_candHfBitCounts->bitCount(i))
01136 << (hfBits*iHf));
01137 iHf++;
01138
01139
01140
01141
01142 } else {
01143 aDataFlag = false;
01144 bDataFlag = false;
01145 iHf = 0;
01146 }
01147 }
01148 }
01149 } else {
01150 iHf = nHfBitCounts%hfPerWord;
01151
01152
01153
01154
01155 }
01156
01157 if (aDataFlag && bDataFlag) {
01158 LogTrace("L1GlobalTriggerPSB")
01159 << "\n HfBitCounts collection filled aData and bData ["
01160 << (iAB + iPair) << "]"
01161 << "\n HfRingEtSums collection has no space to be written"
01162 << std::endl;
01163 }
01164
01165 if (m_candHfRingEtSums) {
01166
01167 for (int i = 0; i < nHfRingEtSums; ++i) {
01168
01169 if (aDataFlag) {
01170 if (iHf < hfPerWord) {
01171
01172 aDataVal = aDataVal
01173 | ((m_candHfRingEtSums->etSum(i))
01174 << (hfBits*iHf));
01175 iHf++;
01176
01177
01178
01179
01180 } else {
01181 aDataFlag = false;
01182 bDataFlag = true;
01183 iHf = 0;
01184 }
01185 }
01186
01187 if (bDataFlag) {
01188 if (iHf < hfPerWord) {
01189
01190 bDataVal = bDataVal
01191 | ((m_candHfRingEtSums->etSum(i))
01192 << (hfBits*iHf));
01193 iHf++;
01194
01195
01196
01197
01198 } else {
01199 aDataFlag = false;
01200 bDataFlag = false;
01201 iHf = 0;
01202 }
01203 }
01204 }
01205 } else {
01206 iHf = nHfRingEtSums%hfPerWord;
01207
01208
01209
01210
01211 }
01212
01213 psbWordValue.setAData(aDataVal, iAB + iPair);
01214 psbWordValue.setBData(bDataVal, iAB + iPair);
01215
01216
01217
01218
01219
01220
01221
01222
01223 if (aDataFlag && bDataFlag) {
01224 LogTrace("L1GlobalTriggerPSB")
01225 << "\n aData and bData ["
01226 << (iAB + iPair) << "] full"
01227 << "\n HfRingEtSums collection has not enough space to be written"
01228 << std::endl;
01229 }
01230
01231 }
01232
01233 break;
01234 default: {
01235
01236 }
01237
01238 break;
01239 }
01240
01241 }
01242
01243
01244
01245
01246
01247
01248
01249 gtDaqReadoutRecord->setGtPsbWord(psbWordValue);
01250
01251 }
01252
01253 }
01254
01255 }
01256
01257
01258 }
01259
01260
01261
01262 void L1GlobalTriggerPSB::reset() {
01263
01264 m_candL1NoIsoEG->clear();
01265 m_candL1IsoEG->clear();
01266 m_candL1CenJet->clear();
01267 m_candL1ForJet->clear();
01268 m_candL1TauJet->clear();
01269
01270
01271 m_candETM = 0;
01272 m_candETT = 0;
01273 m_candHTT = 0;
01274
01275 m_candJetCounts = 0;
01276
01277 m_candHfBitCounts = 0;
01278 m_candHfRingEtSums = 0;
01279
01280 }
01281
01282
01283
01284 void L1GlobalTriggerPSB::printGctObjectData(const int iBxInEvent) const
01285 {
01286
01287 LogTrace("L1GlobalTriggerPSB")
01288 << "\nL1GlobalTrigger: GCT data [hex] received by PSBs for BxInEvent = "
01289 << iBxInEvent << "\n" << std::endl;
01290
01291 std::vector<const L1GctCand*>::const_iterator iterConst;
01292
01293 LogTrace("L1GlobalTriggerPSB") << " GCT NoIsoEG " << std::endl;
01294 for ( iterConst = m_candL1NoIsoEG->begin(); iterConst != m_candL1NoIsoEG->end(); iterConst++ ) {
01295
01296 LogTrace("L1GlobalTriggerPSB")
01297 << std::hex
01298 << "Rank = " << (*iterConst)->rank()
01299 << " Eta index = " << (*iterConst)->etaIndex()
01300 << " Phi index = " << (*iterConst)->phiIndex()
01301 << std::dec
01302 << std::endl;
01303 }
01304
01305 LogTrace("L1GlobalTriggerPSB") << " GCT IsoEG " << std::endl;
01306 for ( iterConst = m_candL1IsoEG->begin(); iterConst != m_candL1IsoEG->end(); iterConst++ ) {
01307 LogTrace("L1GlobalTriggerPSB")
01308 << std::hex
01309 << "Rank = " << (*iterConst)->rank()
01310 << " Eta index = " << (*iterConst)->etaIndex()
01311 << " Phi index = " << (*iterConst)->phiIndex()
01312 << std::dec
01313 << std::endl;
01314 }
01315
01316 LogTrace("L1GlobalTriggerPSB") << " GCT CenJet " << std::endl;
01317 for ( iterConst = m_candL1CenJet->begin(); iterConst != m_candL1CenJet->end(); iterConst++ ) {
01318 LogTrace("L1GlobalTriggerPSB")
01319 << std::hex
01320 << "Rank = " << (*iterConst)->rank()
01321 << " Eta index = " << (*iterConst)->etaIndex()
01322 << " Phi index = " << (*iterConst)->phiIndex()
01323 << std::dec
01324 << std::endl;
01325 }
01326
01327 LogTrace("L1GlobalTriggerPSB") << " GCT ForJet " << std::endl;
01328 for ( iterConst = m_candL1ForJet->begin(); iterConst != m_candL1ForJet->end(); iterConst++ ) {
01329 LogTrace("L1GlobalTriggerPSB")
01330 << std::hex
01331 << "Rank = " << (*iterConst)->rank()
01332 << " Eta index = " << (*iterConst)->etaIndex()
01333 << " Phi index = " << (*iterConst)->phiIndex()
01334 << std::dec
01335 << std::endl;
01336 }
01337
01338 LogTrace("L1GlobalTriggerPSB") << " GCT TauJet " << std::endl;
01339 for ( iterConst = m_candL1TauJet->begin(); iterConst != m_candL1TauJet->end(); iterConst++ ) {
01340 LogTrace("L1GlobalTriggerPSB")
01341 << std::hex
01342 << "Rank = " << (*iterConst)->rank()
01343 << " Eta index = " << (*iterConst)->etaIndex()
01344 << " Phi index = " << (*iterConst)->phiIndex()
01345 << std::dec
01346 << std::endl;
01347 }
01348
01349 LogTrace("L1GlobalTriggerPSB") << " GCT ETM " << std::endl;
01350 if ( m_candETM ) {
01351 LogTrace("L1GlobalTriggerPSB")
01352 << std::hex
01353 << "ET = " << m_candETM->et()
01354 << std::dec
01355 << std::endl;
01356
01357 LogTrace("L1GlobalTriggerPSB")
01358 << std::hex
01359 << "phi = " << m_candETM->phi()
01360 << std::dec
01361 << std::endl;
01362 }
01363
01364 LogTrace("L1GlobalTriggerPSB") << " GCT ETT " << std::endl;
01365 if ( m_candETT ) {
01366 LogTrace("L1GlobalTriggerPSB")
01367 << std::hex
01368 << "ET = " << m_candETT->et()
01369 << std::dec
01370 << std::endl;
01371 }
01372
01373 LogTrace("L1GlobalTriggerPSB") << " GCT HTT " << std::endl;
01374 if ( m_candHTT ) {
01375 LogTrace("L1GlobalTriggerPSB")
01376 << std::hex
01377 << "ET = " << m_candHTT->et()
01378 << std::dec
01379 << std::endl;
01380 }
01381
01382 LogTrace("L1GlobalTriggerPSB") << " GCT JetCounts " << std::endl;
01383 if ( m_candJetCounts ) {
01384 LogTrace("L1GlobalTriggerPSB") << (*m_candJetCounts) << std::endl;
01385 }
01386
01387 LogTrace("L1GlobalTriggerPSB") << " GCT HfBitCounts " << std::endl;
01388 if ( m_candHfBitCounts ) {
01389 LogTrace("L1GlobalTriggerPSB") << (*m_candHfBitCounts) << std::endl;
01390 }
01391
01392 LogTrace("L1GlobalTriggerPSB") << " GCT HfRingEtSums " << std::endl;
01393 if ( m_candHfRingEtSums ) {
01394 LogTrace("L1GlobalTriggerPSB") << (*m_candHfRingEtSums) << std::endl;
01395 }
01396
01397 }
01398
01399
01400
01401