1#include <catch2/catch_test_macros.hpp>
3#include "Framework/Configure/Parameters.h"
6#include "Framework/RunHeader.h"
7#include "Packing/RawDataFile/EventPacket.h"
8#include "Packing/RawDataFile/File.h"
9#include "Packing/RawDataFile/SubsystemPacket.h"
10#include "Packing/Utility/Reader.h"
11#include "Packing/Utility/Writer.h"
21TEST_CASE(
"BinaryIO",
"[Packing][functionality]") {
22 SECTION(
"Unformatted Data") {
23 std::string test_file{
"test.raw"};
26 std::vector<uint16_t> test_vec = {0xFFFF, 0x00FF, 0xFF00, 0xF0F0};
27 uint64_t test_wide = 0xFFFF00FFFF00F0F0;
33 CHECK(w << test_wide);
39 std::vector<uint16_t> read_vec;
40 uint64_t read_wide, dummy;
41 CHECK(r.read(read_vec, 4));
42 CHECK(r >> read_wide);
43 CHECK_FALSE(r >> dummy);
45 CHECK(read_vec == test_vec);
46 CHECK(read_wide == test_wide);
50 SECTION(
"Subsystem Packet") {
51 std::string test_file{
"subsystem_packet_test.raw"};
55 std::vector<uint32_t> data = {0xAAAAAAAA, 0xBBBBBBBB, 0xCCCCCCCC,
56 0xDDDDDDDD, 0xDEDEDEDE, 0xFEDCBA98};
72 CHECK(sp.
data() == data);
76 SECTION(
"Event Packet") {
77 std::string test_file{
"event_packet_test.raw"};
80 std::map<uint16_t, std::vector<uint32_t>> unwrapped_data = {
82 {0xAAAAAAAA, 0xBBBBBBBB, 0xCCCCCCCC, 0xDDDDDDDD, 0xDEDEDEDE,
84 {0xACDC, {0xFEBBBBEF, 0x00112233}}};
99 CHECK(ep.id() == event);
101 for (
auto& subsys : ep.data()) {
102 REQUIRE(unwrapped_data.find(subsys.id()) != unwrapped_data.end());
103 CHECK(unwrapped_data.at(subsys.id()) == subsys.data());
108 SECTION(
"Entire File") {
109 std::string ecal_object_name(
"ecalDummyRaw"),
110 hcal_object_name(
"hcalDummyRaw"),
111 tracker_object_name(
"trackerDummyRaw"),
112 triggerpad_object_name(
"triggerpadDummyRaw");
114 ps.
addParameter(
"filename", std::string(
"file_test.raw"));
117 ps.
addParameter(
"tracker_object_name", tracker_object_name);
118 ps.
addParameter(
"triggerpad_object_name", triggerpad_object_name);
123 std::vector<uint32_t> data = {0xAAAAAAAA, 0xBBBBBBBB, 0xCCCCCCCC,
124 0xDDDDDDDD, 0xDEDEDEDE, 0xFEDCBA98};
134 f.writeRunHeader(rh);
139 for (
int i{0}; i < n_events; i++) {
140 event.getEventHeader().setEventNumber(i_event + i);
142 event.add(ecal_object_name, data);
143 event.add(hcal_object_name, data);
144 event.add(triggerpad_object_name, data);
146 REQUIRE(f.nextEvent());
149 event.onEndOfEvent();
156 std::cout <<
"starting Read" << std::endl;
161 f.writeRunHeader(rh);
162 CHECK(rh.getIntParameter(
"raw_run") == run);
167 for (
int i{0}; i < n_events; i++) {
168 event.getEventHeader().setEventNumber(i);
170 REQUIRE(f.nextEvent());
172 CHECK(event.getEventNumber() == i_event + i);
173 CHECK(data == event.getCollection<uint32_t>(ecal_object_name));
174 CHECK(data == event.getCollection<uint32_t>(hcal_object_name));
175 CHECK(data == event.getCollection<uint32_t>(triggerpad_object_name));
176 CHECK_FALSE(event.exists(tracker_object_name));
179 event.onEndOfEvent();
182 REQUIRE_FALSE(f.nextEvent());
Class implementing an event buffer system for storing event data.
Implements an event buffer system for storing event data.
Class encapsulating parameters for configuring a processor.
void addParameter(const std::string &name, const T &value)
Add a parameter to the parameter list.
The raw data file object.
SubsystemPacket structure.
std::vector< uint32_t > & data()
Get data.