From: "Emeliyanov, D (Dmitry)" <dmitry.emeliyanov@stfc.ac.uk>
Subject: RE: passing decoding errors to HLT clients (fwd)

...

Basically the LVL2 ID is using offline bytestream converters and offline
infrastructure to log decoding errors. 
This process is organized as follows:

1. A LVL2 algorithm gets data from a Data Provider Tool. In addition,
the Data Provider has methods 
  which the algorithm can use to retrieve data errors. The existance of
any errors is signaled to the 
  algorithm by returning a RECOVERABLE StatusCode. Below is an example
from 
  Trigger/TrigAlgorithms/TrigSiTrack/src/TrigSiTrack.cxx : 

  StatusCode stat = m_spacePointTool->fillCollections(m_roiEtaMin,
...); //get data

 if(stat.isRecoverable()) { // check if any errors occured
   msg() << MSG::DEBUG << "Error filling Pixel or SCT identifiers
collection" << endreq; 

   const std::vector<int>* errVect =
m_spacePointTool->fillPixelDataErrors(); // get errors

std::copy(errVect->begin(),errVect->end(),std::back_inserter(m_pixelData
Errors)); //copy errors 
   //to an internal buffer for further processing, e.g. filling
monitoring histograms

   errVect = m_spacePointTool->fillSCT_DataErrors(); // do the same for
SCT 

std::copy(errVect->begin(),errVect->end(),std::back_inserter(m_sctDataEr
rors));
 }

2. Data decoding errors are represented by integer codes. For example, 

InnerDetector/InDetConditions/PixelConditionsServices/src/PixelByteStrea
mErrorsSvc.h :

  public: 
       enum ErrorType {TimeOut=0, firstErrType=TimeOut, BCID=1,
LVL1ID=2, Preamble=3, Trailer=4, Flagged=5, DisableFE=6, Decoding=7, 
                       lastErrType=Decoding };

3. A  bytestream decoder (for example, Pixel Decoder) sends error codes
to the corresponding (offline) ByteStreamErrorsSvc. 

  In
InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRodDecode
r.cxx : 

  PixelRodDecoder::PixelRodDecoder // BS decoder
   ( const std::string& type, const std::string& name,const IInterface*
parent )
    :  AthAlgTool(type,name,parent),

    [....]

    m_errors("PixelByteStreamErrorsSvc",name) // BS error service -
data member of the decoder

   [...] 

    if (headererror != 0){ 
	sc = StatusCode::RECOVERABLE; // the SC to be returned to the
callers in case of errors observed
	errorcode = errorcode | (headererror << 20);
	if (headererror & (1 << 3))
	  m_errors->addPreambleError(); //<--- send error to the BS
error service. 
	if (headererror & (1 << 2))
	  m_errors->addTimeOutError();  //<--- send error to the BS
error service. 
	if (headererror & (1 << 1))
	  m_errors->addLVL1IDError();   //<--- send error to the BS
error service. 
	if (headererror & (1 << 0))
	  m_errors->addBCIDError();     //<--- send error to the BS
error service. 

4.  The LVL2 Data Provider Tool interacts with both BS decoder and BS
error service. The scheme is basically the same as that for 
   the Algorithm - Data Provider interaction : 

   In
Trigger/TrigTools/TrigOnlineSpacePointTool/src/PixelClusterCacheTool.cxx

   StatusCode
PixelClusterCacheTool::m_convertBStoClusters(std::vector<const ROBF*>&
robFrags, // data to decode
                                                 const
std::vector<IdentifierHash> listOfPixIds,
	
std::vector<int>& errorVect) // a buffer for data errors
   {
     [...]

   m_bsErrorSvc->resetCounts();// reset BS error service before
decoding next ROB fragment
   StatusCode
scRod=m_offlineDecoder->fillCollection(robFrag,m_rdoContainer,&reducedLi
st);// call the BS decoder
   if(scRod.isRecoverable()) //if RECOVERABLE then some errors were
observed during decoding
    {
		 n_recov_errors++;
		 for(int idx=0;idx<MAXNUM_PIX_BS_ERRORS;idx++)
		   {
		     int n_errors =
m_bsErrorSvc->getNumberOfErrors(idx);// get number of errors of a
particular type, 
                                                                     //
for example idx=1 gives number of BC ID errors
		     for(int ierror = 0; ierror < n_errors; ierror++)
			   errorVect.push_back(idx);// fill the buffer
for subsequent reporting to LVL2 algorithm
		   }
   }

5. The Data Provider implements methods for sending cached data errors
to LVL2 algorithms (on demand): 

  In
Trigger/TrigTools/TrigOnlineSpacePointTool/src/OnlineSpacePointProviderT
ool.cxx :

  const std::vector<int>*
OnlineSpacePointProviderTool::fillPixelDataErrors()
  {
    return &m_pixelDataErrors;// the buffer filled by the
PixelClusterCacheTool (via errorVect argument)
  }
  const std::vector<int>*
OnlineSpacePointProviderTool::fillSCT_DataErrors()
  {
    return &m_sctDataErrors;
  }

The EF ID solution is pretty much along the same lines: a data provider
calls a BS decoder if the decoder 
returns a recoverable SC the provider calls BS error service and
retrieves the errors.  

Let me know if you have any questions about this. 

With best regards,
Dmitry.