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;
149 if (GTPEvmBoardSense)
168 memcpy(fedData.
data(),
event + eventSize, fedSize);
182 if (
pos != std::string::npos) {
191 return fin_.is_open();
unsigned int getgpshigh(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
constexpr size_t FRDHeaderMaxVersion
std::vector< std::string > fileNames_
static const uint32_t length
std::unique_ptr< FEDRawDataCollection > rawData_
unsigned int get(const unsigned char *, bool)
void produce(edm::Event &e) override
std::vector< char > buffer_
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
void resize(size_t newsize)
bool setRunAndEventInfo(edm::EventID &id, edm::TimeValue_t &theTime, edm::EventAuxiliary::ExperimentType &eType) override
bool openFile(const std::string &fileName)
unsigned long long TimeValue_t
std::vector< std::string >::const_iterator itFileName_
bool evm_board_sense(const unsigned char *p, size_t size)
const bool verifyChecksum_
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
std::vector< std::string >::const_iterator endFileName_
unsigned long long uint64_t
const bool verifyAdler32_
std::vector< std::string > fileNames(unsigned iCatalog) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned int gtpe_get(const unsigned char *)
uint16_t detectedFRDversion_
constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
unsigned int getgpslow(const unsigned char *)
FRDStreamSource(edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)