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.
getParameter<std::string>(
"filename");
24 std::cerr <<
"creating file" << std::endl;
37 uint8_t version = word & utility::mask<4>;
39 EXCEPTION_RAISE(
"RawFileVers",
"Unable to handle raw file version " +
40 std::to_string(version));
43 run_ = ((word >> 4) & utility::mask<28>);
56 for (
auto ifile{
reader_.
tell<uint32_t>()}; ifile < eof; ifile++) {
61 if (crc.
get() != crc_read_in) {
62 EXCEPTION_RAISE(
"CRCNotOk",
63 "Failure to verify CRC checksum of entire input file.");
77 static std::map<uint16_t, std::string> eid_to_name = {
86 std::map<uint16_t, std::vector<uint32_t>> the_subsys_data;
87 for (
auto const &[
id, name] : eid_to_name) {
115 for (
auto &subsys : read_event.data()) {
117 if (eid_to_name.find(subsys.id()) == eid_to_name.end()) {
118 std::cerr << subsys.id() <<
" unrecognized electronics ID."
120 eid_to_name[subsys.id()] =
"EID" + std::to_string(subsys.id());
123 event_->
add(eid_to_name.at(subsys.id()), subsys.data());
134 uint32_t tempHeader =
135 (0 & utility::mask<4>)+((
run_ & utility::mask<28>) << 4);
Implements an event buffer system for storing event data.
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.
int getEventNumber() const
Get the event number.
ldmx::EventHeader & getEventHeader()
Get the event header.
void add(const std::string &collectionName, T &obj)
Adds an object to the event bus.
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.
Class encapsulating parameters for configuring a processor.
T getParameter(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.