CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DCCXtalBlock.cc
Go to the documentation of this file.
1 #include "DCCXtalBlock.h"
2 #include "DCCDataParser.h"
3 #include "DCCDataMapper.h"
4 
5 
8  uint32_t * buffer,
9  uint32_t numbBytes,
10  uint32_t wordsToEnd,
11  uint32_t wordEventOffset,
12  uint32_t expectedXtalID,
13  uint32_t expectedStripID
14 ) : DCCTBBlockPrototype(parser,"XTAL", buffer, numbBytes, wordsToEnd, wordEventOffset),
15 expectedXtalID_(expectedXtalID), expectedStripID_(expectedStripID){
16 
17 
18  //Reset error counters ////
19  errors_["XTAL::HEADER"] = 0;
20  errors_["XTAL::BLOCKID"] = 0;
22 
23  // Get data fields from the mapper and retrieve data /////////////////////////////////////
25  parseData();
27 
28  // check internal data ////////////
29  if(parser_->debug()){ dataCheck();}
31 
32 }
33 
34 
35 
37 
38  std::string checkErrors("");
39 
40  std::pair <bool,std::string> res;
41 
42 
43  if(expectedXtalID_ !=0){
44  res = checkDataField("XTAL ID",expectedXtalID_);
45  if(!res.first){ checkErrors += res.second; (errors_["XTAL::HEADER"])++; }
46  }
47  if(expectedStripID_!=0){
48  res = checkDataField("STRIP ID",expectedStripID_);
49  if(!res.first){ checkErrors += res.second; (errors_["XTAL::HEADER"])++; }
50  }
51  if(checkErrors!=""){
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 
61 
62 void DCCTBXtalBlock::increment(uint32_t numb){
64  else {
65  for(uint32_t counter=0; counter<numb; counter++, dataP_++,wordCounter_++){
66  uint32_t blockID = (*dataP_)>>BPOSITION_BLOCKID;
67  if( blockID != BLOCKID ){
68  (errors_["XTAL::BLOCKID"])++;
69  //errorString_ += std::string("\n") + parser_->index(nunb)+(" blockId has value ") + parser_->getDecString(blockID);
70  //errorString += std::string(", while ")+parser_->getDecString(BLOCKID)+std::string(" is expected");
71  }
72  }
73  }
74 }
75 
77 
78  int result=-1;
79 
80  for( std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator
81  it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
82 
83  if ( (*it)->name() == "XTAL ID" )
84  result=getDataField( (*it)->name() ) ;
85 
86  }
87 
88 
89 
90  return result;
91 
92 }
93 
95  int result=-1;
96 
97  for(std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
98  if ( (*it)->name() == "STRIP ID" )
99  result=getDataField( (*it)->name() ) ;
100 
101  }
102 
103  return result;
104 
105 }
106 
107 
108 
110  std::vector<int> data;
111 
112 
113  for(unsigned int i=1;i <= parser_->numbXtalSamples();i++){
115 
116  data.push_back ( getDataField( name ) );
117 
118  }
119 
120  return data;
121 }
virtual std::pair< bool, std::string > checkDataField(std::string name, uint32_t data)
virtual uint32_t getDataField(std::string name)
int i
Definition: DBlmapReader.cc:9
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
virtual void increment(uint32_t numb, std::string msg="")
virtual void parseData()
DCCTBDataParser * parser_
std::string getDecString(uint32_t data)
std::vector< int > xtalDataSamples()
uint32_t expectedStripID_
Definition: DCCXtalBlock.h:36
DCCTBXtalBlock(DCCTBDataParser *parser, uint32_t *buffer, uint32_t numbBytes, uint32_t wordsToEnd, uint32_t wordEventOffset, uint32_t expectedXtalID, uint32_t expectedStripID)
Definition: DCCXtalBlock.cc:6
uint32_t numbXtalSamples()
tuple result
Definition: query.py:137
DCCTBDataMapper * mapper()
std::map< std::string, uint32_t > errors_
uint32_t expectedXtalID_
Definition: DCCXtalBlock.h:35
void increment(uint32_t numb)
Definition: DCCXtalBlock.cc:62
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static std::atomic< unsigned int > counter
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * xtalFields()