File indexing completed on 2024-04-06 12:10:37
0001
0002
0003
0004
0005
0006
0007 #include "DCCTCCBlock.h"
0008
0009
0010
0011
0012
0013 DCCTBTCCBlock::DCCTBTCCBlock(DCCTBEventBlock* dccBlock,
0014 DCCTBDataParser* parser,
0015 const uint32_t* buffer,
0016 uint32_t numbBytes,
0017 uint32_t wordsToEnd,
0018 uint32_t wordEventOffset,
0019 uint32_t expectedId)
0020 : DCCTBBlockPrototype(parser, "TCC", buffer, numbBytes, wordsToEnd, wordEventOffset),
0021 dccBlock_(dccBlock),
0022 expectedId_(expectedId) {
0023
0024 errors_["TCC::HEADER"] = 0;
0025 errors_["TCC::BLOCKID"] = 0;
0026
0027
0028 if (parser_->numbTTs() == 68) {
0029 mapperFields_ = parser_->mapper()->tcc68Fields();
0030 } else if (parser_->numbTTs() == 32) {
0031 mapperFields_ = parser_->mapper()->tcc32Fields();
0032 } else if (parser_->numbTTs() == 16) {
0033 mapperFields_ = parser_->mapper()->tcc16Fields();
0034 }
0035
0036 parseData();
0037
0038
0039 if (parser_->debug())
0040 dataCheck();
0041 }
0042
0043
0044
0045
0046
0047 void DCCTBTCCBlock::dataCheck() {
0048 std::pair<bool, std::string> res;
0049 std::string checkErrors("");
0050
0051
0052 res = checkDataField("BX", BXMASK & (dccBlock_->getDataField("BX")));
0053 if (!res.first) {
0054 checkErrors += res.second;
0055 (errors_["TCC::HEADER"])++;
0056 }
0057
0058
0059 res = checkDataField("LV1", L1MASK & (dccBlock_->getDataField("LV1")));
0060 if (!res.first) {
0061 checkErrors += res.second;
0062 (errors_["TCC::HEADER"])++;
0063 }
0064
0065
0066 res = checkDataField("TCC ID", expectedId_);
0067 if (!res.first) {
0068 checkErrors += res.second;
0069 (errors_["TCC::HEADER"])++;
0070 }
0071
0072 if (!checkErrors.empty()) {
0073 blockError_ = true;
0074 errorString_ += "\n ======================================================================\n";
0075 errorString_ += std::string(" ") + name_ + std::string("( ID = ") + parser_->getDecString((uint32_t)(expectedId_)) +
0076 std::string(" ) errors : ");
0077 errorString_ += checkErrors;
0078 errorString_ += "\n ======================================================================";
0079 }
0080 }
0081
0082
0083
0084
0085
0086
0087 void DCCTBTCCBlock::increment(uint32_t numb) {
0088
0089
0090 if (!parser_->debug()) {
0091 DCCTBBlockPrototype::increment(numb);
0092 } else {
0093 for (uint32_t counter = 0; counter < numb; counter++, dataP_++, wordCounter_++) {
0094 uint32_t blockID = (*dataP_) >> BPOSITION_BLOCKID;
0095 if (blockID != BLOCKID) {
0096 (errors_["TCC::BLOCKID"])++;
0097
0098
0099 }
0100 }
0101 }
0102 }
0103
0104 std::vector<std::pair<int, bool> > DCCTBTCCBlock::triggerSamples() {
0105 std::vector<std::pair<int, bool> > data;
0106
0107 for (unsigned int i = 1; i <= parser_->numbTTs(); i++) {
0108 std::string name = std::string("TPG#") + parser_->getDecString(i);
0109 int tpgValue = getDataField(name);
0110 std::pair<int, bool> tpg(tpgValue & ETMASK, bool(tpgValue >> BPOSITION_FGVB));
0111 data.push_back(tpg);
0112 }
0113
0114 return data;
0115 }
0116
0117 std::vector<int> DCCTBTCCBlock::triggerFlags() {
0118 std::vector<int> data;
0119
0120 for (unsigned int i = 1; i <= parser_->numbTTs(); i++) {
0121 std::string name = std::string("TTF#") + parser_->getDecString(i);
0122
0123 data.push_back(getDataField(name));
0124 }
0125
0126 return data;
0127 }