24 verifyAdler32_(
pset.getUntrackedParameter<
bool>(
"verifyAdler32",
true)),
25 verifyChecksum_(
pset.getUntrackedParameter<
bool>(
"verifyChecksum",
true)),
26 useL1EventID_(
pset.getUntrackedParameter<
bool>(
"useL1EventID",
false)) {
30 produces<FEDRawDataCollection>();
36 if (
fin_.peek() == EOF) {
46 if (
fin_.tellg() == 0) {
49 fin_.read(hdr, buf_sz);
51 if (
fin_.gcount() == 0)
53 <<
"Unable to read file or empty file" << *
itFileName_;
54 else if (
fin_.gcount() < (ssize_t)buf_sz) {
61 if (frd_version == 1) {
63 fin_.read(hdr, buf_sz_cont);
67 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
68 }
else if (frd_version == 2) {
70 fin_.read(hdr, buf_sz_cont);
74 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
75 }
else if (frd_version > 2) {
76 throw cms::Exception(
"FRDStreamSource::setRunAndEventInfo") <<
"Unknown header version " << frd_version;
102 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
104 const uint32_t totalSize = frdEventMsg->size();
105 if (totalSize >
buffer_.size()) {
114 frdEventMsg = std::make_unique<FRDEventMsgView>(&
buffer_[0]);
119 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
120 if (crc != frdEventMsg->crc32c()) {
121 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
122 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
125 uint32_t adler = adler32(0
L, Z_NULL, 0);
126 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
128 if (adler != frdEventMsg->adler32()) {
130 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x" 135 rawData_ = std::make_unique<FEDRawDataCollection>();
137 uint32_t eventSize = frdEventMsg->eventSize();
138 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
139 bool foundTCDSFED =
false;
140 bool foundGTPFED =
false;
142 while (eventSize > 0) {
152 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
166 if (GTPEvmBoardSense)
185 memcpy(fedData.
data(),
event + eventSize, fedSize);
199 if (
pos != std::string::npos) {
208 return fin_.is_open();
unsigned int getgpshigh(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
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_
constexpr size_t FRDHeaderMaxVersion
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
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
void resize(size_t newsize, size_t wordsize=8)
const bool verifyAdler32_
std::vector< std::string > fileNames(unsigned iCatalog) const
uint16_t getFRDFileHeaderVersion(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
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_
unsigned int getgpslow(const unsigned char *)
FRDStreamSource(edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)