CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/EcalTBRawToDigi/src/DCCXtalBlock.cc

Go to the documentation of this file.
00001 #include "DCCXtalBlock.h"
00002 #include "DCCDataParser.h"
00003 #include "DCCDataMapper.h"
00004 
00005 
00006 DCCTBXtalBlock::DCCTBXtalBlock(
00007         DCCTBDataParser * parser, 
00008         uint32_t * buffer, 
00009         uint32_t numbBytes,  
00010         uint32_t wordsToEnd,
00011         uint32_t wordEventOffset,
00012         uint32_t expectedXtalID,
00013         uint32_t expectedStripID
00014 ) : DCCTBBlockPrototype(parser,"XTAL", buffer, numbBytes, wordsToEnd, wordEventOffset),
00015 expectedXtalID_(expectedXtalID), expectedStripID_(expectedStripID){
00016         
00017         
00018         //Reset error counters ////
00019         errors_["XTAL::HEADER"]  = 0;
00020         errors_["XTAL::BLOCKID"] = 0; 
00022         
00023         // Get data fields from the mapper and retrieve data /////////////////////////////////////
00024         mapperFields_ = parser_->mapper()->xtalFields();        
00025         parseData();
00027         
00028         // check internal data ////////////
00029         if(parser_->debug()){ dataCheck();}
00031 
00032 }
00033 
00034 
00035 
00036 void DCCTBXtalBlock::dataCheck(){
00037         
00038         std::string checkErrors("");
00039                 
00040         std::pair <bool,std::string> res;
00041         
00042         
00043         if(expectedXtalID_ !=0){ 
00044                 res = checkDataField("XTAL ID",expectedXtalID_); 
00045                 if(!res.first){ checkErrors += res.second; (errors_["XTAL::HEADER"])++; } 
00046         }
00047         if(expectedStripID_!=0){ 
00048                 res = checkDataField("STRIP ID",expectedStripID_);
00049                 if(!res.first){ checkErrors += res.second; (errors_["XTAL::HEADER"])++; } 
00050         }
00051         if(checkErrors!=""){
00052                 errorString_ +="\n ======================================================================\n";           
00053                 errorString_ += std::string(" ") + name_ + std::string(" data fields checks errors : ") ;
00054                 errorString_ += checkErrors ;
00055                 errorString_ += "\n ======================================================================";
00056                 blockError_ = true;     
00057         }
00058         
00059 }
00060 
00061 
00062 void  DCCTBXtalBlock::increment(uint32_t numb){
00063         if(!parser_->debug()){ DCCTBBlockPrototype::increment(numb); }
00064         else {
00065                 for(uint32_t counter=0; counter<numb; counter++, dataP_++,wordCounter_++){
00066                         uint32_t blockID = (*dataP_)>>BPOSITION_BLOCKID;
00067                         if( blockID != BLOCKID ){
00068                                 (errors_["XTAL::BLOCKID"])++;
00069                                 //errorString_ += std::string("\n") + parser_->index(nunb)+(" blockId has value ") + parser_->getDecString(blockID);
00070                                 //errorString  += std::string(", while ")+parser_->getDecString(BLOCKID)+std::string(" is expected");
00071                         }
00072                 }
00073         }
00074 }
00075 
00076 int DCCTBXtalBlock::xtalID() {
00077 
00078   int result=-1;
00079 
00080   for(  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator 
00081            it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
00082   
00083     if ( (*it)->name() == "XTAL ID" ) 
00084       result=getDataField( (*it)->name() )  ;
00085     
00086   }
00087 
00088 
00089  
00090   return result; 
00091 
00092 }
00093 
00094 int DCCTBXtalBlock::stripID() {
00095   int result=-1;
00096 
00097   for(std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
00098     if ( (*it)->name() == "STRIP ID" ) 
00099       result=getDataField( (*it)->name() )  ;
00100     
00101   }
00102   
00103   return result;
00104 
00105 }
00106 
00107 
00108 
00109 std::vector<int> DCCTBXtalBlock::xtalDataSamples() {
00110   std::vector<int> data;
00111 
00112 
00113   for(unsigned int i=1;i <= parser_->numbXtalSamples();i++){
00114     std::string name = std::string("ADC#") + parser_->getDecString(i);
00115     
00116     data.push_back ( getDataField( name )  );
00117      
00118   }
00119 
00120   return data;
00121 }