00001
00002
00003
00004
00005
00006
00008
00009
00010 #include "EventFilter/ResourceBroker/interface/FUResource.h"
00011 #include "FWCore/Utilities/interface/CRC16.h"
00012 #include "EventFilter/Utilities/interface/GlobalEventNumber.h"
00013 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00014
00015 #include "interface/shared/frl_header.h"
00016 #include "interface/shared/fed_header.h"
00017 #include "interface/shared/fed_trailer.h"
00018 #include "interface/shared/i2oXFunctionCodes.h"
00019 #include "interface/evb/i2oEVBMsgs.h"
00020
00021 #include "toolbox/mem/Reference.h"
00022
00023 #include "xcept/tools.h"
00024
00025 #include <sstream>
00026 #include <sys/shm.h>
00027
00028
00029 #define FED_HCTRLID 0x50000000
00030 #define FED_TCTRLID 0xa0000000
00031 #define REAL_SOID_MASK 0x0003FF00
00032 #define FED_RBIT_MASK 0x0000C004
00033
00034
00035 using namespace std;
00036 using namespace evf;
00037
00038
00040
00042
00043
00044 bool FUResource::doFedIdCheck_ = true;
00045 bool FUResource::useEvmBoard_ = true;
00046 unsigned int FUResource::gtpEvmId_ = FEDNumbering::getTriggerGTPFEDIds().first;
00047 unsigned int FUResource::gtpDaqId_ = FEDNumbering::getTriggerGTPFEDIds().second;
00048 unsigned int FUResource::gtpeId_ = FEDNumbering::getTriggerEGTPFEDIds().first;
00049
00051
00053
00054
00055 FUResource::FUResource(UInt_t fuResourceId,log4cplus::Logger logger)
00056 : log_(logger)
00057 , fuResourceId_(fuResourceId)
00058 , superFragHead_(0)
00059 , superFragTail_(0)
00060 , nbBytes_(0)
00061 , superFragSize_(0)
00062 {
00063 release();
00064 }
00065
00066
00067
00068 FUResource::~FUResource()
00069 {
00070
00071 }
00072
00073
00075
00077
00078
00079 void FUResource::allocate(FUShmRawCell* shmCell)
00080 {
00081
00082 shmCell_=shmCell;
00083 shmCell_->clear();
00084 shmCell_->setFuResourceId(fuResourceId_);
00085 eventPayloadSize_=shmCell_->payloadSize();
00086 nFedMax_ =shmCell_->nFed();
00087 nSuperFragMax_ =shmCell_->nSuperFrag();
00088 }
00089
00090
00091
00092 void FUResource::release()
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 }
00131
00132
00133
00134 void FUResource::process(MemRef_t* bufRef)
00135 {
00136 if (fatalError()) {
00137 LOG4CPLUS_WARN(log_,"THIS SHOULD *NEVER* HAPPEN!.");
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 }
00162
00163
00164
00165 void FUResource::processDataBlock(MemRef_t* bufRef)
00166 throw (evf::Exception)
00167 {
00168
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
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
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
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
00217 if (iBlock==0) {
00218 nBlock_=nBlock;
00219 }
00220 else {
00221
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
00234
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
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
00256
00257 else {
00258
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
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
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
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
00306 iBlock_++;
00307
00308
00309 bool lastBlockInSuperFrag=(iBlock==nBlock-1);
00310 if (lastBlockInSuperFrag) {
00311
00312
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
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
00342 iSuperFrag_++;
00343
00344 }
00345
00346 return;
00347 }
00348
00349
00350
00351 void FUResource::checkDataBlockPayload(MemRef_t* bufRef)
00352 throw (evf::Exception)
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
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
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
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
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
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
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 }
00449
00450
00451
00452 void FUResource::appendBlockToSuperFrag(MemRef_t* bufRef)
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 }
00464
00465
00466
00467 void FUResource::superFragSize() throw (evf::Exception)
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 }
00501
00502
00503
00504 void FUResource::fillSuperFragPayload() throw (evf::Exception)
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
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 }
00554
00555
00556
00557 void FUResource::findFEDs() throw (evf::Exception)
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
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
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
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
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
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
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
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
00665
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
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
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
00707 fedTrailerAddr=fedTrailerAddr-fedSize;
00708 }
00709
00710
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 }
00721
00722
00723
00724 void FUResource::releaseSuperFrag()
00725 {
00726 if (0==superFragHead_) return;
00727 superFragHead_->release();
00728 superFragHead_=0;
00729 superFragTail_=0;
00730 return;
00731 }
00732
00733
00734
00735 UInt_t FUResource::nbErrors(bool reset)
00736 {
00737 UInt_t result=nbErrors_;
00738 if (reset) nbErrors_=0;
00739 return result;
00740 }
00741
00742
00743
00744 UInt_t FUResource::nbCrcErrors(bool reset)
00745 {
00746 UInt_t result=nbCrcErrors_;
00747 if (reset) nbCrcErrors_=0;
00748 return result;
00749 }
00750
00751
00752
00753 UInt_t FUResource::nbBytes(bool reset)
00754 {
00755 UInt_t result=nbBytes_;
00756 if (reset) nbBytes_=0;
00757 return result;
00758 }