22 verifyAdler32_(
pset.getUntrackedParameter<
bool>(
"verifyAdler32",
true)),
23 verifyChecksum_(
pset.getUntrackedParameter<
bool>(
"verifyChecksum",
true)),
24 useL1EventID_(
pset.getUntrackedParameter<
bool>(
"useL1EventID",
false)) {
27 produces<FEDRawDataCollection>();
33 if (
fin_.peek() == EOF) {
43 if (
fin_.tellg() == 0) {
46 fin_.read((
char*)&fileHead, buf_sz);
48 if (
fin_.gcount() == 0)
50 <<
"Unable to read file or empty file" << *
itFileName_;
51 else if (
fin_.gcount() < (ssize_t)buf_sz)
55 if (frd_version >= 1) {
56 if (fileHead.headerSize_ < buf_sz)
58 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
59 else if (fileHead.headerSize_ > buf_sz)
60 fin_.seekg(fileHead.headerSize_,
fin_.beg);
84 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
86 const uint32_t totalSize = frdEventMsg->size();
87 if (totalSize >
buffer_.size()) {
96 frdEventMsg = std::make_unique<FRDEventMsgView>(&
buffer_[0]);
101 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
102 if (crc != frdEventMsg->crc32c()) {
103 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
104 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
107 uint32_t adler = adler32(0
L, Z_NULL, 0);
108 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
110 if (adler != frdEventMsg->adler32()) {
112 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x"
117 rawData_ = std::make_unique<FEDRawDataCollection>();
119 uint32_t eventSize = frdEventMsg->eventSize();
120 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
121 bool foundTCDSFED =
false;
122 bool foundGTPFED =
false;
124 while (eventSize > 0) {
134 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
140 eType = static_cast<edm::EventAuxiliary::ExperimentType>(fedHeader.
triggerType());
141 theTime = static_cast<edm::TimeValue_t>(((
uint64_t)
tcds->bst.gpstimehigh << 32) |
tcds->bst.gpstimelow);
148 if (GTPEvmBoardSense)
156 theTime = static_cast<edm::TimeValue_t>((gpsh << 32) + gpsl);
167 memcpy(fedData.
data(),
event + eventSize, fedSize);
181 if (
pos != std::string::npos) {
190 return fin_.is_open();