2#include "Packing/RawDataFile/File.h"
4#include "DetDescr/DetectorID.h"
5#include "Packing/Utility/CRC.h"
6#include "Packing/Utility/Mask.h"
15 std::string fn = ps.
get<std::string>(
"filename");
23 std::cerr <<
"creating file" << std::endl;
36 uint8_t version = word & utility::MASK<4>;
38 EXCEPTION_RAISE(
"RawFileVers",
"Unable to handle raw file version " +
39 std::to_string(version));
42 run_ = ((word >> 4) & utility::MASK<28>);
53 if (ps.
get<
bool>(
"verify_checksum")) {
55 for (
auto ifile{
reader_.
tell<uint32_t>()}; ifile < eof; ifile++) {
60 if (crc.
get() != crc_read_in) {
61 EXCEPTION_RAISE(
"CRCNotOk",
62 "Failure to verify CRC checksum of entire input file.");
76 static std::map<uint16_t, std::string> eid_to_name = {
85 std::map<uint16_t, std::vector<uint32_t>> the_subsys_data;
86 for (
auto const &[
id, name] : eid_to_name) {
114 for (
auto &subsys : read_event.data()) {
116 if (eid_to_name.find(subsys.id()) == eid_to_name.end()) {
117 std::cerr << subsys.id() <<
" unrecognized electronics ID."
119 eid_to_name[subsys.id()] =
"EID" + std::to_string(subsys.id());
122 event_->
add(eid_to_name.at(subsys.id()), subsys.data());
133 uint32_t temp_header =
134 (0 & utility::MASK<4>)+((
run_ & utility::MASK<28>) << 4);
Implements an event buffer system for storing event data.
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
int getEventNumber() const
Get the event number.
ldmx::EventHeader & getEventHeader()
Get the event header.
const std::vector< ContentType > & getCollection(const std::string &collectionName, const std::string &passName) const
Get a collection (std::vector) of objects from the event bus.
void add(const std::string &collectionName, T &obj)
Adds an object to the event bus.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
bool skip_unavailable_
for writing, do we skip subsystems if their raw object is unavailable
void writeRunHeader(ldmx::RunHeader &header)
Write the run header.
uint32_t run_
run number corresponding to this file of raw data
std::string tracker_object_name_
the event bus object name of the Tracker encoded data
uint32_t i_entry_
current entry index (may not be same as event number)
framework::Event * event_
handle to the event bus we are reading from or writing to
std::string triggerpad_object_name_
the event bus object name of the Trigger Pad encoded data
uint32_t entries_
number of entries in the file
std::string ecal_object_name_
the event bus object name of the ECal encoded data
utility::Reader reader_
utility class for reading binary data files
utility::Writer writer_
utility class for writing binary data files
bool connect(framework::Event &event)
Connect the passed event bus to this event file.
std::string hcal_object_name_
the event bus object name of the HCal encoded data
utility::CRC crc_
crc calculator for output mode
bool is_output_
are we reading or writing?
bool nextEvent()
Load the next event into our connected event bus.
void close()
close this file
File(const framework::config::Parameters ¶ms)
General file constructor.
std::string pass_name_
for writing, we also should be able to specify a pass name
The HGC ROC and FPGA use a CRC checksum to double check that the data transfer has been done correctl...
uint32_t get()
Get the calculate checksum from the calculator.
void open(const std::string &file_name)
Open a file with this reader.
int tell()
Tell us where the reader is.
void seek(int off, std::ios_base::seekdir dir=std::ios::beg)
Go ("seek") a specific position in the file.
void open(const std::string &file_name)
Open a file with this writer.