CMS 3D CMS Logo

Public Member Functions | Private Attributes

RPCRecordFormatter Class Reference

#include <RPCRecordFormatter.h>

List of all members.

Public Member Functions

std::vector
< rpcrawtodigi::EventRecords
recordPack (uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
int recordUnpack (const rpcrawtodigi::EventRecords &event, RPCDigiCollection *prod, RPCRawDataCounts *counter, RPCRawSynchro::ProdItem *synchro)
 RPCRecordFormatter (int fedId, const RPCReadOutMapping *readoutMapping)
 Creator.
 ~RPCRecordFormatter ()
 Destructor.

Private Attributes

int currentFED
int currentTbLinkInputNumber
const RPCReadOutMappingreadoutMapping

Detailed Description

Definition at line 17 of file RPCRecordFormatter.h.


Constructor & Destructor Documentation

RPCRecordFormatter::RPCRecordFormatter ( int  fedId,
const RPCReadOutMapping readoutMapping 
)

Creator.

Definition at line 33 of file RPCRecordFormatter.cc.

 : currentFED(fedId), readoutMapping(r)
{ }
RPCRecordFormatter::~RPCRecordFormatter ( )

Destructor.

Definition at line 37 of file RPCRecordFormatter.cc.

{ }

Member Function Documentation

std::vector< EventRecords > RPCRecordFormatter::recordPack ( uint32_t  rawDetId,
const RPCDigi digi,
int  trigger_BX 
) const

Definition at line 41 of file RPCRecordFormatter.cc.

References RPCDigi::bx(), currentFED, LinkBoardElectronicIndex::dccId, LinkBoardElectronicIndex::dccInputChannelNum, LinkBoardElectronicIndex::lbNumInLink, LogTrace, LinkBoardPackedStrip::packedStrip(), RPCReadOutMapping::rawDataFrame(), readoutMapping, query::result, RPCDigi::strip(), and LinkBoardElectronicIndex::tbLinkInputNum.

Referenced by RPCPackingModule::eventRecords().

{
  std::vector<EventRecords> result;
   
  LogTrace("") << " DIGI;  det: " << rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
  int stripInDU = digi.strip();

  // decode digi<->map
  typedef std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip> > RawDataFrames;
  RPCReadOutMapping::StripInDetUnit duFrame(rawDetId, stripInDU);
  RawDataFrames rawDataFrames = readoutMapping->rawDataFrame(duFrame);

  for (RawDataFrames::const_iterator ir = rawDataFrames.begin(); ir != rawDataFrames.end(); ir++) {
    
    const LinkBoardElectronicIndex & eleIndex = (*ir).first;
    const LinkBoardPackedStrip & lbPackedStrip = (*ir).second;

    if (eleIndex.dccId == currentFED) {

      LogTrace("pack:")
           <<" dccId= "<<eleIndex.dccId
           <<" dccInputChannelNum= "<<eleIndex.dccInputChannelNum
           <<" tbLinkInputNum= "<<eleIndex.tbLinkInputNum
           <<" lbNumInLink="<<eleIndex.lbNumInLink;

      // BX 
      int current_BX = trigger_BX+digi.bx();
      RecordBX bxr(current_BX);

      // LB 
      int tbLinkInputNumber = eleIndex.tbLinkInputNum;
      int rmb = eleIndex.dccInputChannelNum; 
      RecordSLD lbr( tbLinkInputNumber, rmb);   

      // CD record
      int lbInLink = eleIndex.lbNumInLink;
      int eod = 0;
      int halfP = 0;
      int packedStrip = lbPackedStrip.packedStrip();     
      int partitionNumber = packedStrip/8; 
      RecordCD cdr(lbInLink, partitionNumber, eod, halfP, vector<int>(1,packedStrip) );

      result.push_back(  EventRecords(trigger_BX, bxr, lbr, cdr) );
    }
  }
  return result;
}
int RPCRecordFormatter::recordUnpack ( const rpcrawtodigi::EventRecords event,
RPCDigiCollection prod,
RPCRawDataCounts counter,
RPCRawSynchro::ProdItem synchro 
)

Committing digi to the product

Definition at line 90 of file RPCRecordFormatter.cc.

References RPCRawDataCounts::addReadoutError(), currentFED, currentTbLinkInputNumber, rpcrawtodigi::EventRecords::dataToTriggerDelay(), LinkBoardElectronicIndex::dccId, LinkBoardElectronicIndex::dccInputChannelNum, debug, RPCReadOutMapping::detUnitFrame(), rpcrawtodigi::RecordCD::eod(), error, instance, LinkBoardElectronicIndex::lbNumInLink, RPCReadOutMapping::location(), LogDebug, LogTrace, readoutMapping, rpcrawtodigi::EventRecords::recordCD(), RPCDetId, LinkBoardElectronicIndex::tbLinkInputNum, and rpcrawtodigi::ReadoutError::type().

Referenced by RPCUnpackingModule::produce().

{

  static bool debug = edm::MessageDrop::instance()->debugEnabled;
  ReadoutError error;
  int currentRMB = event.recordSLD().rmb(); 
  int currentTbLinkInputNumber = event.recordSLD().tbLinkInputNumber();

  LinkBoardElectronicIndex eleIndex;
  eleIndex.dccId = currentFED;
  eleIndex.dccInputChannelNum = currentRMB;
  eleIndex.tbLinkInputNum = currentTbLinkInputNumber;
  eleIndex.lbNumInLink = event.recordCD().lbInLink();


  if( event.recordCD().eod() ) {
     if(counter) counter->addReadoutError(currentFED, ReadoutError(eleIndex,ReadoutError::EOD));
  }

  if(readoutMapping == 0) return error.type();
  const LinkBoardSpec* linkBoard = readoutMapping->location(eleIndex);
  if (!linkBoard) {
    if (debug) LogDebug("")<<" ** PROBLEM ** Invalid Linkboard location, skip CD event, " 
              << "dccId: "<<eleIndex.dccId
              << "dccInputChannelNum: " <<eleIndex.dccInputChannelNum
              << " tbLinkInputNum: "<<eleIndex.tbLinkInputNum
              << " lbNumInLink: "<<eleIndex.lbNumInLink;
    error = ReadoutError(eleIndex,ReadoutError::InvalidLB);
    if(counter) counter->addReadoutError(currentFED,error );
    return error.type();
  }


  std::vector<int> packStrips = event.recordCD().packedStrips();
  if (packStrips.size() ==0) {
    error = ReadoutError(eleIndex,ReadoutError::EmptyPackedStrips);
    if(counter) counter->addReadoutError(currentFED, error);
    return error.type();
  }

  for(std::vector<int>::iterator is = packStrips.begin(); is != packStrips.end(); ++is) {

    RPCReadOutMapping::StripInDetUnit duFrame = 
        readoutMapping->detUnitFrame(*linkBoard, LinkBoardPackedStrip(*is) );

    uint32_t rawDetId = duFrame.first;
    int geomStrip = duFrame.second;
    if (!rawDetId) {
      if (debug) LogTrace("") << " ** PROBLEM ** no rawDetId, skip at least part of CD data";
      error = ReadoutError(eleIndex,ReadoutError::InvalidDetId);
      if (counter) counter->addReadoutError(currentFED, error);
      continue;
    }
    if (geomStrip==0) {
      if(debug) LogTrace("") <<" ** PROBLEM ** no strip found";
      error = ReadoutError(eleIndex,ReadoutError::InvalidStrip);
      if (counter) counter->addReadoutError(currentFED, error);
      continue;
    }

    // Creating RPC digi
    RPCDigi digi(geomStrip,event.dataToTriggerDelay()-3);

    if (debug) {
      //LogTrace("") << " LinkBoardElectronicIndex: " << eleIndex.print(); 
      LogTrace("")<<" DIGI;  det: "<<rawDetId<<", strip: "<<digi.strip()<<", bx: "<<digi.bx();
    }
    if (prod) prod->insertDigi(RPCDetId(rawDetId),digi);

//    if (RPCDetId(rawDetId).region() == -1 ) {
//       RPCDetId det(rawDetId);
//       if (det.ring()==    2 ) takeIt = true;
//       if (det.station() == 1) 
//       takeIt = true;
//     LogInfo("RPCRecordFormatter") <<"ENDCAP Region: "<<det.region()<<" disk: "<<det.station()<<" ring: "<<det.ring() <<" sector: "<<det.sector()<<" digiBX: "<<digi.bx()<< std::endl;
//   }

  }

  if(synchro) synchro->push_back( make_pair(eleIndex,event.dataToTriggerDelay() ));

  return error.type();
}

Member Data Documentation

Definition at line 34 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().

Definition at line 35 of file RPCRecordFormatter.h.

Referenced by recordUnpack().

Definition at line 37 of file RPCRecordFormatter.h.

Referenced by recordPack(), and recordUnpack().