3#include "Hcal/HcalRawDecoder.h"
15 const std::vector<uint8_t>& buffer_;
18 uint32_t w = buffer_.at(i_word_) | (buffer_.at(i_word_ + 1) << 8) |
19 (buffer_.at(i_word_ + 2) << 16) |
20 (buffer_.at(i_word_ + 3) << 24);
26 Reader(
const std::vector<uint8_t>& b) : buffer_{b}, i_word_{0} {}
27 operator bool() {
return (i_word_ < buffer_.size()); }
28 Reader& operator>>(uint32_t& w) {
29 if (*
this) w = next();
40 hex(uint32_t w) : word_{w} {}
45inline std::ostream& operator<<(std::ostream& os,
const debug::hex& h) {
46 os <<
"0x" << std::setfill(
'0') << std::setw(8) << std::hex << h.word_
56 const std::string& prefix) {
58 event.add(prefix +
"Version",
version);
59 event.add(prefix +
"FPGA",
fpga);
60 event.add(prefix +
"NSamples",
nsamples);
61 event.add(prefix +
"Spill",
spill);
62 event.add(prefix +
"Ticks",
ticks);
63 event.add(prefix +
"Bunch",
bunch);
64 event.add(prefix +
"Number",
number);
65 event.add(prefix +
"Run",
run);
66 event.add(prefix +
"DD",
DD);
67 event.add(prefix +
"MM",
MM);
68 event.add(prefix +
"hh",
hh);
69 event.add(prefix +
"mm",
mm);
98 std::vector<ldmx::HgcrocDigiCollection::Sample>>
108 auto single_pf_samples = this->
read(bus_reader, eh);
109 for (
const auto& [
id, samples] : single_pf_samples) {
110 eid_to_samples[id] = samples;
131 std::cout <<
"Translating EIDs into DetIDs. Printing skipped EIDs..."
136 for (
auto const& [eid, digi] : eid_to_samples) {
141 if (detmap.exists(eid)) {
142 uint32_t did_raw = detmap.get(eid).raw();
152 std::cout <<
"EID(" << eid.fiber() <<
"," << eid.elink() <<
","
153 << eid.channel() <<
") ";
154 for (
auto& s : digi) std::cout <<
debug::hex(s.raw()) <<
" ";
155 std::cout << std::endl;
167 for (
auto const& [eid, digi] : eid_to_samples) {
168 digis.
addDigi(eid.raw(), digi);
173 std::cout <<
"adding " << digis.
getNumDigis() <<
" digis each with "
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
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.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
static constexpr const char * CONDITIONS_OBJECT_NAME
The name of the EID <-> DetID map for the ECal.
std::string detector_name_
the detector name if we are reading from a file
bool read_from_file_
is the input_name a file or an event object
std::string output_name_
output object to put onto event bus
std::string input_file_
input file of encoded data
void beforeNewRun(ldmx::RunHeader &rh) override
add detector name if we are reading from file
packing::utility::Reader file_reader_
the file reader (if we are doing that)
void configure(framework::config::Parameters &) override
Callback for the EventProcessor to configure itself from the given set of parameters.
std::vector< std::string > input_names_
input object of encoded data
std::map< ldmx::HcalElectronicsID, std::vector< ldmx::HgcrocDigiCollection::Sample > > read(ReaderType &reader, PolarfireEventHeader &eh)
Assume input reader behaves like a binary data input stream where we can "pop" individual 32-bit word...
bool translate_eid_
are get translating electronic IDs?
int roc_version_
version of HGC ROC we are decoding
std::string input_pass_
input pass of creating encoded data
void produce(framework::Event &event) override
use read function to decode data, then translate EIDs into DetIDs
Read out 32-bit words from a 8-bit buffer.
Identifies a location in the Hcal readout chain.
Represents a collection of the digi hits readout by an HGCROC.
unsigned int getNumSamplesPerDigi() const
Get number of samples per digi.
void setNumSamplesPerDigi(unsigned int n)
Set number of samples for each digi.
void setSampleOfInterestIndex(unsigned int n)
Set index of sample of interest.
void setVersion(int v)
Set the version of the ROC we have read.
void addDigi(unsigned int id, const std::vector< Sample > &digi)
Add samples to collection.
unsigned int getNumDigis() const
Get total number of digis.
void open(const std::string &file_name)
Open a file with this reader.
bool eof()
check if file is done