#include <SiStripFEDBufferGenerator.h>
Public Member Functions | |
FEDDAQHeader & | daqHeader () |
FEDDAQTrailer & | daqTrailer () |
FEDBufferGenerator (const uint32_t l1ID=0, const uint16_t bxID=0, const std::vector< bool > &feUnitsEnabled=std::vector< bool >(FEUNITS_PER_FED, true), const std::vector< bool > &channelsEnabled=std::vector< bool >(FEDCH_PER_FED, true), const FEDReadoutMode readoutMode=READOUT_MODE_ZERO_SUPPRESSED, const FEDHeaderType headerType=HEADER_TYPE_FULL_DEBUG, const FEDBufferFormat bufferFormat=BUFFER_FORMAT_OLD_SLINK, const FEDDAQEventType evtType=DAQ_EVENT_TYPE_PHYSICS, const FEDDataType dataType=DATA_TYPE_FAKE) | |
FEDFEHeader & | feHeader () |
void | generateBuffer (FEDRawData *rawDataObject, const FEDStripData &data, const uint16_t sourceID) const |
FEDBufferFormat | getBufferFormat () const |
uint16_t | getBXID () const |
bool | getChannelEnabled (const uint8_t internalFEDChannelNumber) const |
FEDDAQEventType | getDAQEventType () const |
FEDDataType | getFEDDataType () const |
bool | getFEUnitEnabled (const uint8_t internalFEUnitNumber) const |
FEDHeaderType | getHeaderType () const |
uint32_t | getL1ID () const |
FEDReadoutMode | getReadoutMode () const |
FEDBufferGenerator & | setBufferFormat (const FEDBufferFormat newBufferFormat) |
FEDBufferGenerator & | setBXID (const uint16_t newBXID) |
FEDBufferGenerator & | setChannelEnable (const uint8_t internalFEDChannelNumber, const bool enabled) |
FEDBufferGenerator & | setChannelEnables (const std::vector< bool > &channelsEnabled) |
FEDBufferGenerator & | setDAQEventType (const FEDDAQEventType newDAQEventType) |
FEDBufferGenerator & | setFEDDataType (const FEDDataType newFEDDataType) |
FEDBufferGenerator & | setFEUnitEnable (const uint8_t internalFEUnitNumber, const bool enabled) |
FEDBufferGenerator & | setFEUnitEnables (const std::vector< bool > &feUnitsEnabled) |
FEDBufferGenerator & | setHeaderType (const FEDHeaderType newHeaderType) |
FEDBufferGenerator & | setL1ID (const uint32_t newL1ID) |
FEDBufferGenerator & | setReadoutMode (const FEDReadoutMode newReadoutMode) |
TrackerSpecialHeader & | trackerSpecialHeader () |
Static Private Member Functions | |
static size_t | bufferSizeInBytes (const FEDFEHeader &feHeader, const FEDBufferPayload &payload) |
static void | fillBuffer (uint8_t *pointerToStartOfBuffer, const FEDDAQHeader &daqHeader, const FEDDAQTrailer &daqTrailer, const TrackerSpecialHeader &tkSpecialHeader, const FEDFEHeader &feHeader, const FEDBufferPayload &payload) |
Private Attributes | |
std::vector< bool > | channelsEnabled_ |
FEDDAQHeader | defaultDAQHeader_ |
FEDDAQTrailer | defaultDAQTrailer_ |
std::auto_ptr< FEDFEHeader > | defaultFEHeader_ |
TrackerSpecialHeader | defaultTrackerSpecialHeader_ |
std::vector< bool > | feUnitsEnabled_ |
Definition at line 102 of file SiStripFEDBufferGenerator.h.
sistrip::FEDBufferGenerator::FEDBufferGenerator | ( | const uint32_t | l1ID = 0 , |
const uint16_t | bxID = 0 , |
||
const std::vector< bool > & | feUnitsEnabled = std::vector<bool>(FEUNITS_PER_FED,true) , |
||
const std::vector< bool > & | channelsEnabled = std::vector<bool>(FEDCH_PER_FED,true) , |
||
const FEDReadoutMode | readoutMode = READOUT_MODE_ZERO_SUPPRESSED , |
||
const FEDHeaderType | headerType = HEADER_TYPE_FULL_DEBUG , |
||
const FEDBufferFormat | bufferFormat = BUFFER_FORMAT_OLD_SLINK , |
||
const FEDDAQEventType | evtType = DAQ_EVENT_TYPE_PHYSICS , |
||
const FEDDataType | dataType = DATA_TYPE_FAKE |
||
) |
Definition at line 252 of file SiStripFEDBufferGenerator.cc.
References defaultFEHeader_, and Exception.
: defaultDAQHeader_(l1ID,bxID,0,evtType), defaultDAQTrailer_(0,0), defaultTrackerSpecialHeader_(bufferFormat,readoutMode,headerType,dataType), defaultFEHeader_(FEDFEHeader::newFEHeader(headerType)), feUnitsEnabled_(feUnitsEnabled), channelsEnabled_(channelsEnabled) { if (!defaultFEHeader_.get()) { std::ostringstream ss; ss << "Bad header format: " << headerType; throw cms::Exception("FEDBufferGenerator") << ss.str(); } }
size_t sistrip::FEDBufferGenerator::bufferSizeInBytes | ( | const FEDFEHeader & | feHeader, |
const FEDBufferPayload & | payload | ||
) | [inline, static, private] |
Definition at line 385 of file SiStripFEDBufferGenerator.h.
References sistrip::FEDBufferPayload::lengthInBytes(), and sistrip::FEDFEHeader::lengthInBytes().
Referenced by fillBuffer(), and generateBuffer().
{ //FE header + payload + tracker special header + daq header + daq trailer return feHeader.lengthInBytes()+payload.lengthInBytes()+8+8+8; }
FEDDAQHeader & sistrip::FEDBufferGenerator::daqHeader | ( | ) | [inline] |
Definition at line 365 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_.
Referenced by generateBuffer().
{ return defaultDAQHeader_; }
FEDDAQTrailer & sistrip::FEDBufferGenerator::daqTrailer | ( | ) | [inline] |
Definition at line 370 of file SiStripFEDBufferGenerator.h.
References defaultDAQTrailer_.
{ return defaultDAQTrailer_; }
FEDFEHeader & sistrip::FEDBufferGenerator::feHeader | ( | ) | [inline] |
Definition at line 380 of file SiStripFEDBufferGenerator.h.
References defaultFEHeader_.
{ return *defaultFEHeader_; }
void sistrip::FEDBufferGenerator::fillBuffer | ( | uint8_t * | pointerToStartOfBuffer, |
const FEDDAQHeader & | daqHeader, | ||
const FEDDAQTrailer & | daqTrailer, | ||
const TrackerSpecialHeader & | tkSpecialHeader, | ||
const FEDFEHeader & | feHeader, | ||
const FEDBufferPayload & | payload | ||
) | [static, private] |
Definition at line 379 of file SiStripFEDBufferGenerator.cc.
References bufferSizeInBytes(), sistrip::calculateFEDBufferCRC(), sistrip::FEDFEHeader::data(), sistrip::TrackerSpecialHeader::data(), sistrip::FEDDAQTrailer::data(), sistrip::FEDBufferPayload::data(), sistrip::FEDDAQHeader::data(), i, sistrip::FEDBufferPayload::lengthInBytes(), sistrip::FEDFEHeader::lengthInBytes(), sistrip::FEDDAQTrailer::setCRC(), sistrip::FEDDAQTrailer::setEventLengthIn64BitWords(), and sistrip::TrackerSpecialHeader::wasSwapped().
Referenced by generateBuffer().
{ //set the length in the DAQ trailer const size_t lengthInBytes = bufferSizeInBytes(feHeader,payload); FEDDAQTrailer updatedDAQTrailer(daqTrailer); updatedDAQTrailer.setEventLengthIn64BitWords(lengthInBytes/8); //copy pieces into buffer in order uint8_t* bufferPointer = pointerToStartOfBuffer; memcpy(bufferPointer,daqHeader.data(),8); bufferPointer += 8; memcpy(bufferPointer,tkSpecialHeader.data(),8); bufferPointer += 8; memcpy(bufferPointer,feHeader.data(),feHeader.lengthInBytes()); bufferPointer += feHeader.lengthInBytes(); memcpy(bufferPointer,payload.data(),payload.lengthInBytes()); bufferPointer += payload.lengthInBytes(); memcpy(bufferPointer,updatedDAQTrailer.data(),8); //update CRC const uint16_t crc = calculateFEDBufferCRC(pointerToStartOfBuffer,lengthInBytes); updatedDAQTrailer.setCRC(crc); memcpy(bufferPointer,updatedDAQTrailer.data(),8); //word swap if necessary if (tkSpecialHeader.wasSwapped()) { for (size_t i = 0; i < 8; i++) { bufferPointer[i] = bufferPointer[i^4]; } } }
void sistrip::FEDBufferGenerator::generateBuffer | ( | FEDRawData * | rawDataObject, |
const FEDStripData & | data, | ||
const uint16_t | sourceID | ||
) | const |
Definition at line 344 of file SiStripFEDBufferGenerator.cc.
References bufferSizeInBytes(), channelsEnabled_, daqHeader(), FEDRawData::data(), defaultDAQHeader_, defaultDAQTrailer_, defaultFEHeader_, defaultTrackerSpecialHeader_, sistrip::FEDCH_PER_FED, sistrip::FEDCH_PER_FEUNIT, sistrip::FEUNITS_PER_FED, feUnitsEnabled_, fillBuffer(), sistrip::FEDBufferPayload::getFELength(), getReadoutMode(), FEDRawData::resize(), sistrip::TrackerSpecialHeader::setFEEnableForFEUnit(), and sistrip::FEDDAQHeader::setSourceID().
Referenced by sistrip::DigiToRaw::createFedBuffers_().
{ //deal with disabled FE units and channels properly (FE enables, status bits) TrackerSpecialHeader tkSpecialHeader(defaultTrackerSpecialHeader_); std::auto_ptr<FEDFEHeader> fedFeHeader(defaultFEHeader_->clone()); for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) { const bool enabled = feUnitsEnabled_[iFE]; tkSpecialHeader.setFEEnableForFEUnit(iFE,enabled); if (!enabled) { for (uint8_t iFEUnitChannel = 0; iFEUnitChannel < FEDCH_PER_FEUNIT; iFEUnitChannel++) { fedFeHeader->setChannelStatus(iFE,iFEUnitChannel,FEDChannelStatus(0)); } } } for (uint8_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) { if (!channelsEnabled_[iCh]) { fedFeHeader->setChannelStatus(iCh,FEDChannelStatus(0)); } } //set the source ID FEDDAQHeader daqHeader(defaultDAQHeader_); daqHeader.setSourceID(sourceID); //build payload const FEDBufferPayloadCreator payloadPacker(feUnitsEnabled_,channelsEnabled_); const FEDBufferPayload payload = payloadPacker(getReadoutMode(),data); //fill FE lengths for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) { fedFeHeader->setFEUnitLength(iFE,payload.getFELength(iFE)); } //resize buffer rawDataObject->resize(bufferSizeInBytes(*fedFeHeader,payload)); //fill buffer fillBuffer(rawDataObject->data(),daqHeader,defaultDAQTrailer_,tkSpecialHeader,*fedFeHeader,payload); }
FEDBufferFormat sistrip::FEDBufferGenerator::getBufferFormat | ( | ) | const [inline] |
Definition at line 308 of file SiStripFEDBufferGenerator.h.
References sistrip::TrackerSpecialHeader::bufferFormat(), and defaultTrackerSpecialHeader_.
{ return defaultTrackerSpecialHeader_.bufferFormat(); }
uint16_t sistrip::FEDBufferGenerator::getBXID | ( | ) | const [inline] |
Definition at line 293 of file SiStripFEDBufferGenerator.h.
References sistrip::FEDDAQHeader::bxID(), and defaultDAQHeader_.
{ return defaultDAQHeader_.bxID(); }
bool sistrip::FEDBufferGenerator::getChannelEnabled | ( | const uint8_t | internalFEDChannelNumber | ) | const |
Definition at line 281 of file SiStripFEDBufferGenerator.cc.
References channelsEnabled_, and Exception.
{ try { return channelsEnabled_.at(internalFEDChannelNumber); } catch (const std::out_of_range&) { std::ostringstream ss; ss << "Invalid channel number " << internalFEDChannelNumber << ". " << "Should be in internal numbering scheme (0-95)"; throw cms::Exception("FEDBufferGenerator") << ss.str(); } }
FEDDAQEventType sistrip::FEDBufferGenerator::getDAQEventType | ( | ) | const [inline] |
Definition at line 313 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_, and sistrip::FEDDAQHeader::eventType().
{ return defaultDAQHeader_.eventType(); }
FEDDataType sistrip::FEDBufferGenerator::getFEDDataType | ( | ) | const [inline] |
Definition at line 318 of file SiStripFEDBufferGenerator.h.
References sistrip::TrackerSpecialHeader::dataType(), and defaultTrackerSpecialHeader_.
{ return defaultTrackerSpecialHeader_.dataType(); }
bool sistrip::FEDBufferGenerator::getFEUnitEnabled | ( | const uint8_t | internalFEUnitNumber | ) | const |
Definition at line 270 of file SiStripFEDBufferGenerator.cc.
References Exception, and feUnitsEnabled_.
{ try { return feUnitsEnabled_.at(internalFEUnitNumber); } catch (const std::out_of_range&) { std::ostringstream ss; ss << "Invalid FE unit number " << internalFEUnitNumber << ". Should be in internal numbering scheme (0-7)"; throw cms::Exception("FEDBufferGenerator") << ss.str(); } }
FEDHeaderType sistrip::FEDBufferGenerator::getHeaderType | ( | ) | const [inline] |
Definition at line 303 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::headerType().
{ return defaultTrackerSpecialHeader_.headerType(); }
uint32_t sistrip::FEDBufferGenerator::getL1ID | ( | ) | const [inline] |
Definition at line 288 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_, and sistrip::FEDDAQHeader::l1ID().
{ return defaultDAQHeader_.l1ID(); }
FEDReadoutMode sistrip::FEDBufferGenerator::getReadoutMode | ( | ) | const [inline] |
Definition at line 298 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::readoutMode().
Referenced by generateBuffer().
{ return defaultTrackerSpecialHeader_.readoutMode(); }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setBufferFormat | ( | const FEDBufferFormat | newBufferFormat | ) | [inline] |
Definition at line 347 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::setBufferFormat().
{ defaultTrackerSpecialHeader_.setBufferFormat(newBufferFormat); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setBXID | ( | const uint16_t | newBXID | ) | [inline] |
Definition at line 329 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_, and sistrip::FEDDAQHeader::setBXID().
{ defaultDAQHeader_.setBXID(newBXID); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setChannelEnable | ( | const uint8_t | internalFEDChannelNumber, |
const bool | enabled | ||
) |
Definition at line 307 of file SiStripFEDBufferGenerator.cc.
References channelsEnabled_, and Exception.
{ try { channelsEnabled_.at(internalFEDChannelNumber) = enabled; } catch (const std::out_of_range&) { std::ostringstream ss; ss << "Invalid channel number " << internalFEDChannelNumber << ". " <<"Should be in internal numbering scheme (0-95)"; throw cms::Exception("FEDBufferGenerator") << ss.str(); } return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setChannelEnables | ( | const std::vector< bool > & | channelsEnabled | ) |
Definition at line 332 of file SiStripFEDBufferGenerator.cc.
References channelsEnabled_, Exception, and sistrip::FEDCH_PER_FED.
{ if (channelEnables.size() != FEDCH_PER_FED) { std::ostringstream ss; ss << "Setting FED channel enable vector with vector which is the wrong size. Size is " << channelEnables.size() << " it must be " << FEDCH_PER_FED << "." << std::endl; throw cms::Exception("FEDBufferGenerator") << ss.str(); } channelsEnabled_ = channelEnables; return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setDAQEventType | ( | const FEDDAQEventType | newDAQEventType | ) | [inline] |
Definition at line 353 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_, and sistrip::FEDDAQHeader::setEventType().
{ defaultDAQHeader_.setEventType(newDAQEventType); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setFEDDataType | ( | const FEDDataType | newFEDDataType | ) | [inline] |
Definition at line 359 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::setDataType().
{ defaultTrackerSpecialHeader_.setDataType(newFEDDataType); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setFEUnitEnable | ( | const uint8_t | internalFEUnitNumber, |
const bool | enabled | ||
) |
Definition at line 294 of file SiStripFEDBufferGenerator.cc.
References Exception, and feUnitsEnabled_.
{ try { feUnitsEnabled_.at(internalFEUnitNumber) = enabled; } catch (const std::out_of_range&) { std::ostringstream ss; ss << "Invalid FE unit number " << internalFEUnitNumber << ". " << "Should be in internal numbering scheme (0-7)"; throw cms::Exception("FEDBufferGenerator") << ss.str(); } return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setFEUnitEnables | ( | const std::vector< bool > & | feUnitsEnabled | ) |
Definition at line 320 of file SiStripFEDBufferGenerator.cc.
References Exception, sistrip::FEUNITS_PER_FED, and feUnitsEnabled_.
{ if (feUnitEnables.size() != FEUNITS_PER_FED) { std::ostringstream ss; ss << "Setting FE enable vector with vector which is the wrong size. Size is " << feUnitEnables.size() << " it must be " << FEUNITS_PER_FED << "." << std::endl; throw cms::Exception("FEDBufferGenerator") << ss.str(); } feUnitsEnabled_ = feUnitEnables; return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setHeaderType | ( | const FEDHeaderType | newHeaderType | ) | [inline] |
Definition at line 341 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::setHeaderType().
{ defaultTrackerSpecialHeader_.setHeaderType(newHeaderType); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setL1ID | ( | const uint32_t | newL1ID | ) | [inline] |
Definition at line 323 of file SiStripFEDBufferGenerator.h.
References defaultDAQHeader_, and sistrip::FEDDAQHeader::setL1ID().
Referenced by sistrip::DigiToRaw::createFedBuffers_().
{ defaultDAQHeader_.setL1ID(newL1ID); return *this; }
FEDBufferGenerator & sistrip::FEDBufferGenerator::setReadoutMode | ( | const FEDReadoutMode | newReadoutMode | ) | [inline] |
Definition at line 335 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_, and sistrip::TrackerSpecialHeader::setReadoutMode().
Referenced by sistrip::DigiToRaw::DigiToRaw().
{ defaultTrackerSpecialHeader_.setReadoutMode(newReadoutMode); return *this; }
TrackerSpecialHeader & sistrip::FEDBufferGenerator::trackerSpecialHeader | ( | ) | [inline] |
Definition at line 375 of file SiStripFEDBufferGenerator.h.
References defaultTrackerSpecialHeader_.
{ return defaultTrackerSpecialHeader_; }
std::vector<bool> sistrip::FEDBufferGenerator::channelsEnabled_ [private] |
Definition at line 168 of file SiStripFEDBufferGenerator.h.
Referenced by generateBuffer(), getChannelEnabled(), setChannelEnable(), and setChannelEnables().
Definition at line 163 of file SiStripFEDBufferGenerator.h.
Referenced by daqHeader(), generateBuffer(), getBXID(), getDAQEventType(), getL1ID(), setBXID(), setDAQEventType(), and setL1ID().
Definition at line 164 of file SiStripFEDBufferGenerator.h.
Referenced by daqTrailer(), and generateBuffer().
std::auto_ptr<FEDFEHeader> sistrip::FEDBufferGenerator::defaultFEHeader_ [private] |
Definition at line 166 of file SiStripFEDBufferGenerator.h.
Referenced by FEDBufferGenerator(), feHeader(), and generateBuffer().
Definition at line 165 of file SiStripFEDBufferGenerator.h.
Referenced by generateBuffer(), getBufferFormat(), getFEDDataType(), getHeaderType(), getReadoutMode(), setBufferFormat(), setFEDDataType(), setHeaderType(), setReadoutMode(), and trackerSpecialHeader().
std::vector<bool> sistrip::FEDBufferGenerator::feUnitsEnabled_ [private] |
Definition at line 167 of file SiStripFEDBufferGenerator.h.
Referenced by generateBuffer(), getFEUnitEnabled(), setFEUnitEnable(), and setFEUnitEnables().