#include <L1GtTextToRaw.h>
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 |
Description: generate raw data from dumped text file.
Implementation: <TODO: enter implementation details>
$Date$ $Revision$
Definition at line 38 of file L1GtTextToRaw.h.
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] |
void L1GtTextToRaw::beginJob | ( | void | ) | [private, virtual] |
beginning of job stuff
Reimplemented from edm::EDProducer.
Definition at line 100 of file L1GtTextToRaw.cc.
References cleanTextFile().
{ 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().
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; boost::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); }
int L1GtTextToRaw::m_daqGtFedId [private] |
FED ID for the system.
Definition at line 78 of file L1GtTextToRaw.h.
Referenced by L1GtTextToRaw(), and produce().
int L1GtTextToRaw::m_rawDataSize [private] |
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().