CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1GTEvmDigiToRaw Class Reference

#include <L1GTEvmDigiToRaw.h>

Inheritance diagram for L1GTEvmDigiToRaw:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 L1GTEvmDigiToRaw (const edm::ParameterSet &)
 constructor(s)
virtual ~L1GTEvmDigiToRaw ()
 destructor

Private Member Functions

virtual void beginJob ()
 beginning of job stuff
virtual void endJob ()
 end of job stuff
void packFDL (const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
 pack FDL blocks for various bunch crosses
void packGTFE (const edm::EventSetup &, unsigned char *, L1GtfeExtWord &, cms_uint16_t activeBoardsGtValue)
void packHeader (unsigned char *, edm::Event &)
 block packers -------------
void packTCS (const edm::EventSetup &evSetup, unsigned char *ptrGt, L1TcsWord &tcsBlock)
 pack the TCS block
void packTrailer (unsigned char *, unsigned char *, int)
 pack trailer word
virtual void produce (edm::Event &, const edm::EventSetup &)
 loop over events

Private Attributes

cms_uint16_t m_activeBoardsMaskGt
 mask for active boards
int m_bstLengthBytes
 length of BST record (in bytes)
int m_evmGtFedId
edm::InputTag m_evmGtInputTag
 input tag for GT EVM record
bool m_isDebugEnabled
int m_maxBxInEvent
int m_minBxInEvent
int m_totalBxInEvent
 total Bx's in the event, obtained from GTFE block
int m_verbosity
 verbosity level

Detailed Description

Description: generate raw data from digis.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 43 of file L1GTEvmDigiToRaw.h.


Constructor & Destructor Documentation

L1GTEvmDigiToRaw::L1GTEvmDigiToRaw ( const edm::ParameterSet pSet) [explicit]

constructor(s)

Definition at line 57 of file L1GTEvmDigiToRaw.cc.

References LogDebug, m_activeBoardsMaskGt, m_evmGtFedId, and m_evmGtInputTag.

                                                              :
    m_evmGtFedId(pSet.getUntrackedParameter<int>("EvmGtFedId",
            FEDNumbering::MINTriggerGTPFEDID)),
    m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
    m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
    m_totalBxInEvent(0),
    m_minBxInEvent(0), m_maxBxInEvent(),
    m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
    m_isDebugEnabled(edm::isDebugEnabled())



{

    LogDebug("L1GTEvmDigiToRaw") << "\nMask for active boards (hex format): "
            << std::hex << std::setw(sizeof(m_activeBoardsMaskGt)*2)
            << std::setfill('0') << m_activeBoardsMaskGt << std::dec
            << std::setfill(' ') << "\nInput tag for EVM GT record: "
            << m_evmGtInputTag << "\nFED Id for EVM GT record: "
            << m_evmGtFedId << " \n" << std::endl;

    //
    produces<FEDRawDataCollection>();

}
L1GTEvmDigiToRaw::~L1GTEvmDigiToRaw ( ) [virtual]

destructor

Definition at line 84 of file L1GTEvmDigiToRaw.cc.

{

    // empty now

}

Member Function Documentation

void L1GTEvmDigiToRaw::beginJob ( void  ) [private, virtual]

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 94 of file L1GTEvmDigiToRaw.cc.

{

    // empty now

}
void L1GTEvmDigiToRaw::endJob ( void  ) [private, virtual]

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 736 of file L1GTEvmDigiToRaw.cc.

{

    // empty now
}
void L1GTEvmDigiToRaw::packFDL ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1GtFdlWord fdlBlock 
) [private]

pack FDL blocks for various bunch crosses

Definition at line 634 of file L1GTEvmDigiToRaw.cc.

References L1GtFdlWord::getSize(), LogDebug, LogTrace, m_isDebugEnabled, m_verbosity, L1GtFdlWord::setBoardIdWord64(), L1GtFdlWord::setBxInEventWord64(), L1GtFdlWord::setBxNrWord64(), L1GtFdlWord::setEventNrWord64(), L1GtFdlWord::setFinalORWord64(), L1GtFdlWord::setGtDecisionWordAWord64(), L1GtFdlWord::setGtDecisionWordBWord64(), L1GtFdlWord::setGtDecisionWordExtendedWord64(), L1GtFdlWord::setGtPrescaleFactorIndexAlgoWord64(), L1GtFdlWord::setGtPrescaleFactorIndexTechWord64(), L1GtFdlWord::setGtTechnicalTriggerWordWord64(), L1GtFdlWord::setLocalBxNrWord64(), L1GtFdlWord::setLumiSegmentNrWord64(), L1GtFdlWord::setNoAlgoWord64(), L1GtFdlWord::setOrbitNrWord64(), L1GtFdlWord::setPhysicsDeclaredWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

{

    if (m_verbosity && m_isDebugEnabled) {
        LogDebug("L1GTEvmDigiToRaw") << "\nPacking FDL \n" << std::endl;
    }

    int uLength = L1GlobalTriggerReadoutSetup::UnitLength;

    // initialize the required number of word64
    int nrWord64 = fdlBlock.getSize()/uLength;
    std::vector<cms_uint64_t> tmpWord64;
    tmpWord64.resize(nrWord64);

    for (int iWord = 0; iWord < nrWord64; ++iWord) {
        tmpWord64[iWord] = 0x0000000000000000ULL;
    }

    // fill the values in the words
    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        fdlBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
        fdlBlock.setBxInEventWord64(tmpWord64[iWord], iWord);
        fdlBlock.setBxNrWord64(tmpWord64[iWord], iWord);
        fdlBlock.setEventNrWord64(tmpWord64[iWord], iWord);

        fdlBlock.setGtTechnicalTriggerWordWord64(tmpWord64[iWord], iWord);

        fdlBlock.setGtDecisionWordAWord64(tmpWord64[iWord], iWord);
        fdlBlock.setGtDecisionWordBWord64(tmpWord64[iWord], iWord);

        fdlBlock.setGtDecisionWordExtendedWord64(tmpWord64[iWord], iWord);

        fdlBlock.setPhysicsDeclaredWord64(tmpWord64[iWord], iWord);
        fdlBlock.setGtPrescaleFactorIndexTechWord64(tmpWord64[iWord], iWord);
        fdlBlock.setGtPrescaleFactorIndexAlgoWord64(tmpWord64[iWord], iWord);
        fdlBlock.setNoAlgoWord64(tmpWord64[iWord], iWord);
        fdlBlock.setFinalORWord64(tmpWord64[iWord], iWord);

        fdlBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
        fdlBlock.setLumiSegmentNrWord64(tmpWord64[iWord], iWord);
        fdlBlock.setLocalBxNrWord64(tmpWord64[iWord], iWord);

    }

    // put the words in the FED record

    cms_uint64_t* pw =
        reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));

    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        *pw++ = tmpWord64[iWord];

        if (m_verbosity && m_isDebugEnabled) {
            LogTrace("L1GTEvmDigiToRaw")
            << std::setw(4) << iWord << "  "
            << std::hex << std::setfill('0')
            << std::setw(16) << tmpWord64[iWord]
            << std::dec << std::setfill(' ')
            << std::endl;
        }
    }

}
void L1GTEvmDigiToRaw::packGTFE ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1GtfeExtWord gtfeBlock,
cms_uint16_t  activeBoardsGtValue 
) [private]

pack the GTFE block gives the number of bunch crosses in the event, as well as the active boards records for inactive boards are not written in the GT EVM record

Definition at line 507 of file L1GTEvmDigiToRaw.cc.

References L1GtfeExtWord::getSize(), LogDebug, LogTrace, m_bstLengthBytes, m_isDebugEnabled, m_verbosity, L1GtfeWord::setActiveBoardsWord64(), L1GtfeWord::setAltNrBxBoardWord64(), L1GtfeWord::setBoardIdWord64(), L1GtfeExtWord::setBstWord64(), L1GtfeWord::setBxNrWord64(), L1GtfeWord::setRecordLength1Word64(), L1GtfeWord::setRecordLengthWord64(), L1GtfeWord::setSetupVersionWord64(), L1GtfeWord::setTotalTriggerNrWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

{

    if (m_verbosity && m_isDebugEnabled) {
        LogDebug("L1GTEvmDigiToRaw") << "\nPacking GTFE \n" << std::endl;
    }

    int uLength = L1GlobalTriggerReadoutSetup::UnitLength;

    // initialize the required number of word64
    int nrWord64 = gtfeBlock.getSize()/uLength;
    std::vector<cms_uint64_t> tmpWord64;
    tmpWord64.resize(nrWord64);

    for (int iWord = 0; iWord < nrWord64; ++iWord) {
        tmpWord64[iWord] = 0x0000000000000000ULL;
    }

    // fill the values in the words
    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        gtfeBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
        gtfeBlock.setRecordLength1Word64(tmpWord64[iWord], iWord);
        gtfeBlock.setRecordLengthWord64(tmpWord64[iWord], iWord);
        gtfeBlock.setBxNrWord64(tmpWord64[iWord], iWord);
        gtfeBlock.setSetupVersionWord64(tmpWord64[iWord], iWord);
        gtfeBlock.setActiveBoardsWord64(tmpWord64[iWord], iWord, activeBoardsGtValue);
        gtfeBlock.setAltNrBxBoardWord64(tmpWord64[iWord], iWord);
        gtfeBlock.setTotalTriggerNrWord64(tmpWord64[iWord], iWord);

        for (int iBst = 0; iBst < m_bstLengthBytes; ++iBst) {
            gtfeBlock.setBstWord64(tmpWord64[iWord], iBst, iWord);
        }

    }

    // put the words in the FED record

    cms_uint64_t* pw =
        reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));

    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        *pw++ = tmpWord64[iWord];

        if (m_verbosity && m_isDebugEnabled) {
            LogTrace("L1GTEvmDigiToRaw")
                    << std::setw(4) << iWord << "  "
                    << std::hex << std::setfill('0')
                    << std::setw(16) << tmpWord64[iWord]
                    << std::dec << std::setfill(' ')
                    << std::endl;
        }
    }


}
void L1GTEvmDigiToRaw::packHeader ( unsigned char *  ptrGt,
edm::Event iEvent 
) [private]

block packers -------------

pack header

Definition at line 456 of file L1GTEvmDigiToRaw.cc.

References edm::EventBase::bunchCrossing(), edm::EventID::event(), edm::EventBase::id(), LogDebug, m_evmGtFedId, m_isDebugEnabled, m_verbosity, and FEDHeader::set().

Referenced by produce().

{
    // TODO FIXME where from to get all numbers?

    // Event Trigger type identifier
    int triggerTypeVal = 0;

    // Level-1 event number generated by the TTC system
    int lvl1IdVal = iEvent.id().event();

    // The bunch crossing number
    int bxCross = iEvent.bunchCrossing();
    cms_uint16_t bxCrossHw = 0;
    if ((bxCross & 0xFFF) == bxCross) {
        bxCrossHw = static_cast<cms_uint16_t> (bxCross);
    }
    else {
        bxCrossHw = 0; // Bx number too large, set to 0!
        if (m_verbosity && m_isDebugEnabled) {
            LogDebug("L1GTEvmDigiToRaw")
                    << "\nBunch cross number [hex] = "
                    << std::hex << bxCross
                    << "\n  larger than 12 bits. Set to 0! \n"
                    << std::dec
                    << std::endl;
        }
    }
    int bxIdVal = bxCrossHw;

    // Identifier of the FED
    int sourceIdVal = m_evmGtFedId;

    // Version identifier of the FED data format
    int versionVal = 0;

    // 0 -> the current header word is the last one.
    // 1-> other header words can follow
    // (always 1 for ECAL)
    bool moreHeadersVal = false;


    FEDHeader gtFEDHeader(ptrGt);

    gtFEDHeader.set(ptrGt,
                    triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
                    moreHeadersVal);


}
void L1GTEvmDigiToRaw::packTCS ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1TcsWord tcsBlock 
) [private]

pack the TCS block

Definition at line 570 of file L1GTEvmDigiToRaw.cc.

References L1TcsWord::getSize(), LogDebug, LogTrace, m_isDebugEnabled, m_verbosity, L1TcsWord::setAssignedPartitionsWord64(), L1TcsWord::setBoardIdWord64(), L1TcsWord::setBxNrWord64(), L1TcsWord::setDaqNrWord64(), L1TcsWord::setEventNrWord64(), L1TcsWord::setLuminositySegmentNrWord64(), L1TcsWord::setOrbitNrWord64(), L1TcsWord::setPartRunNrWord64(), L1TcsWord::setPartTrigNrWord64(), L1TcsWord::setStatusWord64(), L1TcsWord::setTriggerTypeWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

{

    if (m_verbosity && m_isDebugEnabled) {
        LogDebug("L1GTEvmDigiToRaw") << "\nPacking TCS \n" << std::endl;
    }

    int uLength = L1GlobalTriggerReadoutSetup::UnitLength;

    // initialize the required number of word64
    int nrWord64 = tcsBlock.getSize()/uLength;
    std::vector<cms_uint64_t> tmpWord64;
    tmpWord64.resize(nrWord64);

    for (int iWord = 0; iWord < nrWord64; ++iWord) {
        tmpWord64[iWord] = 0x0000000000000000ULL;
    }

    // fill the values in the words
    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        tcsBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
        tcsBlock.setBxNrWord64(tmpWord64[iWord], iWord);
        tcsBlock.setDaqNrWord64(tmpWord64[iWord], iWord);
        tcsBlock.setTriggerTypeWord64(tmpWord64[iWord], iWord);
        tcsBlock.setStatusWord64(tmpWord64[iWord], iWord);
        tcsBlock.setLuminositySegmentNrWord64(tmpWord64[iWord], iWord);

        tcsBlock.setPartRunNrWord64(tmpWord64[iWord], iWord);
        tcsBlock.setAssignedPartitionsWord64(tmpWord64[iWord], iWord);

        tcsBlock.setPartTrigNrWord64(tmpWord64[iWord], iWord);
        tcsBlock.setEventNrWord64(tmpWord64[iWord], iWord);

        tcsBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);

    }

    // put the words in the FED record

    cms_uint64_t* pw =
        reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));

    for (int iWord = 0; iWord < nrWord64; ++iWord) {

        *pw++ = tmpWord64[iWord];

        if (m_verbosity && m_isDebugEnabled) {
            LogTrace("L1GTEvmDigiToRaw")
                    << std::setw(4) << iWord << "  "
                    << std::hex << std::setfill('0')
                    << std::setw(16) << tmpWord64[iWord]
                    << std::dec << std::setfill(' ')
                    << std::endl;
        }
    }


}
void L1GTEvmDigiToRaw::packTrailer ( unsigned char *  ptrGt,
unsigned char *  ptrGtBegin,
int  dataSize 
) [private]

pack trailer word

Definition at line 705 of file L1GTEvmDigiToRaw.cc.

References evf::compute_crc(), and FEDTrailer::set().

Referenced by produce().

{

    // TODO FIXME where from to get all numbers?

    // The length of the event fragment counted in 64-bit words including header and trailer
    int lengthVal = dataSize/8;

    // Cyclic Redundancy Code of the event fragment including header and trailer
    int crcVal = evf::compute_crc(ptrGtBegin, dataSize);

    // Event fragment status information
    int evtStatusVal = 0;

    // Current value of the Trigger Throttling System bits.
    int ttsBitsVal = 0;

    // 0 -> the current trailer word is the last one.
    // 1-> other trailer words can follow
    // (always 0 for ECAL)
    bool moreTrailersVal = false;

    FEDTrailer gtFEDTrailer(ptrGt);
    gtFEDTrailer.set(ptrGt,
                     lengthVal, crcVal, evtStatusVal, ttsBitsVal,
                     moreTrailersVal);

}
void L1GTEvmDigiToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
) [private, virtual]

loop over events

Implements edm::EDProducer.

Definition at line 103 of file L1GTEvmDigiToRaw.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), L1GtfeExtWord::bstLengthBytes(), FEDRawData::data(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1TcsWord::getSize(), L1GtfeExtWord::getSize(), L1GtFdlWord::getSize(), GTFE, edm::HandleBase::isValid(), LogDebug, LogTrace, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_isDebugEnabled, m_maxBxInEvent, m_minBxInEvent, m_totalBxInEvent, m_verbosity, packFDL(), packGTFE(), packHeader(), packTCS(), packTrailer(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), edm::Event::put(), L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), FEDRawData::resize(), FEDRawData::size(), TCS, and TIM.

{

    // define new FEDRawDataCollection
    // it contains ALL FEDs in an event
    std::auto_ptr<FEDRawDataCollection> allFedRawData(new FEDRawDataCollection);

    FEDRawData& gtRawData = allFedRawData->FEDData(m_evmGtFedId);

    // get records from EventSetup

    //  board maps
    edm::ESHandle< L1GtBoardMaps > l1GtBM;
    evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );

    const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
    int boardMapsSize = boardMaps.size();

    typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;

    // create an ordered vector for the GT EVM record
    // header (pos 0 in record) and trailer (last position in record)
    // not included, as they are not in board list
    std::vector<L1GtBoard> gtRecordMap;
    gtRecordMap.reserve(boardMapsSize);

    for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
        for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
                != boardMaps.end(); ++itBoard) {

            if (itBoard->gtPositionEvmRecord() == iPos) {
                gtRecordMap.push_back(*itBoard);
                break;
            }

        }
    }



    // get L1GlobalTriggerEvmReadoutRecord
    edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord;
    iEvent.getByLabel(m_evmGtInputTag, gtReadoutRecord);

    if (!gtReadoutRecord.isValid()) {
        edm::LogWarning("L1GTEvmDigiToRaw")
                << "\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " << m_evmGtInputTag
                << "\nrequested in configuration, but not found in the event."
                << "\nQuit packing this event" << std::endl;

        // put the raw data in the event
        iEvent.put(allFedRawData);

        return;
    }

    if (m_verbosity && m_isDebugEnabled) {
        std::ostringstream myCoutStream;
        gtReadoutRecord->print(myCoutStream);
        LogTrace("L1GTEvmDigiToRaw")
                << "\n The following L1 GT EVM readout record will be packed.\n"
                << " Some boards could be disabled before packing,"
                << " see detailed board packing.\n"
                << myCoutStream.str() << "\n"
                << std::endl;
    }

    // get GTFE block
    L1GtfeExtWord gtfeBlock = gtReadoutRecord->gtfeWord();

    // get the number of Bx in the event for alternative 0 and alternative 1
    cms_uint16_t recordLength0 = gtfeBlock.recordLength();
    cms_uint16_t recordLength1 = gtfeBlock.recordLength1();

    // length of BST record (in bytes)
    m_bstLengthBytes= static_cast<int> (gtfeBlock.bstLengthBytes());

    // get list of active blocks from the GTFE block
    // and mask some blocks, if required
    // blocks not active are not written to the record

    cms_uint16_t activeBoardsGtInitial = gtfeBlock.activeBoards();
    cms_uint16_t altNrBxBoardInitial = gtfeBlock.altNrBxBoard();

    // mask some boards, if needed

    cms_uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;

    if (m_verbosity && m_isDebugEnabled) {
        LogDebug("L1GTEvmDigiToRaw")
                << "\nActive boards before masking(hex format): " << std::hex
                << std::setw(sizeof ( activeBoardsGtInitial ) * 2) << std::setfill('0')
                << activeBoardsGtInitial << std::dec << std::setfill(' ')
                << "\nActive boards after masking(hex format):  " << std::hex
                << std::setw(sizeof ( activeBoardsGt ) * 2) << std::setfill('0')
                << activeBoardsGt << std::dec
                << std::setfill(' ') << " \n"
                << std::endl;
    }

    // get the size of the record

    unsigned int gtDataSize = 0;

    unsigned int headerSize = 8;
    gtDataSize += headerSize;

    for (CItBoardMaps
            itBoard = boardMaps.begin();
            itBoard != boardMaps.end(); ++itBoard) {

        if (itBoard->gtBoardType() == GTFE) {
            gtDataSize += gtfeBlock.getSize();
            continue;
        }


        int iActiveBit = itBoard->gtBitEvmActiveBoards();
        bool activeBoardToPack = false;

        int altNrBxBoardVal = -1;

        if (iActiveBit >= 0) {
            activeBoardToPack = activeBoardsGt & (1 << iActiveBit);

            altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;

            if (altNrBxBoardVal == 1) {
                m_totalBxInEvent = recordLength1;
            } else if (altNrBxBoardVal == 0) {
                m_totalBxInEvent = recordLength0;
            } else {
                if (m_verbosity) {
                    edm::LogWarning("L1GTEvmDigiToRaw")
                    << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
                    << " for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
                    << "\n  iActiveBit =            " << iActiveBit
                    << "\n  altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<  std::dec
                    << "\n  activeBoardsGt =      0x" << std::hex << activeBoardsGt <<  std::dec
                    << "\n  activeBoardToPack =   " << activeBoardToPack
                    << "\n Set altNrBxBoardVal tentatively to "
                    << recordLength0 << "\n Job may crash or produce wrong results!\n\n"
                    << std::endl;
                }

                m_totalBxInEvent = recordLength0;
            }
        } else {
            // board not in the ActiveBoards for the record
            continue;
        }

        if (activeBoardToPack) {

            switch (itBoard->gtBoardType()) {
                case GTFE: {
                        // size already added;
                    }

                    break;
                case FDL: {
                        L1GtFdlWord fdlBlock;
                        gtDataSize += m_totalBxInEvent*fdlBlock.getSize();
                    }

                    break;
                case TCS: {
                        L1TcsWord tcsBlock;
                        gtDataSize += tcsBlock.getSize();
                    }

                    break;
                case TIM: {
                        // not considered
                    }

                    break;
                default: {
                        // do nothing, all blocks are given in GtBoardType enum
                    }

                    break;
            }
        }

    }


    unsigned int trailerSize = 8;
    gtDataSize += trailerSize;

    // resize, GT raw data record has variable length,
    // depending on active boards (read in GTFE)
    gtRawData.resize(gtDataSize);

    // ptrGt: pointer to the beginning of GT record in the raw data

    unsigned char* ptrGt = gtRawData.data();
    unsigned char* ptrGtBegin = gtRawData.data();

    if (m_verbosity && m_isDebugEnabled) {
        LogDebug("L1GTEvmDigiToRaw") << "\n Size of raw data: " << gtRawData.size() << "\n"
                << std::endl;
    }

    // ------- pack boards -------

    // pack header
    packHeader(ptrGt, iEvent);
    ptrGt += headerSize; // advance with header size

    // loop over other blocks in the raw record, if they are active

    for (CItBoardMaps
            itBoard = gtRecordMap.begin();
            itBoard != gtRecordMap.end(); ++itBoard) {

        if (itBoard->gtBoardType() == GTFE) {

            packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);

            if (m_verbosity && m_isDebugEnabled) {

                std::ostringstream myCoutStream;
                gtfeBlock.print(myCoutStream);
                LogTrace("L1GTEvmDigiToRaw")
                        << myCoutStream.str() << "\n"
                        << std::endl;
            }

            ptrGt += gtfeBlock.getSize(); // advance with GTFE block size

            continue;
        }


        // pack modules other than GTFE if they are active

        int iActiveBit = itBoard->gtBitEvmActiveBoards();
        bool activeBoardToPack = false;

        int altNrBxBoardVal = -1;

        if (iActiveBit >= 0) {
            activeBoardToPack = activeBoardsGt & (1 << iActiveBit);

            altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;

            if (altNrBxBoardVal == 1) {
                m_totalBxInEvent = recordLength1;
            } else if (altNrBxBoardVal == 0) {
                m_totalBxInEvent = recordLength0;
            } else {
                if (m_verbosity) {
                    edm::LogWarning("L1GTEvmDigiToRaw")
                    << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
                    << " for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
                    << "\n  iActiveBit =            " << iActiveBit
                    << "\n  altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<  std::dec
                    << "\n  activeBoardsGt =      0x" << std::hex << activeBoardsGt <<  std::dec
                    << "\n  activeBoardToPack =   " << activeBoardToPack
                    << "\n Set altNrBxBoardVal tentatively to "
                    << recordLength0 << "\n Job may crash or produce wrong results!\n\n"
                    << std::endl;
                }

                m_totalBxInEvent = recordLength0;
            }

            m_minBxInEvent = (m_totalBxInEvent + 1)/2 - m_totalBxInEvent;
            m_maxBxInEvent = (m_totalBxInEvent + 1)/2 - 1;

        } else {
            // board not in the ActiveBoards for the record
            continue;
        }

        if (activeBoardToPack) {

            if (m_verbosity && m_isDebugEnabled) {
                LogDebug("L1GTEvmDigiToRaw")
                        << "\nBoard " << std::hex << "0x" << ( itBoard->gtBoardId() ) << std::dec
                        << "\n  Number of bunch crosses in the record: " << m_totalBxInEvent
                        << " = " << "[" << m_minBxInEvent << ", " << m_maxBxInEvent
                        << "] BX\n"
                        << std::endl;
            }

            // active board, pack it
            switch (itBoard->gtBoardType()) {

                case TCS: {

                        L1TcsWord tcsBlock = gtReadoutRecord->tcsWord();
                        packTCS(evSetup, ptrGt, tcsBlock);

                        if (m_verbosity && m_isDebugEnabled) {

                            std::ostringstream myCoutStream;
                            tcsBlock.print(myCoutStream);
                            LogTrace("L1GTEvmDigiToRaw")
                                    << myCoutStream.str() << "\n"
                                    << std::endl;
                        }

                        ptrGt += tcsBlock.getSize(); // advance with TCS block size

                    }
                    break;
                case FDL: {

                        for (int iBxInEvent = m_minBxInEvent; iBxInEvent <= m_maxBxInEvent;
                                ++iBxInEvent) {

                            L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
                            packFDL(evSetup, ptrGt, fdlBlock);

                            if (m_verbosity && m_isDebugEnabled) {

                                std::ostringstream myCoutStream;
                                fdlBlock.print(myCoutStream);
                                LogTrace("L1GTEvmDigiToRaw")
                                        << myCoutStream.str() << "\n"
                                        << std::endl;
                            }

                            ptrGt += fdlBlock.getSize(); // advance with FDL block size
                        }

                    }
                    break;
                default: {

                        // do nothing, all blocks are given in GtBoardType enum
                        break;
                    }
            }

        }
    }

    // pack trailer
    packTrailer(ptrGt, ptrGtBegin, gtDataSize);

    // put the raw data in the event

    iEvent.put(allFedRawData);


}

Member Data Documentation

mask for active boards

Definition at line 96 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

length of BST record (in bytes)

Definition at line 110 of file L1GTEvmDigiToRaw.h.

Referenced by packGTFE(), and produce().

FED Id for GT EVM record default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc

Definition at line 90 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), packHeader(), and produce().

input tag for GT EVM record

Definition at line 93 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

Definition at line 116 of file L1GTEvmDigiToRaw.h.

Referenced by packFDL(), packGTFE(), packHeader(), packTCS(), and produce().

max Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block assume symmetrical number of BX around L1Accept

Definition at line 107 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

min Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block assume symmetrical number of BX around L1Accept

Definition at line 103 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

total Bx's in the event, obtained from GTFE block

Definition at line 99 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

verbosity level

Definition at line 115 of file L1GTEvmDigiToRaw.h.

Referenced by packFDL(), packGTFE(), packHeader(), packTCS(), and produce().