CMS 3D CMS Logo

evf::FUResource Class Reference

#include <EventFilter/ResourceBroker/interface/FUResource.h>

List of all members.

Public Member Functions

void allocate (FUShmRawCell *shmCell)
void appendBlockToSuperFrag (MemRef_t *bufRef)
UInt_t buResourceId () const
void checkDataBlockPayload (MemRef_t *bufRef) throw (evf::Exception)
bool crcBeingChecked ()
void doCrcCheck (bool doCrcCheck)
UInt_t evtNumber () const
bool fatalError () const
void fillSuperFragPayload () throw (evf::Exception)
void findFEDs () throw (evf::Exception)
 FUResource (UInt_t fuResourceId, log4cplus::Logger logger)
UInt_t fuResourceId () const
void incNbSent ()
bool isAllocated () const
bool isComplete () const
UInt_t nbBytes (bool reset=true)
UInt_t nbCrcErrors (bool reset=true)
UInt_t nbErrors (bool reset=true)
UInt_t nbSent () const
void process (MemRef_t *bufRef)
void processDataBlock (MemRef_t *bufRef) throw (evf::Exception)
void release ()
void releaseSuperFrag ()
evf::FUShmRawCellshmCell ()
void superFragSize () throw (evf::Exception)
virtual ~FUResource ()

Static Public Member Functions

static void doFedIdCheck (bool doFedIdCheck)
static void useEvmBoard (bool useEvmBoard)

Private Attributes

UInt_t buResourceId_
bool doCrcCheck_
UInt_t eventPayloadSize_
UInt_t eventSize_
UInt_t evtNumber_
bool fatalError_
UInt_t fedSize_ [1024]
UInt_t fuResourceId_
UInt_t iBlock_
UInt_t iSuperFrag_
log4cplus::Logger log_
UInt_t nbBytes_
UInt_t nbCrcErrors_
UInt_t nbErrors_
UInt_t nBlock_
UInt_t nbSent_
UInt_t nFedMax_
UInt_t nSuperFrag_
UInt_t nSuperFragMax_
evf::FUShmRawCellshmCell_
MemRef_tsuperFragHead_
UInt_t superFragSize_
MemRef_tsuperFragTail_

Static Private Attributes

static bool doFedIdCheck_ = true
static unsigned int gtpDaqId_ = FEDNumbering::getTriggerGTPFEDIds().second
static unsigned int gtpeId_ = FEDNumbering::getTriggerEGTPFEDIds().first
static unsigned int gtpEvmId_ = FEDNumbering::getTriggerGTPFEDIds().first
static bool useEvmBoard_ = true


Detailed Description

Definition at line 17 of file FUResource.h.


Constructor & Destructor Documentation

FUResource::FUResource ( UInt_t  fuResourceId,
log4cplus::Logger  logger 
)

Definition at line 55 of file FUResource.cc.

References release().

00056   : log_(logger)
00057   , fuResourceId_(fuResourceId)
00058   , superFragHead_(0)
00059   , superFragTail_(0)
00060   , nbBytes_(0)
00061   , superFragSize_(0)
00062 {
00063   release();
00064 }

FUResource::~FUResource (  )  [virtual]

Definition at line 68 of file FUResource.cc.

00069 {
00070   
00071 }


Member Function Documentation

void FUResource::allocate ( FUShmRawCell shmCell  ) 

Definition at line 79 of file FUResource.cc.

References evf::FUShmRawCell::clear(), eventPayloadSize_, fuResourceId_, evf::FUShmRawCell::nFed(), nFedMax_, evf::FUShmRawCell::nSuperFrag(), nSuperFragMax_, evf::FUShmRawCell::payloadSize(), evf::FUShmRawCell::setFuResourceId(), and shmCell_.

Referenced by evf::FUResourceTable::buildResource().

00080 {
00081   //release();
00082   shmCell_=shmCell;
00083   shmCell_->clear();
00084   shmCell_->setFuResourceId(fuResourceId_);
00085   eventPayloadSize_=shmCell_->payloadSize();
00086   nFedMax_         =shmCell_->nFed();
00087   nSuperFragMax_   =shmCell_->nSuperFrag();
00088 }

void FUResource::appendBlockToSuperFrag ( MemRef_t bufRef  ) 

Definition at line 452 of file FUResource.cc.

References superFragHead_, and superFragTail_.

Referenced by processDataBlock().

00453 {
00454   if (0==superFragHead_) {
00455     superFragHead_=bufRef;
00456     superFragTail_=bufRef;
00457   }
00458   else {
00459     superFragTail_->setNextReference(bufRef);
00460     superFragTail_=bufRef;
00461   }
00462   return;
00463 }

UInt_t evf::FUResource::buResourceId (  )  const [inline]

Definition at line 57 of file FUResource.h.

References buResourceId_.

Referenced by processDataBlock().

00057 { return buResourceId_; }

void FUResource::checkDataBlockPayload ( MemRef_t bufRef  )  throw (evf::Exception)

Definition at line 351 of file FUResource.cc.

References parseConfig::block, evtNumber_, iBlock_, and nbErrors_.

Referenced by processDataBlock().

00353 {
00354   UInt_t   frameSize      =0;
00355   UInt_t   bufSize        =0;
00356   UInt_t   segSize        =0;
00357   UInt_t   segSizeExpected=0;
00358 
00359   frlh_t  *frlHeader      =0;
00360   
00361   UChar_t *blockAddr      =0;
00362   UChar_t *frlHeaderAddr  =0;
00363   
00364   frameSize    =sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME);
00365 
00366   blockAddr    =(UChar_t*)bufRef->getDataLocation();
00367   frlHeaderAddr=blockAddr+frameSize;
00368   frlHeader    =(frlh_t*)frlHeaderAddr;
00369   
00370   I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME *block
00371     =(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME*)blockAddr;
00372     
00373 
00374   // check that FRL trigno is consistent with FU evtNumber
00375   if(evtNumber_!=frlHeader->trigno) {
00376     nbErrors_++;
00377     std::stringstream oss;
00378     oss<<"FRL header \"trigno\" does not match "
00379        <<"FU  \"evtNumber\"."
00380        <<" trigno:"<<frlHeader->trigno
00381        <<" evtNumber:"<<evtNumber_;
00382     XCEPT_RAISE(evf::Exception,oss.str());
00383   }
00384   
00385 
00386   // check that FRL trigno is consistent with RU eventNumber
00387   if(block->eventNumber!=frlHeader->trigno) {
00388     nbErrors_++;
00389     std::stringstream oss;
00390     oss<<"FRL header \"trigno\" does not match "
00391        <<"RU builder header \"eventNumber\"."
00392        <<" trigno:"<<frlHeader->trigno
00393        <<" eventNumber:"<<block->eventNumber;
00394     XCEPT_RAISE(evf::Exception,oss.str());
00395   }
00396   
00397 
00398   // check that block numbers reported by FRL / RU are consistent
00399   if(block->blockNb!=frlHeader->segno) {
00400     nbErrors_++;
00401     std::stringstream oss;
00402     oss<<"FRL header \"segno\" does not match"
00403        <<"RU builder header \"blockNb\"."
00404        <<" segno:"<<frlHeader->segno
00405        <<" blockNb:"<<block->blockNb;
00406     XCEPT_RAISE(evf::Exception,oss.str());
00407   }
00408   
00409   
00410   // reported block number consistent with expectation
00411   if(block->blockNb!=iBlock_) {
00412     nbErrors_++;
00413     std::stringstream oss;
00414     oss<<"Incorrect block number."
00415        <<" Expected:"<<iBlock_
00416        <<" Received:"<<block->blockNb;
00417     XCEPT_RAISE(evf::Exception, oss.str());
00418   }
00419   
00420   
00421   // reported payload size consistent with expectation
00422   bufSize        =bufRef->getDataSize();
00423   segSizeExpected=bufSize-frameSize-sizeof(frlh_t);
00424   segSize        =frlHeader->segsize & FRL_SEGSIZE_MASK;
00425   if(segSize!=segSizeExpected) {
00426     nbErrors_++;
00427     std::stringstream oss;
00428     oss<<"FRL header segment size is not as expected."
00429        <<" Expected:"<<segSizeExpected
00430        <<" Received:"<<segSize;
00431     XCEPT_RAISE(evf::Exception, oss.str());
00432   }
00433   
00434   
00435   // Check that FU and FRL headers agree on end of super-fragment
00436   bool fuLastBlockInSuperFrag =(block->blockNb==(block->nbBlocksInSuperFragment-1));
00437   bool frlLastBlockInSuperFrag=((frlHeader->segsize & FRL_LAST_SEGM)!=0);
00438   if (fuLastBlockInSuperFrag!=frlLastBlockInSuperFrag) {
00439     nbErrors_++;
00440     std::stringstream oss;
00441     oss<<"FU / FRL header end-of-superfragment mismatch."
00442        <<" FU header:"<<fuLastBlockInSuperFrag
00443        <<" FRL header:"<<frlLastBlockInSuperFrag;
00444     XCEPT_RAISE(evf::Exception,oss.str());
00445   }
00446   
00447   return;
00448 }

bool evf::FUResource::crcBeingChecked (  )  [inline]

Definition at line 50 of file FUResource.h.

References doCrcCheck_.

00050 { return doCrcCheck_; }

void evf::FUResource::doCrcCheck ( bool  doCrcCheck  )  [inline]

Definition at line 48 of file FUResource.h.

References doCrcCheck_.

Referenced by evf::FUResourceTable::buildResource().

00048 { doCrcCheck_  =doCrcCheck; }

static void evf::FUResource::doFedIdCheck ( bool  doFedIdCheck  )  [inline, static]

Definition at line 45 of file FUResource.h.

References doFedIdCheck_.

Referenced by evf::FUResourceBroker::actionPerformed(), and evf::FUResourceBroker::configuring().

UInt_t evf::FUResource::evtNumber (  )  const [inline]

Definition at line 58 of file FUResource.h.

References evtNumber_.

Referenced by findFEDs(), and processDataBlock().

00058 { return evtNumber_; }

bool evf::FUResource::fatalError (  )  const [inline]

Definition at line 52 of file FUResource.h.

References fatalError_.

Referenced by evf::FUResourceTable::buildResource(), and process().

00052 { return fatalError_; }

void FUResource::fillSuperFragPayload (  )  throw (evf::Exception)

Definition at line 504 of file FUResource.cc.

References evtNumber_, fuResourceId_, iSuperFrag_, evf::FUShmRawCell::markSuperFrag(), nbBytes(), nbBytes_, nbErrors_, shmCell_, superFragHead_, superFragSize_, and evf::FUShmRawCell::writeData().

Referenced by processDataBlock().

00505 {
00506   UChar_t *blockAddr    =0;
00507   UChar_t *frlHeaderAddr=0;
00508   UChar_t *fedAddr      =0;
00509   UInt_t   nbBytes      =0;
00510   UInt_t   nbBytesTot   =0;
00511   frlh_t  *frlHeader    =0;
00512   UChar_t *bufferPos    =0;
00513   UChar_t *startPos     =0;
00514   
00515   MemRef_t* bufRef=superFragHead_;
00516   while(bufRef != 0) {
00517     blockAddr    =(UChar_t*)bufRef->getDataLocation();
00518     frlHeaderAddr=blockAddr+sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME);
00519     fedAddr      =frlHeaderAddr+sizeof(frlh_t);
00520     frlHeader    =(frlh_t*)frlHeaderAddr;
00521     nbBytes      =frlHeader->segsize & FRL_SEGSIZE_MASK;
00522     nbBytesTot  +=nbBytes;
00523     
00524     // check if still within limits
00525     if(nbBytesTot>superFragSize_) {
00526       nbErrors_++;
00527       stringstream oss;
00528       oss<<"Reached end of buffer."
00529          <<" fuResourceId:"<<fuResourceId_
00530          <<" evtNumber:"<<evtNumber_
00531          <<" iSuperFrag:"<<iSuperFrag_;
00532       XCEPT_RAISE(evf::Exception,oss.str());
00533     }
00534     
00535     bufferPos=shmCell_->writeData(fedAddr,nbBytes);
00536     if (0==startPos) startPos=bufferPos;
00537     
00538     nbBytes_+=nbBytes;
00539     bufRef=bufRef->getNextReference();
00540   }
00541   
00542   if (!shmCell_->markSuperFrag(iSuperFrag_,superFragSize_,startPos)) {
00543     nbErrors_++;
00544     stringstream oss;
00545     oss<<"Failed to mark super fragment in shared mem buffer."
00546        <<" fuResourceId:"<<fuResourceId_
00547        <<" evtNumber:"<<evtNumber_
00548        <<" iSuperFrag:"<<iSuperFrag_;
00549     XCEPT_RAISE(evf::Exception,oss.str());
00550   }
00551   
00552   return;
00553 }

void FUResource::findFEDs (  )  throw (evf::Exception)

Definition at line 557 of file FUResource.cc.

References evf::compute_crc(), fedt_struct::conscheck, evf::evtn::daq_board_sense(), doCrcCheck_, doFedIdCheck_, fedh_struct::eventid, fedt_struct::eventsize, evf::evtn::evm_board_sense(), evtNumber(), evtNumber_, FED_CRCS_MASK, FED_CRCS_SHIFT, FED_EVSZ_MASK, FED_HCTRLID, FED_HCTRLID_MASK, FED_LVL1_MASK, FED_RBIT_MASK, FED_TCTRLID, FED_TCTRLID_MASK, fedSize_, evf::evtn::get(), gtpDaqId_, evf::evtn::gtpe_board_sense(), evf::evtn::gtpe_get(), gtpeId_, gtpEvmId_, FEDNumbering::inRange(), int, iSuperFrag_, log_, evf::FUShmRawCell::markFed(), nbCrcErrors_, nbErrors_, REAL_SOID_MASK, evf::FUShmRawCell::setEvtNumber(), shmCell_, fedh_struct::sourceid, evf::FUShmRawCell::superFragAddr(), evf::FUShmRawCell::superFragSize(), superFragSize(), and useEvmBoard_.

Referenced by processDataBlock().

00558 {
00559   UChar_t* superFragAddr =0;
00560   UInt_t   superFragSize =0;
00561   
00562   UChar_t *fedTrailerAddr=0;
00563   UChar_t *fedHeaderAddr =0;
00564   
00565   UInt_t   fedSize       =0;
00566   UInt_t   sumOfFedSizes =0;
00567   UInt_t   evtNumber     =0;
00568   
00569   UShort_t crc           =0;
00570   UShort_t crcChk        =0;
00571   
00572   fedt_t  *fedTrailer    =0;
00573   fedh_t  *fedHeader     =0;
00574   
00575   
00576   superFragAddr =shmCell_->superFragAddr(iSuperFrag_);
00577   superFragSize =shmCell_->superFragSize(iSuperFrag_);
00578   fedTrailerAddr=superFragAddr+superFragSize-sizeof(fedt_t);
00579   
00580   while (fedTrailerAddr>superFragAddr) {
00581     
00582     fedTrailer    =(fedt_t*)fedTrailerAddr;
00583     fedSize       =(fedTrailer->eventsize & FED_EVSZ_MASK) << 3;
00584     sumOfFedSizes+=fedSize;
00585     
00586     // check for fed trailer id
00587     if ((fedTrailer->eventsize & FED_TCTRLID_MASK)!=FED_TCTRLID) {
00588       nbErrors_++;
00589       stringstream oss;
00590       oss<<"Missing FED trailer id."
00591          <<" evtNumber:"<<evtNumber_
00592          <<" iSuperFrag:"<<iSuperFrag_;
00593       XCEPT_RAISE(evf::Exception,oss.str());
00594     }
00595     
00596     fedHeaderAddr=fedTrailerAddr-fedSize+sizeof(fedt_t);
00597     
00598     // check that fed header is within buffer
00599     if(fedHeaderAddr<superFragAddr) {
00600       nbErrors_++;
00601       stringstream oss;
00602       oss<<"FED header address out-of-bounds."
00603          <<" evtNumber:"<<evtNumber_
00604          <<" iSuperFrag:"<<iSuperFrag_;
00605       XCEPT_RAISE(evf::Exception,oss.str());
00606     }
00607     
00608     // check that payload starts within buffer
00609     if((fedHeaderAddr+sizeof(fedh_t))>(superFragAddr+superFragSize)) {
00610       nbErrors_++;
00611       stringstream oss;
00612       oss<<"FED payload out-of-bounds."
00613          <<" evtNumber:"<<evtNumber_
00614          <<" iSuperFrag:"<<iSuperFrag_;
00615       XCEPT_RAISE(evf::Exception,oss.str());
00616     }
00617     
00618     fedHeader  =(fedh_t*)fedHeaderAddr;
00619     
00620     // check for fed header id
00621     if ((fedHeader->eventid & FED_HCTRLID_MASK)!=FED_HCTRLID) {
00622       nbErrors_++;
00623       stringstream oss;
00624       oss<<"Missing FED header id."
00625          <<" evtNumber:"<<evtNumber_
00626          <<" iSuperFrag:"<<iSuperFrag_;
00627       XCEPT_RAISE(evf::Exception,oss.str());
00628     }
00629     
00630     UInt_t fedId=(fedHeader->sourceid & REAL_SOID_MASK) >> 8;
00631     
00632     // check evtNumber consisency
00633     evtNumber=fedHeader->eventid & FED_LVL1_MASK;
00634     if (evtNumber!=evtNumber_) {
00635       nbErrors_++;
00636       stringstream oss;
00637       oss<<"FU / FED evtNumber mismatch."
00638          <<" FU:"<<evtNumber_
00639          <<" FED:"<<evtNumber
00640          <<" fedid:"<<fedId;
00641       XCEPT_RAISE(evf::Exception,oss.str());
00642     }
00643   
00644     // check that fedid is within valid ranges
00645     if (fedId>=1024||
00646         (doFedIdCheck_&&(!FEDNumbering::inRange(fedId)))) {
00647       LOG4CPLUS_WARN(log_,"Invalid fedid. Data will still be logged"
00648                      <<" evtNumber:"<<evtNumber_
00649                      <<" fedid:"<<fedId);
00650       nbErrors_++;
00651     }
00652 
00653     // check if a previous fed has already claimed same fed id
00654 
00655     if(fedSize_[fedId]!=0) {
00656       LOG4CPLUS_ERROR(log_,"Duplicated fedid. Data will be lost for"
00657                       <<" evtNumber:"<<evtNumber_
00658                       <<" fedid:"<<fedId);
00659       nbErrors_++;
00660     }
00661     
00662     if (fedId<1024) fedSize_[fedId]=fedSize;
00663 
00664     //if gtp EVM block is available set cell event number to global partition-independent trigger number
00665     //daq block partition-independent event number is left as an option in case of problems
00666 
00667     if(fedId == gtpeId_)
00668       if(evf::evtn::gtpe_board_sense(fedHeaderAddr)) shmCell_->setEvtNumber(evf::evtn::gtpe_get(fedHeaderAddr));
00669     if(useEvmBoard_ && (fedId == gtpEvmId_))
00670       if(evf::evtn::evm_board_sense(fedHeaderAddr,fedSize)) shmCell_->setEvtNumber(evf::evtn::get(fedHeaderAddr, true));
00671     if(!useEvmBoard_ && (fedId == gtpDaqId_))
00672       if(evf::evtn::daq_board_sense(fedHeaderAddr)) shmCell_->setEvtNumber(evf::evtn::get(fedHeaderAddr, false));
00673     // crc check
00674     if (doCrcCheck_) {
00675       UInt_t conscheck=fedTrailer->conscheck;
00676       crc=((fedTrailer->conscheck & FED_CRCS_MASK) >> FED_CRCS_SHIFT);
00677       fedTrailer->conscheck &= (~FED_CRCS_MASK);
00678       fedTrailer->conscheck &= (~FED_RBIT_MASK);
00679       crcChk=compute_crc(fedHeaderAddr,fedSize);
00680       
00681       if (crc!=crcChk) {
00682         LOG4CPLUS_INFO(log_,"crc check failed."
00683                        <<" evtNumber:"<<evtNumber_
00684                        <<" fedid:"<<fedId
00685                        <<" crc:"<<crc
00686                        <<" chk:"<<crcChk);
00687         nbErrors_++;
00688         nbCrcErrors_++;
00689       }
00690       fedTrailer->conscheck=conscheck;
00691     }
00692     
00693     
00694     // mark fed
00695     if (!shmCell_->markFed(fedId,fedSize,fedHeaderAddr)) {
00696       nbErrors_++;
00697       stringstream oss;
00698       oss<<"Failed to mark fed in buffer."
00699          <<" evtNumber:"<<evtNumber_
00700          <<" fedId:"<<fedId
00701          <<" fedSize:"<<fedSize
00702          <<" fedAddr:0x"<<hex<<(int)fedHeaderAddr<<dec;
00703       XCEPT_RAISE(evf::Exception,oss.str());
00704     }
00705     
00706     // Move to the next fed trailer
00707     fedTrailerAddr=fedTrailerAddr-fedSize;
00708   }
00709   
00710   // check that we indeed end up on the starting address of the buffer
00711   if ((fedTrailerAddr+sizeof(fedh_t))!=superFragAddr) {
00712     std::stringstream oss;
00713     oss<<"First FED in superfragment ouf-of-bound."
00714        <<" evtNumber:"<<evtNumber_
00715        <<" iSuperFrag:"<<iSuperFrag_;
00716     XCEPT_RAISE(evf::Exception,oss.str());
00717   }
00718   
00719   return;
00720 }

UInt_t evf::FUResource::fuResourceId (  )  const [inline]

Definition at line 56 of file FUResource.h.

References fuResourceId_.

Referenced by processDataBlock().

00056 { return fuResourceId_; }

void evf::FUResource::incNbSent (  )  [inline]

Definition at line 61 of file FUResource.h.

References nbSent_.

00061 { nbSent_++; }

bool evf::FUResource::isAllocated (  )  const [inline]

Definition at line 53 of file FUResource.h.

References shmCell_.

Referenced by evf::FUResourceTable::buildResource().

00053 { return 0!=shmCell_; }

bool evf::FUResource::isComplete (  )  const [inline]

Definition at line 132 of file FUResource.h.

References iBlock_, iSuperFrag_, nBlock_, and nSuperFrag_.

Referenced by evf::FUResourceTable::buildResource().

00133 {
00134   return (nBlock_&&nSuperFrag_&&(iSuperFrag_==nSuperFrag_)&&(iBlock_==nBlock_));
00135 }

UInt_t FUResource::nbBytes ( bool  reset = true  ) 

Definition at line 753 of file FUResource.cc.

References nbBytes_, and HLT_VtxMuL3::result.

Referenced by fillSuperFragPayload().

00754 {
00755   UInt_t result=nbBytes_;
00756   if (reset) nbBytes_=0;
00757   return result;
00758 }

UInt_t FUResource::nbCrcErrors ( bool  reset = true  ) 

Definition at line 744 of file FUResource.cc.

References nbCrcErrors_, and HLT_VtxMuL3::result.

Referenced by evf::FUResourceTable::buildResource().

00745 {
00746   UInt_t result=nbCrcErrors_;
00747   if (reset) nbCrcErrors_=0;
00748   return result;
00749 }

UInt_t FUResource::nbErrors ( bool  reset = true  ) 

Definition at line 735 of file FUResource.cc.

References nbErrors_, and HLT_VtxMuL3::result.

Referenced by evf::FUResourceTable::buildResource().

00736 {
00737   UInt_t result=nbErrors_;
00738   if (reset) nbErrors_=0;
00739   return result;
00740 }

UInt_t evf::FUResource::nbSent (  )  const [inline]

Definition at line 60 of file FUResource.h.

References nbSent_.

00060 { return nbSent_; }

void FUResource::process ( MemRef_t bufRef  ) 

Definition at line 134 of file FUResource.cc.

References e, Exception, fatalError(), fatalError_, log_, and processDataBlock().

Referenced by evf::FUResourceTable::buildResource().

00135 {
00136   if (fatalError()) {
00137     LOG4CPLUS_WARN(log_,"THIS SHOULD *NEVER* HAPPEN!."); // DEBUG
00138     bufRef->release();
00139     return;
00140   }
00141   
00142   MemRef_t* itBufRef = bufRef;
00143   while(0!=itBufRef&&!fatalError()) {
00144     MemRef_t* next=itBufRef->getNextReference();
00145     itBufRef->setNextReference(0);
00146     
00147     try {
00148       processDataBlock(itBufRef);
00149     }
00150     catch (xcept::Exception& e) {
00151       LOG4CPLUS_ERROR(log_,"EVENT LOST:"
00152                       <<xcept::stdformat_exception_history(e));
00153       fatalError_=true;
00154       bufRef->setNextReference(next);
00155     }
00156     
00157     itBufRef=next;
00158   }
00159   
00160   return;
00161 }

void FUResource::processDataBlock ( MemRef_t bufRef  )  throw (evf::Exception)

Definition at line 165 of file FUResource.cc.

References appendBlockToSuperFrag(), parseConfig::block, buResourceId(), buResourceId_, checkDataBlockPayload(), e, evtNumber(), evtNumber_, Exception, fillSuperFragPayload(), findFEDs(), fuResourceId(), fuResourceId_, iBlock_, iSuperFrag_, nbErrors_, nBlock_, nSuperFrag_, nSuperFragMax_, releaseSuperFrag(), evf::FUShmRawCell::setBuResourceId(), evf::FUShmRawCell::setEvtNumber(), shmCell_, and superFragSize().

Referenced by process().

00167 {
00168   // reset iBlock_/nBlock_ counters
00169   if (iBlock_==nBlock_) {
00170     iBlock_=0;
00171     nBlock_=0xffffffff;
00172   }
00173   
00174   I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME *block=
00175     (I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME*)bufRef->getDataLocation();
00176   
00177   UInt_t iBlock      =block->blockNb;
00178   UInt_t nBlock      =block->nbBlocksInSuperFragment;
00179   UInt_t iSuperFrag  =block->superFragmentNb;
00180   UInt_t nSuperFrag  =block->nbSuperFragmentsInEvent;
00181   
00182   UInt_t fuResourceId=block->fuTransactionId;
00183   UInt_t buResourceId=block->buResourceId;
00184   UInt_t evtNumber   =block->eventNumber;
00185 
00186   // check fuResourceId consistency
00187   if (fuResourceId!=fuResourceId_) {
00188     nbErrors_++;
00189     stringstream oss;
00190     oss<<"RU/FU fuResourceId mismatch."
00191        <<" Received:"<<fuResourceId
00192        <<" Expected:"<<fuResourceId_;
00193     XCEPT_RAISE(evf::Exception,oss.str());
00194   }
00195   
00196   // check iBlock consistency
00197   if (iBlock!=iBlock_) {
00198     nbErrors_++;
00199     stringstream oss;
00200     oss<<"RU/FU block number mismatch."
00201        <<" Received:"<<iBlock
00202        <<" Expected:"<<iBlock_;
00203     XCEPT_RAISE(evf::Exception,oss.str());
00204   }
00205   
00206   // check iSuperFrag consistency
00207   if (iSuperFrag!=iSuperFrag_) {
00208     nbErrors_++;
00209     stringstream oss;
00210     oss<<"RU/FU superfragment number mismatch."
00211        <<" Received:"<<iSuperFrag
00212        <<" Expected:"<<iSuperFrag_;
00213     XCEPT_RAISE(evf::Exception,oss.str());
00214   }
00215 
00216   // assign nBlock_
00217   if (iBlock==0) {
00218     nBlock_=nBlock;
00219   }
00220   else {
00221     // check nBlock_
00222     if (nBlock!=nBlock_) {
00223       nbErrors_++;
00224       stringstream oss;
00225       oss<<"RU/FU number of blocks mismatch."
00226          <<" Received:"<<nBlock
00227          <<" Expected:"<<nBlock_;
00228       XCEPT_RAISE(evf::Exception,oss.str());
00229     }
00230   }
00231   
00232   
00233   // if this is the first block in the event,
00234   // *assign* evtNumber,buResourceId,nSuperFrag ...
00235   if (iBlock==0&&iSuperFrag==0) {
00236     evtNumber_   =evtNumber;
00237     buResourceId_=buResourceId;
00238     nSuperFrag_  =nSuperFrag;
00239     
00240     shmCell_->setEvtNumber(evtNumber);
00241     shmCell_->setBuResourceId(buResourceId);
00242 
00243     // check that buffers are allocated for nSuperFrag superfragments
00244     if(nSuperFrag_>nSuperFragMax_) {
00245       nbErrors_++;
00246       stringstream oss;
00247       oss<<"Invalid maimum number of superfragments."
00248          <<" fuResourceId:"<<fuResourceId_
00249          <<" evtNumber:"<<evtNumber_
00250          <<" nSuperFrag:"<<nSuperFrag_
00251          <<" nSuperFragMax:"<<nSuperFragMax_;
00252       XCEPT_RAISE(evf::Exception,oss.str());
00253     }
00254   }
00255   // ... otherwise,
00256   // *check* evtNumber,buResourceId,nSuperFrag
00257   else {
00258     // check evtNumber
00259     if (evtNumber!=evtNumber_) {
00260       nbErrors_++;
00261       stringstream oss;
00262       oss<<"RU/FU evtNumber mismatch."
00263          <<" Received:"<<evtNumber
00264          <<" Expected:"<<evtNumber_;
00265       XCEPT_RAISE(evf::Exception,oss.str());
00266     }
00267     
00268     // check buResourceId
00269     if (buResourceId!=buResourceId_) {
00270       nbErrors_++;
00271       stringstream oss;
00272       oss<<"RU/FU buResourceId mismatch."
00273          <<" Received:"<<buResourceId
00274          <<" Expected:"<<buResourceId_;
00275       XCEPT_RAISE(evf::Exception,oss.str());
00276     }
00277     
00278     // check nSuperFrag
00279     if (nSuperFrag!=nSuperFrag_) {
00280       nbErrors_++;
00281       stringstream oss;
00282       oss<<"RU/FU number of superfragments mismatch."
00283          <<" Received:"<<nSuperFrag
00284          <<" Expected:"<<nSuperFrag_;
00285       XCEPT_RAISE(evf::Exception,oss.str());
00286     }
00287   }
00288   
00289   
00290   // check payload
00291   try {
00292     checkDataBlockPayload(bufRef);
00293   }
00294   catch (xcept::Exception& e) {
00295     stringstream oss;
00296     oss<<"data block payload failed check."
00297        <<" evtNumber:"<<evtNumber_
00298        <<" buResourceId:"<<buResourceId_
00299        <<" iSuperFrag:"<<iSuperFrag_;
00300     XCEPT_RETHROW(evf::Exception,oss.str(),e);
00301   }
00302   
00303   appendBlockToSuperFrag(bufRef);
00304 
00305   // increment iBlock_, as expected for the next message
00306   iBlock_++;
00307   
00308   // superfragment complete ...
00309   bool lastBlockInSuperFrag=(iBlock==nBlock-1);
00310   if (lastBlockInSuperFrag) {
00311     
00312     // ... fill the FED buffers contained in the superfragment
00313     try {
00314       superFragSize();
00315       fillSuperFragPayload();
00316       findFEDs();
00317     }
00318     catch (xcept::Exception& e) {
00319       stringstream oss;
00320       oss<<"Invalid super fragment."
00321          <<" evtNumber:"<<evtNumber_
00322          <<" buResourceId:"<<buResourceId_
00323          <<" iSuperFrag:"<<iSuperFrag_;
00324       XCEPT_RETHROW(evf::Exception,oss.str(),e);
00325     }
00326     
00327     // ... release the buffers associated with the superfragment
00328     try {
00329       releaseSuperFrag();
00330     }
00331     catch (xcept::Exception& e) {
00332       nbErrors_++;
00333       stringstream oss;
00334       oss<<"Failed to release super fragment."
00335          <<" evtNumber:"<<evtNumber_
00336          <<" buResourceId:"<<buResourceId_
00337          <<" iSuperFrag:"<<iSuperFrag_;
00338       XCEPT_RETHROW(evf::Exception,oss.str(),e);
00339     }
00340 
00341     // increment iSuperFrag_, as expected for the next message(s)
00342     iSuperFrag_++;
00343     
00344   } // lastBlockInSuperFragment
00345   
00346   return;
00347 }

void FUResource::release (  ) 

Definition at line 92 of file FUResource.cc.

References buResourceId_, doCrcCheck_, e, eventSize_, evtNumber_, Exception, fatalError_, fedSize_, i, iBlock_, iSuperFrag_, log_, nbCrcErrors_, nbErrors_, nBlock_, nbSent_, nSuperFrag_, shmCell_, superFragHead_, and superFragTail_.

Referenced by evf::FUResourceTable::buildResource(), and FUResource().

00093 {
00094   doCrcCheck_   =false;
00095   fatalError_   =false;
00096   
00097   buResourceId_ =0xffffffff;
00098   evtNumber_    =0xffffffff;
00099   
00100   if (0!=superFragHead_) {
00101     try {
00102       superFragHead_->release();
00103     }
00104     catch (xcept::Exception& e) {
00105       LOG4CPLUS_ERROR(log_,"Failed to release superFragHead: "
00106                       <<xcept::stdformat_exception_history(e));
00107     }
00108   }
00109   
00110   superFragHead_=0;
00111   superFragTail_=0;
00112   
00113   iBlock_       =0;
00114   nBlock_       =0xffffffff;
00115   iSuperFrag_   =0;
00116   nSuperFrag_   =0xffffffff;
00117 
00118   nbSent_       =0;
00119   
00120   nbErrors_     =0;
00121   nbCrcErrors_  =0;
00122 
00123   for (UInt_t i=0;i<1024;i++) fedSize_[i]=0;
00124   eventSize_    =0;
00125   
00126   if (0!=shmCell_) {
00127     shmdt(shmCell_);
00128     shmCell_=0;
00129   }
00130 }

void FUResource::releaseSuperFrag (  ) 

Definition at line 724 of file FUResource.cc.

References superFragHead_, and superFragTail_.

Referenced by processDataBlock().

00725 {
00726   if (0==superFragHead_) return;
00727   superFragHead_->release(); // throws xcept::Exception
00728   superFragHead_=0;
00729   superFragTail_=0;
00730   return;
00731 }

evf::FUShmRawCell* evf::FUResource::shmCell (  )  [inline]

Definition at line 67 of file FUResource.h.

References shmCell_.

Referenced by evf::FUResourceTable::buildResource().

00067 { return shmCell_; }

void FUResource::superFragSize (  )  throw (evf::Exception)

Definition at line 467 of file FUResource.cc.

References eventPayloadSize_, eventSize_, evtNumber_, fuResourceId_, iSuperFrag_, nbErrors_, superFragHead_, and superFragSize_.

Referenced by findFEDs(), and processDataBlock().

00468 {
00469   UChar_t *blockAddr    =0;
00470   UChar_t *frlHeaderAddr=0;
00471   frlh_t  *frlHeader    =0;
00472 
00473   superFragSize_=0;
00474 
00475   UInt_t frameSize=sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME);
00476   MemRef_t* bufRef=superFragHead_;
00477   
00478   while (0!=bufRef) {
00479     blockAddr      =(UChar_t*)bufRef->getDataLocation();
00480     frlHeaderAddr  =blockAddr+frameSize;
00481     frlHeader      =(frlh_t*)frlHeaderAddr;
00482     superFragSize_+=frlHeader->segsize & FRL_SEGSIZE_MASK; 
00483     bufRef         =bufRef->getNextReference();
00484   }
00485   
00486   eventSize_+=superFragSize_;
00487 
00488   if (eventSize_>eventPayloadSize_) {  
00489     nbErrors_++;
00490     stringstream oss;
00491     oss<<"Event size exceeds maximum size."
00492        <<" fuResourceId:"<<fuResourceId_
00493        <<" evtNumber:"<<evtNumber_
00494        <<" iSuperFrag:"<<iSuperFrag_
00495        <<" eventSize:"<<eventSize_
00496        <<" eventPayloadSize:"<<eventPayloadSize_;
00497     XCEPT_RAISE(evf::Exception,oss.str());
00498   }
00499   
00500 }

static void evf::FUResource::useEvmBoard ( bool  useEvmBoard  )  [inline, static]

Definition at line 47 of file FUResource.h.

References useEvmBoard_.

Referenced by evf::FUResourceBroker::actionPerformed(), and evf::FUResourceBroker::configuring().


Member Data Documentation

UInt_t evf::FUResource::buResourceId_ [private]

Definition at line 85 of file FUResource.h.

Referenced by buResourceId(), processDataBlock(), and release().

bool evf::FUResource::doCrcCheck_ [private]

Definition at line 81 of file FUResource.h.

Referenced by crcBeingChecked(), doCrcCheck(), findFEDs(), and release().

bool FUResource::doFedIdCheck_ = true [static, private]

Definition at line 78 of file FUResource.h.

Referenced by doFedIdCheck(), and findFEDs().

UInt_t evf::FUResource::eventPayloadSize_ [private]

Definition at line 91 of file FUResource.h.

Referenced by allocate(), and superFragSize().

UInt_t evf::FUResource::eventSize_ [private]

Definition at line 108 of file FUResource.h.

Referenced by release(), and superFragSize().

UInt_t evf::FUResource::evtNumber_ [private]

Definition at line 86 of file FUResource.h.

Referenced by checkDataBlockPayload(), evtNumber(), fillSuperFragPayload(), findFEDs(), processDataBlock(), release(), and superFragSize().

bool evf::FUResource::fatalError_ [private]

Definition at line 82 of file FUResource.h.

Referenced by fatalError(), process(), and release().

UInt_t evf::FUResource::fedSize_[1024] [private]

Definition at line 106 of file FUResource.h.

Referenced by findFEDs(), and release().

UInt_t evf::FUResource::fuResourceId_ [private]

Definition at line 84 of file FUResource.h.

Referenced by allocate(), fillSuperFragPayload(), fuResourceId(), processDataBlock(), and superFragSize().

unsigned int FUResource::gtpDaqId_ = FEDNumbering::getTriggerGTPFEDIds().second [static, private]

Definition at line 113 of file FUResource.h.

Referenced by findFEDs().

unsigned int FUResource::gtpeId_ = FEDNumbering::getTriggerEGTPFEDIds().first [static, private]

Definition at line 115 of file FUResource.h.

Referenced by findFEDs().

unsigned int FUResource::gtpEvmId_ = FEDNumbering::getTriggerGTPFEDIds().first [static, private]

Definition at line 114 of file FUResource.h.

Referenced by findFEDs().

UInt_t evf::FUResource::iBlock_ [private]

Definition at line 95 of file FUResource.h.

Referenced by checkDataBlockPayload(), isComplete(), processDataBlock(), and release().

UInt_t evf::FUResource::iSuperFrag_ [private]

Definition at line 97 of file FUResource.h.

Referenced by fillSuperFragPayload(), findFEDs(), isComplete(), processDataBlock(), release(), and superFragSize().

log4cplus::Logger evf::FUResource::log_ [private]

Definition at line 75 of file FUResource.h.

Referenced by findFEDs(), process(), and release().

UInt_t evf::FUResource::nbBytes_ [private]

Definition at line 104 of file FUResource.h.

Referenced by fillSuperFragPayload(), and nbBytes().

UInt_t evf::FUResource::nbCrcErrors_ [private]

Definition at line 103 of file FUResource.h.

Referenced by findFEDs(), nbCrcErrors(), and release().

UInt_t evf::FUResource::nbErrors_ [private]

Definition at line 102 of file FUResource.h.

Referenced by checkDataBlockPayload(), fillSuperFragPayload(), findFEDs(), nbErrors(), processDataBlock(), release(), and superFragSize().

UInt_t evf::FUResource::nBlock_ [private]

Definition at line 96 of file FUResource.h.

Referenced by isComplete(), processDataBlock(), and release().

UInt_t evf::FUResource::nbSent_ [private]

Definition at line 100 of file FUResource.h.

Referenced by incNbSent(), nbSent(), and release().

UInt_t evf::FUResource::nFedMax_ [private]

Definition at line 92 of file FUResource.h.

Referenced by allocate().

UInt_t evf::FUResource::nSuperFrag_ [private]

Definition at line 98 of file FUResource.h.

Referenced by isComplete(), processDataBlock(), and release().

UInt_t evf::FUResource::nSuperFragMax_ [private]

Definition at line 93 of file FUResource.h.

Referenced by allocate(), and processDataBlock().

evf::FUShmRawCell* evf::FUResource::shmCell_ [private]

Definition at line 110 of file FUResource.h.

Referenced by allocate(), fillSuperFragPayload(), findFEDs(), isAllocated(), processDataBlock(), release(), and shmCell().

MemRef_t* evf::FUResource::superFragHead_ [private]

Definition at line 88 of file FUResource.h.

Referenced by appendBlockToSuperFrag(), fillSuperFragPayload(), release(), releaseSuperFrag(), and superFragSize().

UInt_t evf::FUResource::superFragSize_ [private]

Definition at line 107 of file FUResource.h.

Referenced by fillSuperFragPayload(), and superFragSize().

MemRef_t* evf::FUResource::superFragTail_ [private]

Definition at line 89 of file FUResource.h.

Referenced by appendBlockToSuperFrag(), release(), and releaseSuperFrag().

bool FUResource::useEvmBoard_ = true [static, private]

Definition at line 80 of file FUResource.h.

Referenced by findFEDs(), and useEvmBoard().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:46:48 2009 for CMSSW by  doxygen 1.5.4