CMS 3D CMS Logo

DCCTCCBlock.cc
Go to the documentation of this file.
1 /*--------------------------------------------------------------*/
2 /* DCC TCC BLOCK CLASS */
3 /* */
4 /* Author : N.Almeida (LIP) Date : 30/05/2005 */
5 /*--------------------------------------------------------------*/
6 
7 #include "DCCTCCBlock.h"
8 
9 /*-------------------------------------------------*/
10 /* DCCTBTCCBlock::DCCTBTCCBlock */
11 /* class constructor */
12 /*-------------------------------------------------*/
15  const uint32_t* buffer,
16  uint32_t numbBytes,
17  uint32_t wordsToEnd,
18  uint32_t wordEventOffset,
19  uint32_t expectedId)
20  : DCCTBBlockPrototype(parser, "TCC", buffer, numbBytes, wordsToEnd, wordEventOffset),
21  dccBlock_(dccBlock),
22  expectedId_(expectedId) {
23  //Reset error counters
24  errors_["TCC::HEADER"] = 0;
25  errors_["TCC::BLOCKID"] = 0;
26 
27  //Get data fields from the mapper and retrieve data
28  if (parser_->numbTTs() == 68) {
30  } else if (parser_->numbTTs() == 32) {
32  } else if (parser_->numbTTs() == 16) {
34  }
35 
36  parseData();
37 
38  // check internal data
39  if (parser_->debug())
40  dataCheck();
41 }
42 
43 /*---------------------------------------------------*/
44 /* DCCTBTCCBlock::dataCheck */
45 /* check data with data fields */
46 /*---------------------------------------------------*/
48  std::pair<bool, std::string> res; //check result
49  std::string checkErrors(""); //error string
50 
51  //check BX(LOCAL) field (1st word bit 16)
52  res = checkDataField("BX", BXMASK & (dccBlock_->getDataField("BX")));
53  if (!res.first) {
54  checkErrors += res.second;
55  (errors_["TCC::HEADER"])++;
56  }
57 
58  //check LV1(LOCAL) field (1st word bit 32)
59  res = checkDataField("LV1", L1MASK & (dccBlock_->getDataField("LV1")));
60  if (!res.first) {
61  checkErrors += res.second;
62  (errors_["TCC::HEADER"])++;
63  }
64 
65  //check TCC ID field (1st word bit 0)
66  res = checkDataField("TCC ID", expectedId_);
67  if (!res.first) {
68  checkErrors += res.second;
69  (errors_["TCC::HEADER"])++;
70  }
71 
72  if (!checkErrors.empty()) {
73  blockError_ = true;
74  errorString_ += "\n ======================================================================\n";
75  errorString_ += std::string(" ") + name_ + std::string("( ID = ") + parser_->getDecString((uint32_t)(expectedId_)) +
76  std::string(" ) errors : ");
77  errorString_ += checkErrors;
78  errorString_ += "\n ======================================================================";
79  }
80 }
81 
82 /*--------------------------------------------------*/
83 /* DCCTBTCCBlock::increment */
84 /* increment a TCC block */
85 /*--------------------------------------------------*/
86 
87 void DCCTBTCCBlock::increment(uint32_t numb) {
88  //if no debug is required increments the number of blocks
89  //otherwise checks if block id is really B'011'=3
90  if (!parser_->debug()) {
92  } else {
93  for (uint32_t counter = 0; counter < numb; counter++, dataP_++, wordCounter_++) {
94  uint32_t blockID = (*dataP_) >> BPOSITION_BLOCKID;
95  if (blockID != BLOCKID) {
96  (errors_["TCC::BLOCKID"])++;
97  //errorString_ += std::string("\n") + parser_->index(nunb)+(" blockId has value ") + parser_->getDecString(blockID);
98  //errorString += std::string(", while ")+parser_->getDecString(BLOCKID)+std::string(" is expected");
99  }
100  }
101  }
102 }
103 
104 std::vector<std::pair<int, bool> > DCCTBTCCBlock::triggerSamples() {
105  std::vector<std::pair<int, bool> > data;
106 
107  for (unsigned int i = 1; i <= parser_->numbTTs(); i++) {
109  int tpgValue = getDataField(name);
110  std::pair<int, bool> tpg(tpgValue & ETMASK, bool(tpgValue >> BPOSITION_FGVB));
111  data.push_back(tpg);
112  }
113 
114  return data;
115 }
116 
117 std::vector<int> DCCTBTCCBlock::triggerFlags() {
118  std::vector<int> data;
119 
120  for (unsigned int i = 1; i <= parser_->numbTTs(); i++) {
122 
123  data.push_back(getDataField(name));
124  }
125 
126  return data;
127 }
virtual std::pair< bool, std::string > checkDataField(std::string name, uint32_t data)
virtual uint32_t getDataField(std::string name)
virtual void increment(uint32_t numb, std::string msg="")
const uint32_t * dataP_
uint32_t expectedId_
Definition: DCCTCCBlock.h:69
virtual void parseData()
void dataCheck()
Definition: DCCTCCBlock.cc:47
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
DCCTBDataParser * parser_
std::string getDecString(uint32_t data)
std::map< std::string, uint32_t > errors_
Definition: Electron.h:6
std::vector< int > triggerFlags()
Definition: DCCTCCBlock.cc:117
std::vector< std::pair< int, bool > > triggerSamples()
Definition: DCCTCCBlock.cc:104
void increment(uint32_t numb)
Definition: DCCTCCBlock.cc:87
uint32_t numbTTs()
DCCTBDataMapper * mapper()
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc32Fields()
DCCTBEventBlock * dccBlock_
Definition: DCCTCCBlock.h:68
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DCCTBTCCBlock(DCCTBEventBlock *dccBlock, DCCTBDataParser *parser, const uint32_t *buffer, uint32_t numbBytes, uint32_t wordsToEnd, uint32_t wordEventOffset, uint32_t expectedId)
Definition: DCCTCCBlock.cc:13
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc16Fields()
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc68Fields()