20 : ProducerSourceFromFiles(
pset, desc,
true),
21 verifyAdler32_(
pset.getUntrackedParameter<
bool>(
"verifyAdler32",
true)),
22 verifyChecksum_(
pset.getUntrackedParameter<
bool>(
"verifyChecksum",
true)),
23 useL1EventID_(
pset.getUntrackedParameter<
bool>(
"useL1EventID",
false)) {
26 produces<FEDRawDataCollection>();
32 if (
fin_.peek() == EOF) {
42 if (
fin_.tellg() == 0) {
45 fin_.read((
char*)&fileHead, buf_sz);
47 if (
fin_.gcount() == 0)
49 <<
"Unable to read file or empty file" << *
itFileName_;
50 else if (
fin_.gcount() < (ssize_t)buf_sz)
54 if (frd_version >= 1) {
55 if (fileHead.headerSize_ < buf_sz)
57 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
58 else if (fileHead.headerSize_ > buf_sz)
59 fin_.seekg(fileHead.headerSize_,
fin_.beg);
83 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
85 const uint32_t totalSize = frdEventMsg->size();
86 if (totalSize >
buffer_.size()) {
100 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
101 if (crc != frdEventMsg->crc32c()) {
102 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
103 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
106 uint32_t adler = adler32(0
L, Z_NULL, 0);
107 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
109 if (adler != frdEventMsg->adler32()) {
111 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x"
116 rawData_ = std::make_unique<FEDRawDataCollection>();
118 uint32_t eventSize = frdEventMsg->eventSize();
119 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
120 bool foundTCDSFED =
false;
121 bool foundGTPFED =
false;
123 while (eventSize > 0) {
133 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
139 eType = static_cast<edm::EventAuxiliary::ExperimentType>(fedHeader.
triggerType());
140 theTime = static_cast<edm::TimeValue_t>(((
uint64_t)
tcds->bst.gpstimehigh << 32) |
tcds->bst.gpstimelow);
147 if (GTPEvmBoardSense)
155 theTime = static_cast<edm::TimeValue_t>((gpsh << 32) + gpsl);
166 memcpy(fedData.
data(),
event + eventSize, fedSize);
180 if (
pos != std::string::npos) {
189 return fin_.is_open();