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