CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1GlobalTriggerEvmRawToDigi Class Reference

#include <L1GlobalTriggerEvmRawToDigi.h>

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

List of all members.

Public Member Functions

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

Private Member Functions

virtual void beginJob ()
void dumpFedRawData (const unsigned char *, int, std::ostream &)
 dump FED raw data
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)
void produceEmptyProducts (edm::Event &)
 produce empty products in case of problems
void unpackHeader (const unsigned char *, FEDHeader &)
 block unpackers
void unpackTrailer (const unsigned char *, FEDTrailer &)
 unpack trailer word

Private Attributes

boost::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 tags for GT EVM record
L1GtFdlWordm_gtFdlWord
L1GtfeExtWordm_gtfeWord
bool m_isDebugEnabled
int m_lowSkipBxInEvent
int m_recordLength0
 total Bx's in the event, obtained from GTFE block
int m_recordLength1
 corresponding to alternative 1 in altNrBxBoard()
L1TcsWordm_tcsWord
int m_totalBxInEvent
 number of Bx for a board, obtained from GTFE block (record length & alternative)
int m_unpackBxInEvent
int m_uppSkipBxInEvent
int m_verbosity
 verbosity level

Detailed Description

Description: unpack EVM raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Description: unpack raw data into digitized data.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 45 of file L1GlobalTriggerEvmRawToDigi.h.


Constructor & Destructor Documentation

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

constructor(s)

Definition at line 59 of file L1GlobaTriggerEvmRawToDigi.cc.

References LogDebug, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, m_tcsWord, m_unpackBxInEvent, and m_verbosity.

                                                                                    :

    // input tag for EVM GT record
            m_evmGtInputTag(pSet.getParameter<edm::InputTag> ("EvmGtInputTag")),

            // FED Id for GT EVM record
            // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
            // default value: assume the EVM record is the first GT record
            m_evmGtFedId(pSet.getUntrackedParameter<int> (
                    "EvmGtFedId", FEDNumbering::MINTriggerGTPFEDID)),

            // mask for active boards
            m_activeBoardsMaskGt(pSet.getParameter<unsigned int> ("ActiveBoardsMask")),

            // number of bunch crossing to be unpacked
            m_unpackBxInEvent(pSet.getParameter<int> ("UnpackBxInEvent")),

            m_lowSkipBxInEvent(0), m_uppSkipBxInEvent(0),

            m_recordLength0(0), m_recordLength1(0),

            m_totalBxInEvent(0),

            // length of BST record (in bytes)
            m_bstLengthBytes(pSet.getParameter<int> ("BstLengthBytes")),

            m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),

            m_isDebugEnabled(edm::isDebugEnabled())

{

    produces<L1GlobalTriggerEvmReadoutRecord> ();

    if (m_verbosity && m_isDebugEnabled) {

        LogDebug("L1GlobalTriggerEvmRawToDigi")
                << "\nInput tag for EVM GT record:             " << m_evmGtInputTag
                << "\nFED Id for EVM GT record:                " << m_evmGtFedId
                << "\nMask for active boards (hex format):     " << std::hex
                << std::setw(sizeof(m_activeBoardsMaskGt) * 2) << std::setfill('0')
                << m_activeBoardsMaskGt
                << std::dec << std::setfill(' ')
                << "\nNumber of bunch crossing to be unpacked: " << m_unpackBxInEvent
                << "\nLength of BST message [bytes]:           " << m_bstLengthBytes << "\n"
                << std::endl;
    }

    if ( ( m_unpackBxInEvent > 0 ) && ( ( m_unpackBxInEvent % 2 ) == 0 )) {
        m_unpackBxInEvent = m_unpackBxInEvent - 1;

        if (m_verbosity) {
            edm::LogInfo("L1GlobalTriggerEvmRawToDigi")
                    << "\nWARNING: Number of bunch crossing to be unpacked rounded to: "
                    << m_unpackBxInEvent << "\n         The number must be an odd number!\n"
                    << std::endl;
        }
    }

    // create GTFE, TCS, FDL cards once per analyzer
    // content will be reset whenever needed

    m_gtfeWord = new L1GtfeExtWord();
    m_tcsWord = new L1TcsWord();
    m_gtFdlWord = new L1GtFdlWord();

}
L1GlobalTriggerEvmRawToDigi::~L1GlobalTriggerEvmRawToDigi ( ) [virtual]

destructor

Definition at line 128 of file L1GlobaTriggerEvmRawToDigi.cc.

References m_gtFdlWord, m_gtfeWord, and m_tcsWord.

                                                          {

    delete m_gtfeWord;
    delete m_tcsWord;
    delete m_gtFdlWord;

}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 138 of file L1GlobaTriggerEvmRawToDigi.cc.

                                           {

    // empty now

}
void L1GlobalTriggerEvmRawToDigi::dumpFedRawData ( const unsigned char *  gtPtr,
int  gtSize,
std::ostream &  myCout 
) [private]

dump FED raw data

Definition at line 808 of file L1GlobaTriggerEvmRawToDigi.cc.

References i, LogDebug, LogTrace, L1GlobalTriggerReadoutSetup::UnitLength, and L1GlobalTriggerReadoutSetup::WordLength.

Referenced by produce().

                                                                    {

    LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;

    int wLength = L1GlobalTriggerReadoutSetup::WordLength;
    int uLength = L1GlobalTriggerReadoutSetup::UnitLength;

    int gtWords = gtSize / uLength;
    LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):"
            << gtWords << "\n" << std::endl;

    const boost::uint64_t* payload =
            reinterpret_cast<boost::uint64_t*> (const_cast<unsigned char*> (gtPtr));

    for (unsigned int i = 0; i < gtSize / sizeof(boost::uint64_t); i++) {
        myCout << std::setw(4) << i << "  " << std::hex << std::setfill('0') << std::setw(16)
                << payload[i] << std::dec << std::setfill(' ') << std::endl;
    }

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

Reimplemented from edm::EDProducer.

Definition at line 831 of file L1GlobaTriggerEvmRawToDigi.cc.

                                         {

    // empty now
}
void L1GlobalTriggerEvmRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 145 of file L1GlobaTriggerEvmRawToDigi.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), FEDRawData::data(), dumpFedRawData(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1TcsWord::getSize(), L1GtfeExtWord::getSize(), L1GtFdlWord::getSize(), GMT, L1GtParameters::gtBstLengthBytes(), GTFE, edm::HandleBase::isValid(), LogDebug, LogTrace, L1TcsWord::luminositySegmentNr(), L1GtFdlWord::lumiSegmentNr(), m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_gtFdlWord, m_gtfeWord, m_isDebugEnabled, m_lowSkipBxInEvent, m_recordLength0, m_recordLength1, m_tcsWord, m_totalBxInEvent, m_unpackBxInEvent, m_uppSkipBxInEvent, m_verbosity, max(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), produceEmptyProducts(), edm::ESHandle< T >::product(), edm::Handle< T >::product(), PSB, edm::Event::put(), L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), L1GtFdlWord::reset(), L1TcsWord::reset(), L1GtfeExtWord::reset(), L1GtfeExtWord::resize(), L1GtfeWord::setActiveBoards(), L1TcsWord::setLuminositySegmentNr(), L1GtFdlWord::setLumiSegmentNr(), L1GtfeWord::setRecordLength(), L1GtfeWord::setRecordLength1(), FEDRawData::size(), TCS, TIM, L1GtFdlWord::unpack(), L1TcsWord::unpack(), L1GtfeExtWord::unpack(), unpackHeader(), and unpackTrailer().

                                                                                        {

    // 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;
            }

        }
    }

    // raw collection

    edm::Handle<FEDRawDataCollection> fedHandle;
    iEvent.getByLabel(m_evmGtInputTag, fedHandle);

    if (!fedHandle.isValid()) {
        if (m_verbosity) {
            edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
                    << "\nWarning: FEDRawDataCollection with input tag " << m_evmGtInputTag
                    << "\nrequested in configuration, but not found in the event."
                    << "\nQuit unpacking this event" << std::endl;
        }

        produceEmptyProducts(iEvent);

        return;
    }

    // retrieve data for Global Trigger EVM FED
    const FEDRawData& raw = ( fedHandle.product() )->FEDData(m_evmGtFedId);

    int gtSize = raw.size();

    // get a const pointer to the beginning of the data buffer
    const unsigned char* ptrGt = raw.data();

    // get a const pointer to the end of the data buffer
    const unsigned char* endPtrGt = ptrGt + gtSize;

    //
    if (m_verbosity && m_isDebugEnabled) {

        LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Size of raw data: "
                << gtSize << "\n" << std::endl;

        std::ostringstream myCoutStream;
        dumpFedRawData(ptrGt, gtSize, myCoutStream);

        LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Dump FEDRawData\n"
                << myCoutStream.str() << "\n" << std::endl;

    }

    // unpack header
    int headerSize = 8;

    if ((ptrGt + headerSize) > endPtrGt) {
        edm::LogError("L1GlobalTriggerEvmRawToDigi")
                << "\nError: Pointer after header greater than end pointer."
                << "\n Put empty products in the event!"
                << "\n Quit unpacking this event." << std::endl;

        produceEmptyProducts(iEvent);

        return;
    }

    FEDHeader cmsHeader(ptrGt);
    FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);

    unpackHeader(ptrGt, cmsHeader);
    ptrGt += headerSize; // advance with header size

    // unpack first GTFE to find the length of the record and the active boards
    // here GTFE assumed immediately after the header

    bool gtfeUnpacked = false;

    // get the length of the BST message from parameter set or from event setup

    int bstLengthBytes = 0;

    if (m_bstLengthBytes < 0) {
        // length from event setup // TODO cache it, if too slow

        edm::ESHandle<L1GtParameters> l1GtPar;
        evSetup.get<L1GtParametersRcd> ().get(l1GtPar);
        const L1GtParameters* m_l1GtPar = l1GtPar.product();

        bstLengthBytes = static_cast<int> (m_l1GtPar->gtBstLengthBytes());

    } else {
        // length from parameter set
        bstLengthBytes = m_bstLengthBytes;
    }

    if (m_verbosity) {
        LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Length of BST message (in bytes): "
                << bstLengthBytes << "\n" << std::endl;
    }

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

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

            // unpack GTFE
            if (itBoard->gtPositionEvmRecord() == 1) {

                // resize to the right size before unapacking
                m_gtfeWord->resize(bstLengthBytes);

                m_gtfeWord->unpack(ptrGt);
                ptrGt += m_gtfeWord->getSize(); // advance with GTFE block size
                gtfeUnpacked = true;

                if (m_verbosity && m_isDebugEnabled) {

                    std::ostringstream myCoutStream;
                    m_gtfeWord->print(myCoutStream);
                    LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n"
                            << std::endl;
                }

                // break the loop - GTFE was found
                break;

            } else {

                if (m_verbosity) {
                    edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
                            << "\nWarning: GTFE block found in raw data does not follow header."
                            << "\nAssumed start position of the block is wrong!"
                            << "\nQuit unpacking this event" << std::endl;
                }

                produceEmptyProducts(iEvent);

                return;

            }

        }
    }

    // quit if no GTFE found
    if (!gtfeUnpacked) {

        if (m_verbosity) {
            edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
                    << "\nWarning: no GTFE block found in raw data."
                    << "\nCan not find the record length (BxInEvent) and the active boards!"
                    << "\nQuit unpacking this event" << std::endl;
        }

        produceEmptyProducts(iEvent);

        return;
    }

    // life normal here, GTFE found

    // get list of active blocks
    // blocks not active are not written to the record
    boost::uint16_t activeBoardsGtInitial = m_gtfeWord->activeBoards();
    boost::uint16_t altNrBxBoardInitial = m_gtfeWord->altNrBxBoard();

    // mask some boards, if needed
    boost::uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;
    m_gtfeWord->setActiveBoards(activeBoardsGt);

    if (m_verbosity) {
        LogDebug("L1GlobalTriggerEvmRawToDigi") << "\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;
    }

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

    int numberGtfeBoards = 0;
    int numberFdlBoards = 0;
    int numberPsbBoards = 0;
    int numberGmtBoards = 0;
    int numberTcsBoards = 0;
    int numberTimBoards = 0;

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

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

        if (iActiveBit >= 0) {
            activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
        } else {
            // board not in the ActiveBoards for the record
            continue;
        }

        if (activeBoardToUnpack) {

            switch (itBoard->gtBoardType()) {
                case GTFE: {
                    numberGtfeBoards++;
                }

                    break;
                case FDL: {
                    numberFdlBoards++;
                }

                    break;
                case PSB: {
                    numberPsbBoards++;
                }

                    break;
                case GMT: {
                    numberGmtBoards++;
                }

                    break;
                case TCS: {
                    numberTcsBoards++;
                }

                    break;
                case TIM: {
                    numberTimBoards++;
                }

                    break;
                default: {
                    // do nothing, all blocks are given in GtBoardType enum
                    if (m_verbosity) {
                        LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type "
                                << itBoard->gtBoardType() << " not expected  in record.\n"
                                << std::endl;
                    }

                }

                    break;
            }
        }

    }

    // produce the L1GlobalTriggerEvmReadoutRecord now, after we found how many
    // BxInEvent the record has and how many boards are active
    //LogDebug("L1GlobalTriggerEvmRawToDigi")
    //<< "\nL1GlobalTriggerEvmRawToDigi: producing L1GlobalTriggerEvmReadoutRecord\n"
    //<< std::endl;

    // get number of Bx in the event from GTFE block corresponding to alternative 0 and 1 in
    m_recordLength0 = m_gtfeWord->recordLength();
    m_recordLength1 = m_gtfeWord->recordLength1();

    int maxBxInEvent = std::max(m_recordLength0, m_recordLength1);

    std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
            new L1GlobalTriggerEvmReadoutRecord(maxBxInEvent, numberFdlBoards));

    // ... then unpack modules other than GTFE, if requested

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

        int iActiveBit = itBoard->gtBitEvmActiveBoards();

        bool activeBoardToUnpack = false;
        bool activeBoardInitial = false;

        int altNrBxBoardVal = -1;

        if (iActiveBit >= 0) {
            activeBoardInitial = activeBoardsGtInitial & ( 1 << iActiveBit );
            activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );

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

            if (altNrBxBoardVal == 1) {
                m_totalBxInEvent = m_recordLength1;
            } else if (altNrBxBoardVal == 0) {
                m_totalBxInEvent = m_recordLength0;
            } else {
                if (m_verbosity) {
                    edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
                            << "\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  activeBoardInitial =    " << activeBoardInitial
                            << "\n  activeBoardToUnpack =   " << activeBoardToUnpack
                            << "\n Set altNrBxBoardVal tentatively to "
                            << m_recordLength0 << "\n Job may crash or produce wrong results!\n\n"
                            << std::endl;
                }

                m_totalBxInEvent = m_recordLength0;
            }

            // number of BX required to be unpacked

            if (m_unpackBxInEvent > m_totalBxInEvent) {
                if (m_verbosity) {
                    LogDebug("L1GlobalTriggerEvmRawToDigi")
                            << "\nWARNING: Number of available bunch crosses for board"
                            << ( itBoard->gtBoardId() ) << " in the record ( " << m_totalBxInEvent
                            << " ) \n is smaller than the number of bunch crosses requested to be unpacked ("
                            << m_unpackBxInEvent << " )!!! \n         Unpacking only "
                            << m_totalBxInEvent << " bunch crosses.\n" << std::endl;
                }

                m_lowSkipBxInEvent = 0;
                m_uppSkipBxInEvent = m_totalBxInEvent;

            } else if (m_unpackBxInEvent < 0) {

                m_lowSkipBxInEvent = 0;
                m_uppSkipBxInEvent = m_totalBxInEvent;

                if (m_verbosity) {
                    LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nUnpacking all " << m_totalBxInEvent
                            << " bunch crosses available." << "\n" << std::endl;
                }

            } else if (m_unpackBxInEvent == 0) {

                m_lowSkipBxInEvent = m_totalBxInEvent;
                m_uppSkipBxInEvent = m_totalBxInEvent;

                if (m_verbosity) {
                    LogDebug("L1GlobalTriggerEvmRawToDigi")
                            << "\nNo bxInEvent required to be unpacked from " << m_totalBxInEvent
                            << " bunch crosses available." << "\n" << std::endl;
                }

                // change RecordLength
                // cast int to boost::uint16_t (there are normally 3 or 5 BxInEvent)
                m_gtfeWord->setRecordLength(static_cast<boost::uint16_t> (m_unpackBxInEvent));
                m_gtfeWord->setRecordLength1(static_cast<boost::uint16_t> (m_unpackBxInEvent));

            } else {

                m_lowSkipBxInEvent = ( m_totalBxInEvent - m_unpackBxInEvent ) / 2;
                m_uppSkipBxInEvent = m_totalBxInEvent - m_lowSkipBxInEvent;

                if (m_verbosity) {
                    LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nUnpacking " << m_unpackBxInEvent
                            << " bunch crosses from " << m_totalBxInEvent
                            << " bunch crosses available." << "\n" << std::endl;
                }

                // change RecordLength
                // cast int to boost::uint16_t (there are normally 3 or 5 BxInEvent)
                m_gtfeWord->setRecordLength(static_cast<boost::uint16_t> (m_unpackBxInEvent));
                m_gtfeWord->setRecordLength1(static_cast<boost::uint16_t> (m_unpackBxInEvent));

            }

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

        if (!activeBoardInitial) {
            if (m_verbosity) {
                LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type "
                        << itBoard->gtBoardName() << " with index " << itBoard->gtBoardIndex()
                        << " not active initially in raw data.\n" << std::endl;
            }
            continue;
        }

        // active board initially, could unpack it
        switch (itBoard->gtBoardType()) {

            case TCS: {

                // if pointer after TCS payload is greater than pointer at
                // the end of GT payload, produce empty products and quit unpacking
                if ((ptrGt + m_tcsWord->getSize()) > endPtrGt) {
                    edm::LogError("L1GlobalTriggerEvmRawToDigi")
                            << "\nError: Pointer after TCS "
                            << " greater than end pointer."
                            << "\n Put empty products in the event!"
                            << "\n Quit unpacking this event." << std::endl;

                    produceEmptyProducts(iEvent);

                    return;
                }

                // unpack only if requested, otherwise skip it
                if (activeBoardToUnpack) {

                    m_tcsWord->unpack(ptrGt);

                    // add 1 to the GT luminosity number to use the same convention as
                    // offline, where LS number starts with 1;
                    // in GT hardware, LS starts with 0
                    boost::uint16_t lsNr = m_tcsWord->luminositySegmentNr() + 1;
                    m_tcsWord->setLuminositySegmentNr(lsNr);

                    // add TCS block to GT EVM readout record
                    gtReadoutRecord->setTcsWord(*m_tcsWord);

                    if (m_verbosity && m_isDebugEnabled) {

                        std::ostringstream myCoutStream;
                        m_tcsWord->print(myCoutStream);
                        LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n"
                                << std::endl;
                    }

                    // ... and reset it
                    m_tcsWord->reset();
                }

                ptrGt += m_tcsWord->getSize(); // advance with TCS block size

            }
                break;
            case FDL: {
                for (int iFdl = 0; iFdl < m_totalBxInEvent; ++iFdl) {

                    // if pointer after FDL payload is greater than pointer at
                    // the end of GT payload, produce empty products and quit unpacking
                    if ((ptrGt + m_gtFdlWord->getSize()) > endPtrGt) {
                        edm::LogError("L1GlobalTriggerEvmRawToDigi")
                                << "\nError: Pointer after FDL " << iFdl
                                << " greater than end pointer."
                                << "\n Put empty products in the event!"
                                << "\n Quit unpacking this event." << std::endl;

                        produceEmptyProducts(iEvent);

                        return;
                    }

                    // unpack only if requested, otherwise skip it
                    if (activeBoardToUnpack) {

                        // unpack only bxInEvent requested, otherwise skip it
                        if ( ( iFdl >= m_lowSkipBxInEvent ) && ( iFdl < m_uppSkipBxInEvent )) {

                            m_gtFdlWord->unpack(ptrGt);

                            // add 1 to the GT luminosity number to use the same convention as
                            // offline, where LS number starts with 1;
                            // in GT hardware, LS starts with 0
                            boost::uint16_t lsNr = m_gtFdlWord->lumiSegmentNr() + 1;
                            m_gtFdlWord->setLumiSegmentNr(lsNr);

                            // add FDL block to GT readout record
                            gtReadoutRecord->setGtFdlWord(*m_gtFdlWord);

                            if (m_verbosity && m_isDebugEnabled) {

                                std::ostringstream myCoutStream;
                                m_gtFdlWord->print(myCoutStream);
                                LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str()
                                        << "\n" << std::endl;
                            }

                            // ... and reset it
                            m_gtFdlWord->reset();
                        }

                    }

                    ptrGt += m_gtFdlWord->getSize(); // advance with FDL block size

                }
            }

                break;
            default: {
                // do nothing, all blocks are given in GtBoardType enum
                if (m_verbosity) {
                    LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type "
                            << itBoard->gtBoardType() << " not expected  in record.\n" << std::endl;
                }
            }
                break;

        }

    }

    // add GTFE block to GT readout record, after updating active boards and record length

    gtReadoutRecord->setGtfeWord(*m_gtfeWord);

    // ... and reset it
    m_gtfeWord->reset();

    // unpack trailer

    int trailerSize = 8;

    // if pointer after trailer is greater than pointer at
    // the end of GT payload, produce empty products and quit unpacking
    if ((ptrGt + trailerSize) > endPtrGt) {
        edm::LogError("L1GlobalTriggerEvmRawToDigi")
                << "\nError: Pointer after trailer "
                << " greater than end pointer."
                << "\n Put empty products in the event!"
                << "\n Quit unpacking this event." << std::endl;

        produceEmptyProducts(iEvent);

        return;
    }

    unpackTrailer(ptrGt, cmsTrailer);

    if (m_verbosity && m_isDebugEnabled) {
        std::ostringstream myCoutStream;
        gtReadoutRecord->print(myCoutStream);
        LogTrace("L1GlobalTriggerEvmRawToDigi")
                << "\n The following L1 GT EVM readout record was unpacked.\n"
                << myCoutStream.str() << "\n" << std::endl;
    }

    // put records into event
    iEvent.put(gtReadoutRecord);

}
void L1GlobalTriggerEvmRawToDigi::produceEmptyProducts ( edm::Event iEvent) [private]

produce empty products in case of problems

Definition at line 797 of file L1GlobaTriggerEvmRawToDigi.cc.

References edm::Event::put().

Referenced by produce().

                                                                       {

    std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
            new L1GlobalTriggerEvmReadoutRecord());

    // put empty records into event

    iEvent.put(gtReadoutRecord);
}
void L1GlobalTriggerEvmRawToDigi::unpackHeader ( const unsigned char *  gtPtr,
FEDHeader cmsHeader 
) [private]

block unpackers

unpack header

Definition at line 698 of file L1GlobaTriggerEvmRawToDigi.cc.

References FEDHeader::bxID(), edm::isDebugEnabled(), LogDebug, FEDHeader::lvl1ID(), FEDHeader::moreHeaders(), FEDHeader::sourceID(), FEDHeader::triggerType(), and FEDHeader::version().

Referenced by produce().

                                                                                               {

    // TODO  if needed in another format

    // print the header info
    if (edm::isDebugEnabled()) {

        const boost::uint64_t* payload =
                reinterpret_cast<boost::uint64_t*> (const_cast<unsigned char*> (gtPtr));

        std::ostringstream myCoutStream;

        // one word only
        int iWord = 0;

        myCoutStream << std::setw(4) << iWord << "  " << std::hex << std::setfill('0')
                << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
                << std::endl;

        myCoutStream << "  Event_type:  " << std::hex << " hex: " << "     " << std::setw(1)
                << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.triggerType() << std::endl;

        myCoutStream << "  LVL1_Id:     " << std::hex << " hex: " << "" << std::setw(6)
                << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.lvl1ID() << std::endl;

        myCoutStream << "  BX_Id:       " << std::hex << " hex: " << "   " << std::setw(3)
                << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.bxID() << std::endl;

        myCoutStream << "  Source_Id:   " << std::hex << " hex: " << "   " << std::setw(3)
                << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.sourceID() << std::endl;

        myCoutStream << "  FOV:         " << std::hex << " hex: " << "     " << std::setw(1)
                << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.version() << std::endl;

        myCoutStream << "  H:           " << std::hex << " hex: " << "     " << std::setw(1)
                << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ') << std::dec
                << " dec: " << cmsHeader.moreHeaders() << std::endl;

        LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n"
                << std::endl;

    }

}
void L1GlobalTriggerEvmRawToDigi::unpackTrailer ( const unsigned char *  trlPtr,
FEDTrailer cmsTrailer 
) [private]

unpack trailer word

Definition at line 750 of file L1GlobaTriggerEvmRawToDigi.cc.

References FEDTrailer::crc(), FEDTrailer::evtStatus(), FEDTrailer::lenght(), LogDebug, m_isDebugEnabled, m_verbosity, FEDTrailer::moreTrailers(), and FEDTrailer::ttsBits().

Referenced by produce().

                                                                                                   {

    // TODO  if needed in another format

    // print the trailer info
    if (m_verbosity && m_isDebugEnabled) {

        const boost::uint64_t* payload =
                reinterpret_cast<boost::uint64_t*> (const_cast<unsigned char*> (trlPtr));

        std::ostringstream myCoutStream;

        // one word only
        int iWord = 0;

        myCoutStream << std::setw(4) << iWord << "  " << std::hex << std::setfill('0')
                << std::setw(16) << payload[iWord] << std::dec << std::setfill(' ') << "\n"
                << std::endl;

        myCoutStream << "  Event_length:  " << std::hex << " hex: " << "" << std::setw(6)
                << std::setfill('0') << cmsTrailer.lenght() << std::setfill(' ') << std::dec
                << " dec: " << cmsTrailer.lenght() << std::endl;

        myCoutStream << "  CRC:           " << std::hex << " hex: " << "  " << std::setw(4)
                << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
                << " dec: " << cmsTrailer.crc() << std::endl;

        myCoutStream << "  Event_status:  " << std::hex << " hex: " << "    " << std::setw(2)
                << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ') << std::dec
                << " dec: " << cmsTrailer.evtStatus() << std::endl;

        myCoutStream << "  TTS_bits:      " << std::hex << " hex: " << "     " << std::setw(1)
                << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ') << std::dec
                << " dec: " << cmsTrailer.ttsBits() << std::endl;

        myCoutStream << "  More trailers: " << std::hex << " hex: " << "     " << std::setw(1)
                << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ') << std::dec
                << " dec: " << cmsTrailer.moreTrailers() << std::endl;

        LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str()
                << "\n" << std::endl;

    }

}

Member Data Documentation

mask for active boards

Definition at line 93 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

length of BST record (in bytes)

Definition at line 119 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

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

Definition at line 90 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

input tags for GT EVM record

Definition at line 86 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

lowest bxInEvent to be unpacked in the event assume symmetrical number of BX around L1Accept

Definition at line 100 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

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

corresponding to alternative 0 in altNrBxBoard()

Definition at line 109 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

corresponding to alternative 1 in altNrBxBoard()

Definition at line 112 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

number of Bx for a board, obtained from GTFE block (record length & alternative)

Definition at line 115 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

Definition at line 96 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), and produce().

upper bxInEvent to be unpacked in the event assume symmetrical number of BX around L1Accept

Definition at line 104 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by produce().

verbosity level

Definition at line 124 of file L1GlobalTriggerEvmRawToDigi.h.

Referenced by L1GlobalTriggerEvmRawToDigi(), produce(), and unpackTrailer().