#include <EventFilter/L1GlobalTriggerRawToDigi/interface/L1GtTextToRaw.h>
Public Member Functions | |
L1GtTextToRaw (const edm::ParameterSet &) | |
constructor(s) | |
virtual | ~L1GtTextToRaw () |
destructor | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
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 |
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 lat::endl(), Exception, FEDNumbering::getTriggerGTPFEDIds(), edm::ParameterSet::getUntrackedParameter(), in, LogDebug, m_daqGtFedId, m_rawDataSize, m_textFile, m_textFileName, and m_textFileType.
00043 { 00044 00045 m_textFileType = pSet.getUntrackedParameter<std::string>("TextFileType", "VmeSpyDump"); 00046 00047 LogDebug("L1GtTextToRaw") 00048 << "\nText file type: " << m_textFileType << "\n" 00049 << std::endl; 00050 00051 m_textFileName = pSet.getUntrackedParameter<std::string>("TextFileName", "gtfe.dmp"); 00052 00053 LogDebug("L1GtTextToRaw") 00054 << "\nText file name: " << m_textFileName << "\n" 00055 << std::endl; 00056 00057 // event size 00058 m_rawDataSize = pSet.getUntrackedParameter<int>("RawDataSize"); 00059 00060 LogDebug("L1GtTextToRaw") 00061 << "\nRaw data size (units of 8 bits): " << m_rawDataSize 00062 << "\n If negative value, the size is retrieved from the trailer." << "\n" 00063 << std::endl; 00064 00065 // FED Id for GT DAQ record 00066 // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc 00067 // default value: assume the DAQ record is the last GT record 00068 m_daqGtFedId = pSet.getUntrackedParameter<int>( 00069 "DaqGtFedId", FEDNumbering::getTriggerGTPFEDIds().second); 00070 00071 LogDebug("L1GtTextToRaw") 00072 << "\nFED Id for DAQ GT record: " 00073 << m_daqGtFedId << " \n" 00074 << std::endl; 00075 00076 // open test file 00077 m_textFile.open(m_textFileName.c_str(), std::ios::in); 00078 if( !m_textFile.good() ) { 00079 throw cms::Exception("NotFound") 00080 << "\nError: failed to open text file = " << m_textFileName << "\n" 00081 << std::endl; 00082 } 00083 00084 // 00085 produces<FEDRawDataCollection>(); 00086 00087 }
L1GtTextToRaw::~L1GtTextToRaw | ( | ) | [virtual] |
void L1GtTextToRaw::beginJob | ( | const edm::EventSetup & | evSetup | ) | [private, virtual] |
beginning of job stuff
Reimplemented from edm::EDProducer.
Definition at line 100 of file L1GtTextToRaw.cc.
References cleanTextFile().
00101 { 00102 00103 cleanTextFile(); 00104 00105 }
void L1GtTextToRaw::cleanTextFile | ( | ) | [private, virtual] |
clean the text file, if needed
Definition at line 108 of file L1GtTextToRaw.cc.
References lat::endl(), and LogDebug.
Referenced by beginJob().
00109 { 00110 00111 LogDebug("L1GtTextToRaw") 00112 << "\nCleaning the text file\n" 00113 << std::endl; 00114 00115 00116 00117 }
end of job stuff
Reimplemented from edm::EDProducer.
Definition at line 216 of file L1GtTextToRaw.cc.
int L1GtTextToRaw::getDataSize | ( | ) | [private, virtual] |
get the size of the record
Definition at line 120 of file L1GtTextToRaw.cc.
References lat::endl(), and LogDebug.
Referenced by produce().
00121 { 00122 00123 LogDebug("L1GtTextToRaw") 00124 << "\nComputing raw data size with getRecordSize() method." 00125 << std::endl; 00126 00127 int rawDataSize = 0; 00128 00129 LogDebug("L1GtTextToRaw") 00130 << "\nComputed raw data size: " << rawDataSize 00131 << std::endl; 00132 00133 00134 return rawDataSize; 00135 00136 }
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(), lat::endl(), getDataSize(), j, LogDebug, LogTrace, m_daqGtFedId, m_rawDataSize, m_textFile, edm::Event::put(), FEDRawData::resize(), and FEDRawData::size().
00141 { 00142 00143 // get the size of the record 00144 00145 int rawDataSize = 0; 00146 00147 if (m_rawDataSize < 0) { 00148 rawDataSize = getDataSize(); 00149 } else { 00150 rawDataSize = m_rawDataSize; 00151 00152 } 00153 00154 // define new FEDRawDataCollection 00155 // it contains ALL FEDs in an event 00156 std::auto_ptr<FEDRawDataCollection> fedRawColl(new FEDRawDataCollection); 00157 00158 FEDRawData& rawData = fedRawColl->FEDData(m_daqGtFedId); 00159 // resize, GT raw data record has variable length, 00160 // depending on active boards (read in GTFE) 00161 rawData.resize(rawDataSize); 00162 00163 00164 LogDebug("L1GtTextToRaw") 00165 << "\n Size of raw data: " << rawData.size() << "\n" 00166 << std::endl; 00167 00168 00169 // read the text file 00170 // the file must have one 64 bits per line (usually in hex format) 00171 // events are separated by empty lines 00172 00173 std::string lineString; 00174 00175 boost::uint64_t lineInt = 0ULL; 00176 int sizeL = sizeof(lineInt); 00177 00178 int fedBlockSize = 8; // block size in bits for FedRawData 00179 int maskBlock = 0xff; // fedBlockSize and maskBlock must be consistent 00180 00181 int iLine = 0; 00182 00183 while (std::getline(m_textFile, lineString)) { 00184 00185 if (lineString.empty()) { 00186 break; 00187 } 00188 00189 // convert string to int 00190 std::istringstream iss(lineString); 00191 00192 iss >> std::hex >> lineInt; 00193 00194 LogTrace("L1GtTextToRaw") 00195 << std::dec << std::setw(4) << std::setfill('0') << iLine << ": " 00196 << std::hex << std::setw(sizeL*2) << lineInt 00197 << std::dec << std::setfill(' ') 00198 << std::endl; 00199 00200 // copy data 00201 for (int j = 0; j < sizeL; j++) { 00202 char blockContent = (lineInt >> (fedBlockSize * j)) & maskBlock; 00203 rawData.data()[iLine*sizeL + j] = blockContent; 00204 } 00205 00206 00207 ++iLine; 00208 } 00209 00210 // put the raw data in the event 00211 iEvent.put(fedRawColl); 00212 }
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().