CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/EcalTBRawToDigi/src/DCCTCCBlock.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------*/
00002 /* DCC TCC BLOCK CLASS                                          */
00003 /*                                                              */
00004 /* Author : N.Almeida (LIP)  Date   : 30/05/2005                */
00005 /*--------------------------------------------------------------*/
00006 
00007 #include "DCCTCCBlock.h"
00008 
00009 /*-------------------------------------------------*/
00010 /* DCCTBTCCBlock::DCCTBTCCBlock                        */
00011 /* class constructor                               */
00012 /*-------------------------------------------------*/
00013 DCCTBTCCBlock::DCCTBTCCBlock(
00014         DCCTBEventBlock * dccBlock,
00015         DCCTBDataParser * parser, 
00016         uint32_t * buffer, 
00017         uint32_t numbBytes,  
00018         uint32_t wordsToEnd,
00019         uint32_t wordEventOffset,
00020         uint32_t expectedId) : 
00021   DCCTBBlockPrototype(parser,"TCC", buffer, numbBytes, wordsToEnd, wordEventOffset),dccBlock_(dccBlock), expectedId_(expectedId){
00022 
00023   //Reset error counters
00024   errors_["TCC::HEADER"]  = 0;
00025   errors_["TCC::BLOCKID"] = 0;
00026         
00027   //Get data fields from the mapper and retrieve data 
00028   if(      parser_->numbTTs() == 68){ mapperFields_ = parser_->mapper()->tcc68Fields();}
00029   else if( parser_->numbTTs() == 32){ mapperFields_ = parser_->mapper()->tcc32Fields();}        
00030   else if( parser_->numbTTs() == 16){ mapperFields_ = parser_->mapper()->tcc16Fields();}
00031   
00032   parseData();
00033   
00034   // check internal data 
00035   if(parser_->debug())
00036     dataCheck();
00037 }
00038  
00039 /*---------------------------------------------------*/
00040 /* DCCTBTCCBlock::dataCheck                            */
00041 /* check data with data fields                       */
00042 /*---------------------------------------------------*/
00043 void DCCTBTCCBlock::dataCheck(){
00044   std::pair <bool,std::string> res;            //check result
00045   std::string checkErrors("");            //error string
00046 
00047   //check BX(LOCAL) field (1st word bit 16)
00048   res = checkDataField("BX", BXMASK & (dccBlock_->getDataField("BX")));
00049   if(!res.first){ 
00050     checkErrors += res.second; 
00051     (errors_["TCC::HEADER"])++; 
00052   }
00053   
00054   //check LV1(LOCAL) field (1st word bit 32)
00055   res = checkDataField("LV1", L1MASK & (dccBlock_->getDataField("LV1"))); 
00056   if(!res.first){ 
00057     checkErrors += res.second; 
00058     (errors_["TCC::HEADER"])++; 
00059   }
00060   
00061   //check TCC ID field (1st word bit 0)
00062   res = checkDataField("TCC ID",expectedId_); 
00063   if(!res.first){ 
00064     checkErrors += res.second; 
00065     (errors_["TCC::HEADER"])++; 
00066   } 
00067   
00068   
00069   if(checkErrors!=""){
00070          blockError_=true;
00071     errorString_ +="\n ======================================================================\n"; 
00072          errorString_ += std::string(" ") + name_ + std::string("( ID = ")+parser_->getDecString((uint32_t)(expectedId_))+std::string(" ) errors : ") ;
00073          errorString_ += checkErrors ;
00074          errorString_ += "\n ======================================================================";
00075   }
00076   
00077   
00078 }
00079 
00080 
00081 /*--------------------------------------------------*/
00082 /* DCCTBTCCBlock::increment                           */
00083 /* increment a TCC block                            */
00084 /*--------------------------------------------------*/
00085 
00086 void  DCCTBTCCBlock::increment(uint32_t numb){
00087   //if no debug is required increments the number of blocks
00088   //otherwise checks if block id is really B'011'=3
00089   if(!parser_->debug()){ 
00090     DCCTBBlockPrototype::increment(numb); 
00091   }
00092   else {
00093     for(uint32_t counter=0; counter<numb; counter++, dataP_++, wordCounter_++){
00094       uint32_t blockID = (*dataP_) >> BPOSITION_BLOCKID;
00095       if( blockID != BLOCKID ){
00096         (errors_["TCC::BLOCKID"])++;
00097         //errorString_ += std::string("\n") + parser_->index(nunb)+(" blockId has value ") + parser_->getDecString(blockID);
00098         //errorString  += std::string(", while ")+parser_->getDecString(BLOCKID)+std::string(" is expected");
00099       }
00100     }
00101   }
00102   
00103 }
00104 
00105 
00106 
00107 std::vector< std::pair<int,bool> > DCCTBTCCBlock::triggerSamples() {
00108   std::vector< std::pair<int,bool> > data;
00109 
00110   for(unsigned int i=1;i <= parser_->numbTTs();i++){
00111     std::string name = std::string("TPG#") + parser_->getDecString(i);
00112     int tpgValue = getDataField( name ) ;
00113                  std::pair<int,bool> tpg( tpgValue&ETMASK, bool(tpgValue>>BPOSITION_FGVB));
00114     data.push_back (tpg);
00115      
00116   }
00117 
00118   return data;
00119 }
00120 
00121 
00122 
00123 
00124 std::vector<int> DCCTBTCCBlock::triggerFlags() {
00125   std::vector<int> data;
00126 
00127   for(unsigned int i=1; i<= parser_->numbTTs();i++){
00128     std::string name = std::string("TTF#") + parser_->getDecString(i);
00129     
00130     data.push_back ( getDataField( name )  );
00131      
00132   }
00133 
00134   return data;
00135 }
00136 
00137 
00138 
00139