#include <DTROS8FileReader.h>
Public Member Functions | |
virtual bool | checkEndOfFile () |
DTROS8FileReader (const edm::ParameterSet &pset) | |
Constructor. | |
virtual int | fillRawData (edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data) |
Generate and fill FED raw data for a full event. | |
virtual | ~DTROS8FileReader () |
Destructor. | |
Private Attributes | |
edm::EventNumber_t | eventNum |
RawFile | inputFile |
edm::RunNumber_t | runNum |
Static Private Attributes | |
static const int | ros8WordLenght = 4 |
Read DT ROS8 raw data files
Definition at line 18 of file DTROS8FileReader.h.
DTROS8FileReader::DTROS8FileReader | ( | const edm::ParameterSet & | pset | ) |
Constructor.
Definition at line 32 of file DTROS8FileReader.cc.
References Exception, RawFile::fail(), lut2db_cfg::filename, edm::ParameterSet::getParameter(), inputFile, and RawFile::open().
: runNum(1), eventNum(0) { const string & filename = pset.getParameter<string>("fileName"); inputFile.open(filename.c_str()); if( inputFile.fail() ) { throw cms::Exception("InputFileMissing") << "DTROS8FileReader: the input file: " << filename <<" is not present"; } }
DTROS8FileReader::~DTROS8FileReader | ( | ) | [virtual] |
Destructor.
Definition at line 45 of file DTROS8FileReader.cc.
References RawFile::close(), and inputFile.
bool DTROS8FileReader::checkEndOfFile | ( | ) | [virtual] |
Definition at line 143 of file DTROS8FileReader.cc.
References RawFile::eof(), and inputFile.
Referenced by fillRawData().
int DTROS8FileReader::fillRawData | ( | edm::EventID & | eID, |
edm::Timestamp & | tstamp, | ||
FEDRawDataCollection *& | data | ||
) | [virtual] |
Generate and fill FED raw data for a full event.
Implements DaqBaseReader.
Definition at line 50 of file DTROS8FileReader.cc.
References checkEndOfFile(), filterCSVwithJSON::copy, gather_cfg::cout, data, FEDRawData::data(), FEDRawDataCollection::FEDData(), i, inputFile, FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), and ros8WordLenght.
{ data = new FEDRawDataCollection(); try { if( checkEndOfFile() ) throw 1; // Get the total number of words from the 1st word in the payload int numberOfWords; int nread = 0; nread = inputFile.read(dataPointer<int>( &numberOfWords ), ros8WordLenght); if ( nread<=0 ) throw 1; // Get the event data (all words but the 1st) int* eventData = new int[numberOfWords]; nread = inputFile.read(dataPointer<int>( eventData + 1 ), (numberOfWords-1) * ros8WordLenght ); if ( nread<=0 ) throw 1; // Check that the event data size corresponds to the 1st word datum if ( eventData[numberOfWords-1] != numberOfWords ) { cout << "[DTROS8FileReader]: word counter mismatch exception: " << numberOfWords << " " << eventData[numberOfWords-1] << endl; throw 99; } // The header added by the local DAQ occupies 8 words, starting from the 2nd int* head = eventData + 1; /* Header word 0: run number Header word 1: spill number Header word 2: event number Header word 3: reserved Header word 4: ROS data offset Header word 5: PU data offset Header word 6: reserved Header word 7: reserved */ // WARNING: the event number is reset at a new spill eID = EventID( head[0], 1U, head[1]*head[2]); // The pointer to the ROS payload (the 1st word being the ROS words counter) int* rosData = eventData + head[4]; // The ROS payload size int eventDataSize = *rosData * ros8WordLenght; // It has to be a multiple of 8 bytes. if not, adjust the size of the FED payload int adjustment = (eventDataSize/4)%2 == 1 ? 4 : 0; //if ( (eventDataSize/4)%2 ) adjustment = 4; // The FED ID is always the first in the DT range FEDRawData& fedRawData = data->FEDData( FEDNumbering::MINDTFEDID ); fedRawData.resize(eventDataSize+adjustment); // I pass only the ROS data to the Event copy(reinterpret_cast<unsigned char*>(rosData), reinterpret_cast<unsigned char*>(rosData) + eventDataSize, fedRawData.data()); // needed to get rid of memory leaks (?) delete[] eventData; return true; } catch( int i ) { if ( i == 1 ){ cout << "[DTROS8FileReader]: END OF FILE REACHED. " << "No information read for the requested event" << endl; delete data; data=0; return false; } else { cout << "[DTROS8FileReader]: PROBLEM WITH EVENT INFORMATION ON THE FILE. " << "EVENT DATA READING FAILED code= " << i << endl; delete data; data=0; return false; } } }
edm::EventNumber_t DTROS8FileReader::eventNum [private] |
Definition at line 38 of file DTROS8FileReader.h.
RawFile DTROS8FileReader::inputFile [private] |
Definition at line 35 of file DTROS8FileReader.h.
Referenced by checkEndOfFile(), DTROS8FileReader(), fillRawData(), and ~DTROS8FileReader().
const int DTROS8FileReader::ros8WordLenght = 4 [static, private] |
Definition at line 40 of file DTROS8FileReader.h.
Referenced by fillRawData().
edm::RunNumber_t DTROS8FileReader::runNum [private] |
Definition at line 37 of file DTROS8FileReader.h.