CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DCCTBBlockPrototype Class Reference

#include <DCCBlockPrototype.h>

Inheritance diagram for DCCTBBlockPrototype:
DCCTBEventBlock DCCTBSRPBlock DCCTBTCCBlock DCCTBTowerBlock DCCTBTrailerBlock DCCTBXtalBlock

Public Member Functions

bool blockError ()
 
virtual std::pair< bool,
std::string > 
checkDataField (std::string name, uint32_t data)
 
virtual std::pair< bool,
std::string > 
compare (DCCTBBlockPrototype *block)
 
 DCCTBBlockPrototype (DCCTBDataParser *parser, std::string name, uint32_t *buffer, uint32_t numbBytes, uint32_t wordsToEndOfEvent, uint32_t wordEventOffset=0)
 
virtual void displayData (std::ostream &os=std::cout)
 
std::map< std::string, uint32_t > & errorCounters ()
 
std::string & errorString ()
 
virtual uint32_t getDataField (std::string name)
 
virtual uint32_t getDataWord (uint32_t wordPosition, uint32_t bitPosition, uint32_t mask)
 
DCCTBDataParsergetParser ()
 
virtual void increment (uint32_t numb, std::string msg="")
 
std::string name ()
 
virtual void parseData ()
 
virtual void seeIfIsPossibleToIncrement (uint32_t numb, std::string msg="")
 
virtual void setDataField (std::string name, uint32_t data)
 
uint32_t size ()
 
uint32_t wOffset ()
 
virtual ~DCCTBBlockPrototype ()
 

Protected Member Functions

std::string formatString (std::string myString, uint32_t minPositions)
 

Protected Attributes

uint32_t * beginOfBuffer_
 
bool blockError_
 
uint32_t blockSize_
 
std::string blockString_
 
std::map< std::string, uint32_t > dataFields_
 
uint32_t * dataP_
 
std::map< std::string, uint32_t > errors_
 
std::string errorString_
 
std::set< DCCTBDataField
*, DCCTBDataFieldComparator > * 
mapperFields_
 
std::string name_
 
DCCTBDataParserparser_
 
std::string processingString_
 
uint32_t wordCounter_
 
uint32_t wordEventOffset_
 
uint32_t wordsToEndOfEvent_
 

Detailed Description

Definition at line 23 of file DCCBlockPrototype.h.

Constructor & Destructor Documentation

DCCTBBlockPrototype::DCCTBBlockPrototype ( DCCTBDataParser parser,
std::string  name,
uint32_t *  buffer,
uint32_t  numbBytes,
uint32_t  wordsToEndOfEvent,
uint32_t  wordEventOffset = 0 
)

Definition at line 10 of file DCCBlockPrototype.cc.

References beginOfBuffer_, blockError_, blockSize_, dataP_, name(), name_, geometryXMLtoCSV::parser, parser_, wordCounter_, wordEventOffset_, and wordsToEndOfEvent_.

10  {
11 
12  blockError_ = false;
13  parser_ = parser;
14  name_ = name;
15  dataP_ = buffer ;
16  beginOfBuffer_ = buffer ;
17  blockSize_ = numbBytes ;
18  wordEventOffset_ = wordEventOffset;
19  wordsToEndOfEvent_ = wordsToEndOfEvent;
20 
21  wordCounter_ = 0;
22 
23  /*
24  std::cout<<std::endl;
25  std::cout<<" DEBUG::DCCTBBlockPrototype:: Block Name : "<<name_<<std::endl;
26  std::cout<<" DEBUG::DCCTBBlockPrototype:: Block size [bytes] : "<<std::dec<<blockSize_<<std::endl;
27  std::cout<<" DEBUG::DCCTBBlockPrototype:: Number Of Words : "<<std::dec<<blockSize_/4<<std::endl;
28  std::cout<<" DEBUG::DCCTBBlockPrototype:: word event offset : "<<std::dec<<wordEventOffset_<<std::endl;
29  std::cout<<" DEBUG::DCCTBBlockPrototype:: words to end of event : "<<std::dec<<wordsToEndOfEvent_<<std::endl;
30  std::cout<<" DEBUG::DCCTBBlockPrototype:: First Word (*dataP_) : 0x"<<hex<<(*dataP_)<<std::endl;
31  std::cout<<std::endl;
32  */
33 }
DCCTBDataParser * parser_
virtual DCCTBBlockPrototype::~DCCTBBlockPrototype ( )
inlinevirtual

Definition at line 36 of file DCCBlockPrototype.h.

36 {}

Member Function Documentation

bool DCCTBBlockPrototype::blockError ( )
inline

Definition at line 62 of file DCCBlockPrototype.h.

References blockError_.

Referenced by DCCTBEventBlock::eventHasErrors().

62 {return blockError_;}
std::pair< bool, std::string > DCCTBBlockPrototype::checkDataField ( std::string  name,
uint32_t  data 
)
virtual

Definition at line 183 of file DCCBlockPrototype.cc.

References blockError_, getDataField(), DCCTBDataParser::getDecString(), convertSQLitetoXML_cfg::output, and parser_.

Referenced by DCCTBXtalBlock::dataCheck(), DCCTBTrailerBlock::dataCheck(), DCCTBEventBlock::dataCheck(), DCCTBSRPBlock::dataCheck(), DCCTBTowerBlock::dataCheck(), and DCCTBTCCBlock::dataCheck().

183  {
184 
185  std::string output("");
186  std::pair<bool,std::string> res;
187  bool errorFound(false);
188  uint32_t parsedData = getDataField(name);
189  if( parsedData != data){
190  output += std::string("\n Field : ")+name+(" has value ")+parser_->getDecString( parsedData )+ std::string(", while ")+parser_->getDecString(data)+std::string(" is expected");
191 
192  //debug//////////
193  //std::cout<<output<<std::endl;
195 
196  blockError_ = true;
197  errorFound = true;
198  }
199  res.first = !errorFound;
200  res.second = output;
201  return res;
202 }
virtual uint32_t getDataField(std::string name)
DCCTBDataParser * parser_
std::string getDecString(uint32_t data)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< bool, std::string > DCCTBBlockPrototype::compare ( DCCTBBlockPrototype block)
virtual

Definition at line 254 of file DCCBlockPrototype.cc.

References blockSize_, alignCSCRings::e, getDataField(), mapperFields_, name(), name_, dbtoconf::out, run_regression::ret, size(), wOffset(), and wordEventOffset_.

Referenced by DCCTBEventBlock::compare(), and setDataField().

254  {
255 
256 
257  std::pair<bool,std::string> ret(true,"");
258 
259 
260  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it;
261  std::stringstream out;
262 
263 
264 
265  out<<"\n ======================================================================";
266  out<<"\n ORIGINAL BLOCK : ";
267  out<<"\n Block name : "<<name_<<", size : "<<std::dec<<blockSize_<<" bytes, event WOffset : "<<wordEventOffset_;
268  out<<"\n COMPARISION BLOCK : ";
269  out<<"\n Block name : "<<(block->name())<<", size : "<<std::dec<<(block->size())<<" bytes, event WOffset : "<<(block->wOffset());
270  out<<"\n =====================================================================";
271 
272 
273  if( block->name() != name_ ){
274  ret.first = false;
275  out<<"\n ERROR >> It is not possible to compare blocks with different names ! ";
276  ret.second += out.str();
277  return ret;
278  }
279 
280  if( block->size() != blockSize_ ){
281  ret.first = false;
282  out<<"\n WARNING >> Blocks have different sizes "
283  <<"\n WARNING >> Comparision will be carried on untill possible";
284  }
285 
286 
287  if( block->wOffset()!= wordEventOffset_){
288  ret.first = false;
289  out<<"\n WARNING >> Blocks have different word offset within the event ";
290  }
291 
292 
293  std::string dataFieldName;
294 
295  for(it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
296 
297  dataFieldName = (*it)->name();
298 
299  uint32_t aValue, bValue;
300 
301  //Access original block data fields /////////////////////////////////////////////////////
302  try{ aValue = getDataField(dataFieldName); }
303 
304  catch(ECALTBParserBlockException &e ){
305  ret.first = false;
306  out<<"\n ERROR ON ORIGINAL BLOCK unable to get data field :"<<dataFieldName;
307  out<<"\n Comparision was stoped ! ";
308  ret.second += out.str();
309  return ret;
310  }
312 
313  //Access comparision block data fields ///////////////////////////////////////////////////////
314  try{ bValue = block->getDataField(dataFieldName); }
315  catch(ECALTBParserBlockException &e ){
316  ret.first = false;
317  out<<"\n ERROR ON COMPARISION BLOCK unable to get data field :"<<dataFieldName
318  <<"\n Comparision was stoped ! ";
319  ret.second += out.str();
320  return ret;
321  }
323 
324 
325  //std::cout<<"\n data Field name "<<dataFieldName<<std::endl;
326  //std::cout<<"\n aValue "<<std::dec<<aValue<<std::endl;
327  //std::cout<<"\n bValue "<<std::dec<<bValue<<std::endl;
328 
329 
330 
331  // Compare values
332  if( aValue != bValue ){
333  ret.first = false;
334  out<<"\n Data Field : "<<dataFieldName
335  <<"\n ORIGINAL BLOCK value : "<<std::dec<<std::setw(5)<<aValue<<" , COMPARISION BLOCK value : "<<std::dec<<std::setw(5)<<bValue;
336  //std::cout<<"\n debug... "<<out<<std::endl;
337  }
338  }
339  out<<"\n ======================================================================\n";
340  ret.second = out.str();
341 
342  return ret;
343 
344 }
virtual uint32_t getDataField(std::string name)
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
tuple out
Definition: dbtoconf.py:99
void DCCTBBlockPrototype::displayData ( std::ostream &  os = std::cout)
virtual

Definition at line 153 of file DCCBlockPrototype.cc.

References blockSize_, alignCSCRings::e, formatString(), getDataField(), mapperFields_, name_, position, LaserDQM_cfg::process, and wordEventOffset_.

Referenced by DCCTBEventBlock::displayEvent(), parseData(), and seeIfIsPossibleToIncrement().

153  {
154 
155 
156  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it;
157 
158  bool process(true);
159  os << "\n ======================================================================\n";
160  os << " Block name : "<<name_<<", size : "<<std::dec<<blockSize_<<" bytes, event WOffset : "<<wordEventOffset_;
161  long currentPosition(0), position(-1);
162 
163  std::string dataFieldName;
164  for(it = mapperFields_->begin(); it!= mapperFields_->end() && process; it++){
165  try{
166  dataFieldName = (*it)->name();
167  currentPosition = (*it)->wordPosition();
168  if( currentPosition != position ){
169  os << "\n W["<<std::setw(5)<<std::setfill('0')<<currentPosition<<"]" ;
170  position = currentPosition;
171  }
172  os<<" "<<formatString(dataFieldName,14)<<" = "<<std::dec<<std::setw(5)<<getDataField(dataFieldName);
173  } catch (ECALTBParserBlockException & e){ process = false; os<<" not able to get data field..."<<dataFieldName<<std::endl;}
174  }
175  os<<"\n ======================================================================\n";
176 
177 }
virtual uint32_t getDataField(std::string name)
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
static int position[264][3]
Definition: ReadPGInfo.cc:509
tuple process
Definition: LaserDQM_cfg.py:3
std::string formatString(std::string myString, uint32_t minPositions)
std::map<std::string,uint32_t>& DCCTBBlockPrototype::errorCounters ( )
inline

Definition at line 49 of file DCCBlockPrototype.h.

References errors_.

49 { return errors_; }
std::map< std::string, uint32_t > errors_
std::string& DCCTBBlockPrototype::errorString ( )
inline

Definition at line 57 of file DCCBlockPrototype.h.

References errorString_.

Referenced by DCCTBEventBlock::eventErrorString().

57 { return errorString_;}
std::string DCCTBBlockPrototype::formatString ( std::string  myString,
uint32_t  minPositions 
)
protected

Definition at line 220 of file DCCBlockPrototype.cc.

References i, and run_regression::ret.

Referenced by displayData().

220  {
221  std::string ret(myString);
222  uint32_t stringSize = ret.size();
223  if( minPositions > stringSize ){
224  for(uint32_t i=0;i< minPositions-stringSize;i++){ ret+=" ";}
225  }
226  return ret;
227 
228 }
int i
Definition: DBlmapReader.cc:9
uint32_t DCCTBBlockPrototype::getDataField ( std::string  name)
virtual

Definition at line 206 of file DCCBlockPrototype.cc.

References blockError_, dataFields_, and name_.

Referenced by checkDataField(), compare(), DCCTBSRPBlock::dataCheck(), DCCTBTowerBlock::dataCheck(), DCCTBTCCBlock::dataCheck(), DCCTBEventBlock::DCCTBEventBlock(), displayData(), DCCTBEventBlock::eventErrorString(), DCCTBTowerBlock::parseXtalData(), DCCTBXtalBlock::stripID(), DCCTBTowerBlock::towerID(), DCCTBTCCBlock::triggerFlags(), DCCTBTCCBlock::triggerSamples(), DCCTBXtalBlock::xtalDataSamples(), and DCCTBXtalBlock::xtalID().

206  {
207 
208  std::map<std::string,uint32_t>::iterator it = dataFields_.find(name);
209  if(it == dataFields_.end()){
210  throw ECALTBParserBlockException( std::string("\n field named : ")+name+std::string(" was not found in block ")+name_ );
211  blockError_=true;
212  }
213 
214  return (*it).second;
215 
216 }
std::map< std::string, uint32_t > dataFields_
uint32_t DCCTBBlockPrototype::getDataWord ( uint32_t  wordPosition,
uint32_t  bitPosition,
uint32_t  mask 
)
virtual

Definition at line 98 of file DCCBlockPrototype.cc.

References dataP_, increment(), and wordCounter_.

Referenced by parseData().

98  {
99 
100  /*
101  std::cout<<"\n DEBUG::DCCTBBlockPrototype getDataWord method "
102  <<"\n DEBUG::DCCTBBlockPrototype wordPosition = "<<wordPosition
103  <<"\n DEBUG::DCCTBBlockPrototype wordCounter = "<<wordCounter_
104  <<"\n DEBUG::DCCTBBlockPrototype going to increment = "<<(wordPosition-wordCounter_)<<std::endl;
105  */
106  if( wordPosition > wordCounter_ ){ increment(wordPosition - wordCounter_); }
107 
108  return ((*dataP_)>>bitPosition)&mask;
109 
110 }
virtual void increment(uint32_t numb, std::string msg="")
DCCTBDataParser* DCCTBBlockPrototype::getParser ( )
inline

Returns data parser

Definition at line 67 of file DCCBlockPrototype.h.

References parser_.

67 { return parser_; }
DCCTBDataParser * parser_
void DCCTBBlockPrototype::increment ( uint32_t  numb,
std::string  msg = "" 
)
virtual
std::string DCCTBBlockPrototype::name ( void  )
inline
void DCCTBBlockPrototype::parseData ( )
virtual

Definition at line 36 of file DCCBlockPrototype.cc.

References a, blockError_, blockSize_, data, dataFields_, displayData(), alignCSCRings::e, error, errorString_, getDataWord(), DCCTBDataParser::getDecString(), mapperFields_, name_, parser_, and wordEventOffset_.

Referenced by DCCTBEventBlock::DCCTBEventBlock(), DCCTBSRPBlock::DCCTBSRPBlock(), DCCTBTCCBlock::DCCTBTCCBlock(), DCCTBTowerBlock::DCCTBTowerBlock(), DCCTBTrailerBlock::DCCTBTrailerBlock(), and DCCTBXtalBlock::DCCTBXtalBlock().

36  {
37  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it; //iterator for data fields
38 
39  //for debug purposes
40  //std::cout << "Starting to parse data in block named : " << std::endl;
41  //std::cout << " Fields: " << std::dec << (mapperFields_->size()) << std::endl;
42  //std::cout << "\n begin of buffer : "<<hex<<(*beginOfBuffer_)<<std::endl;
43 
44  //cycle through mapper fields
45  for(it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
46 
47  /*
48  //for debug purposes
49  std::cout << "\n Field name : " << (*it)->name();
50  std::cout << "\n Word position : " <<std::dec<< (*it)->wordPosition();
51  std::cout << "\n Bit position : " << (*it)->bitPosition();
52  std::cout << "\n Size : " << hex << (*it)->mask() << std::endl;
53  std::cout << "\n data pointer : " <<hex<<(*dataP_)<<std::endl;
54  std::cout << "\n wordsToEndOfEvent : " <<std::dec<<wordsToEndOfEvent_<<std::endl;
55  */
56 
57  try{
58  uint32_t data = getDataWord( (*it)->wordPosition() , (*it)->bitPosition(),(*it)->mask());
59  dataFields_[(*it)->name()]= data;
60 
61  }catch( ECALTBParserBlockException & e){
62 
63  std::string localString;
64 
65  localString +="\n ======================================================================\n";
66  localString += std::string(" ") + name_ + std::string(" :: out of scope Error :: Unable to get data field : ") + (*it)->name();
67  localString += "\n Word position inside block : " + parser_->getDecString( (*it)->wordPosition() );
68  localString += "\n Word position inside event : " + parser_->getDecString( (*it)->wordPosition() + wordEventOffset_);
69  localString += "\n Block Size [bytes] : " + parser_->getDecString(blockSize_);
70  localString += "\n Action -> Stop parsing this block !";
71  localString += "\n ======================================================================";
72 
73  std::string error("\n Last decoded fields until error : ");
74 
75  std::ostringstream a;
76 
77  try{ displayData(a);}
78  catch(ECALTBParserBlockException &e){}
79 
80  std::string outputErrorString(a.str());
81  error += outputErrorString;
82 
83  errorString_ += localString + error;
84 
85  blockError_ = true;
86 
88 
89  }
90  }
91 
92  //debugg
93  //displayData(std::cout);
94 }
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
DCCTBDataParser * parser_
std::map< std::string, uint32_t > dataFields_
std::string getDecString(uint32_t data)
virtual uint32_t getDataWord(uint32_t wordPosition, uint32_t bitPosition, uint32_t mask)
virtual void displayData(std::ostream &os=std::cout)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121
void DCCTBBlockPrototype::seeIfIsPossibleToIncrement ( uint32_t  numb,
std::string  msg = "" 
)
virtual

Definition at line 122 of file DCCBlockPrototype.cc.

References a, blockError_, blockSize_, displayData(), alignCSCRings::e, error, lumiQueryAPI::msg, wordCounter_, and wordsToEndOfEvent_.

Referenced by increment().

122  {
123 
124  /*
125  std::cout<<"\n See if is possible to increment numb ="<<std::dec<<numb<<" msg "<<msg<<std::endl;
126  std::cout<<" wordCounter_ "<<wordCounter_<<std::endl;
127  std::cout<<" blockSize "<<blockSize_<<std::endl;
128  std::cout<<" wordsToEndOfEvent_ "<<wordsToEndOfEvent_<<std::endl;
129  */
130 
131  if (( ((wordCounter_+numb +1) > blockSize_/4)) ||( wordCounter_ + numb > wordsToEndOfEvent_ )){
132 
133  std::string error=std::string("\n Unable to get next block position (parser stoped!)") +msg;
134  error += "\n Decoded fields untill error : ";
135  //ostream dataUntilError ;
136  std::ostringstream a;
137  std::string outputErrorString;
138 
139 
140  try{ displayData(a);}
141  catch(ECALTBParserBlockException &e){}
142  outputErrorString = a.str();
143  error += outputErrorString;
144 
145  throw ECALTBParserBlockException(error);
146  blockError_=true;
147  }
148 
149 }
virtual void displayData(std::ostream &os=std::cout)
double a
Definition: hdecay.h:121
void DCCTBBlockPrototype::setDataField ( std::string  name,
uint32_t  data 
)
virtual

Definition at line 235 of file DCCBlockPrototype.cc.

References compare(), data, dataFields_, mapperFields_, name(), and name_.

235  {
236  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it; //iterator for data fields
237  bool fieldFound(false);
238  for(it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
239  if( ! ((*it)->name()).compare(name) ){ fieldFound = true; }
240  }
241 
242  if(fieldFound){ dataFields_[name]= data;}
243  else{
244  throw ECALTBParserBlockException( std::string("\n field named : ")+name+std::string(" was not found in block ")+name_ );
245  }
246 
247 }
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * mapperFields_
std::map< std::string, uint32_t > dataFields_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual std::pair< bool, std::string > compare(DCCTBBlockPrototype *block)
uint32_t DCCTBBlockPrototype::size ( void  )
inline

Definition at line 55 of file DCCBlockPrototype.h.

References blockSize_.

Referenced by compare().

55 { return blockSize_; }
uint32_t DCCTBBlockPrototype::wOffset ( )
inline

Definition at line 60 of file DCCBlockPrototype.h.

References wordEventOffset_.

Referenced by compare().

60 { return wordEventOffset_;}

Member Data Documentation

uint32_t* DCCTBBlockPrototype::beginOfBuffer_
protected

Definition at line 74 of file DCCBlockPrototype.h.

Referenced by DCCTBBlockPrototype().

bool DCCTBBlockPrototype::blockError_
protected
uint32_t DCCTBBlockPrototype::blockSize_
protected
std::string DCCTBBlockPrototype::blockString_
protected

Definition at line 85 of file DCCBlockPrototype.h.

std::map<std::string,uint32_t> DCCTBBlockPrototype::dataFields_
protected

Definition at line 90 of file DCCBlockPrototype.h.

Referenced by getDataField(), parseData(), and setDataField().

uint32_t* DCCTBBlockPrototype::dataP_
protected
std::map<std::string,uint32_t> DCCTBBlockPrototype::errors_
protected
std::string DCCTBBlockPrototype::errorString_
protected
std::set<DCCTBDataField *,DCCTBDataFieldComparator>* DCCTBBlockPrototype::mapperFields_
protected
std::string DCCTBBlockPrototype::name_
protected
DCCTBDataParser* DCCTBBlockPrototype::parser_
protected
std::string DCCTBBlockPrototype::processingString_
protected

Definition at line 86 of file DCCBlockPrototype.h.

uint32_t DCCTBBlockPrototype::wordCounter_
protected
uint32_t DCCTBBlockPrototype::wordEventOffset_
protected
uint32_t DCCTBBlockPrototype::wordsToEndOfEvent_
protected