22 verifyAdler32_(
pset.getUntrackedParameter<
bool>(
"verifyAdler32",
true)),
23 verifyChecksum_(
pset.getUntrackedParameter<
bool>(
"verifyChecksum",
true)),
24 useL1EventID_(
pset.getUntrackedParameter<
bool>(
"useL1EventID",
false)) {
28 produces<FEDRawDataCollection>();
34 if (
fin_.peek() == EOF) {
44 if (
fin_.tellg() == 0) {
47 fin_.read((
char*)&fileHead, buf_sz);
49 if (
fin_.gcount() == 0)
51 <<
"Unable to read file or empty file" << *
itFileName_;
52 else if (
fin_.gcount() < (ssize_t)buf_sz)
56 if (frd_version >= 1) {
57 if (fileHead.headerSize_ < buf_sz)
59 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
60 else if (fileHead.headerSize_ > buf_sz)
61 fin_.seekg(fileHead.headerSize_,
fin_.beg);
85 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
87 const uint32_t totalSize = frdEventMsg->size();
88 if (totalSize >
buffer_.size()) {
97 frdEventMsg = std::make_unique<FRDEventMsgView>(&
buffer_[0]);
102 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
103 if (crc != frdEventMsg->crc32c()) {
104 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
105 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
108 uint32_t adler = adler32(0
L, Z_NULL, 0);
109 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
111 if (adler != frdEventMsg->adler32()) {
113 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x"
118 rawData_ = std::make_unique<FEDRawDataCollection>();
120 uint32_t eventSize = frdEventMsg->eventSize();
121 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
122 bool foundTCDSFED =
false;
123 bool foundGTPFED =
false;
125 while (eventSize > 0) {
135 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
141 eType = static_cast<edm::EventAuxiliary::ExperimentType>(fedHeader.
triggerType());
142 theTime = static_cast<edm::TimeValue_t>(((
uint64_t)
tcds->bst.gpstimehigh << 32) |
tcds->bst.gpstimelow);
149 if (GTPEvmBoardSense)
157 theTime = static_cast<edm::TimeValue_t>((gpsh << 32) + gpsl);
168 memcpy(fedData.
data(),
event + eventSize, fedSize);
182 if (
pos != std::string::npos) {
191 return fin_.is_open();