CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DataFormats/L1GlobalTrigger/src/L1GtfeWord.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeWord.h"
00019 
00020 // system include files
00021 #include <iomanip>
00022 
00023 // user include files
00024 
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00027 
00028 // constructors
00029 
00030 // empty constructor, all members set to zero;
00031 L1GtfeWord::L1GtfeWord() :
00032     m_boardId(0), m_recordLength1(0), m_recordLength(0), m_bxNr(0), m_setupVersion(0),
00033             m_activeBoards(0), m_altNrBxBoard(0), m_totalTriggerNr(0) {
00034 
00035     // empty
00036 
00037 }
00038 
00039 // constructor from unpacked values;
00040 L1GtfeWord::L1GtfeWord(
00041         cms_uint16_t boardIdValue, cms_uint16_t recordLength1Value,
00042         cms_uint16_t recordLengthValue, cms_uint16_t bxNrValue,
00043         cms_uint32_t setupVersionValue, cms_uint16_t activeBoardsValue,
00044         cms_uint16_t altNrBxBoardValue, cms_uint32_t totalTriggerNrValue) :
00045     m_boardId(boardIdValue), m_recordLength1(recordLength1Value),
00046             m_recordLength(recordLengthValue), m_bxNr(bxNrValue),
00047             m_setupVersion(setupVersionValue), m_activeBoards(activeBoardsValue), m_altNrBxBoard(
00048                     altNrBxBoardValue), m_totalTriggerNr(totalTriggerNrValue)
00049 
00050 {
00051 
00052     // empty
00053 }
00054 
00055 // destructor
00056 L1GtfeWord::~L1GtfeWord()
00057 {
00058 
00059     // empty now
00060 
00061 }
00062 
00063 // equal operator
00064 bool L1GtfeWord::operator==(const L1GtfeWord& result) const
00065 {
00066 
00067     if(m_boardId != result.m_boardId) {
00068         return false;
00069     }
00070 
00071     if(m_recordLength1 != result.m_recordLength1) {
00072         return false;
00073     }
00074 
00075     if(m_recordLength != result.m_recordLength) {
00076         return false;
00077     }
00078 
00079     if(m_bxNr != result.m_bxNr) {
00080         return false;
00081     }
00082 
00083     if(m_setupVersion != result.m_setupVersion) {
00084         return false;
00085     }
00086 
00087     if(m_activeBoards != result.m_activeBoards) {
00088         return false;
00089     }
00090 
00091     if(m_altNrBxBoard != result.m_altNrBxBoard) {
00092         return false;
00093     }
00094 
00095     if(m_totalTriggerNr != result.m_totalTriggerNr) {
00096         return false;
00097     }
00098 
00099     // all members identical
00100     return true;
00101 
00102 }
00103 
00104 // unequal operator
00105 bool L1GtfeWord::operator!=(const L1GtfeWord& result) const
00106 {
00107 
00108     return !( result == *this);
00109 
00110 }
00111 
00112 // methods
00113 
00114 // set the BoardId value from a 64-bits word
00115 void L1GtfeWord::setBoardId(const cms_uint64_t& word64)
00116 {
00117     m_boardId = (word64 & BoardIdMask) >> BoardIdShift;
00118 }
00119 
00120 // set the BoardId value in a 64-bits word, having the index iWord
00121 // in the GTFE raw record
00122 void L1GtfeWord::setBoardIdWord64(cms_uint64_t& word64, int iWord)
00123 {
00124 
00125     if (iWord == BoardIdWord) {
00126         word64 = word64 | (static_cast<cms_uint64_t> (m_boardId) << BoardIdShift);
00127     }
00128 
00129 }
00130 
00131 
00132 // set the RecordLength1 value from a 64-bits word
00133 void L1GtfeWord::setRecordLength1(const cms_uint64_t& word64)
00134 {
00135     m_recordLength1 = (word64 & RecordLength1Mask) >> RecordLength1Shift;
00136 }
00137 
00138 // set the RecordLength1 value in a 64-bits word, having the index iWord
00139 // in the GTFE raw record
00140 void L1GtfeWord::setRecordLength1Word64(cms_uint64_t& word64, int iWord)
00141 {
00142 
00143     if (iWord == RecordLength1Word) {
00144         word64 = word64 |
00145                  (static_cast<cms_uint64_t> (m_recordLength1) << RecordLength1Shift);
00146     }
00147 
00148 }
00149 
00150 
00151 // set the RecordLength value from a 64-bits word
00152 void L1GtfeWord::setRecordLength(const cms_uint64_t& word64)
00153 {
00154     m_recordLength = (word64 & RecordLengthMask) >> RecordLengthShift;
00155 }
00156 
00157 // set the RecordLength value in a 64-bits word, having the index iWord
00158 // in the GTFE raw record
00159 void L1GtfeWord::setRecordLengthWord64(cms_uint64_t& word64, int iWord)
00160 {
00161 
00162     if (iWord == RecordLengthWord) {
00163         word64 = word64 |
00164                  (static_cast<cms_uint64_t> (m_recordLength) << RecordLengthShift);
00165     }
00166 
00167 }
00168 
00169 
00170 // set the BxNr value from a 64-bits word
00171 void L1GtfeWord::setBxNr(const cms_uint64_t& word64)
00172 {
00173     m_bxNr = (word64 & BxNrMask) >> BxNrShift;
00174 }
00175 
00176 // set the BxNr value in a 64-bits word, having the index iWord
00177 // in the GTFE raw record
00178 void L1GtfeWord::setBxNrWord64(cms_uint64_t& word64, int iWord)
00179 {
00180 
00181     if (iWord == BxNrWord) {
00182         word64 = word64 | (static_cast<cms_uint64_t> (m_bxNr) << BxNrShift);
00183     }
00184 
00185 }
00186 
00187 
00188 // set the SetupVersion value from a 64-bits word
00189 void L1GtfeWord::setSetupVersion(const cms_uint64_t& word64)
00190 {
00191     m_setupVersion = (word64 & SetupVersionMask) >> SetupVersionShift;
00192 }
00193 
00194 // set the SetupVersion value in a 64-bits word, having the index iWord
00195 // in the GTFE raw record
00196 void L1GtfeWord::setSetupVersionWord64(cms_uint64_t& word64, int iWord)
00197 {
00198 
00199     if (iWord == SetupVersionWord) {
00200         word64 = word64 |
00201                  (static_cast<cms_uint64_t> (m_setupVersion) << SetupVersionShift);
00202     }
00203 
00204 }
00205 
00206 
00207 // get / set BST flag: 0 or 1 - via setup version (no private member)
00208 const int L1GtfeWord::bstFlag() const {
00209 
00210     int bstFlagValue = 0;
00211     bstFlagValue = static_cast<int> (m_setupVersion & BstFlagMask);
00212 
00213     return bstFlagValue;
00214 
00215 }
00216 
00217 void L1GtfeWord::setBstFlag(const int bstFlagValue) {
00218 
00219     m_setupVersion = m_setupVersion | ( static_cast<cms_uint32_t> (bstFlagValue) & BstFlagMask );
00220 
00221 }
00222 
00223 
00224 
00225 // set the ActiveBoards value from a 64-bits word
00226 void L1GtfeWord::setActiveBoards(const cms_uint64_t& word64)
00227 {
00228     m_activeBoards = (word64 & ActiveBoardsMask) >> ActiveBoardsShift;
00229 }
00230 
00231 // set the ActiveBoards value in a 64-bits word, having the index iWord
00232 // in the GTFE raw record
00233 void L1GtfeWord::setActiveBoardsWord64(cms_uint64_t& word64, int iWord)
00234 {
00235 
00236     if (iWord == ActiveBoardsWord) {
00237         word64 = word64 |
00238                  (static_cast<cms_uint64_t> (m_activeBoards) << ActiveBoardsShift);
00239     }
00240 
00241 }
00242 
00243 // set the ActiveBoards value in a 64-bits word, having the index iWord
00244 // in the GTFE raw record from the value activeBoardsValue
00245 void L1GtfeWord::setActiveBoardsWord64(cms_uint64_t& word64, int iWord,
00246                                        cms_int16_t activeBoardsValue)
00247 {
00248     if (iWord == ActiveBoardsWord) {
00249         word64 = word64 |
00250                  (static_cast<cms_uint64_t> (activeBoardsValue) << ActiveBoardsShift);
00251     }
00252 
00253 }
00254 
00255 
00256 
00257 // set the AltNrBxBoard value from a 64-bits word
00258 void L1GtfeWord::setAltNrBxBoard(const cms_uint64_t& word64)
00259 {
00260     m_altNrBxBoard = (word64 & AltNrBxBoardMask) >> AltNrBxBoardShift;
00261 }
00262 
00263 // set the AltNrBxBoard value in a 64-bits word, having the index iWord
00264 // in the GTFE raw record
00265 void L1GtfeWord::setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord)
00266 {
00267 
00268     if (iWord == AltNrBxBoardWord) {
00269         word64 = word64 |
00270                  (static_cast<cms_uint64_t> (m_altNrBxBoard) << AltNrBxBoardShift);
00271     }
00272 
00273 }
00274 
00275 // set the AltNrBxBoard value in a 64-bits word, having the index iWord
00276 // in the GTFE raw record from the value altNrBxBoardValue
00277 void L1GtfeWord::setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord,
00278                                        cms_int16_t altNrBxBoardValue)
00279 {
00280     if (iWord == AltNrBxBoardWord) {
00281         word64 = word64 |
00282                  (static_cast<cms_uint64_t> (altNrBxBoardValue) << AltNrBxBoardShift);
00283     }
00284 
00285 }
00286 
00287 // set the TotalTriggerNr value from a 64-bits word
00288 void L1GtfeWord::setTotalTriggerNr(const cms_uint64_t& word64)
00289 {
00290     m_totalTriggerNr = (word64 & TotalTriggerNrMask) >> TotalTriggerNrShift;
00291 }
00292 
00293 // set the TotalTriggerNr value in a 64-bits word, having the index iWord
00294 // in the GTFE raw record
00295 void L1GtfeWord::setTotalTriggerNrWord64(cms_uint64_t& word64, int iWord)
00296 {
00297 
00298     if (iWord == TotalTriggerNrWord) {
00299         word64 = word64 |
00300                  (static_cast<cms_uint64_t> (m_totalTriggerNr) << TotalTriggerNrShift);
00301     }
00302 
00303 }
00304 
00305 
00306 
00307 // reset the content of a L1GtfeWord
00308 void L1GtfeWord::reset()
00309 {
00310 
00311     m_boardId = 0;
00312     m_recordLength1 = 0;
00313     m_recordLength = 0;
00314     m_bxNr = 0;
00315     m_setupVersion = 0;
00316     //
00317     m_activeBoards = 0;
00318     m_altNrBxBoard = 0;
00319     m_totalTriggerNr = 0;
00320 }
00321 
00322 // pretty print the content of a L1GtfeWord
00323 void L1GtfeWord::print(std::ostream& myCout) const
00324 {
00325 
00326     myCout << "\n L1GtfeWord::print \n" << std::endl;
00327 
00328     myCout << "  BoardId:              "
00329     << std::hex << " hex: " << "      " << std::setw(2) << std::setfill('0') << m_boardId
00330     << std::setfill(' ')
00331     << std::dec << " dec: " << m_boardId
00332     << std::endl;
00333 
00334     myCout << "  BX for alternative 1: "
00335     << std::hex << " hex: " << "       " << std::setw(1) <<  m_recordLength1
00336     << std::dec << " dec: " <<  m_recordLength1
00337     << std::endl;
00338 
00339     myCout << "  BX for alternative 0: "
00340     << std::hex << " hex: " << "       " << std::setw(1) <<  m_recordLength
00341     << std::dec << " dec: " <<  m_recordLength
00342     << std::endl;
00343 
00344     myCout << "  BxNr:                 "
00345     << std::hex << " hex: "  << "     " << std::setw(3) << std::setfill('0') << m_bxNr
00346     << std::setfill(' ')
00347     << std::dec << " dec: " << m_bxNr
00348     << std::endl;
00349 
00350     myCout << "  SetupVersion:         "
00351     << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_setupVersion
00352     << std::setfill(' ')
00353     << std::dec << " dec: " << m_setupVersion
00354     << std::endl;
00355 
00356     //
00357 
00358     myCout << "  ActiveBoards:         "
00359     << std::hex << " hex: " << "    " << std::setw(4) << std::setfill('0') << m_activeBoards
00360     << std::setfill(' ')
00361     << std::dec << " dec: " << m_activeBoards
00362     << std::endl;
00363 
00364     myCout << "  AltNrBxBoard:         "
00365     << std::hex << " hex: " << "    " << std::setw(4) << std::setfill('0') << m_altNrBxBoard
00366     << std::setfill(' ')
00367     << std::dec << " dec: " << m_altNrBxBoard
00368     << std::endl;
00369 
00370     myCout << "  TotalTriggerNr:       "
00371     << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_totalTriggerNr
00372     << std::setfill(' ')
00373     << std::dec << " dec: " << m_totalTriggerNr
00374     << std::endl;
00375 
00376 
00377 }
00378 
00379 // unpack GTFE
00380 // gtfePtr pointer to the beginning of the GTFE block in the raw data
00381 
00382 void L1GtfeWord::unpack(const unsigned char* gtfePtr)
00383 {
00384     LogDebug("L1GtfeWord")
00385     << "\nUnpacking GTFE block.\n"
00386     << std::endl;
00387 
00388     const cms_uint64_t* payload =
00389         reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtfePtr));
00390 
00391     setBoardId(payload[BoardIdWord]);
00392     setRecordLength1(payload[RecordLength1Word]);
00393     setRecordLength(payload[RecordLengthWord]);
00394     setBxNr(payload[BxNrWord]);
00395     setSetupVersion(payload[SetupVersionWord]);
00396     setActiveBoards(payload[ActiveBoardsWord]);
00397     setAltNrBxBoard(payload[AltNrBxBoardWord]);
00398     setTotalTriggerNr(payload[TotalTriggerNrWord]);
00399 
00400 
00401     if ( edm::isDebugEnabled() ) {
00402 
00403         for (int iWord = 0; iWord < BlockSize; ++iWord) {
00404             LogTrace("L1GtfeWord")
00405             << std::setw(4) << iWord << "  "
00406             << std::hex << std::setfill('0')
00407             << std::setw(16) << payload[iWord]
00408             << std::dec << std::setfill(' ')
00409             << std::endl;
00410         }
00411 
00412     }
00413 
00414 }
00415 
00416 // static class members
00417 
00418 // block description in the raw GT record
00419 
00420 // block size in 64bits words
00421 const int L1GtfeWord::BlockSize = 2;        // 2 x 64bits
00422 
00423 const int L1GtfeWord::BoardIdWord = 0;
00424 const int L1GtfeWord::RecordLength1Word = 0;
00425 const int L1GtfeWord::RecordLengthWord = 0;
00426 const int L1GtfeWord::BxNrWord = 0;
00427 const int L1GtfeWord::SetupVersionWord = 0;
00428 
00429 const cms_uint64_t L1GtfeWord::BoardIdMask =       0xFF00000000000000ULL;
00430 const cms_uint64_t L1GtfeWord::RecordLength1Mask = 0x00F0000000000000ULL;
00431 const cms_uint64_t L1GtfeWord::RecordLengthMask =  0x000F000000000000ULL;
00432 const cms_uint64_t L1GtfeWord::BxNrMask =          0x00000FFF00000000ULL;
00433 const cms_uint64_t L1GtfeWord::SetupVersionMask =  0x00000000FFFFFFFFULL;
00434 
00435 const cms_uint32_t L1GtfeWord::BstFlagMask = 0x0001;
00436 
00437 // shifts could be computed from masks...
00438 const int L1GtfeWord::BoardIdShift = 56;
00439 const int L1GtfeWord::RecordLength1Shift = 52;
00440 const int L1GtfeWord::RecordLengthShift = 48;
00441 const int L1GtfeWord::BxNrShift = 32;
00442 const int L1GtfeWord::SetupVersionShift = 0;
00443 
00444 //
00445 const int L1GtfeWord::ActiveBoardsWord = 1;
00446 const int L1GtfeWord::AltNrBxBoardWord = 1;
00447 const int L1GtfeWord::TotalTriggerNrWord = 1;
00448 
00449 const cms_uint64_t L1GtfeWord::ActiveBoardsMask =   0xFFFF000000000000ULL;
00450 const cms_uint64_t L1GtfeWord::AltNrBxBoardMask =   0x0000FFFF00000000ULL;
00451 const cms_uint64_t L1GtfeWord::TotalTriggerNrMask = 0x00000000FFFFFFFFULL;
00452 
00453 const int L1GtfeWord::ActiveBoardsShift = 48;
00454 const int L1GtfeWord::AltNrBxBoardShift = 32;
00455 const int L1GtfeWord::TotalTriggerNrShift = 0;
00456 
00457