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(hdr, 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) {
59 if (frd_version == 1) {
61 fin_.read(hdr, buf_sz_cont);
65 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
66 }
else if (frd_version == 2) {
68 fin_.read(hdr, buf_sz_cont);
72 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
73 }
else if (frd_version > 2) {
74 throw cms::Exception(
"FRDStreamSource::setRunAndEventInfo") <<
"Unknown header version " << frd_version;
100 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
102 const uint32_t totalSize = frdEventMsg->size();
103 if (totalSize >
buffer_.size()) {
112 frdEventMsg = std::make_unique<FRDEventMsgView>(&
buffer_[0]);
117 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
118 if (crc != frdEventMsg->crc32c()) {
119 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
120 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
123 uint32_t adler = adler32(0
L, Z_NULL, 0);
124 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
126 if (adler != frdEventMsg->adler32()) {
128 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x" 133 rawData_ = std::make_unique<FEDRawDataCollection>();
135 uint32_t eventSize = frdEventMsg->eventSize();
136 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
137 bool foundTCDSFED =
false;
138 bool foundGTPFED =
false;
140 while (eventSize > 0) {
150 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
164 if (GTPEvmBoardSense)
183 memcpy(fedData.
data(),
event + eventSize, fedSize);
197 if (
pos != std::string::npos) {
206 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)