CMS 3D CMS Logo

DCCXtalBlock.cc
Go to the documentation of this file.
1 #include "DCCXtalBlock.h"
2 #include "DCCDataParser.h"
3 #include "DCCDataMapper.h"
4 
6  const uint32_t *buffer,
7  uint32_t numbBytes,
8  uint32_t wordsToEnd,
9  uint32_t wordEventOffset,
10  uint32_t expectedXtalID,
11  uint32_t expectedStripID)
12  : DCCTBBlockPrototype(parser, "XTAL", buffer, numbBytes, wordsToEnd, wordEventOffset),
13  expectedXtalID_(expectedXtalID),
14  expectedStripID_(expectedStripID) {
15  //Reset error counters ////
16  errors_["XTAL::HEADER"] = 0;
17  errors_["XTAL::BLOCKID"] = 0;
19 
20  // Get data fields from the mapper and retrieve data /////////////////////////////////////
22  parseData();
24 
25  // check internal data ////////////
26  if (parser_->debug()) {
27  dataCheck();
28  }
30 }
31 
33  std::string checkErrors("");
34 
35  std::pair<bool, std::string> res;
36 
37  if (expectedXtalID_ != 0) {
38  res = checkDataField("XTAL ID", expectedXtalID_);
39  if (!res.first) {
40  checkErrors += res.second;
41  (errors_["XTAL::HEADER"])++;
42  }
43  }
44  if (expectedStripID_ != 0) {
45  res = checkDataField("STRIP ID", expectedStripID_);
46  if (!res.first) {
47  checkErrors += res.second;
48  (errors_["XTAL::HEADER"])++;
49  }
50  }
51  if (!checkErrors.empty()) {
52  errorString_ += "\n ======================================================================\n";
53  errorString_ += std::string(" ") + name_ + std::string(" data fields checks errors : ");
54  errorString_ += checkErrors;
55  errorString_ += "\n ======================================================================";
56  blockError_ = true;
57  }
58 }
59 
60 void DCCTBXtalBlock::increment(uint32_t numb) {
61  if (!parser_->debug()) {
63  } else {
64  for (uint32_t counter = 0; counter < numb; counter++, dataP_++, wordCounter_++) {
65  uint32_t blockID = (*dataP_) >> BPOSITION_BLOCKID;
66  if (blockID != BLOCKID) {
67  (errors_["XTAL::BLOCKID"])++;
68  //errorString_ += std::string("\n") + parser_->index(nunb)+(" blockId has value ") + parser_->getDecString(blockID);
69  //errorString += std::string(", while ")+parser_->getDecString(BLOCKID)+std::string(" is expected");
70  }
71  }
72  }
73 }
74 
76  int result = -1;
77 
78  for (std::set<DCCTBDataField *, DCCTBDataFieldComparator>::iterator it = mapperFields_->begin();
79  it != mapperFields_->end();
80  it++) {
81  if ((*it)->name() == "XTAL ID")
82  result = getDataField((*it)->name());
83  }
84 
85  return result;
86 }
87 
89  int result = -1;
90 
91  for (std::set<DCCTBDataField *, DCCTBDataFieldComparator>::iterator it = mapperFields_->begin();
92  it != mapperFields_->end();
93  it++) {
94  if ((*it)->name() == "STRIP ID")
95  result = getDataField((*it)->name());
96  }
97 
98  return result;
99 }
100 
102  std::vector<int> data;
103 
104  for (unsigned int i = 1; i <= parser_->numbXtalSamples(); i++) {
106 
107  data.push_back(getDataField(name));
108  }
109 
110  return data;
111 }
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_
virtual void parseData()
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
DCCTBDataParser * parser_
DCCTBXtalBlock(DCCTBDataParser *parser, const uint32_t *buffer, uint32_t numbBytes, uint32_t wordsToEnd, uint32_t wordEventOffset, uint32_t expectedXtalID, uint32_t expectedStripID)
Definition: DCCXtalBlock.cc:5
std::string getDecString(uint32_t data)
std::vector< int > xtalDataSamples()
uint32_t expectedStripID_
Definition: DCCXtalBlock.h:32
std::map< std::string, uint32_t > errors_
Definition: Electron.h:6
uint32_t numbXtalSamples()
DCCTBDataMapper * mapper()
uint32_t expectedXtalID_
Definition: DCCXtalBlock.h:31
void increment(uint32_t numb)
Definition: DCCXtalBlock.cc:60
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * xtalFields()