40 throw cms::Exception(
"InputFileMissing") <<
"[DTDDUFileReader]: the input file: " << filename <<
" is not present";
42 cout <<
"DTDDUFileReader: DaqSource file '" << filename <<
"' was succesfully opened" << endl;
45 uint32_t runNumber_tmp = 1;
53 cout <<
" Dear user, please be patient, " << skipEvents <<
" are being skipped .." << endl;
57 produces<FEDRawDataCollection>();
68 vector<uint64_t> eventData;
69 size_t estimatedEventDimension = 102400;
70 eventData.reserve(estimatedEventDimension);
73 bool haederTag =
false;
75 bool headerAlreadyFound =
false;
81 while (!
isTrailer(word, dataTag, wordCount)) {
88 cout <<
"[DTDDUFileReader]: ERROR! no more words and failed to get the trailer" << endl;
99 cout <<
"[DTDDUFileReader]: ERROR! failed to get the trailer" << endl;
107 if (!headerAlreadyFound)
109 headerAlreadyFound =
true;
123 eventData.push_back(word);
144 if (dduID < 770 || dduID > 775) {
145 cout <<
"[DTDDUFileReader]: ERROR. DDU ID out of range. DDU id=" <<
dduID << endl;
150 fedRawData.
resize(eventDataSize);
152 copy(reinterpret_cast<unsigned char*>(&eventData[0]),
153 reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize,
164 std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
171 uint32_t msBits_tmp = newWorld->
msBits;
173 newWorld->
lsBits = msBits_tmp;
186 uint32_t
data[2] = {0, 0};
188 data[0] |= td[3] & 0x3ffff;
189 data[0] |= (td[2] << 18) & 0xfffc0000;
190 data[1] |= (td[2] >> 14) & 0x0f;
191 data[1] |= (td[1] << 4) & 0x3ffff0;
192 data[1] |= (td[0] << 22) & 0xffc00000;
194 isData = (td[0] >> 10) & 0x01;
197 dduWord = (
uint64_t(data[1]) << 32) | data[0];
204 FEDHeader candidate(reinterpret_cast<const unsigned char*>(&word));
205 if (candidate.
check()) {
217 FEDTrailer candidate(reinterpret_cast<const unsigned char*>(&word));
218 if (candidate.
check()) {
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
virtual bool checkEndOfFile()
DTDDUFileReader(const edm::ParameterSet &pset)
Constructor.
RawFile * open(const char *path)
Open file.
bool isHeader(uint64_t word, bool dataTag)
check for a 64 bits word to be a DDU header
int read(void *data, size_t nbytes)
Read from file.
bool check() const
Check that the trailer is OK.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int close()
Close file if necessary.
void produce(edm::Event &, edm::EventSetup const &) override
void resize(size_t newsize)
void swap(uint64_t &word)
swapping the lsBits with the msBits
edm::RunNumber_t runNumber
edm::EventNumber_t eventNumber
int eof()
Check end of file.
unsigned long long uint64_t
int ignore(long offset)
Ignore some bytes.
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
bool isTrailer(uint64_t word, bool dataTag, unsigned int wordCount)
check for a 64 bits word to be a DDU trailer
uint64_t dmaUnpack(bool &isData, int &nread)
pre-unpack the data if read via DMA
static const int dduWordLength
~DTDDUFileReader() override
Destructor.