CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/EventFilter/GctRawToDigi/src/GctFormatTranslateBase.cc

Go to the documentation of this file.
00001 #include "EventFilter/GctRawToDigi/src/GctFormatTranslateBase.h"
00002 
00003 // Framework headers
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 
00006 // INITIALISE STATICS
00007 const std::string GctFormatTranslateBase::INVALID_BLOCK_HEADER_STR = "UNKNOWN/INVALID BLOCK HEADER";
00008 
00009 
00010 // PUBLIC METHODS
00011 
00012 GctFormatTranslateBase::GctFormatTranslateBase(bool hltMode, bool unpackSharedRegions):
00013   m_collections(0),
00014   m_hltMode(hltMode),
00015   m_unpackSharedRegions(unpackSharedRegions),
00016   m_srcCardRouting(),
00017   m_packingBxId(0),
00018   m_packingEventId(0)
00019 {
00020 }
00021 
00022 GctFormatTranslateBase::~GctFormatTranslateBase() { }
00023 
00024 const std::string& GctFormatTranslateBase::getBlockDescription(const GctBlockHeader& header) const
00025 {
00026   if(!header.valid()) { return INVALID_BLOCK_HEADER_STR; }
00027   return blockNameMap().find(header.blockId())->second;
00028 }
00029 
00030 
00031 // PROTECTED METHODS
00032 
00033 L1GctJetCandCollection * const GctFormatTranslateBase::gctJets(const unsigned cat) const
00034 {
00035   switch(cat)
00036   {
00037     case TAU_JETS: return colls()->gctTauJets();
00038     case FORWARD_JETS: return colls()->gctForJets();
00039     default: return colls()->gctCenJets();
00040   } 
00041 }
00042 
00043 void GctFormatTranslateBase::writeRawHeader(unsigned char * data, uint32_t blockId, uint32_t nSamples) const
00044 {
00045   uint32_t hdr = generateRawHeader(blockId, nSamples, packingBxId(), packingEventId());
00046   uint32_t * p = reinterpret_cast<uint32_t*>(const_cast<unsigned char *>(data));
00047   *p = hdr;
00048 }
00049 
00050 bool GctFormatTranslateBase::checkBlock(const GctBlockHeader& hdr) const
00051 {
00052   // check block is valid
00053   if ( !hdr.valid() )
00054   {
00055     LogDebug("GCT") << "Block unpack error: cannot unpack the following unknown/invalid block:\n" << hdr;
00056     return false;     
00057   }
00058 
00059   // check block doesn't have too many time samples
00060   if ( hdr.nSamples() >= 0xf ) {
00061     LogDebug("GCT") << "Block unpack error: cannot unpack a block with 15 or more time samples:\n" << hdr;
00062     return false; 
00063   }
00064   return true;
00065 }
00066 
00067