artdaq_core  v3_06_11
RawEvent_t.cc
1 #include "artdaq-core/Data/Fragment.hh"
2 #include "artdaq-core/Data/RawEvent.hh"
3 
4 #define BOOST_TEST_MODULE(RawEvent_t)
5 #include <cetlib/quiet_unit_test.hpp>
6 
7 BOOST_AUTO_TEST_SUITE(RawEvent_test)
8 
9 BOOST_AUTO_TEST_CASE(RawEventHeader)
10 {
12 
13  BOOST_REQUIRE_EQUAL(reh.run_id, 0);
14  BOOST_REQUIRE_EQUAL(reh.subrun_id, 0);
15  BOOST_REQUIRE_EQUAL(reh.event_id, 0);
16  BOOST_REQUIRE_EQUAL(reh.sequence_id, 0);
17  BOOST_REQUIRE_EQUAL(reh.timestamp, 0);
18  BOOST_REQUIRE_EQUAL(reh.is_complete, false);
19 
20  TLOG(TLVL_INFO) << "Default RawEventHeader: " << reh;
21 }
22 
23 BOOST_AUTO_TEST_CASE(RawEvent_Methods)
24 {
25  artdaq::RawEvent r1(1, 2, 3, 4, 5);
26 
27  BOOST_REQUIRE_EQUAL(r1.wordCount(), 0);
28  BOOST_REQUIRE_EQUAL(r1.runID(), 1);
29  BOOST_REQUIRE_EQUAL(r1.subrunID(), 2);
30  BOOST_REQUIRE_EQUAL(r1.eventID(), 3);
31  BOOST_REQUIRE_EQUAL(r1.sequenceID(), 4);
32  BOOST_REQUIRE_EQUAL(r1.timestamp(), 5);
33  BOOST_REQUIRE_EQUAL(r1.isComplete(), false);
34 
35  artdaq::FragmentPtr frag = std::make_unique<artdaq::Fragment>(101, 202, artdaq::Fragment::DataFragmentType, 303);
36  r1.insertFragment(std::move(frag));
37 
38  r1.markComplete();
39  BOOST_REQUIRE_EQUAL(r1.isComplete(), true);
40 
41  TLOG(TLVL_INFO) << "RawEvent: " << r1;
42 }
43 
44 BOOST_AUTO_TEST_CASE(InsertFragment)
45 {
46  // SCF - The RawEvent::insertFragment() method used to check and verify that
47  // the sequence ID of the fragment equaled the sequence ID in the RawEvent
48  // header. This doesn't work for the DS50 aggregator as it packs multiple
49  // fragments with different sequence IDs into a single RawEvent. This test
50  // verifies that the we're able to do this.
51  artdaq::RawEvent r1(1, 2, 3, 4, 5);
52  std::unique_ptr<artdaq::Fragment> f1(new artdaq::Fragment(1, 1));
53  std::unique_ptr<artdaq::Fragment> f2(new artdaq::Fragment(2, 1));
54  std::unique_ptr<artdaq::Fragment> f3(new artdaq::Fragment(3, 1));
55 
56  r1.insertFragment(std::move(f1));
57  r1.insertFragment(std::move(f2));
58  r1.insertFragment(std::move(f3));
59  BOOST_REQUIRE_EQUAL(r1.numFragments(), 3);
60 
61  f1.reset(nullptr);
62  BOOST_REQUIRE_EXCEPTION(r1.insertFragment(std::move(f1)), cet::exception,
63  [&](cet::exception e) { return e.category() == "LogicError"; });
64 }
65 
66 BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< Fragment > FragmentPtr
A std::unique_ptr to a Fragment object.
Definition: Fragment.hh:54
static constexpr type_t DataFragmentType
Copy DataFragmentType from RawFragmentHeader.
Definition: Fragment.hh:149
event_id_t event_id
Event number should be either sequence ID or Timestamp of component Fragments.
Definition: RawEvent.hh:37
subrun_id_t subrun_id
Fragments don&#39;t know about subruns.
Definition: RawEvent.hh:36
The header information used to identify key properties of the RawEvent object.
Definition: RawEvent.hh:26
run_id_t run_id
Fragments don&#39;t know about runs.
Definition: RawEvent.hh:35
A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is t...
Definition: Fragment.hh:85
timestamp_t timestamp
The timestamp of the first Fragment received for this event.
Definition: RawEvent.hh:39
bool is_complete
Does the event contain the expected number of Fragment objects?
Definition: RawEvent.hh:40
RawEvent is the artdaq view of a generic event, containing a header and zero or more Fragments...
Definition: RawEvent.hh:100
sequence_id_t sequence_id
RawEvent sequence_id should be the same as its component Fragment sequence_ids.
Definition: RawEvent.hh:38