20 : ProducerSourceFromFiles(pset, desc,
true),
21 verifyAdler32_(pset.getUntrackedParameter<
bool>(
"verifyAdler32",
true)),
22 verifyChecksum_(pset.getUntrackedParameter<
bool>(
"verifyChecksum",
true)),
23 useL1EventID_(pset.getUntrackedParameter<
bool>(
"useL1EventID",
false)) {
26 produces<FEDRawDataCollection>();
32 if (
fin_.peek() == EOF) {
42 if (
fin_.tellg() == 0) {
45 fin_.read((
char*)&fileHead, buf_sz);
47 if (
fin_.gcount() == 0)
49 <<
"Unable to read file or empty file" << *
itFileName_;
50 else if (
fin_.gcount() < (ssize_t)buf_sz)
54 if (frd_version >= 1) {
57 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
70 *((uint32_t*)(&
buffer_[0])) = detectedFRDversion_;
82 id =
edm::EventID(frdEventMsg->run(), frdEventMsg->lumi(), frdEventMsg->event());
84 const uint32_t totalSize = frdEventMsg->size();
85 if (totalSize >
buffer_.size()) {
99 crc =
crc32c(crc, (
const unsigned char*)frdEventMsg->payload(), frdEventMsg->eventSize());
100 if (crc != frdEventMsg->crc32c()) {
101 throw cms::Exception(
"FRDStreamSource::getNextEvent") <<
"Found a wrong crc32c checksum: expected 0x" << std::hex
102 << frdEventMsg->crc32c() <<
" but calculated 0x" << crc;
105 uint32_t adler = adler32(0
L, Z_NULL, 0);
106 adler = adler32(adler, (Bytef*)frdEventMsg->payload(), frdEventMsg->eventSize());
108 if (adler != frdEventMsg->adler32()) {
110 <<
"Found a wrong Adler32 checksum: expected 0x" << std::hex << frdEventMsg->adler32() <<
" but calculated 0x" 115 rawData_ = std::make_unique<FEDRawDataCollection>();
117 uint32_t eventSize = frdEventMsg->eventSize();
118 unsigned char*
event = (
unsigned char*)frdEventMsg->payload();
119 bool foundTCDSFED =
false;
120 bool foundGTPFED =
false;
122 while (eventSize > 0) {
132 throw cms::Exception(
"FedRawDataInputSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
146 if (GTPEvmBoardSense)
164 fedData.resize(fedSize);
165 memcpy(fedData.data(),
event + eventSize, fedSize);
167 assert(eventSize == 0);
175 std::cout <<
" open file.. " << fileName << std::endl;
178 size_t pos = fileName.find(
':');
179 if (pos != std::string::npos) {
181 if (prefix !=
"file")
188 return fin_.is_open();
unsigned int detectedFRDversion_
unsigned int getgpshigh(const unsigned char *)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool gtpe_board_sense(const unsigned char *p)
static const uint32_t length
std::unique_ptr< FEDRawDataCollection > rawData_
unsigned int get(const unsigned char *, bool)
void produce(edm::Event &e) override
const uint32 FRDHeaderVersionSize[6]
std::vector< char > buffer_
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
std::vector< std::string > const & fileNames() const
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)
unsigned long long uint64_t
const bool verifyAdler32_
const uint32_t gpstimelow
const uint32_t gpstimehigh
unsigned int gtpe_get(const unsigned char *)
const struct Header_v1 header
unsigned int getgpslow(const unsigned char *)
FRDStreamSource(edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)