#include <DTROS25FileReader.h>
Public Member Functions | |
virtual bool | checkEndOfFile () |
DTROS25FileReader (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. | |
bool | isHeader (uint32_t word) |
check for a 32 bits word to be a ROS25 header | |
bool | isTrailer (uint32_t word) |
check for a 32 bits word to be a ROS25 trailer | |
void | swap (uint32_t &word) |
swapping the lsBits with the msBits | |
virtual | ~DTROS25FileReader () |
Destructor. | |
Private Attributes | |
edm::EventNumber_t | eventNumber |
RawFile | inputFile |
edm::RunNumber_t | runNumber |
Static Private Attributes | |
static const int | rosWordLenght = 4 |
Read DT ROS8 raw data files
Definition at line 20 of file DTROS25FileReader.h.
DTROS25FileReader::DTROS25FileReader | ( | const edm::ParameterSet & | pset | ) |
Constructor.
Definition at line 32 of file DTROS25FileReader.cc.
References Exception, RawFile::fail(), lut2db_cfg::filename, edm::ParameterSet::getUntrackedParameter(), inputFile, and RawFile::open().
: runNumber(1), eventNumber(0) { const string & filename = pset.getUntrackedParameter<string>("fileName"); inputFile.open(filename.c_str()); if( inputFile.fail() ) { throw cms::Exception("InputFileMissing") << "DTROS25FileReader: the input file: " << filename <<" is not present"; } }
DTROS25FileReader::~DTROS25FileReader | ( | ) | [virtual] |
Destructor.
Definition at line 45 of file DTROS25FileReader.cc.
References RawFile::close(), and inputFile.
bool DTROS25FileReader::checkEndOfFile | ( | ) | [virtual] |
Definition at line 162 of file DTROS25FileReader.cc.
References RawFile::eof(), and inputFile.
int DTROS25FileReader::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 DTROS25FileReader.cc.
References filterCSVwithJSON::copy, gather_cfg::cout, FEDRawData::data(), runTheMatrix::data, eventNumber, FEDRawDataCollection::FEDData(), ExpressReco_HICollisions_FallBack::FEDRawDataCollection, i, inputFile, isHeader(), isTrailer(), FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), rosWordLenght, runNumber, and swap().
{ data = new FEDRawDataCollection(); vector<uint32_t> eventData; size_t estimatedEventDimension = 102400; // dimensione hardcoded eventData.reserve(estimatedEventDimension); uint32_t word = 0; try { bool marked = false; // getting the data word by word from the file // do it until you get the ROS25 trailer while ( !isTrailer(word) ) { // get the first word int nread = inputFile.read(dataPointer<uint32_t>( &word ), rosWordLenght); // WARNING!!! ||swapping it|| (Check whether it is necessary) swap(word); if ( nread<=0 ) throw 1; // get the ROS25 header if (isHeader(word)) marked=true; // from now on fill the eventData with the ROS data if (marked) { eventData.push_back(word); } } // next event reading will start with meaningless trailer+header from DTLocalDAQ // those will be skipped automatically when seeking for the ROS25 header //if (eventData.size() > estimatedEventDimension) throw 2; // Setting the Event ID eID = EventID( runNumber, 1U, eventNumber); // eventDataSize = (Number Of Words)* (Word Size) int eventDataSize = eventData.size()*rosWordLenght; // 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; // The FED ID is always the first in the DT range FEDRawData& fedRawData = data->FEDData( FEDNumbering::MINDTFEDID ); fedRawData.resize(eventDataSize+adjustment); copy(reinterpret_cast<unsigned char*>(&eventData[0]), reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize, fedRawData.data()); return true; } catch( int i ) { if ( i == 1 ){ cout<<"[DTROS25FileReader]: ERROR! failed to get the trailer"<<endl; delete data; data=0; return false; } else { cout<<"[DTROS25FileReader]:" <<" ERROR! ROS data exceeding estimated event dimension. Event size = " <<eventData.size()<<endl; delete data; data=0; return false; } } }
bool DTROS25FileReader::isHeader | ( | uint32_t | word | ) |
check for a 32 bits word to be a ROS25 header
Definition at line 139 of file DTROS25FileReader.cc.
References eventNumber.
Referenced by fillRawData().
{ bool it_is = false; if ( (word >> 24 ) == 31 ) { it_is = true; ++eventNumber; } return it_is; }
bool DTROS25FileReader::isTrailer | ( | uint32_t | word | ) |
check for a 32 bits word to be a ROS25 trailer
Definition at line 151 of file DTROS25FileReader.cc.
Referenced by fillRawData().
{ bool it_is = false; if ( (word >> 24 ) == 63 ) { it_is = true; } return it_is; }
void DTROS25FileReader::swap | ( | uint32_t & | word | ) |
swapping the lsBits with the msBits
Definition at line 129 of file DTROS25FileReader.cc.
References twoNibble::lsBits, and twoNibble::msBits.
Referenced by fillRawData().
Definition at line 52 of file DTROS25FileReader.h.
Referenced by fillRawData(), and isHeader().
RawFile DTROS25FileReader::inputFile [private] |
Definition at line 49 of file DTROS25FileReader.h.
Referenced by checkEndOfFile(), DTROS25FileReader(), fillRawData(), and ~DTROS25FileReader().
const int DTROS25FileReader::rosWordLenght = 4 [static, private] |
Definition at line 54 of file DTROS25FileReader.h.
Referenced by fillRawData().
edm::RunNumber_t DTROS25FileReader::runNumber [private] |
Definition at line 51 of file DTROS25FileReader.h.
Referenced by fillRawData().