8 #include "art/Framework/Core/EDAnalyzer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Principal/Handle.h"
12 #include "canvas/Utilities/Exception.h"
14 #include "artdaq-core-demo/Overlays/ToyFragment.hh"
15 #include "artdaq-core/Data/ContainerFragment.hh"
16 #include "artdaq-core/Data/Fragment.hh"
19 #define TRACE_NAME "CheckIntegrity"
59 virtual void analyze(art::Event
const& evt);
62 std::string raw_data_label_;
68 , raw_data_label_(pset.get<std::string>(
"raw_data_label"))
77 std::vector<std::string> fragment_type_labels{
"TOY1",
"TOY2",
"ContainerTOY1",
"ContainerTOY2" };
79 for (
auto label : fragment_type_labels)
81 art::Handle<artdaq::Fragments> fragments_with_label;
83 evt.getByLabel(raw_data_label_, label, fragments_with_label);
84 if (!fragments_with_label.isValid())
continue;
86 if (label ==
"Container" || label ==
"ContainerTOY1" || label ==
"ContainerTOY2")
88 for (
auto cont : *fragments_with_label)
93 containerFragments.push_back(contf[ii]);
94 fragments.push_back(*containerFragments.back());
100 for (
auto frag : *fragments_with_label)
102 fragments.emplace_back(frag);
107 TLOG(TLVL_INFO) <<
"Run " << evt.run() <<
", subrun " << evt.subRun()
108 <<
", event " << evt.event() <<
" has " << fragments.size()
109 <<
" fragment(s) of type TOY1 or TOY2";
112 for (
const auto& frag : fragments)
118 TLOG(TLVL_ERROR) <<
"Error: in run " << evt.run() <<
", subrun " << evt.subRun() <<
119 ", event " << evt.event() <<
", seqID " << frag.sequenceID() <<
120 ", fragID " << frag.fragmentID() <<
": Size mismatch!" <<
130 for (; adc_iter != bb.
dataEndADCs(); adc_iter++, expected_adc++)
137 TLOG(TLVL_ERROR) <<
"Error: in run " << evt.run() <<
", subrun " << evt.subRun() <<
138 ", event " << evt.event() <<
", seqID " << frag.sequenceID() <<
139 ", fragID " << frag.fragmentID() <<
": expected an ADC value of " << expected_adc <<
140 ", got " << *adc_iter;
148 TLOG(TLVL_ERROR) <<
"Error: in run " << evt.run() <<
", subrun " << evt.subRun() <<
149 ", event " << evt.event() <<
", seqID " << frag.sequenceID() <<
150 ", fragID " << frag.fragmentID() <<
": " << *adc_iter <<
" is out-of-range for this Fragment type";
159 TLOG(TLVL_DEBUG) <<
"In run " << evt.run() <<
", subrun " << evt.subRun() <<
160 ", event " << evt.event() <<
", everything is fine";
std::vector< Fragment > Fragments
virtual void analyze(art::Event const &evt)
Analyze an event. Called by art for each event in run (based on command line options) ...
virtual ~CheckIntegrity()=default
Default destructor.
Header::event_size_t hdr_event_size() const
uint8_t hdr_distribution_type() const
adc_t const * dataBeginADCs() const
static size_t adc_range(int daq_adc_bits)
Metadata::count_t block_count() const
detail::RawFragmentHeader::RawDataType RawDataType
std::list< FragmentPtr > FragmentPtrs
Demonstration art::EDAnalyzer which checks that all ToyFragment ADC counts are in the defined range...
CheckIntegrity(fhicl::ParameterSet const &pset)
CheckIntegrity Constructor.
adc_t const * dataEndADCs() const