45 <<
"[DTDDUFileReader]: the input file: " << filename <<
" is not present";
47 cout <<
"DTDDUFileReader: DaqSource file '" << filename <<
"' was succesfully opened" << endl;
50 uint32_t runNumber_tmp=1;
58 cout<<
" Dear user, please be patient, "<<skipEvents<<
" are being skipped .."<<endl;
62 produces<FEDRawDataCollection>();
76 vector<uint64_t> eventData;
77 size_t estimatedEventDimension = 102400;
78 eventData.reserve(estimatedEventDimension);
81 bool haederTag =
false;
83 bool headerAlreadyFound =
false;
89 while ( !
isTrailer(word, dataTag, wordCount) ) {
96 cout<<
"[DTDDUFileReader]: ERROR! no more words and failed to get the trailer"<<endl;
97 delete data; data=
nullptr;
106 cout<<
"[DTDDUFileReader]: ERROR! failed to get the trailer"<<endl;
107 delete data; data=
nullptr;
113 if (!headerAlreadyFound)
115 headerAlreadyFound=
true;
130 eventData.push_back(word);
154 if ( dduID<770 || dduID > 775 ) {
155 cout<<
"[DTDDUFileReader]: ERROR. DDU ID out of range. DDU id="<<
dduID<<endl;
160 fedRawData.
resize(eventDataSize);
162 copy(reinterpret_cast<unsigned char*>(&eventData[0]),
163 reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize, fedRawData.
data());
175 std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
183 uint32_t msBits_tmp = newWorld->
msBits;
185 newWorld->
lsBits = msBits_tmp;
200 uint32_t
data[2] = {0, 0};
202 data[0] |= td[3] & 0x3ffff;
203 data[0] |= (td[2] << 18 ) & 0xfffc0000;
204 data[1] |= (td[2] >> 14 ) & 0x0f;
205 data[1] |= (td[1] << 4 ) & 0x3ffff0;
206 data[1] |= (td[0] << 22 ) & 0xffc00000;
208 isData = ( td[0] >> 10 ) & 0x01;
211 dduWord = (
uint64_t(data[1]) << 32) | data[0];
219 FEDHeader candidate(reinterpret_cast<const unsigned char*>(&word));
220 if ( candidate.
check() ) {
234 FEDTrailer candidate(reinterpret_cast<const unsigned char*>(&word));
235 if ( candidate.
check() ) {
238 if ( wordCount == candidate.
lenght())
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.
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 lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
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.
uint64_t dmaUnpack(bool &isData, int &nread)
pre-unpack the data if read via DMA
bool isTrailer(uint64_t word, bool dataTag, int wordCount)
check for a 64 bits word to be a DDU trailer
static const int dduWordLength
~DTDDUFileReader() override
Destructor.