37 unsigned char* tcds_pointer =
nullptr;
40 if (daqSource_->useL1EventID()) {
41 uint32_t L1EventID = event_->event();
45 aux.setProcessHistoryID(daqSource_->processHistoryID());
46 daqSource_->makeEventWrapper(eventPrincipal,
aux);
47 }
else if (tcds_pointer ==
nullptr) {
48 uint32_t L1EventID = event_->event();
49 throw cms::Exception(
"DAQSource::read") <<
"No TCDS FED in event with FEDHeader EID -: " << L1EventID;
55 daqSource_->eventRunNumber(),
56 daqSource_->currentLumiSection(),
59 daqSource_->processGUID(),
60 !daqSource_->fileListLoopMode(),
62 aux.setProcessHistoryID(daqSource_->processHistoryID());
63 daqSource_->makeEventWrapper(eventPrincipal,
aux);
68 daqProvenanceHelpers_[0]->branchDescription(),
std::move(edp), daqProvenanceHelpers_[0]->dummyProvenance());
73 unsigned char*& tcds_pointer) {
76 gettimeofday(&stv,
nullptr);
81 uint32_t eventSize = event_->eventSize();
82 unsigned char*
event = (
unsigned char*)event_->payload();
83 tcds_pointer =
nullptr;
85 uint16_t selectedTCDSFed = 0;
86 while (eventSize > 0) {
96 throw cms::Exception(
"DAQSource::fillFEDRawDataCollection") <<
"Out of range FED ID : " <<
fedId;
97 }
else if (
fedId >= MINTCDSuTCAFEDID_ &&
fedId <= MAXTCDSuTCAFEDID_) {
98 if (!selectedTCDSFed) {
99 selectedTCDSFed =
fedId;
100 tcds_pointer =
event + eventSize;
106 <<
"Second TCDS FED ID " <<
fedId <<
" found. First ID: " << selectedTCDSFed;
111 memcpy(fedData.
data(),
event + eventSize, fedSize);
120 daqProvenanceHelpers_.clear();
121 daqProvenanceHelpers_.emplace_back(std::make_shared<const edm::DaqProvenanceHelper>(
123 return daqProvenanceHelpers_;
129 event_ = std::make_unique<FRDEventMsgView>(dataBlockAddr_);
130 if (event_->size() > dataBlockMax_) {
132 <<
" event id:" << event_->event() <<
" lumi:" << event_->lumi() <<
" run:" << event_->run()
133 <<
" of size:" << event_->size() <<
" bytes does not fit into a chunk of size:" << dataBlockMax_ <<
" bytes";
140 if (event_->version() >= 5) {
141 crc_ =
crc32c(crc_, (
const unsigned char*)event_->payload(), event_->eventSize());
142 if (crc_ != event_->crc32c())
149 std::stringstream
ss;
150 ss <<
"Found a wrong crc32c checksum: expected 0x" << std::hex << event_->crc32c() <<
" but calculated 0x" << crc_;
159 std::vector<int>
const& numSources,
162 for (
auto&
baseDir : baseDirs) {
164 buPaths_.emplace_back(baseDirP / runDirP);
172 unsigned char* tcds_pointer =
nullptr;
175 auto const&
event = events_[0];
176 if (daqSource_->useL1EventID()) {
177 uint32_t L1EventID =
event->event();
181 aux.setProcessHistoryID(daqSource_->processHistoryID());
182 daqSource_->makeEventWrapper(eventPrincipal,
aux);
183 }
else if (tcds_pointer ==
nullptr) {
184 uint32_t L1EventID =
event->event();
185 throw cms::Exception(
"DAQSource::read") <<
"No TCDS FED in event with FEDHeader EID -: " << L1EventID;
191 daqSource_->eventRunNumber(),
192 daqSource_->currentLumiSection(),
195 daqSource_->processGUID(),
196 !daqSource_->fileListLoopMode(),
198 aux.setProcessHistoryID(daqSource_->processHistoryID());
199 daqSource_->makeEventWrapper(eventPrincipal,
aux);
203 daqProvenanceHelpers_[0]->branchDescription(),
std::move(edp), daqProvenanceHelpers_[0]->dummyProvenance());
204 eventCached_ =
false;
209 unsigned char*& tcds_pointer) {
212 gettimeofday(&stv,
nullptr);
217 tcds_pointer =
nullptr;
219 uint16_t selectedTCDSFed = 0;
220 int selectedTCDSFileIndex = -1;
222 uint32_t eventSize = events_[
index]->eventSize();
223 unsigned char*
event = (
unsigned char*)events_[
index]->
payload();
224 while (eventSize > 0) {
234 throw cms::Exception(
"DataModeFRDStriped:::fillFRDCollection") <<
"Out of range FED ID : " <<
fedId;
235 }
else if (
fedId >= MINTCDSuTCAFEDID_ &&
fedId <= MAXTCDSuTCAFEDID_) {
236 if (!selectedTCDSFed) {
237 selectedTCDSFed =
fedId;
238 selectedTCDSFileIndex =
index;
239 tcds_pointer =
event + eventSize;
243 }
else if (!testing_)
245 <<
"Second TCDS FED ID " <<
fedId <<
" found in file " << selectedTCDSFileIndex
246 <<
". First ID: " << selectedTCDSFed <<
" in file " <<
index;
250 memcpy(fedData.
data(),
event + eventSize, fedSize);
260 daqProvenanceHelpers_.clear();
261 daqProvenanceHelpers_.emplace_back(std::make_shared<const edm::DaqProvenanceHelper>(
263 return daqProvenanceHelpers_;
282 for (
size_t i = 0;
i < events_.size();
i++) {
284 auto const&
event = events_[
i];
285 if (
event->version() >= 5) {
286 crc =
crc32c(crc, (
const unsigned char*)
event->payload(),
event->eventSize());
287 if (crc !=
event->crc32c()) {
288 std::ostringstream
ss;
289 ss <<
"Found a wrong crc32c checksum at readout index " <<
i <<
": expected 0x" << std::hex <<
event->crc32c()
290 <<
" but calculated 0x" << crc <<
". ";
307 std::vector<std::string> additionalFiles;
311 additionalFiles.push_back(primaryName +
"_1");
312 return std::make_pair(
true, additionalFiles);
316 auto fullname =
fullpath.filename();
318 for (
size_t i = 1;
i < buPaths_.size();
i++) {
320 additionalFiles.push_back(newPath.generic_string());
322 return std::make_pair(
true, additionalFiles);
326 blockCompleted_ =
false;
329 for (
unsigned int i = 0;
i < events_.size();
i++) {
331 dataBlockAddrs_[
i] += events_[
i]->size();
339 for (
int i = 0;
i < numFiles_;
i++) {
340 if (dataBlockAddrs_[
i] >= dataBlockMaxAddrs_[
i]) {
342 assert(dataBlockAddrs_[
i] == dataBlockMaxAddrs_[
i]);
343 blockCompleted_ =
true;
348 <<
"not all striped blocks were completed at the same time";
352 events_.emplace_back(std::make_unique<FRDEventMsgView>(dataBlockAddrs_[
i]));
353 if (dataBlockAddrs_[
i] + events_[
i]->
size() > dataBlockMaxAddrs_[
i])
355 <<
" event id:" << events_[
i]->event() <<
" lumi:" << events_[
i]->lumi() <<
" run:" << events_[
i]->run()
356 <<
" of size:" << events_[
i]->size() <<
" bytes does not fit into the buffer or has corrupted header";
358 return !blockCompleted_;
std::string getChecksumError() const override
std::string getChecksumError() const override
std::pair< bool, std::vector< std::string > > defineAdditionalFiles(std::string const &primaryName, bool fileListMode) const override
bool checksumValid() override
bool checksumValid() override
edm::Timestamp fillFRDCollection(FEDRawDataCollection &rawData, bool &tcdsInRange, unsigned char *&tcds_pointer)
static const uint32_t length
edm::Timestamp fillFEDRawDataCollection(FEDRawDataCollection &rawData, bool &tcdsInRange, unsigned char *&tcds_pointer)
bool nextEventView() override
void readEvent(edm::EventPrincipal &eventPrincipal) override
edm::EventAuxiliary makeEventAuxiliary(const tcds::Raw_v1 *, unsigned int runNumber, unsigned int lumiSection, bool isRealData, const edm::EventAuxiliary::ExperimentType &, const std::string &processGUID, bool verifyLumiSection, bool suppressWarning)
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
void put(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, ProductProvenance const &productProvenance) const
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > & makeDaqProvenanceHelpers() override
unsigned long long TimeValue_t
bool nextEventView() override
void readEvent(edm::EventPrincipal &eventPrincipal) override
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
void makeDirectoryEntries(std::vector< std::string > const &baseDirs, std::vector< int > const &numSources, std::string const &runDir) override
void resize(size_t newsize, size_t wordsize=8)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > & makeDaqProvenanceHelpers() override