CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1GtPackUnpackAnalyzer Class Reference

#include <L1GtPackUnpackAnalyzer.h>

Inheritance diagram for L1GtPackUnpackAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

 L1GtPackUnpackAnalyzer (const edm::ParameterSet &)
 ~L1GtPackUnpackAnalyzer ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 analyze each event
virtual void analyzeGMT (const edm::Event &, const edm::EventSetup &)
 GMT comparison.
virtual void analyzeGT (const edm::Event &, const edm::EventSetup &)
 GT comparison.
virtual void beginJob ()
virtual void endJob ()
 end of job

Private Attributes

edm::InputTag m_finalGtGmtInputTag
 input tag for the final GT DAQ and GMT records:
edm::InputTag m_initialDaqGtInputTag
 input tag for the initial GT DAQ record:
edm::InputTag m_initialMuGmtInputTag
 input tag for the initial GMT readout collection:

Detailed Description

Description: pack - unpack validation for L1 GT DAQ record.

Implementation: Pack (DigiToRaw) and unpack (RawToDigi) a L1 GT DAQ record. Compare the initial DAQ record with the final one and print them if they are different.

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Description: see header file.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 38 of file L1GtPackUnpackAnalyzer.h.


Constructor & Destructor Documentation

L1GtPackUnpackAnalyzer::L1GtPackUnpackAnalyzer ( const edm::ParameterSet parSet) [explicit]

Definition at line 34 of file L1GtPackUnpackAnalyzer.cc.

References edm::ParameterSet::getParameter(), m_finalGtGmtInputTag, m_initialDaqGtInputTag, and m_initialMuGmtInputTag.

{

    // input tag for the initial GT DAQ record: 
    m_initialDaqGtInputTag = parSet.getParameter<edm::InputTag>("InitialDaqGtInputTag");

    // input tag for the initial GMT readout collection: 
    m_initialMuGmtInputTag = parSet.getParameter<edm::InputTag>("InitialMuGmtInputTag");

    // input tag for the final GT DAQ and GMT records: 
    m_finalGtGmtInputTag = parSet.getParameter<edm::InputTag>("FinalGtGmtInputTag");
    

    edm::LogInfo("L1GtPackUnpackAnalyzer")
    << "\nInput tag for the initial GT DAQ record:          "
    << m_initialDaqGtInputTag << " \n"
    << "\nInput tag for the initial GMT readout collection: "
    << m_initialMuGmtInputTag << " \n"
    << "\nInput tag for the final GT DAQ and GMT records:   "
    << m_finalGtGmtInputTag << " \n"
    << std::endl;

}
L1GtPackUnpackAnalyzer::~L1GtPackUnpackAnalyzer ( )

Definition at line 59 of file L1GtPackUnpackAnalyzer.cc.

{   
    // empty   
}

Member Function Documentation

void L1GtPackUnpackAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup evSetup 
) [private, virtual]

analyze each event

Implements edm::EDAnalyzer.

Definition at line 351 of file L1GtPackUnpackAnalyzer.cc.

References analyzeGMT(), and analyzeGT().

{
    
    // GT DAQ comparison
    analyzeGT(iEvent, evSetup);

    // GMT comparison
    analyzeGMT(iEvent, evSetup);

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

GMT comparison.

Definition at line 290 of file L1GtPackUnpackAnalyzer.cc.

References edm::Event::getByLabel(), edm::HandleBase::isValid(), m_finalGtGmtInputTag, and m_initialMuGmtInputTag.

Referenced by analyze().

                                      {

    // define an output stream to print into
    // it can then be directed to whatever log level is desired
    std::ostringstream myCoutStream;

    // get initial L1MuGMTReadoutCollection
    edm::Handle<L1MuGMTReadoutCollection> gmtRcInitial;
    iEvent.getByLabel(m_initialMuGmtInputTag, gmtRcInitial);

    if (!gmtRcInitial.isValid()) {
        edm::LogError("L1GtPackUnpackAnalyzer")
                << "Initial L1MuGMTReadoutCollection with input tag \n  "
                << m_initialMuGmtInputTag << " not found.\n\n"
                << std::endl;
        return;
               
    }

    std::vector<L1MuGMTReadoutRecord> muRecordsInitial = gmtRcInitial->getRecords();

    // get final L1MuGMTReadoutCollection
    edm::Handle<L1MuGMTReadoutCollection> gmtRcFinal;
    iEvent.getByLabel(m_finalGtGmtInputTag, gmtRcFinal);

    if (!gmtRcFinal.isValid()) {
        edm::LogError("L1GtPackUnpackAnalyzer")
                << "Final L1MuGMTReadoutCollection with input tag \n  "
                << m_finalGtGmtInputTag << " not found.\n\n"
                << std::endl;
        return;
               
    }

    std::vector<L1MuGMTReadoutRecord> muRecordsFinal = gmtRcFinal->getRecords();

    int muRecordsInitialSize = muRecordsInitial.size();
    int muRecordsFinalSize = muRecordsFinal.size();
    
    if (muRecordsInitialSize == muRecordsFinalSize) {
        myCoutStream 
            << "\nInitial and final L1MuGMTReadoutCollection record size: identical.\n";
        myCoutStream << "  Size: " << muRecordsInitialSize << std::endl;
    }
    else {
        myCoutStream 
            << "\nInitial and final  L1MuGMTReadoutCollection record size: different.\n";
        myCoutStream << "  Initial size: " << muRecordsInitialSize << std::endl;
        myCoutStream << "  Final size: " << muRecordsFinalSize << std::endl;

    }

    edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;

    myCoutStream.str("");
    myCoutStream.clear();

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

GT comparison.

Definition at line 74 of file L1GtPackUnpackAnalyzer.cc.

References L1GtPsbWord::boardId(), L1GtPsbWord::bxInEvent(), edm::Event::getByLabel(), edm::HandleBase::isValid(), m_finalGtGmtInputTag, m_initialDaqGtInputTag, L1GtFdlWord::print(), L1GtfeWord::print(), and L1GtPsbWord::print().

Referenced by analyze().

{

    // define an output stream to print into
    // it can then be directed to whatever log level is desired
    std::ostringstream myCoutStream;

    // get the initial L1GlobalTriggerReadoutRecord
    edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordInitial;
    iEvent.getByLabel(m_initialDaqGtInputTag, gtReadoutRecordInitial);

    if (!gtReadoutRecordInitial.isValid()) {
        edm::LogError("L1GtTrigReport")
                << "Initial L1GlobalTriggerReadoutRecord with input tag \n  "
                << m_initialDaqGtInputTag << " not found.\n\n"
                << std::endl;
        return;
               
    }
    
    // get the final L1GlobalTriggerReadoutRecord
    edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordFinal;
    iEvent.getByLabel(m_finalGtGmtInputTag, gtReadoutRecordFinal);

    if (!gtReadoutRecordFinal.isValid()) {
        edm::LogError("L1GtTrigReport")
                << "Final L1GlobalTriggerReadoutRecord with input tag \n  "
                << m_finalGtGmtInputTag << " not found.\n\n"
                << std::endl;
        return;
               
    }
    
    // compare GTFE
    const L1GtfeWord& gtfeWordInitial = gtReadoutRecordInitial->gtfeWord();
    const L1GtfeWord& gtfeWordFinal = gtReadoutRecordFinal->gtfeWord();
   
    if (gtfeWordInitial == gtfeWordFinal) {
        myCoutStream << "\nInitial and final GTFE blocks: identical.\n";
        gtfeWordInitial.print(myCoutStream);       
    } else {
        myCoutStream << "\nInitial and final GTFE blocks: different.\n";

        myCoutStream << "\nInitial GTFE block\n";
        gtfeWordInitial.print(myCoutStream);       

        myCoutStream << "\nFinal GTFE block\n";
        gtfeWordFinal.print(myCoutStream);       
        
    }
    
    edm::LogInfo("L1GtPackUnpackAnalyzer")
    << myCoutStream.str()
    << std::endl;


    myCoutStream.str("");
    myCoutStream.clear();

    // FDL comparison
    const std::vector<L1GtFdlWord>& gtFdlVectorInitial = gtReadoutRecordInitial->gtFdlVector();
    const std::vector<L1GtFdlWord>& gtFdlVectorFinal = gtReadoutRecordFinal->gtFdlVector();
       
    int gtFdlVectorInitialSize = gtFdlVectorInitial.size();
    int gtFdlVectorFinalSize = gtFdlVectorFinal.size();
    
    if (gtFdlVectorInitialSize == gtFdlVectorFinalSize) {
        myCoutStream << "\nInitial and final FDL vector size: identical.\n";
        myCoutStream << "  Size: " << gtFdlVectorInitialSize << std::endl;
        
        for (int iFdl = 0; iFdl < gtFdlVectorInitialSize; ++iFdl) {
            
            const L1GtFdlWord& fdlWordInitial = gtFdlVectorInitial[iFdl];
            const L1GtFdlWord& fdlWordFinal = gtFdlVectorFinal[iFdl];
            
            if (fdlWordInitial == fdlWordFinal) {
                myCoutStream << "\nInitial and final FDL blocks: identical.\n";
                fdlWordInitial.print(myCoutStream); 
                
            } else {
                myCoutStream << "\nInitial and final FDL blocks: different.\n";

                myCoutStream << "\nInitial FDL block\n";
                fdlWordInitial.print(myCoutStream);       

                myCoutStream << "\nFinal FDL block\n";
                fdlWordFinal.print(myCoutStream);       
                               
            }
            
        }
    }
    else {
        myCoutStream << "\nInitial and final FDL vector size: different.\n";
        myCoutStream << "  Initial size: " << gtFdlVectorInitialSize << std::endl;
        myCoutStream << "  Final size: " << gtFdlVectorFinalSize << std::endl;

    }

    edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;

    myCoutStream.str("");
    myCoutStream.clear();
   
    
    // PSB comparison
    const std::vector<L1GtPsbWord>& gtPsbVectorInitial = gtReadoutRecordInitial->gtPsbVector();
    const std::vector<L1GtPsbWord>& gtPsbVectorFinal = gtReadoutRecordFinal->gtPsbVector();
       
    int gtPsbVectorInitialSize = gtPsbVectorInitial.size();
    int gtPsbVectorFinalSize = gtPsbVectorFinal.size();
    
    if (gtPsbVectorInitialSize == gtPsbVectorFinalSize) {
        myCoutStream << "\nInitial and final PSB vector size: identical.\n";
        myCoutStream << "  Size: " << gtPsbVectorInitialSize << std::endl;

        // the order of PSB block in the gtPsbVector is different in emulator and unpacker
        // TODO can be fixed?
        for (int iPsb = 0; iPsb < gtPsbVectorInitialSize; ++iPsb) {
            
            const L1GtPsbWord& psbWordInitial = gtPsbVectorInitial[iPsb];
            const boost::uint16_t boardIdInitial = psbWordInitial.boardId();
            const int bxInEventInitial = psbWordInitial.bxInEvent();
            
            // search the corresponding PSB in the final record using the 
            // BoardId and the BxInEvent  
            
            bool foundPSB = false;
            
            for (int iPsbF = 0; iPsbF < gtPsbVectorFinalSize; ++iPsbF) {

                const L1GtPsbWord& psbWordFinal = gtPsbVectorFinal[iPsbF];
                const boost::uint16_t boardIdFinal = psbWordFinal.boardId();
                const int bxInEventFinal = psbWordFinal.bxInEvent();
                
                if ((boardIdFinal == boardIdInitial) && (bxInEventInitial
                        == bxInEventFinal)) {
                    
                    foundPSB = true;
                    
                    // compare the boards
                    if (psbWordInitial == psbWordFinal) {
                        myCoutStream
                                << "\nInitial and final PSB blocks: identical.\n";
                        psbWordInitial.print(myCoutStream);

                    }
                    else {
                        myCoutStream
                                << "\nInitial and final PSB blocks: different.\n";

                        myCoutStream << "\nInitial PSB block\n";
                        psbWordInitial.print(myCoutStream);

                        myCoutStream << "\nFinal PSB block\n";
                        psbWordFinal.print(myCoutStream);

                    }
                }

            }
            
            if (!foundPSB) {
                myCoutStream
                        << "\nNo final PSB with boardID = " << boardIdInitial
                        << " and BxINEvent = " << bxInEventInitial << " was found"
                        << "\nInitial and final PSB vectors: different";
                
            }

        }
    }
    else {
        myCoutStream << "\nInitial and final PSB vector size: different.\n";
        myCoutStream << "  Initial size: " << gtPsbVectorInitialSize << std::endl;
        myCoutStream << "  Final size: " << gtPsbVectorFinalSize << std::endl;

    }

    edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;

    myCoutStream.str("");
    myCoutStream.clear();
   
    

    
    
    // get reference to muon collection
    const edm::RefProd<L1MuGMTReadoutCollection> muCollRefProdInitial =
            gtReadoutRecordInitial->muCollectionRefProd();

    const edm::RefProd<L1MuGMTReadoutCollection> muCollRefProdFinal =
            gtReadoutRecordFinal->muCollectionRefProd();

    if (muCollRefProdInitial == muCollRefProdFinal) {
        myCoutStream 
            << "\nInitial and final RefProd<L1MuGMTReadoutCollection>: identical.\n";
    }
    else {
        myCoutStream 
            << "\nInitial and final RefProd<L1MuGMTReadoutCollection>: different.\n";

    }

    edm::LogInfo("L1GtPackUnpackAnalyzer")
    << myCoutStream.str()
    << std::endl;

    myCoutStream.str("");
    myCoutStream.clear();


}
void L1GtPackUnpackAnalyzer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file L1GtPackUnpackAnalyzer.cc.

{
    // empty
}
void L1GtPackUnpackAnalyzer::endJob ( void  ) [private, virtual]

end of job

Reimplemented from edm::EDAnalyzer.

Definition at line 364 of file L1GtPackUnpackAnalyzer.cc.

{

    // empty

}

Member Data Documentation

input tag for the final GT DAQ and GMT records:

Definition at line 70 of file L1GtPackUnpackAnalyzer.h.

Referenced by analyzeGMT(), analyzeGT(), and L1GtPackUnpackAnalyzer().

input tag for the initial GT DAQ record:

Definition at line 64 of file L1GtPackUnpackAnalyzer.h.

Referenced by analyzeGT(), and L1GtPackUnpackAnalyzer().

input tag for the initial GMT readout collection:

Definition at line 67 of file L1GtPackUnpackAnalyzer.h.

Referenced by analyzeGMT(), and L1GtPackUnpackAnalyzer().