CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DataFormats/L1GlobalTrigger/src/L1TcsWord.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "DataFormats/L1GlobalTrigger/interface/L1TcsWord.h"
00019 
00020 // system include files
00021 #include <iomanip>
00022 
00023 // user include files
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00026 
00027 // forward declarations
00028 
00029 // constructors
00030 
00031 // empty constructor, all members set to zero;
00032 L1TcsWord::L1TcsWord()
00033 {
00034 
00035     m_boardId = 0;
00036     m_bxNr = 0;
00037     m_daqNr = 0;
00038     m_triggerType = 0;
00039     m_status = 0;
00040     m_luminositySegmentNr = 0;
00041     m_partRunNr = 0;
00042     m_assignedPartitions = 0;
00043     m_partTrigNr = 0;
00044     m_eventNr = 0;
00045     m_orbitNr = 0;
00046 
00047 }
00048 
00049 // constructor from unpacked values;
00050 L1TcsWord::L1TcsWord(
00051     cms_uint16_t boardIdValue,
00052     cms_uint16_t bxNrValue,
00053     cms_uint16_t daqNrValue,
00054     cms_uint16_t triggerTypeValue,
00055     cms_uint16_t statusValue,
00056     cms_uint16_t luminositySegmentNrValue,
00057     cms_uint32_t partRunNrValue,
00058     cms_uint32_t assignedPartitionsValue,
00059     cms_uint32_t partTrigNrValue,
00060     cms_uint32_t eventNrValue,
00061     cms_uint64_t orbitNrValue )
00062 {
00063 
00064     m_boardId = boardIdValue;
00065     m_bxNr = bxNrValue;
00066     m_daqNr = daqNrValue;
00067     m_triggerType = triggerTypeValue;
00068     m_status = statusValue;
00069     m_luminositySegmentNr = luminositySegmentNrValue;
00070     m_partRunNr = partRunNrValue;
00071     m_assignedPartitions = assignedPartitionsValue;
00072     m_partTrigNr = partTrigNrValue;
00073     m_eventNr = eventNrValue;
00074     m_orbitNr = orbitNrValue;
00075 
00076 }
00077 
00078 // destructor
00079 L1TcsWord::~L1TcsWord()
00080 {
00081 
00082     // empty
00083 
00084 }
00085 
00086 // equal operator
00087 bool L1TcsWord::operator==(const L1TcsWord& result) const
00088 {
00089 
00090     if (m_boardId != result.m_boardId) {
00091         return false;
00092     }
00093 
00094     if (m_bxNr != result.m_bxNr) {
00095         return false;
00096     }
00097 
00098     if (m_daqNr != result.m_daqNr) {
00099         return false;
00100     }
00101 
00102     if (m_triggerType != result.m_triggerType) {
00103         return false;
00104     }
00105 
00106     if (m_status != result.m_status) {
00107         return false;
00108     }
00109 
00110     if (m_luminositySegmentNr != result.m_luminositySegmentNr) {
00111         return false;
00112     }
00113 
00114     if (m_partRunNr != result.m_partRunNr) {
00115         return false;
00116     }
00117 
00118     if (m_assignedPartitions != result.m_assignedPartitions) {
00119         return false;
00120     }
00121 
00122     if (m_partTrigNr != result.m_partTrigNr) {
00123         return false;
00124     }
00125 
00126     if (m_eventNr != result.m_eventNr) {
00127         return false;
00128     }
00129 
00130     if (m_orbitNr != result.m_orbitNr) {
00131         return false;
00132     }
00133 
00134     // all members identical
00135     return true;
00136 
00137 }
00138 
00139 // unequal operator
00140 bool L1TcsWord::operator!=(const L1TcsWord& result) const
00141 {
00142 
00143     return !( result == *this);
00144 
00145 }
00146 
00147 // methods
00148 
00149 // set the BoardId value from a 64-bits word
00150 void L1TcsWord::setBoardId(const cms_uint64_t& word64)
00151 {
00152     m_boardId = (word64 & BoardIdMask) >> BoardIdShift;
00153 
00154 }
00155 
00156 // set the BoardId value in a 64-bits word, having the index iWord
00157 // in the GTFE raw record
00158 void L1TcsWord::setBoardIdWord64(cms_uint64_t& word64, int iWord)
00159 {
00160 
00161     if (iWord == BoardIdWord) {
00162         word64 = word64 | (static_cast<cms_uint64_t> (m_boardId) << BoardIdShift);
00163     }
00164 
00165 }
00166 
00167 
00168 // set the BxNr value from a 64-bits word
00169 void L1TcsWord::setBxNr(const cms_uint64_t& word64)
00170 {
00171 
00172     m_bxNr = (word64 & BxNrMask) >> BxNrShift;
00173 
00174 }
00175 
00176 // set the BxNr value in a 64-bits word, having the index iWord
00177 // in the GTFE EVM raw record
00178 void L1TcsWord::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 
00189 // set the DaqNr value from a 64-bits word
00190 void L1TcsWord::setDaqNr(const cms_uint64_t& word64)
00191 {
00192 
00193     m_daqNr = (word64 & DaqNrMask) >> DaqNrShift;
00194 
00195 }
00196 
00197 // set the DaqNr value in a 64-bits word, having the index iWord
00198 // in the GTFE EVM raw record
00199 void L1TcsWord::setDaqNrWord64(cms_uint64_t& word64, int iWord)
00200 {
00201 
00202     if (iWord == DaqNrWord) {
00203         word64 = word64 | (static_cast<cms_uint64_t> (m_daqNr) << DaqNrShift);
00204     }
00205 
00206 }
00207 
00208 
00209 // set the TriggerType value from a 64-bits word
00210 void L1TcsWord::setTriggerType(const cms_uint64_t& word64)
00211 {
00212 
00213     m_triggerType = (word64 & TriggerTypeMask) >> TriggerTypeShift;
00214 
00215 }
00216 
00217 // set the TriggerType value in a 64-bits word, having the index iWord
00218 // in the GTFE EVM raw record
00219 void L1TcsWord::setTriggerTypeWord64(cms_uint64_t& word64, int iWord)
00220 {
00221 
00222     if (iWord == TriggerTypeWord) {
00223         word64 = word64 |
00224                  (static_cast<cms_uint64_t> (m_triggerType) << TriggerTypeShift);
00225     }
00226 
00227 }
00228 
00229 
00230 // set the Status value from a 64-bits word
00231 void L1TcsWord::setStatus(const cms_uint64_t& word64)
00232 {
00233 
00234     m_status = (word64 & StatusMask) >> StatusShift;
00235 
00236 }
00237 
00238 // set the Status value in a 64-bits word, having the index iWord
00239 // in the GTFE EVM raw record
00240 void L1TcsWord::setStatusWord64(cms_uint64_t& word64, int iWord)
00241 {
00242 
00243     if (iWord == StatusWord) {
00244         word64 = word64 | (static_cast<cms_uint64_t> (m_status) << StatusShift);
00245     }
00246 
00247 }
00248 
00249 
00250 
00251 // set the luminosity segment number value from a 64-bits word
00252 void L1TcsWord::setLuminositySegmentNr(const cms_uint64_t& word64)
00253 {
00254 
00255     m_luminositySegmentNr =
00256         (word64 & LuminositySegmentNrMask) >> LuminositySegmentNrShift;
00257 
00258 }
00259 
00260 // set the luminosity segment number value in a 64-bits word, having the index iWord
00261 // in the GTFE EVM raw record
00262 void L1TcsWord::setLuminositySegmentNrWord64(cms_uint64_t& word64, int iWord)
00263 {
00264 
00265     if (iWord == LuminositySegmentNrWord) {
00266         word64 = word64 |
00267                  (static_cast<cms_uint64_t> (m_luminositySegmentNr) << LuminositySegmentNrShift);
00268     }
00269 
00270 }
00271 
00272 
00273 
00274 // set the PartRunNr value from a 64-bits word
00275 void L1TcsWord::setPartRunNr(const cms_uint64_t& word64)
00276 {
00277 
00278     m_partRunNr = (word64 & PartRunNrMask) >> PartRunNrShift;
00279 
00280 }
00281 
00282 // set the PartRunNr value in a 64-bits word, having the index iWord
00283 // in the GTFE EVM raw record
00284 void L1TcsWord::setPartRunNrWord64(cms_uint64_t& word64, int iWord)
00285 {
00286 
00287     if (iWord == PartRunNrWord) {
00288         word64 = word64 |
00289                  (static_cast<cms_uint64_t> (m_partRunNr) << PartRunNrShift);
00290     }
00291 
00292 }
00293 
00294 
00295 
00296 // set the AssignedPartitions value from a 64-bits word
00297 void L1TcsWord::setAssignedPartitions(const cms_uint64_t& word64)
00298 {
00299 
00300     m_assignedPartitions = (word64 & AssignedPartitionsMask)
00301                            >> AssignedPartitionsShift;
00302 
00303 }
00304 
00305 // set the AssignedPartitions value in a 64-bits word, having the index iWord
00306 // in the GTFE EVM raw record
00307 void L1TcsWord::setAssignedPartitionsWord64(cms_uint64_t& word64, int iWord)
00308 {
00309 
00310     if (iWord == AssignedPartitionsWord) {
00311         word64 = word64 |
00312                  (static_cast<cms_uint64_t> (m_assignedPartitions)
00313                   << AssignedPartitionsShift);
00314     }
00315 
00316 }
00317 
00318 
00319 
00320 // set the PartTrigNr value from a 64-bits word
00321 void L1TcsWord::setPartTrigNr(const cms_uint64_t& word64)
00322 {
00323 
00324     m_partTrigNr = (word64 & PartTrigNrMask) >> PartTrigNrShift;
00325 
00326 }
00327 
00328 // set the PartTrigNr value in a 64-bits word, having the index iWord
00329 // in the GTFE EVM raw record
00330 void L1TcsWord::setPartTrigNrWord64(cms_uint64_t& word64, int iWord)
00331 {
00332 
00333     if (iWord == PartTrigNrWord) {
00334         word64 = word64 |
00335                  (static_cast<cms_uint64_t> (m_partTrigNr) << PartTrigNrShift);
00336     }
00337 
00338 }
00339 
00340 
00341 
00342 // set the EventNr value from a 64-bits word
00343 void L1TcsWord::setEventNr(const cms_uint64_t& word64)
00344 {
00345 
00346     m_eventNr = (word64 & EventNrMask) >> EventNrShift;
00347 
00348 }
00349 
00350 // set the EventNr value in a 64-bits word, having the index iWord
00351 // in the GTFE EVM raw record
00352 void L1TcsWord::setEventNrWord64(cms_uint64_t& word64, int iWord)
00353 {
00354 
00355     if (iWord == EventNrWord) {
00356         word64 = word64 |
00357                  (static_cast<cms_uint64_t> (m_eventNr) << EventNrShift);
00358     }
00359 
00360 }
00361 
00362 
00363 
00364 // set the OrbitNr value from a 64-bits word
00365 void L1TcsWord::setOrbitNrFrom(const cms_uint64_t& word64)
00366 {
00367 
00368     m_orbitNr = (word64 & OrbitNrMask) >> OrbitNrShift;
00369 
00370 }
00371 
00372 // set the OrbitNr value in a 64-bits word, having the index iWord
00373 // in the GTFE EVM raw record
00374 void L1TcsWord::setOrbitNrWord64(cms_uint64_t& word64, int iWord)
00375 {
00376 
00377     if (iWord == OrbitNrWord) {
00378         word64 = word64 | (static_cast<cms_uint64_t> (m_orbitNr) << OrbitNrShift);
00379     }
00380 
00381 }
00382 
00383 
00384 // reset the content of a L1TcsWord
00385 void L1TcsWord::reset()
00386 {
00387 
00388     m_boardId = 0;
00389     m_bxNr = 0;
00390     m_daqNr = 0;
00391     m_triggerType = 0;
00392     m_status = 0;
00393     m_luminositySegmentNr = 0;
00394     m_partRunNr = 0;
00395     m_assignedPartitions = 0;
00396     m_partTrigNr = 0;
00397     m_eventNr = 0;
00398     m_orbitNr = 0;
00399 
00400 
00401 }
00402 
00403 
00404 // pretty print
00405 void L1TcsWord::print(std::ostream& myCout) const
00406 {
00407 
00408     myCout << "\n L1TcsWord::print \n" << std::endl;
00409 
00410     int iWord = 0;
00411 
00412     myCout << "\n Word " << iWord << std::endl;
00413 
00414     myCout << "  Board Id:            "
00415     << std::hex << " hex: " << "        "<< std::setw(4) << std::setfill('0') << m_boardId
00416     << std::setfill(' ')
00417     << std::dec << " dec: " << m_boardId
00418     << std::endl;
00419 
00420 
00421     myCout << "  BxNr:                "
00422     << std::hex << " hex: "  << "         " << std::setw(3) << std::setfill('0') << m_bxNr
00423     << std::setfill(' ')
00424     << std::dec << " dec: " << m_bxNr
00425     << std::endl;
00426 
00427 
00428     myCout << "  DaqNr:               "
00429     << std::hex << " hex: " << "           " << std::setw(1) << m_daqNr
00430     << std::dec << " dec: " << m_daqNr
00431     << std::endl;
00432 
00433     myCout << "  TriggerType:         "
00434     << std::hex << " hex: " << "           " << std::setw(1) << m_triggerType
00435     << std::dec << " dec: " << m_triggerType
00436     << std::endl;
00437 
00438     myCout << "  Status:              "
00439     << std::hex << " hex: " << "           " << std::setw(1) << m_status
00440     << std::dec << " dec: " << m_status
00441     << std::endl;
00442 
00443     myCout << "  LuminositySegmentNr: "
00444     << std::hex << " hex: " << "        " << std::setw(4) << m_luminositySegmentNr
00445     << std::dec << " dec: " << m_luminositySegmentNr
00446     << std::endl;
00447 
00448 
00449     iWord++;
00450     myCout << "\n Word " << iWord << std::endl;
00451 
00452     myCout << "  PartRunNr:           "
00453     << std::hex << " hex: " << "    " << std::setw(8) << std::setfill('0') << m_partRunNr
00454     << std::setfill(' ')
00455     << std::dec << " dec: " << m_partRunNr
00456     << std::endl;
00457 
00458     myCout << "  AssignedPartitions:  "
00459     << std::hex << " hex: " << "    " << std::setw(8) << std::setfill('0')
00460     << m_assignedPartitions
00461     << std::setfill(' ')
00462     << std::dec << " dec: " << m_assignedPartitions
00463     << std::endl;
00464 
00465 
00466     iWord++;
00467     myCout << "\n Word " << iWord << std::endl;
00468 
00469     myCout << "  PartTrigNr:          "
00470     << std::hex << " hex: " << "    " << std::setw(8) << std::setfill('0') << m_partTrigNr
00471     << std::setfill(' ')
00472     << std::dec << " dec: " << m_partTrigNr
00473     << std::endl;
00474 
00475 
00476     myCout << "  EventNr:             "
00477     << std::hex << " hex: " << "    " << std::setw(8) << std::setfill('0') << m_eventNr
00478     << std::setfill(' ')
00479     << std::dec << " dec: " << m_eventNr
00480     << std::endl;
00481 
00482     iWord++;
00483     myCout << "\n Word " << iWord << std::endl;
00484 
00485     myCout << "  OrbitNr:             "
00486     << std::hex << " hex: " << "" << std::setw(12) << std::setfill('0') << m_orbitNr
00487     << std::setfill(' ')
00488     << std::dec << " dec: " << m_orbitNr
00489     << std::endl;
00490 
00491     iWord++;
00492     myCout << "\n Word " << iWord << std::endl;
00493 
00494     myCout << "  Empty word          "
00495     << std::endl;
00496 
00497 }
00498 
00499 
00500 // unpack TCS
00501 // tcsPtr pointer to the beginning of the TCS block in the raw data
00502 void L1TcsWord::unpack(const unsigned char* tcsPtr)
00503 {
00504     LogDebug("L1GtTcsWord")
00505     << "\nUnpacking TCS block.\n"
00506     << std::endl;
00507 
00508     const cms_uint64_t* payload =
00509         reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(tcsPtr));
00510 
00511     setBoardId(payload[BoardIdWord]);
00512     setBxNr(payload[BxNrWord]);
00513     setDaqNr(payload[DaqNrWord]);
00514     setTriggerType(payload[TriggerTypeWord]);
00515     setStatus(payload[StatusWord]);
00516     setLuminositySegmentNr(payload[LuminositySegmentNrWord]);
00517 
00518     setPartRunNr(payload[PartRunNrWord]);
00519     setAssignedPartitions(payload[AssignedPartitionsWord]);
00520 
00521     setPartTrigNr(payload[PartTrigNrWord]);
00522     setEventNr(payload[EventNrWord]);
00523 
00524     setOrbitNrFrom(payload[OrbitNrWord]);
00525 
00526     if ( edm::isDebugEnabled() ) {
00527 
00528         for (int iWord = 0; iWord < BlockSize; ++iWord) {
00529             LogTrace("L1GtTcsWord")
00530             << std::setw(4) << iWord << "  "
00531             << std::hex << std::setfill('0')
00532             << std::setw(16) << payload[iWord]
00533             << std::dec << std::setfill(' ')
00534             << std::endl;
00535         }
00536 
00537     }
00538 
00539 }
00540 
00541 // static class members
00542 
00543 // block description in the raw GT record
00544 
00545 // block size in 64bits words (BlockSize * 64 bits)
00546 const int L1TcsWord::BlockSize = 5;
00547 
00548 // word 0
00549 
00550 // index of the word in the TCS block containig the variable
00551 const int L1TcsWord::BoardIdWord = 0;
00552 const int L1TcsWord::BxNrWord = 0;
00553 const int L1TcsWord::DaqNrWord = 0;
00554 const int L1TcsWord::TriggerTypeWord = 0;
00555 const int L1TcsWord::StatusWord = 0;
00556 const int L1TcsWord::LuminositySegmentNrWord = 0;
00557 
00558 // mask to get the 64-bit-value from the corresponding word in the TCS block
00559 const cms_uint64_t L1TcsWord::BoardIdMask =               0xFFFF000000000000ULL;
00560 const cms_uint64_t L1TcsWord::BxNrMask =                  0x00000FFF00000000ULL;
00561 const cms_uint64_t L1TcsWord::DaqNrMask =                 0x000000000F000000ULL;
00562 const cms_uint64_t L1TcsWord::TriggerTypeMask =           0x0000000000F00000ULL;
00563 const cms_uint64_t L1TcsWord::StatusMask =                0x00000000000F0000ULL;
00564 const cms_uint64_t L1TcsWord::LuminositySegmentNrMask =   0x000000000000FFFFULL;
00565 
00566 // shift to the right to get the value from the "64-bit-value"
00567 const int L1TcsWord::BoardIdShift = 48;
00568 const int L1TcsWord::BxNrShift = 32;
00569 const int L1TcsWord::DaqNrShift = 24;
00570 const int L1TcsWord::TriggerTypeShift = 20;
00571 const int L1TcsWord::StatusShift = 16;
00572 const int L1TcsWord::LuminositySegmentNrShift = 0;
00573 
00574 // word 1
00575 
00576 const int L1TcsWord::PartRunNrWord = 1;
00577 const int L1TcsWord::AssignedPartitionsWord = 1;
00578 
00579 const cms_uint64_t L1TcsWord::PartRunNrMask          =   0xFFFFFFFF00000000ULL;
00580 const cms_uint64_t L1TcsWord::AssignedPartitionsMask =   0x00000000FFFFFFFFULL;
00581 
00582 const int L1TcsWord::PartRunNrShift = 32;
00583 const int L1TcsWord::AssignedPartitionsShift = 0;
00584 
00585 // word 2
00586 
00587 const int L1TcsWord::PartTrigNrWord = 2;
00588 const int L1TcsWord::EventNrWord = 2;
00589 
00590 const cms_uint64_t L1TcsWord::PartTrigNrMask =   0xFFFFFFFF00000000ULL;
00591 const cms_uint64_t L1TcsWord::EventNrMask    =   0x00000000FFFFFFFFULL;
00592 
00593 const int L1TcsWord::PartTrigNrShift = 32;
00594 const int L1TcsWord::EventNrShift = 0;
00595 
00596 // word 3
00597 
00598 const int L1TcsWord::OrbitNrWord = 3;
00599 
00600 const cms_uint64_t L1TcsWord::OrbitNrMask =   0x0000FFFFFFFFFFFFULL;
00601 
00602 const int L1TcsWord::OrbitNrShift = 0;
00603 
00604 
00605 // word 4
00606 
00607 // empty
00608 
00609 
00610