CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1GtTextToRaw Class Reference

#include <L1GtTextToRaw.h>

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

List of all members.

Public Member Functions

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

Private Member Functions

virtual void beginJob ()
 beginning of job stuff
virtual void cleanTextFile ()
 clean the text file, if needed
virtual void endJob ()
 end of job stuff
virtual int getDataSize ()
 get the size of the record
virtual void produce (edm::Event &, const edm::EventSetup &)
 loop over events

Private Attributes

int m_daqGtFedId
 FED ID for the system.
int m_rawDataSize
 raw event size (including header and trailer) in units of 8 bits
std::ifstream m_textFile
 the file itself
std::string m_textFileName
 file name for the text file
std::string m_textFileType
 file type for the text file

Detailed Description

Description: generate raw data from dumped text file.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 38 of file L1GtTextToRaw.h.


Constructor & Destructor Documentation

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

constructor(s)

Definition at line 42 of file L1GtTextToRaw.cc.

References Exception, edm::ParameterSet::getUntrackedParameter(), recoMuon::in, LogDebug, m_daqGtFedId, m_rawDataSize, m_textFile, m_textFileName, m_textFileType, and FEDNumbering::MAXTriggerGTPFEDID.

{

    m_textFileType = pSet.getUntrackedParameter<std::string>("TextFileType", "VmeSpyDump");

    LogDebug("L1GtTextToRaw")
    << "\nText file type: " << m_textFileType << "\n"
    << std::endl;

    m_textFileName = pSet.getUntrackedParameter<std::string>("TextFileName", "gtfe.dmp");

    LogDebug("L1GtTextToRaw")
    << "\nText file name: " << m_textFileName << "\n"
    << std::endl;

    // event size
    m_rawDataSize = pSet.getUntrackedParameter<int>("RawDataSize");

    LogDebug("L1GtTextToRaw")
    << "\nRaw data size (units of 8 bits): " << m_rawDataSize
    << "\n  If negative value, the size is retrieved from the trailer." << "\n"
    << std::endl;

    // FED Id for GT DAQ record
    // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
    // default value: assume the DAQ record is the last GT record 
    m_daqGtFedId = pSet.getUntrackedParameter<int>(
                       "DaqGtFedId", FEDNumbering::MAXTriggerGTPFEDID);

    LogDebug("L1GtTextToRaw")
    << "\nFED Id for DAQ GT record: "
    << m_daqGtFedId << " \n"
    << std::endl;

    // open test file
    m_textFile.open(m_textFileName.c_str(), std::ios::in);
    if( !m_textFile.good() ) {
        throw cms::Exception("NotFound")
        << "\nError: failed to open text file = " << m_textFileName << "\n"
        << std::endl;
    }

    //
    produces<FEDRawDataCollection>();

}
L1GtTextToRaw::~L1GtTextToRaw ( ) [virtual]

destructor

Definition at line 90 of file L1GtTextToRaw.cc.

{

    // empty now

}

Member Function Documentation

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

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 100 of file L1GtTextToRaw.cc.

References cleanTextFile().

void L1GtTextToRaw::cleanTextFile ( ) [private, virtual]

clean the text file, if needed

Definition at line 108 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by beginJob().

{

    LogDebug("L1GtTextToRaw")
    << "\nCleaning the text file\n"
    << std::endl;



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

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 216 of file L1GtTextToRaw.cc.

{

    // empty now
}
int L1GtTextToRaw::getDataSize ( ) [private, virtual]

get the size of the record

Definition at line 120 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by produce().

{

    LogDebug("L1GtTextToRaw")
    << "\nComputing raw data size with getRecordSize() method."
    << std::endl;

    int rawDataSize = 0;

    LogDebug("L1GtTextToRaw")
    << "\nComputed raw data size: " << rawDataSize
    << std::endl;


    return rawDataSize;

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

loop over events

Implements edm::EDProducer.

Definition at line 140 of file L1GtTextToRaw.cc.

References FEDRawData::data(), getDataSize(), j, LogDebug, LogTrace, m_daqGtFedId, m_rawDataSize, m_textFile, edm::Event::put(), FEDRawData::resize(), and FEDRawData::size().

{

    // get the size of the record

    int rawDataSize = 0;

    if (m_rawDataSize < 0) {
        rawDataSize = getDataSize();
    } else {
        rawDataSize = m_rawDataSize;

    }

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

    FEDRawData& rawData = fedRawColl->FEDData(m_daqGtFedId);
    // resize, GT raw data record has variable length,
    // depending on active boards (read in GTFE)
    rawData.resize(rawDataSize);


    LogDebug("L1GtTextToRaw")
    << "\n Size of raw data: " << rawData.size() << "\n"
    << std::endl;


    // read the text file
    // the file must have one 64 bits per line (usually in hex format)
    // events are separated by empty lines
    
    std::string lineString;

    cms_uint64_t lineInt = 0ULL;
    int sizeL = sizeof(lineInt);

    int fedBlockSize = 8; // block size in bits for FedRawData
    int maskBlock = 0xff; // fedBlockSize and maskBlock must be consistent

    int iLine = 0;

    while (std::getline(m_textFile, lineString)) {

        if (lineString.empty()) {
            break;
        }

        // convert string to int
        std::istringstream iss(lineString);

        iss >> std::hex >> lineInt;

        LogTrace("L1GtTextToRaw")
        << std::dec << std::setw(4) << std::setfill('0') << iLine << ": " 
        << std::hex << std::setw(sizeL*2) << lineInt 
        << std::dec << std::setfill(' ')
        << std::endl;

        // copy data
        for (int j = 0; j < sizeL; j++) {
            char blockContent = (lineInt >> (fedBlockSize * j)) & maskBlock;
            rawData.data()[iLine*sizeL + j] = blockContent;
        }


        ++iLine;
    }

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

Member Data Documentation

FED ID for the system.

Definition at line 78 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

raw event size (including header and trailer) in units of 8 bits

Definition at line 75 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::ifstream L1GtTextToRaw::m_textFile [private]

the file itself

Definition at line 81 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::string L1GtTextToRaw::m_textFileName [private]

file name for the text file

Definition at line 72 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

std::string L1GtTextToRaw::m_textFileType [private]

file type for the text file

Definition at line 69 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().