CMS 3D CMS Logo

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

DCCTBTowerBlock Class Reference

#include <DCCTowerBlock.h>

Inheritance diagram for DCCTBTowerBlock:
DCCTBBlockPrototype

List of all members.

Public Member Functions

 DCCTBTowerBlock (DCCTBEventBlock *dccBlock, DCCTBDataParser *parser, uint32_t *buffer, uint32_t numbBytes, uint32_t wordsToEnd, uint32_t wordEventOffset, uint32_t expectedTowerID)
void parseXtalData ()
int towerID ()
std::vector< DCCTBXtalBlock * > & xtalBlocks ()
std::vector< DCCTBXtalBlock * > xtalBlocksById (uint32_t stripId, uint32_t xtalId)
 ~DCCTBTowerBlock ()

Protected Types

enum  towerFields { BXMASK = 0xFFF, L1MASK = 0xFFF }

Protected Member Functions

void dataCheck ()

Protected Attributes

DCCTBEventBlockdccBlock_
uint32_t expectedTowerID_
std::vector< DCCTBXtalBlock * > xtalBlocks_

Detailed Description

Definition at line 21 of file DCCTowerBlock.h.


Member Enumeration Documentation

enum DCCTBTowerBlock::towerFields [protected]
Enumerator:
BXMASK 
L1MASK 

Definition at line 48 of file DCCTowerBlock.h.

{ BXMASK = 0xFFF,L1MASK = 0xFFF };

Constructor & Destructor Documentation

DCCTBTowerBlock::DCCTBTowerBlock ( DCCTBEventBlock dccBlock,
DCCTBDataParser parser,
uint32_t *  buffer,
uint32_t  numbBytes,
uint32_t  wordsToEnd,
uint32_t  wordEventOffset,
uint32_t  expectedTowerID 
)

Definition at line 11 of file DCCTowerBlock.cc.

References DCCTBBlockPrototype::errors_, DCCTBDataParser::mapper(), DCCTBBlockPrototype::mapperFields_, DCCTBBlockPrototype::parseData(), DCCTBBlockPrototype::parser_, and DCCTBDataMapper::towerFields().

: DCCTBBlockPrototype(parser,"TOWERHEADER", buffer, numbBytes,wordsToEnd, wordEventOffset ) 
 , dccBlock_(dccBlock), expectedTowerID_(expectedTowerID)
{
        
        //Reset error counters ///////////
        errors_["FE::HEADER"]        = 0;
        errors_["FE::TT/SC ID"]      = 0; 
        errors_["FE::BLOCK LENGTH"]  = 0;

        
        
        // Get data fields from the mapper and retrieve data /////////////////////////////////////
        mapperFields_ = parser_->mapper()->towerFields();       
        parseData();
 }
DCCTBTowerBlock::~DCCTBTowerBlock ( )

Definition at line 118 of file DCCTowerBlock.cc.

References xtalBlocks_.

                                 {
        std::vector<DCCTBXtalBlock *>::iterator it;
        for(it=xtalBlocks_.begin();it!=xtalBlocks_.end();it++){ delete (*it);}
        xtalBlocks_.clear();
}

Member Function Documentation

void DCCTBTowerBlock::dataCheck ( ) [protected]

Definition at line 126 of file DCCTowerBlock.cc.

References DCCTBBlockPrototype::blockError_, DCCTBBlockPrototype::checkDataField(), dccBlock_, DCCTBBlockPrototype::errors_, DCCTBBlockPrototype::errorString_, expectedTowerID_, DCCTBBlockPrototype::getDataField(), DCCTBDataParser::getDecString(), L1MASK, DCCTBBlockPrototype::name_, and DCCTBBlockPrototype::parser_.

Referenced by parseXtalData().

                               {
        std::string checkErrors("");    
        
        
        std::pair <bool,std::string> res;
        
        // For TB we don-t check Bx 
        //res = checkDataField("BX", BXMASK & (dccBlock_->getDataField("BX")));
        //if(!res.first){ checkErrors += res.second; (errors_["FE::HEADER"])++; }
        
        // mod to account for ECAL counters starting from 0 in the front end N. Almeida
        res = checkDataField("LV1", L1MASK &  (dccBlock_->getDataField("LV1")  -1)   ); 
        if(!res.first){ checkErrors += res.second; (errors_["FE::HEADER"])++; }
        
        
        if(expectedTowerID_ != 0){ 
                res = checkDataField("TT/SC ID",expectedTowerID_); 
                if(!res.first){ checkErrors += res.second; (errors_["FE::HEADER"])++; } 
        }
        
        if( checkErrors !="" ){
                std::string myTowerId;
                
                errorString_ +="\n ======================================================================\n"; 
                errorString_ += std::string(" ") + name_ + std::string("( ID = ")+parser_->getDecString((uint32_t)(expectedTowerID_))+std::string(" ) errors : ") ;
                errorString_ += checkErrors ;
                errorString_ += "\n ======================================================================";
                blockError_ = true;     
        }
} 
void DCCTBTowerBlock::parseXtalData ( )

Definition at line 39 of file DCCTowerBlock.cc.

References DCCTBBlockPrototype::blockError_, DCCTBBlockPrototype::blockSize_, dataCheck(), DCCTBBlockPrototype::dataP_, dccBlock_, DCCTBDataParser::debug(), DCCTBBlockPrototype::errors_, DCCTBBlockPrototype::errorString_, DCCTBBlockPrototype::getDataField(), DCCTBDataParser::getDecString(), DCCTBBlockPrototype::increment(), DCCTBBlockPrototype::name_, DCCTBDataParser::numbXtalSamples(), DCCTBBlockPrototype::parser_, DCCTBBlockPrototype::wordCounter_, DCCTBBlockPrototype::wordEventOffset_, DCCTBBlockPrototype::wordsToEndOfEvent_, and xtalBlocks_.

Referenced by DCCTBEventBlock::DCCTBEventBlock().

                                    {
        
        uint32_t numbBytes = blockSize_;
        uint32_t wordsToEnd =wordsToEndOfEvent_;
        
        // See if we can construct the correct number of XTAL Blocks////////////////////////////////////////////////////////////////////////////////
        uint32_t numbDWInXtalBlock = ( parser_->numbXtalSamples() )/4 + 1;
        uint32_t length            = getDataField("BLOCK LENGTH");
        uint32_t numbOfXtalBlocks  = 0 ;
        
        if( length > 0 ){ numbOfXtalBlocks = (length-1)/numbDWInXtalBlock; }
        uint32_t xtalBlockSize     =  numbDWInXtalBlock*8;
        //uint32_t pIncrease         =  numbDWInXtalBlock*2;
        
        //std::cout<<"\n DEBUG::numbDWInXtal Block "<<dec<<numbDWInXtalBlock<<std::endl;
        //std::cout<<"\n DEBUG::length             "<<length<<std::endl;
        //std::cout<<"\n DEBUG::xtalBlockSize      "<<xtalBlockSize<<std::endl;
        //std::cout<<"\n DEBUG::pIncreade          "<<pIncrease<<std::endl;

        
        
        bool zs = dccBlock_->getDataField("ZS");
        if( !zs && numbOfXtalBlocks != 25 ){
        
           
                (errors_["FE::BLOCK LENGTH"])++;
                errorString_ += "\n ======================================================================\n";          
                errorString_ += std::string(" ") + name_ + std::string(" ZS is not active, error in the Tower Length !") ;
                errorString_ += "\n Tower Length is : " + (parser_->getDecString(numbBytes/8))+std::string(" , while it should be : ");
                std::string myString = parser_->getDecString((uint32_t)(25*numbDWInXtalBlock+1));
                errorString_ += "\n It was only possible to build : " + parser_->getDecString( numbOfXtalBlocks)+ std::string(" XTAL blocks");
                errorString_ += "\n ======================================================================";
                blockError_ = true;
        };
        if( numbOfXtalBlocks > 25 ){
                if (errors_["FE::BLOCK LENGTH"]==0)(errors_["FE::BLOCK LENGTH"])++;
                errorString_ += "\n ======================================================================\n";          
                errorString_ += std::string(" ") + name_ + std::string(" Tower Length is larger then expected...!") ;
                errorString_ += "\n Tower Length is : " + parser_->getDecString(numbBytes/8)+std::string(" , while it should be at maximum : ");
                std::string myString = parser_->getDecString((uint32_t)(25*numbDWInXtalBlock+1));
                errorString_ += "\n Action -> data after the xtal 25 is ignored... "; 
                errorString_ += "\n ======================================================================";
                blockError_ = true;
                
        }
        
        blockSize_     += length*8;  //??????????????????????
        
        // Get XTAL Data //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        uint32_t stripID, xtalID;
        
        
        for(uint32_t numbXtal=1; numbXtal <= numbOfXtalBlocks && numbXtal <=25 ; numbXtal++){
        
                increment(1);
                
                stripID =( numbXtal-1)/5 + 1;   
                xtalID  = numbXtal - (stripID-1)*5;
                
                
                if(!zs){        
                        xtalBlocks_.push_back(  new DCCTBXtalBlock( parser_, dataP_, xtalBlockSize, wordsToEnd-wordCounter_,wordCounter_+wordEventOffset_,xtalID, stripID) );
                }else{
                        xtalBlocks_.push_back(  new DCCTBXtalBlock( parser_, dataP_, xtalBlockSize, wordsToEnd-wordCounter_,wordCounter_+wordEventOffset_,0,0));
                }
                
                increment(xtalBlockSize/4-1);
        }

                
        // Check internal data ////////////
        if(parser_->debug()){ dataCheck();};
}
int DCCTBTowerBlock::towerID ( )

Definition at line 178 of file DCCTowerBlock.cc.

References DCCTBBlockPrototype::getDataField(), DCCTBBlockPrototype::mapperFields_, and query::result.

Referenced by EcalTBDaqFormatter::DecodeMEM(), and EcalTB07DaqFormatter::DecodeMEM().

                             {
  int result=-1;

  for(std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it = mapperFields_->begin(); it!= mapperFields_->end(); it++){
    if ( (*it)->name() == "TT/SC ID" ) 
      result=getDataField( (*it)->name() )  ;
    
  }
  
  return result;

}
std::vector< DCCTBXtalBlock * > & DCCTBTowerBlock::xtalBlocks ( ) [inline]

Definition at line 57 of file DCCTowerBlock.h.

References xtalBlocks_.

Referenced by EcalTBDaqFormatter::DecodeMEM(), and EcalTB07DaqFormatter::DecodeMEM().

{ return xtalBlocks_; }
std::vector< DCCTBXtalBlock * > DCCTBTowerBlock::xtalBlocksById ( uint32_t  stripId,
uint32_t  xtalId 
)

Definition at line 160 of file DCCTowerBlock.cc.

References alignCSCRings::e, and xtalBlocks_.

                                                                                              {
        std::vector<DCCTBXtalBlock *> myVector; 
        std::vector<DCCTBXtalBlock *>::iterator it;
        
        for( it = xtalBlocks_.begin(); it!= xtalBlocks_.end(); it++ ){
                try{
                        
                  std::pair<bool,std::string> stripIdCheck   = (*it)->checkDataField("STRIP ID",stripId);
                  std::pair<bool,std::string> xtalIdCheck    = (*it)->checkDataField("XTAL ID",xtalId);
                        
                        if(xtalIdCheck.first && stripIdCheck.first ){ myVector.push_back( (*it) ); }
                        
                }catch (ECALTBParserBlockException &e){/*ignore*/ }
        }
        
        return myVector;
}

Member Data Documentation

Definition at line 51 of file DCCTowerBlock.h.

Referenced by dataCheck(), and parseXtalData().

uint32_t DCCTBTowerBlock::expectedTowerID_ [protected]

Definition at line 52 of file DCCTowerBlock.h.

Referenced by dataCheck().

std::vector<DCCTBXtalBlock * > DCCTBTowerBlock::xtalBlocks_ [protected]

Definition at line 50 of file DCCTowerBlock.h.

Referenced by parseXtalData(), xtalBlocks(), xtalBlocksById(), and ~DCCTBTowerBlock().