LDMX Software
SingleSubsystemUnpacker.cxx
1
2#include "Packing/SingleSubsystemUnpacker.h"
3
4namespace packing {
5
9
11 reader_.open(ps.getParameter<std::string>("raw_file"));
12 num_bytes_per_event_ = ps.getParameter<int>("num_bytes_per_event");
13 output_name_ = ps.getParameter<std::string>("output_name");
14 detector_name_ = ps.getParameter<std::string>("detector_name");
15}
16
18 if (!reader_ or reader_.eof()) abortEvent();
19
20 std::vector<uint8_t> buff;
21 if (!reader_.read(buff, num_bytes_per_event_)) {
22 EXCEPTION_RAISE("MalForm", "Raw file provided was unable to read " +
23 std::to_string(num_bytes_per_event_) +
24 " bytes in an event.");
25 }
26 event.add(output_name_, buff);
27}
28
29} // namespace packing
30
31DECLARE_PRODUCER_NS(packing, SingleSubsystemUnpacker)
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
void abortEvent()
Abort the event immediately.
Implements an event buffer system for storing event data.
Definition Event.h:41
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:54
void setDetectorName(const std::string &det)
Set the name of the detector that was used in this run.
Definition RunHeader.h:80
std::string detector_name_
Detector file name.
utility::Reader reader_
raw data file we are reading
int num_bytes_per_event_
number of bytes in each event
std::string output_name_
destination object name
void beforeNewRun(ldmx::RunHeader &rh) override
Handle allowing producers to modify run headers before the run begins.
void produce(framework::Event &event) override
Actually do the unpacking/decoding.
void configure(framework::config::Parameters &ps) override
Configure the unpacker and open the raw data file for IO.
void open(const std::string &file_name)
Open a file with this reader.
Definition Reader.h:35
bool eof()
check if file is done
Definition Reader.h:214
Reader & read(WordType *w, std::size_t count)
Read the next 'count' words into the input handle.
Definition Reader.h:113