CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DataFormats/L1GlobalTrigger/src/L1GtFdlWord.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
00019 
00020 // system include files
00021 #include <iostream>
00022 #include <iomanip>
00023 #include <vector>
00024 #include <string>
00025 
00026 // user include files
00027 
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00030 
00031 // constructors
00032 
00033 // empty constructor, all members set to zero;
00034 L1GtFdlWord::L1GtFdlWord()
00035 {
00036 
00037     m_boardId = 0;
00038     m_bxInEvent = 0;
00039     m_bxNr = 0;
00040     m_eventNr = 0;
00041 
00042     // technical triggers std::vector<bool>
00043     m_gtTechnicalTriggerWord.reserve(
00044         L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers);
00045     m_gtTechnicalTriggerWord.assign(
00046         L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers, false);
00047 
00048     // decision word  std::vector<bool>
00049     m_gtDecisionWord.reserve(
00050         L1GlobalTriggerReadoutSetup::NumberPhysTriggers);
00051     m_gtDecisionWord.assign(
00052         L1GlobalTriggerReadoutSetup::NumberPhysTriggers, false);
00053 
00054     // extended decision word  std::vector<bool>
00055     m_gtDecisionWordExtended.reserve(
00056         L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended);
00057     m_gtDecisionWordExtended.assign(
00058         L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended, false);
00059 
00060     m_physicsDeclared = 0;
00061     m_gtPrescaleFactorIndexTech = 0;
00062     m_gtPrescaleFactorIndexAlgo = 0;
00063 
00064     m_noAlgo = 0;
00065 
00066     m_finalOR = 0;
00067 
00068 
00069     m_orbitNr = 0;
00070     m_lumiSegmentNr = 0;
00071     m_localBxNr = 0;
00072 
00073 }
00074 
00075 // constructor from unpacked values;
00076 L1GtFdlWord::L1GtFdlWord(cms_uint16_t boardIdValue, int bxInEventValue,
00077         cms_uint16_t bxNrValue, cms_uint32_t eventNrValue,
00078         TechnicalTriggerWord gtTechnicalTriggerWordValue,
00079         DecisionWord gtDecisionWordValue,
00080         DecisionWordExtended gtDecisionWordExtendedValue,
00081         cms_uint16_t gtPrescaleFactorIndexTechValue,
00082         cms_uint16_t gtPrescaleFactorIndexAlgoValue,
00083         cms_uint16_t noAlgoValue, cms_uint16_t finalORValue,
00084         cms_uint32_t orbitNrValue, cms_uint16_t lumiSegmentNrValue,
00085         cms_uint16_t localBxNrValue) :
00086     m_boardId(boardIdValue), m_bxInEvent(bxInEventValue), m_bxNr(bxNrValue),
00087             m_eventNr(eventNrValue),
00088             m_gtTechnicalTriggerWord(gtTechnicalTriggerWordValue),
00089             m_gtDecisionWord(gtDecisionWordValue),
00090             m_gtDecisionWordExtended(gtDecisionWordExtendedValue),
00091             m_gtPrescaleFactorIndexTech(gtPrescaleFactorIndexTechValue),
00092             m_gtPrescaleFactorIndexAlgo(gtPrescaleFactorIndexAlgoValue),
00093             m_noAlgo(noAlgoValue), m_finalOR(finalORValue),
00094             m_orbitNr(orbitNrValue), m_lumiSegmentNr(lumiSegmentNrValue),
00095             m_localBxNr(localBxNrValue)
00096 
00097 {
00098     m_physicsDeclared = 0;
00099 
00100     // the rest done in initialization list
00101 }
00102 
00103 // destructor
00104 L1GtFdlWord::~L1GtFdlWord()
00105 {
00106 
00107     // empty now
00108 }
00109 
00110 // equal operator
00111 bool L1GtFdlWord::operator==(const L1GtFdlWord& result) const
00112 {
00113 
00114     if (m_boardId   != result.m_boardId) {
00115         return false;
00116     }
00117 
00118     if (m_bxInEvent != result.m_bxInEvent) {
00119         return false;
00120     }
00121 
00122     if (m_bxNr      != result.m_bxNr) {
00123         return false;
00124     }
00125     if (m_eventNr   != result.m_eventNr) {
00126         return false;
00127     }
00128 
00129     if (m_gtTechnicalTriggerWord != result.m_gtTechnicalTriggerWord) {
00130         return false;
00131     }
00132 
00133     if (m_gtDecisionWord         != result.m_gtDecisionWord) {
00134         return false;
00135     }
00136 
00137     if (m_gtDecisionWordExtended != result.m_gtDecisionWordExtended) {
00138         return false;
00139     }
00140 
00141     if (m_physicsDeclared != result.m_physicsDeclared) {
00142         return false;
00143     }
00144 
00145     if (m_gtPrescaleFactorIndexTech != result.m_gtPrescaleFactorIndexTech) {
00146         return false;
00147     }
00148 
00149     if (m_gtPrescaleFactorIndexAlgo != result.m_gtPrescaleFactorIndexAlgo) {
00150         return false;
00151     }
00152 
00153     if (m_noAlgo                != result.m_noAlgo) {
00154         return false;
00155     }
00156 
00157     if (m_finalOR               != result.m_finalOR) {
00158         return false;
00159     }
00160 
00161     if (m_orbitNr != result.m_orbitNr) {
00162         return false;
00163     }
00164 
00165     if (m_lumiSegmentNr != result.m_lumiSegmentNr) {
00166         return false;
00167     }
00168 
00169     if (m_localBxNr != result.m_localBxNr) {
00170         return false;
00171     }
00172 
00173     // all members identical
00174     return true;
00175 
00176 }
00177 
00178 // unequal operator
00179 bool L1GtFdlWord::operator!=(const L1GtFdlWord& result) const
00180 {
00181 
00182     return !( result == *this);
00183 
00184 }
00185 
00186 
00187 // methods
00188 
00189 // set the BoardId value from a 64-bits word
00190 void L1GtFdlWord::setBoardId(const cms_uint64_t& word64)
00191 {
00192     m_boardId = (word64 & BoardIdMask) >> BoardIdShift;
00193 
00194 }
00195 
00196 // set the BoardId value in a 64-bits word, having the index iWord
00197 // in the GTFE raw record
00198 void L1GtFdlWord::setBoardIdWord64(cms_uint64_t& word64, const int iWord)
00199 {
00200 
00201     if (iWord == BoardIdWord) {
00202         word64 = word64 | (static_cast<cms_uint64_t> (m_boardId) << BoardIdShift);
00203     }
00204 
00205 }
00206 
00207 
00208 // set the BxInEvent value from a 64-bits word
00209 void L1GtFdlWord::setBxInEvent(const cms_uint64_t& word64)
00210 {
00211     int baseValue = 16; // using hexadecimal values;
00212     int hexBxInEvent = (word64 & BxInEventMask) >> BxInEventShift;
00213     m_bxInEvent = (hexBxInEvent + baseValue/2)%baseValue - baseValue/2;
00214 
00215 }
00216 
00217 // set the BxInEvent value in a 64-bits word, having the index iWord
00218 // in the GTFE raw record
00219 void L1GtFdlWord::setBxInEventWord64(cms_uint64_t& word64, const int iWord)
00220 {
00221 
00222     if (iWord == BxInEventWord) {
00223         int baseValue = 16; // using hexadecimal values;
00224         int hexBxInEvent = (m_bxInEvent + baseValue)%baseValue;
00225         word64 = word64 | (static_cast<cms_uint64_t> (hexBxInEvent)
00226                            << BxInEventShift);
00227     }
00228 
00229 }
00230 
00231 
00232 // set the BxNr value from a 64-bits word
00233 void L1GtFdlWord::setBxNr(const cms_uint64_t& word64)
00234 {
00235     m_bxNr = (word64 & BxNrMask) >> BxNrShift;
00236 
00237 }
00238 
00239 // set the BxNr value in a 64-bits word, having the index iWord
00240 // in the GTFE raw record
00241 void L1GtFdlWord::setBxNrWord64(cms_uint64_t& word64, const int iWord)
00242 {
00243 
00244     if (iWord == BxNrWord) {
00245         word64 = word64 | (static_cast<cms_uint64_t> (m_bxNr) << BxNrShift);
00246     }
00247 
00248 }
00249 
00250 
00251 // set the EventNr value from a 64-bits word
00252 void L1GtFdlWord::setEventNr(const cms_uint64_t& word64)
00253 {
00254     m_eventNr = (word64 & EventNrMask) >> EventNrShift;
00255 
00256 }
00257 
00258 // set the EventNr value in a 64-bits word, having the index iWord
00259 // in the GTFE raw record
00260 void L1GtFdlWord::setEventNrWord64(cms_uint64_t& word64, const int iWord)
00261 {
00262 
00263     if (iWord == EventNrWord) {
00264         word64 = word64 | (static_cast<cms_uint64_t> (m_eventNr) << EventNrShift);
00265     }
00266 
00267 }
00268 
00269 
00270 // print GT technical trigger word in bitset style
00271 //    depend on the type of TechnicalTriggerWord
00272 //    this version: <vector<bool>
00273 void L1GtFdlWord::printGtTechnicalTriggerWord(std::ostream& myCout) const
00274 {
00275 
00276     myCout << "  Technical triggers (bitset style):    \n  " ;
00277 
00278     int sizeW64 = 64; // 64 bits words
00279     int iBit = 0;
00280 
00281     for (std::vector<bool>::const_reverse_iterator ritBit = m_gtTechnicalTriggerWord.rbegin();
00282             ritBit != m_gtTechnicalTriggerWord.rend(); ++ritBit) {
00283 
00284         myCout << (*ritBit ? '1' : '0');
00285 
00286         if ( (((iBit + 1)%16) == (sizeW64%16)) && (iBit != 63) ) {
00287             myCout << " ";
00288         }
00289 
00290         iBit++;
00291     }
00292 
00293 
00294 }
00295 
00296 // set the GtTechnicalTriggerWord value from a 64-bits word
00297 void L1GtFdlWord::setGtTechnicalTriggerWord(const cms_uint64_t& word64)
00298 {
00299 
00300     int word64Size = sizeof(word64)*8;
00301     cms_uint64_t wordTT = (word64 & GtTechnicalTriggerWordMask)
00302                              >> GtTechnicalTriggerWordShift;
00303 
00304     cms_uint64_t one64 = 1ULL;
00305     for (int iBit = 0; iBit < word64Size; ++iBit) {
00306         m_gtTechnicalTriggerWord.at(iBit) = wordTT & (one64 << iBit);
00307     }
00308 
00309 }
00310 
00311 // set the GtTechnicalTriggerWord value in a 64-bits word, having the index iWord
00312 // in the GTFE raw record
00313 void L1GtFdlWord::setGtTechnicalTriggerWordWord64(cms_uint64_t& word64, const int iWord)
00314 {
00315 
00316     if (iWord == GtTechnicalTriggerWordWord) {
00317 
00318         int word64Size = sizeof(word64)*8;
00319         cms_uint64_t wordTT = 0x0000000000000000ULL;
00320 
00321         int iBit = 0;
00322         cms_uint64_t iDecision = 0ULL;
00323 
00324         for (std::vector<bool>::const_iterator itBit = m_gtTechnicalTriggerWord.begin();
00325                 itBit != m_gtTechnicalTriggerWord.end(); ++itBit) {
00326 
00327             iDecision = static_cast<cms_uint64_t> (*itBit);//(*itBit ? 1 : 0);
00328             wordTT = wordTT | (iDecision << iBit);
00329 
00330             iBit++;
00331             if (iBit >= word64Size) {
00332                 break;
00333             }
00334 
00335         }
00336 
00337         word64 = word64 | (wordTT << GtTechnicalTriggerWordShift);
00338 
00339     }
00340 
00341 }
00342 
00343 
00344 // print GT decision word in bitset style
00345 //    depend on the type of DecisionWord
00346 //    this version: <vector<bool>
00347 void L1GtFdlWord::printGtDecisionWord(std::ostream& myCout) const
00348 {
00349 
00350     // decision word (in 64bits words)
00351     int sizeW64 = 64; // 64 bits words
00352 
00353     int iBit = 0;
00354     int jBit = m_gtDecisionWord.size();
00355     int nrDecWord = m_gtDecisionWord.size()/sizeW64;
00356 
00357     std::ostringstream stream64;
00358 
00359     std::vector<std::string> decWord;
00360     decWord.reserve(nrDecWord);
00361 
00362     for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWord.rbegin();
00363             ritBit != m_gtDecisionWord.rend(); ++ritBit) {
00364 
00365         stream64 << (*ritBit ? '1' : '0');
00366 
00367         if ( (((iBit + 1)%16) == (sizeW64%16)) ) {
00368             stream64  << " ";
00369         }
00370 
00371         if ( ((iBit + 1)%sizeW64) == 0) {
00372             std::string iW = stream64.str();
00373             stream64.str("");
00374 
00375             decWord.push_back(iW);
00376         }
00377 
00378 
00379         iBit++;
00380         jBit--;
00381     }
00382 
00383     int iWord = 0;
00384 
00385     for (std::vector<std::string>::reverse_iterator ritWord = decWord.rbegin();
00386             ritWord != decWord.rend(); ++ritWord) {
00387 
00388         myCout << std::endl;
00389         myCout << "  DecisionWord (bitset style): bits "
00390         << iWord*sizeW64 + sizeW64 - 1 << " : " << iWord*sizeW64 << "\n  ";
00391         myCout << *ritWord;
00392 
00393         iWord++;
00394 
00395     }
00396 }
00397 
00398 // set the GtDecisionWord value from a 64-bits word
00399 // WordA: bits 0 - 63
00400 void L1GtFdlWord::setGtDecisionWordA(const cms_uint64_t& word64)
00401 {
00402 
00403     int word64Size = sizeof(word64)*8; // well, it should be 64, if not...  :-)
00404     cms_uint64_t wordA = (word64 & GtDecisionWordAMask) >> GtDecisionWordAShift;
00405 
00406     cms_uint64_t one64 = 1ULL;
00407 
00408     for (int iBit = 0; iBit < word64Size; ++iBit) {
00409         m_gtDecisionWord.at(iBit) = wordA & (one64 << iBit);
00410     }
00411 
00412 }
00413 
00414 // set the GtDecisionWord value from a 64-bits word
00415 // WordB: bits 64 - 127
00416 void L1GtFdlWord::setGtDecisionWordB(const cms_uint64_t& word64)
00417 {
00418 
00419     int word64Size = sizeof(word64)*8;
00420     cms_uint64_t wordB = (word64 & GtDecisionWordBMask) >> GtDecisionWordBShift;
00421 
00422     cms_uint64_t one64 = 1ULL;
00423 
00424     for (int iBit = 0; iBit < word64Size; ++iBit) {
00425         m_gtDecisionWord.at(iBit + word64Size) = wordB & (one64 << iBit);
00426 
00427     }
00428 
00429 }
00430 
00431 
00432 // set the GtDecisionWord value in a 64-bits word, having the index iWord
00433 // in the GTFE raw record
00434 // WordA: bits 0 - 63
00435 
00436 // a bit forced: assumes wordSize64 = 64, but also take word shift
00437 void L1GtFdlWord::setGtDecisionWordAWord64(cms_uint64_t& word64, const int iWord)
00438 {
00439 
00440     if (iWord == GtDecisionWordAWord) {
00441 
00442         int word64Size = sizeof(word64)*8;
00443         cms_uint64_t wordA = 0x0000000000000000ULL;
00444 
00445         int iBit = 0;
00446         cms_uint64_t iDecision = 0ULL;
00447 
00448         for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin();
00449                 itBit != m_gtDecisionWord.end(); ++itBit) {
00450 
00451             iDecision = static_cast<cms_uint64_t> (*itBit);//(*itBit ? 1 : 0);
00452             wordA = wordA | (iDecision << iBit);
00453 
00454             iBit++;
00455             if (iBit >= word64Size) {
00456                 break;
00457             }
00458 
00459         }
00460 
00461         word64 = word64 | (wordA << GtDecisionWordAShift);
00462 
00463     }
00464 
00465 }
00466 
00467 
00468 // set the GtDecisionWord value in a 64-bits word, having the index iWord
00469 // in the GTFE raw record
00470 // WordB: bits 64 - 127
00471 
00472 // a bit forced: assumes wordSize64 = 64, but also take word shift
00473 void L1GtFdlWord::setGtDecisionWordBWord64(cms_uint64_t& word64, const int iWord)
00474 {
00475 
00476     if (iWord == GtDecisionWordBWord) {
00477 
00478         int word64Size = sizeof(word64)*8;
00479         cms_uint64_t wordB = 0x0000000000000000ULL;
00480 
00481         int iBit = 0;
00482         cms_uint64_t iDecision = 0ULL;
00483 
00484         for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin();
00485                 itBit != m_gtDecisionWord.end(); ++itBit) {
00486 
00487             if (iBit >= word64Size) {
00488                 // skip first word64Size bits, they go in wordA
00489                 iDecision = static_cast<cms_uint64_t> (*itBit);//(*itBit ? 1 : 0);
00490                 wordB = wordB | ( iDecision << (iBit - word64Size) );
00491             }
00492 
00493             iBit++;
00494 
00495         }
00496 
00497         word64 = word64 | (wordB << GtDecisionWordBShift);
00498     }
00499 
00500 }
00501 
00502 // print GT decision word extended in bitset style
00503 //    depend on the type of DecisionWord
00504 //    this version: <vector<bool>
00505 void L1GtFdlWord::printGtDecisionWordExtended(std::ostream& myCout) const
00506 {
00507 
00508     myCout << "  DecisionWordExtended (bitset style):    \n  " ;
00509 
00510     int sizeW64 = 64; // 64 bits words
00511     int iBit = 0;
00512 
00513     for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWordExtended.rbegin();
00514             ritBit != m_gtDecisionWordExtended.rend(); ++ritBit) {
00515 
00516         myCout << (*ritBit ? '1' : '0');
00517 
00518         if ( (((iBit + 1)%16) == (sizeW64%16)) && (iBit != 63) ) {
00519             myCout << " ";
00520         }
00521 
00522         iBit++;
00523 
00524     }
00525 
00526 }
00527 
00528 // set the GtDecisionWordExtended value from a 64-bits word
00529 void L1GtFdlWord::setGtDecisionWordExtended(const cms_uint64_t& word64)
00530 {
00531 
00532     int word64Size = sizeof(word64)*8;
00533     cms_uint64_t wordE = (word64 & GtDecisionWordExtendedMask)
00534                             >> GtDecisionWordExtendedShift;
00535 
00536     cms_uint64_t one64 = 1ULL;
00537 
00538     for (int iBit = 0; iBit < word64Size; ++iBit) {
00539         m_gtDecisionWordExtended.at(iBit) = wordE & (one64 << iBit);
00540     }
00541 
00542 
00543 }
00544 
00545 // set the GtDecisionWordExtended value in a 64-bits word, having the index iWord
00546 // in the GTFE raw record
00547 void L1GtFdlWord::setGtDecisionWordExtendedWord64(cms_uint64_t& word64, const int iWord)
00548 {
00549 
00550     if (iWord == GtDecisionWordExtendedWord) {
00551 
00552         int word64Size = sizeof(word64)*8;
00553         cms_uint64_t wordE = 0x0000000000000000ULL;
00554 
00555         int iBit = 0;
00556         cms_uint64_t iDecision = 0ULL;
00557 
00558         for (std::vector<bool>::const_iterator itBit = m_gtDecisionWordExtended.begin();
00559                 itBit != m_gtDecisionWordExtended.end(); ++itBit) {
00560 
00561             iDecision = static_cast<cms_uint64_t> (*itBit);//(*itBit ? 1 : 0);
00562             wordE = wordE | (iDecision << iBit);
00563 
00564             iBit++;
00565             if (iBit >= word64Size) {
00566                 break;
00567             }
00568 
00569         }
00570 
00571         word64 = word64 | (wordE << GtDecisionWordExtendedShift);
00572 
00573     }
00574 
00575 }
00576 
00577 
00578 // set the "physics declared" bit value from a 64-bits word
00579 void L1GtFdlWord::setPhysicsDeclared(const cms_uint64_t& word64)
00580 {
00581     m_physicsDeclared = (word64 & PhysicsDeclaredMask) >> PhysicsDeclaredShift;
00582 }
00583 
00584 // set the "physics declared" bit value in a 64-bits word, having the index iWord
00585 // in the GTFE raw record
00586 void L1GtFdlWord::setPhysicsDeclaredWord64(cms_uint64_t& word64, const int iWord)
00587 {
00588 
00589     if (iWord == PhysicsDeclaredWord) {
00590         word64 = word64 | (static_cast<cms_uint64_t> (m_physicsDeclared)
00591                            << PhysicsDeclaredShift);
00592     }
00593 
00594 }
00595 
00596 
00597 // set the GtPrescaleFactorIndexTech from a 64-bits word
00598 void L1GtFdlWord::setGtPrescaleFactorIndexTech(const cms_uint64_t& word64) {
00599     m_gtPrescaleFactorIndexTech = (word64 & GtPrescaleFactorIndexTechMask)
00600             >> GtPrescaleFactorIndexTechShift;
00601 }
00602 
00603 // set the GtPrescaleFactorIndexTech bits in a 64-bits word, having the index iWord
00604 // in the GTFE raw record
00605 void L1GtFdlWord::setGtPrescaleFactorIndexTechWord64(cms_uint64_t& word64,
00606         const int iWord) {
00607 
00608     if (iWord == GtPrescaleFactorIndexTechWord) {
00609         word64 = word64
00610                 | (static_cast<cms_uint64_t> (m_gtPrescaleFactorIndexTech)
00611                         << GtPrescaleFactorIndexTechShift);
00612     }
00613 
00614 }
00615 
00616 
00617 // set the GtPrescaleFactorIndexAlgo from a 64-bits word
00618 void L1GtFdlWord::setGtPrescaleFactorIndexAlgo(const cms_uint64_t& word64) {
00619     m_gtPrescaleFactorIndexAlgo = (word64 & GtPrescaleFactorIndexAlgoMask)
00620             >> GtPrescaleFactorIndexAlgoShift;
00621 }
00622 
00623 // set the GtPrescaleFactorIndexAlgo bits in a 64-bits word, having the index iWord
00624 // in the GTFE raw record
00625 void L1GtFdlWord::setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t& word64,
00626         const int iWord) {
00627 
00628     if (iWord == GtPrescaleFactorIndexAlgoWord) {
00629         word64 = word64
00630                 | (static_cast<cms_uint64_t> (m_gtPrescaleFactorIndexAlgo)
00631                         << GtPrescaleFactorIndexAlgoShift);
00632     }
00633 
00634 }
00635 
00636 // set the NoAlgo value from a 64-bits word
00637 void L1GtFdlWord::setNoAlgo(const cms_uint64_t& word64)
00638 {
00639     m_noAlgo = (word64 & NoAlgoMask) >> NoAlgoShift;
00640 }
00641 
00642 // set the NoAlgo value in a 64-bits word, having the index iWord
00643 // in the GTFE raw record
00644 void L1GtFdlWord::setNoAlgoWord64(cms_uint64_t& word64, const int iWord)
00645 {
00646 
00647     if (iWord == NoAlgoWord) {
00648         word64 = word64 | (static_cast<cms_uint64_t> (m_noAlgo)
00649                            << NoAlgoShift);
00650     }
00651 
00652 }
00653 
00654 
00655 
00656 
00657 // set the FinalOR value from a 64-bits word
00658 void L1GtFdlWord::setFinalOR(const cms_uint64_t& word64)
00659 {
00660     m_finalOR = (word64 & FinalORMask) >> FinalORShift;
00661 
00662 }
00663 
00664 // set the FinalOR value in a 64-bits word, having the index iWord
00665 // in the GTFE raw record
00666 void L1GtFdlWord::setFinalORWord64(cms_uint64_t& word64, const int iWord)
00667 {
00668 
00669     if (iWord == FinalORWord) {
00670         word64 = word64 | (static_cast<cms_uint64_t> (m_finalOR)
00671                            << FinalORShift);
00672     }
00673 
00674 }
00675 
00676 
00677 // set the orbit number bits from a 64-bits word
00678 void L1GtFdlWord::setOrbitNr(const cms_uint64_t& word64) {
00679     m_orbitNr = (word64 & OrbitNrMask) >> OrbitNrShift;
00680 }
00681 
00682 // set the orbit number bits in a 64-bits word, having the index iWord
00683 // in the GTFE raw record
00684 void L1GtFdlWord::setOrbitNrWord64(cms_uint64_t& word64, const int iWord) {
00685 
00686     if (iWord == OrbitNrWord) {
00687         word64 = word64 | (static_cast<cms_uint64_t> (m_orbitNr)
00688                 << OrbitNrShift);
00689     }
00690 
00691 }
00692 
00693 
00694 
00695 // set the luminosity segment number bits from a 64-bits word
00696 void L1GtFdlWord::setLumiSegmentNr(const cms_uint64_t& word64) {
00697     m_lumiSegmentNr = (word64 & LumiSegmentNrMask) >> LumiSegmentNrShift;
00698 }
00699 
00700 // set the luminosity segment number bits in a 64-bits word, having the index iWord
00701 // in the GTFE raw record
00702 void L1GtFdlWord::setLumiSegmentNrWord64(cms_uint64_t& word64,
00703         const int iWord) {
00704 
00705     if (iWord == LumiSegmentNrWord) {
00706         word64 = word64 | (static_cast<cms_uint64_t> (m_lumiSegmentNr)
00707                 << LumiSegmentNrShift);
00708     }
00709 
00710 }
00711 
00712 
00713 // set the LocalBxNr value from a 64-bits word
00714 void L1GtFdlWord::setLocalBxNr(const cms_uint64_t& word64)
00715 {
00716     m_localBxNr = (word64 & LocalBxNrMask) >> LocalBxNrShift;
00717 }
00718 
00719 // set the LocalBxNr value in a 64-bits word, having the index iWord
00720 // in the GTFE raw record
00721 void L1GtFdlWord::setLocalBxNrWord64(cms_uint64_t& word64, const int iWord)
00722 {
00723 
00724     if (iWord == LocalBxNrWord) {
00725         word64 = word64 | (static_cast<cms_uint64_t> (m_localBxNr)
00726                            << LocalBxNrShift);
00727     }
00728 
00729 }
00730 
00731 
00732 
00733 // reset the content of a L1GtFdlWord
00734 void L1GtFdlWord::reset()
00735 {
00736 
00737     m_boardId = 0;
00738     m_bxInEvent = 0;
00739     m_bxNr = 0;
00740     m_eventNr = 0;
00741 
00742     // technical triggers std::vector<bool>
00743     m_gtTechnicalTriggerWord.assign(
00744         L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers, false);
00745 
00746     // decision word  std::vector<bool>
00747     m_gtDecisionWord.assign(
00748         L1GlobalTriggerReadoutSetup::NumberPhysTriggers, false);
00749 
00750     // extended decision word  std::vector<bool>
00751     m_gtDecisionWordExtended.assign(
00752         L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended, false);
00753 
00754     m_physicsDeclared = 0;
00755     m_gtPrescaleFactorIndexTech = 0;
00756     m_gtPrescaleFactorIndexAlgo = 0;
00757 
00758     m_noAlgo = 0;
00759     m_finalOR = 0;
00760 
00761     m_orbitNr = 0;
00762     m_lumiSegmentNr = 0;
00763     m_localBxNr = 0;
00764 
00765 }
00766 
00767 // pretty print the content of a L1GtFdlWord
00768 void L1GtFdlWord::print(std::ostream& myCout) const
00769 {
00770 
00771     myCout << "\n L1GtFdlWord::print \n" << std::endl;
00772 
00773     int iWord = 0;
00774 
00775     myCout << "\n Word " << iWord << std::endl;
00776 
00777     myCout << "  Board Id:         "
00778     << std::hex << " hex: " << "    " << std::setw(4) << std::setfill('0') << m_boardId
00779     << std::setfill(' ')
00780     << std::dec << " dec: " << m_boardId
00781     << std::endl;
00782     //
00783 
00784     int baseValue = 16; // using hexadecimal values;
00785     int hexBxInEvent = (m_bxInEvent + baseValue)%baseValue;
00786 
00787     myCout << "  BxInEvent:        "
00788     << std::hex << " hex: " << "       " << std::setw(1) << hexBxInEvent
00789     << std::dec << " dec: " << m_bxInEvent
00790     << std::endl;
00791 
00792     myCout << "  BxNr:             "
00793     << std::hex << " hex: "  << "     " << std::setw(3) << std::setfill('0') << m_bxNr
00794     << std::setfill(' ')
00795     << std::dec << " dec: " << m_bxNr
00796     << std::endl;
00797 
00798 
00799     myCout << "  EventNr:          "
00800     << std::hex << " hex: " << "  " << std::setw(6) << std::setfill('0') << m_eventNr
00801     << std::setfill(' ')
00802     << std::dec << " dec: " << m_eventNr
00803     << std::endl;
00804 
00805     // technical triggers
00806 
00807     iWord++;
00808     myCout << "\n Word " << iWord << std::endl;
00809 
00810     printGtTechnicalTriggerWord(myCout);
00811     myCout << std::endl;
00812 
00813     // physics triggers (2 words!)
00814 
00815     iWord++;
00816     myCout << "\n Word " << iWord;
00817     iWord++;
00818     myCout << " and word " << iWord;
00819 
00820     printGtDecisionWord(myCout);
00821     myCout << std::endl;
00822 
00823     // decision word extended (64 bits)
00824 
00825     iWord++;
00826     myCout << "\n Word " << iWord << std::endl;
00827 
00828     printGtDecisionWordExtended(myCout);
00829     myCout << std::endl;
00830 
00831     //
00832     iWord++;
00833     myCout << "\n Word " << iWord << std::endl;
00834 
00835     myCout << "  PhysicsDeclared:           "
00836     << std::hex << " hex: "  << "    " << std::setw(4) << std::setfill('0')
00837     << m_physicsDeclared
00838     << std::setfill(' ')
00839     << std::dec << " dec: " << m_physicsDeclared
00840     << std::endl;
00841 
00842     myCout << "  GtPrescaleFactorIndexTech: "
00843     << std::hex << " hex: "  << "    " << std::setw(4) << std::setfill('0')
00844     << m_gtPrescaleFactorIndexTech
00845     << std::setfill(' ')
00846     << std::dec << " dec: " << m_gtPrescaleFactorIndexTech
00847     << std::endl;
00848 
00849     myCout << "  GtPrescaleFactorIndexAlgo: "
00850     << std::hex << " hex: "  << "    " << std::setw(4) << std::setfill('0')
00851     << m_gtPrescaleFactorIndexAlgo
00852     << std::setfill(' ')
00853     << std::dec << " dec: " << m_gtPrescaleFactorIndexAlgo
00854     << std::endl;
00855 
00856     myCout << "  NoAlgo:                    "
00857     << std::hex << " hex: "  << "       " << std::setw(1) << std::setfill('0') << m_noAlgo
00858     << std::setfill(' ')
00859     << std::dec << " dec: " << m_noAlgo
00860     << std::endl;
00861 
00862     myCout << "  FinalOR:                   "
00863     << std::hex << " hex: "  << "      " << std::setw(2) << std::setfill('0') << m_finalOR
00864     << std::setfill(' ')
00865     << std::dec << " dec: " << m_finalOR
00866     << std::endl;
00867 
00868     iWord++;
00869     myCout << "\n Word " << iWord << std::endl;
00870 
00871     myCout << "  OrbitNr:          "
00872     << std::hex << " hex: "  << "" << std::setw(8) << std::setfill('0') << m_orbitNr
00873     << std::setfill(' ')
00874     << std::dec << " dec: " << m_orbitNr
00875     << std::endl;
00876 
00877     myCout << "  LumiSegmentNr:    "
00878     << std::hex << " hex: "  << "    " << std::setw(4) << std::setfill('0') << m_lumiSegmentNr
00879     << std::setfill(' ')
00880     << std::dec << " dec: " << m_lumiSegmentNr
00881     << std::endl;
00882 
00883     myCout << "  LocalBxNr:        "
00884     << std::hex << " hex: "  << "     " << std::setw(3) << std::setfill('0') << m_localBxNr
00885     << std::setfill(' ')
00886     << std::dec << " dec: " << m_localBxNr
00887     << std::endl;
00888 
00889 }
00890 
00891 // unpack FDL
00892 // fdlPtr pointer to the beginning of the FDL block in the raw data
00893 void L1GtFdlWord::unpack(const unsigned char* fdlPtr)
00894 {
00895     LogDebug("L1GtFdlWord")
00896     << "\nUnpacking FDL block.\n"
00897     << std::endl;
00898 
00899     const cms_uint64_t* payload =
00900         reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(fdlPtr));
00901 
00902     setBoardId(payload[BoardIdWord]);
00903     setBxInEvent(payload[BxInEventWord]);
00904     setBxNr(payload[BxNrWord]);
00905     setEventNr(payload[EventNrWord]);
00906 
00907     setGtTechnicalTriggerWord(payload[GtTechnicalTriggerWordWord]);
00908 
00909     setGtDecisionWordA(payload[GtDecisionWordAWord]);
00910 
00911     setGtDecisionWordB(payload[GtDecisionWordBWord]);
00912 
00913     setGtDecisionWordExtended(payload[GtDecisionWordExtendedWord]);
00914 
00915     setPhysicsDeclared(payload[PhysicsDeclaredWord]);
00916     setGtPrescaleFactorIndexTech(payload[GtPrescaleFactorIndexTechWord]);
00917     setGtPrescaleFactorIndexAlgo(payload[GtPrescaleFactorIndexAlgoWord]);
00918     setNoAlgo(payload[NoAlgoWord]);
00919     setFinalOR(payload[FinalORWord]);
00920 
00921     setOrbitNr(payload[OrbitNrWord]);
00922     setLumiSegmentNr(payload[LumiSegmentNrWord]);
00923     setLocalBxNr(payload[LocalBxNrWord]);
00924 
00925     if ( edm::isDebugEnabled() ) {
00926 
00927         for (int iWord = 0; iWord < BlockSize; ++iWord) {
00928             LogTrace("L1GtFdlWord")
00929             << std::setw(4) << iWord << "  "
00930             << std::hex << std::setfill('0')
00931             << std::setw(16) << payload[iWord]
00932             << std::dec << std::setfill(' ')
00933             << std::endl;
00934         }
00935 
00936     }
00937 
00938 }
00939 
00940 
00941 // static class members
00942 
00943 // block description in the raw GT record
00944 
00945 // block size in 64bits words (BlockSize * 64 bits)
00946 const int L1GtFdlWord::BlockSize = 7;
00947 
00948 // word 0
00949 
00950 // index of the word in the FDL block containig the variable
00951 const int L1GtFdlWord::BoardIdWord = 0;
00952 const int L1GtFdlWord::BxInEventWord = 0;
00953 const int L1GtFdlWord::BxNrWord = 0;
00954 const int L1GtFdlWord::EventNrWord = 0;
00955 
00956 // mask to get the 64-bit-value from the corresponding word in the FDL block
00957 const cms_uint64_t L1GtFdlWord::BoardIdMask =   0xFFFF000000000000ULL;
00958 const cms_uint64_t L1GtFdlWord::BxInEventMask = 0x0000F00000000000ULL;
00959 const cms_uint64_t L1GtFdlWord::BxNrMask =      0x00000FFF00000000ULL;
00960 const cms_uint64_t L1GtFdlWord::EventNrMask =   0x0000000000FFFFFFULL;
00961 
00962 // shift to the right to get the value from the "64-bit-value"
00963 const int L1GtFdlWord::BoardIdShift = 48;
00964 const int L1GtFdlWord::BxInEventShift = 44;
00965 const int L1GtFdlWord::BxNrShift = 32;
00966 const int L1GtFdlWord::EventNrShift = 0;
00967 
00968 // word 1
00969 
00970 const int L1GtFdlWord::GtTechnicalTriggerWordWord = 1;
00971 const cms_uint64_t L1GtFdlWord::GtTechnicalTriggerWordMask = 0xFFFFFFFFFFFFFFFFULL;
00972 const int L1GtFdlWord::GtTechnicalTriggerWordShift = 0;
00973 
00974 // word 2 - WordA: bits 0-63
00975 
00976 const int L1GtFdlWord::GtDecisionWordAWord = 2;
00977 const cms_uint64_t L1GtFdlWord::GtDecisionWordAMask = 0xFFFFFFFFFFFFFFFFULL;
00978 const int L1GtFdlWord::GtDecisionWordAShift = 0;
00979 
00980 // word 3 - WordB: bits 64-128
00981 
00982 const int L1GtFdlWord::GtDecisionWordBWord = 3;
00983 const cms_uint64_t L1GtFdlWord::GtDecisionWordBMask = 0xFFFFFFFFFFFFFFFFULL;
00984 const int L1GtFdlWord::GtDecisionWordBShift = 0;
00985 
00986 
00987 // word 4
00988 const int L1GtFdlWord::GtDecisionWordExtendedWord = 4;
00989 const cms_uint64_t L1GtFdlWord::GtDecisionWordExtendedMask = 0xFFFFFFFFFFFFFFFFULL;
00990 const int L1GtFdlWord::GtDecisionWordExtendedShift = 0;
00991 
00992 // word 5
00993 const int L1GtFdlWord::PhysicsDeclaredWord = 5;
00994 const int L1GtFdlWord::GtPrescaleFactorIndexTechWord = 5;
00995 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoWord = 5;
00996 const int L1GtFdlWord::NoAlgoWord = 5;
00997 const int L1GtFdlWord::FinalORWord = 5;
00998 
00999 const cms_uint64_t L1GtFdlWord::PhysicsDeclaredMask =           0x8000000000000000ULL;
01000 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexTechMask = 0x00FF000000000000ULL;
01001 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexAlgoMask = 0x000000FF00000000ULL;
01002 const cms_uint64_t L1GtFdlWord::NoAlgoMask =  0x0000000000000100ULL;
01003 const cms_uint64_t L1GtFdlWord::FinalORMask = 0x00000000000000FFULL;
01004 
01005 const int L1GtFdlWord::PhysicsDeclaredShift = 63;
01006 const int L1GtFdlWord::GtPrescaleFactorIndexTechShift = 48;
01007 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoShift = 32;
01008 const int L1GtFdlWord::NoAlgoShift = 8;
01009 const int L1GtFdlWord::FinalORShift = 0;
01010 
01011 // word 6
01012 const int L1GtFdlWord::OrbitNrWord = 6;
01013 const int L1GtFdlWord::LumiSegmentNrWord = 6;
01014 const int L1GtFdlWord::LocalBxNrWord = 6;
01015 
01016 const cms_uint64_t L1GtFdlWord::OrbitNrMask =        0xFFFFFFFF00000000ULL;
01017 const cms_uint64_t L1GtFdlWord::LumiSegmentNrMask =  0x00000000FFFF0000ULL;
01018 const cms_uint64_t L1GtFdlWord::LocalBxNrMask =      0x0000000000000FFFULL;
01019 
01020 const int L1GtFdlWord::OrbitNrShift = 32;
01021 const int L1GtFdlWord::LumiSegmentNrShift = 16;
01022 const int L1GtFdlWord::LocalBxNrShift = 0;
01023