Go to the documentation of this file.00001
00018
00019 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFDL.h"
00020
00021
00022 #include <iostream>
00023
00024
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00027 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
00028
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00031
00032 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
00033 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00034
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00037
00038 #include "FWCore/Framework/interface/Event.h"
00039
00040 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
00041 #include "CondFormats/L1TObjects/interface/L1GtBoard.h"
00042
00043
00044
00045
00046
00047
00048 L1GlobalTriggerFDL::L1GlobalTriggerFDL() :
00049
00050 m_firstEv(true),
00051 m_firstEvLumiSegment(true),
00052 m_firstEvRun(true),
00053 m_isDebugEnabled(edm::isDebugEnabled())
00054 {
00055
00056
00057 m_gtFdlWord = new L1GtFdlWord();
00058
00059
00060
00061
00062 }
00063
00064
00065 L1GlobalTriggerFDL::~L1GlobalTriggerFDL()
00066 {
00067
00068 reset();
00069 delete m_gtFdlWord;
00070
00071 }
00072
00073
00074
00075
00076 void L1GlobalTriggerFDL::run(
00077 edm::Event& iEvent,
00078 const std::vector<int>& prescaleFactorsAlgoTrig,
00079 const std::vector<int>& prescaleFactorsTechTrig,
00080 const std::vector<unsigned int>& triggerMaskAlgoTrig,
00081 const std::vector<unsigned int>& triggerMaskTechTrig,
00082 const std::vector<unsigned int>& triggerMaskVetoAlgoTrig,
00083 const std::vector<unsigned int>& triggerMaskVetoTechTrig,
00084 const std::vector<L1GtBoard>& boardMaps,
00085 const int totalBxInEvent,
00086 const int iBxInEvent,
00087 const unsigned int numberPhysTriggers, const unsigned int numberTechnicalTriggers,
00088 const unsigned int numberDaqPartitions,
00089 const L1GlobalTriggerGTL* ptrGTL,
00090 const L1GlobalTriggerPSB* ptrPSB,
00091 const int pfAlgoSetIndex,
00092 const int pfTechSetIndex)
00093 {
00094
00095
00096 const unsigned int numberPhysTriggersSet =
00097 L1GlobalTriggerReadoutSetup::NumberPhysTriggers;
00098
00099
00100 std::bitset<numberPhysTriggersSet> gtlDecisionWord = ptrGTL->getAlgorithmOR();
00101
00102
00103 DecisionWord algoDecisionWord(numberPhysTriggers);
00104
00105 for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
00106
00107 bool bitValue = gtlDecisionWord.test( iBit );
00108 algoDecisionWord[ iBit ] = bitValue;
00109 }
00110
00111
00112
00113 if (m_firstEv) {
00114
00115
00116 m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers*totalBxInEvent);
00117
00118 for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
00119
00120 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
00121 }
00122
00123
00124 m_prescaleCounterTechTrig.reserve(numberTechnicalTriggers*totalBxInEvent);
00125
00126 for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
00127
00128 m_prescaleCounterTechTrig.push_back(prescaleFactorsTechTrig);
00129 }
00130
00131 m_firstEv = false;
00132 }
00133
00134
00135 if (m_firstEvLumiSegment) {
00136
00137 m_prescaleCounterAlgoTrig.clear();
00138 for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
00139 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
00140 }
00141
00142 m_prescaleCounterTechTrig.clear();
00143 for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
00144 m_prescaleCounterTechTrig.push_back(prescaleFactorsTechTrig);
00145 }
00146
00147 m_firstEvLumiSegment = false;
00148
00149 }
00150
00151
00152
00153
00154
00155 int inBxInEvent = totalBxInEvent/2 + iBxInEvent;
00156
00157 for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
00158
00159 if (prescaleFactorsAlgoTrig.at(iBit) != 1) {
00160
00161 bool bitValue = algoDecisionWord.at( iBit );
00162 if (bitValue) {
00163
00164 (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
00165 if (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0) {
00166
00167
00168 m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) =
00169 prescaleFactorsAlgoTrig.at(iBit);
00170
00171
00172
00173
00174
00175
00176 } else {
00177
00178
00179 algoDecisionWord[iBit] = false;;
00180
00181
00182
00183
00184
00185 }
00186 }
00187 }
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197 std::vector<bool> techDecisionWord = *(ptrPSB->getGtTechnicalTriggers());
00198
00199
00200
00201 for (unsigned int iBit = 0; iBit < numberTechnicalTriggers; ++iBit) {
00202
00203 if (prescaleFactorsTechTrig.at(iBit) != 1) {
00204
00205 bool bitValue = techDecisionWord.at( iBit );
00206 if (bitValue) {
00207
00208 (m_prescaleCounterTechTrig.at(inBxInEvent).at(iBit))--;
00209 if (m_prescaleCounterTechTrig.at(inBxInEvent).at(iBit) == 0) {
00210
00211
00212 m_prescaleCounterTechTrig.at(inBxInEvent).at(iBit) =
00213 prescaleFactorsTechTrig.at(iBit);
00214
00215
00216
00217
00218
00219
00220 } else {
00221
00222
00223 techDecisionWord[iBit] = false;
00224
00225
00226
00227
00228
00229 }
00230 }
00231 }
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241 boost::uint16_t finalOrValue = 0;
00242
00243 for (unsigned int iDaq = 0; iDaq < numberDaqPartitions; ++iDaq) {
00244
00245 bool daqPartitionFinalOR = false;
00246
00247
00248
00249
00250 bool vetoTechTrig = false;
00251
00252 for (unsigned int iBit = 0; iBit < numberTechnicalTriggers; ++iBit) {
00253
00254 int triggerMaskVetoTechTrigBit =
00255 triggerMaskVetoTechTrig[iBit] & (1 << iDaq);
00256
00257
00258
00259
00260
00261
00262 if (triggerMaskVetoTechTrigBit && techDecisionWord[iBit]) {
00263
00264 daqPartitionFinalOR = false;
00265 vetoTechTrig = true;
00266
00267
00268
00269
00270
00271
00272 break;
00273 }
00274
00275 }
00276
00277
00278 if (!vetoTechTrig) {
00279
00280
00281 bool algoFinalOr = false;
00282
00283 for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
00284
00285 bool iBitDecision = false;
00286
00287 int triggerMaskAlgoTrigBit = triggerMaskAlgoTrig[iBit] & (1 << iDaq);
00288
00289
00290
00291
00292
00293
00294 if (triggerMaskAlgoTrigBit) {
00295 iBitDecision = false;
00296
00297
00298
00299
00300 } else {
00301 iBitDecision = algoDecisionWord[iBit];
00302 }
00303
00304 algoFinalOr = algoFinalOr || iBitDecision;
00305
00306 }
00307
00308
00309
00310 bool techFinalOr = false;
00311
00312 for (unsigned int iBit = 0; iBit < numberTechnicalTriggers; ++iBit) {
00313
00314 bool iBitDecision = false;
00315
00316 int triggerMaskTechTrigBit = triggerMaskTechTrig[iBit] & (1 << iDaq);
00317
00318
00319
00320
00321
00322 if (triggerMaskTechTrigBit) {
00323
00324 iBitDecision = false;
00325
00326
00327
00328
00329 } else {
00330 iBitDecision = techDecisionWord[iBit];
00331 }
00332
00333 techFinalOr = techFinalOr || iBitDecision;
00334 }
00335
00336 daqPartitionFinalOR = algoFinalOr || techFinalOr;
00337
00338 } else {
00339
00340 daqPartitionFinalOR = false;
00341
00342 }
00343
00344
00345 boost::uint16_t daqPartitionFinalORValue =
00346 static_cast<boost::uint16_t>(daqPartitionFinalOR);
00347
00348 finalOrValue = finalOrValue | (daqPartitionFinalORValue << iDaq);
00349
00350 }
00351
00352
00353
00354
00355 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
00356 for (CItBoardMaps
00357 itBoard = boardMaps.begin();
00358 itBoard != boardMaps.end(); ++itBoard) {
00359
00360
00361 if ((itBoard->gtBoardType() == FDL)) {
00362
00363 m_gtFdlWord->setBoardId( itBoard->gtBoardId() );
00364
00365
00366 m_gtFdlWord->setBxInEvent(iBxInEvent);
00367
00368
00369
00370
00371
00372 int bxCross = iEvent.bunchCrossing();
00373 boost::uint16_t bxCrossHw = 0;
00374 if ((bxCross & 0xFFF) == bxCross) {
00375 bxCrossHw = static_cast<boost::uint16_t> (bxCross);
00376 }
00377 else {
00378 bxCrossHw = 0;
00379 if (m_verbosity) {
00380 LogDebug("L1GlobalTrigger")
00381 << "\nBunch cross number [hex] = "
00382 << std::hex << bxCross
00383 << "\n larger than 12 bits. Set to 0! \n"
00384 << std::dec << std::endl;
00385 }
00386 }
00387
00388 m_gtFdlWord->setBxNr(bxCrossHw);
00389
00390
00391 m_gtFdlWord->setEventNr(
00392 static_cast<boost::uint32_t>(iEvent.id().event()) );
00393
00394
00395 m_gtFdlWord->setGtTechnicalTriggerWord(techDecisionWord);
00396
00397
00398 m_gtFdlWord->setGtDecisionWord(algoDecisionWord);
00399
00400
00401 m_gtFdlWord->setGtPrescaleFactorIndexTech(static_cast<boost::uint16_t>(pfTechSetIndex));
00402 m_gtFdlWord->setGtPrescaleFactorIndexAlgo(static_cast<boost::uint16_t>(pfAlgoSetIndex));
00403
00404
00405
00406
00407 m_gtFdlWord->setFinalOR(finalOrValue);
00408
00409
00410 m_gtFdlWord->setOrbitNr(static_cast<boost::uint32_t>(iEvent.orbitNumber()) );
00411
00412
00413 m_gtFdlWord->setLumiSegmentNr(static_cast<boost::uint16_t>(iEvent.luminosityBlock()));
00414
00415
00416 m_gtFdlWord->setLocalBxNr(bxCrossHw);
00417
00418
00419 }
00420
00421 }
00422
00423 }
00424
00425
00426 void L1GlobalTriggerFDL::fillDaqFdlBlock(const int iBxInEvent,
00427 const boost::uint16_t& activeBoardsGtDaq, const int recordLength0,
00428 const int recordLength1, const unsigned int altNrBxBoardDaq,
00429 const std::vector<L1GtBoard>& boardMaps,
00430 std::auto_ptr<L1GlobalTriggerReadoutRecord>& gtDaqReadoutRecord)
00431 {
00432
00433 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
00434 for (CItBoardMaps
00435 itBoard = boardMaps.begin();
00436 itBoard != boardMaps.end(); ++itBoard) {
00437
00438 int iPosition = itBoard->gtPositionDaqRecord();
00439 if (iPosition > 0) {
00440
00441 int iActiveBit = itBoard->gtBitDaqActiveBoards();
00442 bool activeBoard = false;
00443 bool writeBoard = false;
00444
00445 int recLength = -1;
00446
00447 if (iActiveBit >= 0) {
00448 activeBoard = activeBoardsGtDaq & ( 1 << iActiveBit );
00449
00450 int altNrBxBoard = (altNrBxBoardDaq & ( 1 << iActiveBit )) >> iActiveBit;
00451
00452 if (altNrBxBoard == 1) {
00453 recLength = recordLength1;
00454 } else {
00455 recLength = recordLength0;
00456 }
00457
00458 int lowBxInEvent = (recLength + 1)/2 - recLength;
00459 int uppBxInEvent = (recLength + 1)/2 - 1;
00460
00461 if ((iBxInEvent >= lowBxInEvent) && (iBxInEvent <= uppBxInEvent)) {
00462 writeBoard = true;
00463 }
00464
00465 }
00466
00467 if (activeBoard && writeBoard && (itBoard->gtBoardType() == FDL)) {
00468
00469 gtDaqReadoutRecord->setGtFdlWord(*m_gtFdlWord);
00470
00471
00472 }
00473
00474 }
00475
00476 }
00477
00478
00479 }
00480
00481
00482 void L1GlobalTriggerFDL::fillEvmFdlBlock(const int iBxInEvent,
00483 const boost::uint16_t& activeBoardsGtEvm, const int recordLength0,
00484 const int recordLength1, const unsigned int altNrBxBoardEvm,
00485 const std::vector<L1GtBoard>& boardMaps,
00486 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord>& gtEvmReadoutRecord)
00487 {
00488
00489 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
00490 for (CItBoardMaps
00491 itBoard = boardMaps.begin();
00492 itBoard != boardMaps.end(); ++itBoard) {
00493
00494 int iPosition = itBoard->gtPositionEvmRecord();
00495 if (iPosition > 0) {
00496
00497 int iActiveBit = itBoard->gtBitEvmActiveBoards();
00498 bool activeBoard = false;
00499
00500 if (iActiveBit >= 0) {
00501 activeBoard = activeBoardsGtEvm & (1 << iActiveBit);
00502 }
00503
00504 if (activeBoard && (itBoard->gtBoardType() == FDL)) {
00505
00506 gtEvmReadoutRecord->setGtFdlWord(*m_gtFdlWord);
00507
00508
00509 }
00510
00511 }
00512
00513 }
00514
00515 }
00516
00517
00518
00519 void L1GlobalTriggerFDL::reset()
00520 {
00521
00522 m_gtFdlWord->reset();
00523
00524
00525
00526 }