21 : ProducerSourceFromFiles(pset, desc,
true),
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) {
59 <<
"Invalid FRD file header (size mismatch) in file " << *
itFileName_;
73 *((uint32_t*)(&
buffer_[0])) = detectedFRDversion_;
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);
178 std::cout <<
" open file.. " << fileName << std::endl;
181 size_t pos = fileName.find(
':');
182 if (pos != std::string::npos) {
184 if (prefix !=
"file")
191 return fin_.is_open();
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)
constexpr size_t FRDHeaderMaxVersion
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)
EventNumber_t event() 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)
std::vector< std::string >::const_iterator endFileName_
unsigned long long uint64_t
const bool verifyAdler32_
const uint32_t gpstimelow
const uint32_t gpstimehigh
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 *)
std::vector< std::string > fileNames(unsigned iCatalog) const
FRDStreamSource(edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)