15 #include "art/Framework/Core/EDAnalyzer.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
18 #include "art/Framework/Principal/Handle.h"
19 #include "canvas/Utilities/InputTag.h"
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Comment.h"
24 #include "fhiclcpp/types/Name.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
66 Name(
"OpDetWaveformsTag"),
67 Comment(
"input tag of the raw::OpDetWaveform collection to be dumped")};
70 Comment(
"name of the category used for the output"),
71 "DumpOpDetWaveforms"};
74 Name(
"DigitsPerLine"),
75 Comment(
"the dump of ADC readings will put this many of them for each line"),
80 Comment(
"ADC readings are written relative to this number"),
84 Name(
"SortByChannelAndTime"),
86 (
"waveforms are dumped in channel number order, and then timestamp"),
91 Comment(
"write an index in front of each digit dump line; choose between:"
92 " \"tick\" (waveform tick number)"
93 ", \"timestamp\" (electronics clock time in microseconds)"
94 ", \"none\" (no tick label)"),
137 std::unique_ptr<dump::raw::OpDetWaveformDumper::TimeLabelMaker>
fTimeLabel;
140 static std::vector<std::vector<raw::OpDetWaveform const*>>
groupByChannel(
141 std::vector<raw::OpDetWaveform>
const& waveforms);
144 static void sortByTimestamp(std::vector<raw::OpDetWaveform const*>& waveforms);
155 , fOpDetWaveformsTag(config().OpDetWaveformsTag())
156 , fOutputCategory(config().OutputCategory())
157 , fDigitsPerLine(config().DigitsPerLine())
158 , fPedestal(config().Pedestal())
159 , fSortByChannelAndTime(config().SortByChannelAndTime()
163 std::string
const tickLabelStr = config().TickLabel();
164 if (tickLabelStr ==
"none") {
167 else if (tickLabelStr ==
"tick") {
168 fTimeLabel = std::make_unique<dump::raw::OpDetWaveformDumper::TickLabelMaker>();
170 else if (tickLabelStr ==
"time") {
171 auto const clock_data =
172 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
173 fTimeLabel = std::make_unique<TimestampLabelMaker>(clock_data.OpticalClock().TickPeriod());
176 throw art::Exception(art::errors::Configuration)
177 <<
"Invalid choice '" << tickLabelStr <<
"' for time label.\n";
188 auto const& Waveforms
194 mf::LogVerbatim(
fOutputCategory) <<
"The event " <<
event.id() <<
" contains data for "
195 << Waveforms.size() <<
" optical detector channels";
198 <<
"A pedestal of " <<
fPedestal <<
" counts will be subtracted from all ADC readings.";
216 for (
auto& channelWaveforms : groupedWaveforms) {
217 if (channelWaveforms.empty())
continue;
220 auto const channel = channelWaveforms.front()->ChannelNumber();
223 <<
" optical detector channel #" << channel <<
" has "
224 << channelWaveforms.size() <<
" waveforms:";
228 dump(log, *pWaveform);
239 std::vector<std::vector<raw::OpDetWaveform const*>>
242 std::vector<std::vector<raw::OpDetWaveform const*>> groups;
243 for (
auto const& waveform : waveforms) {
244 auto const channel = waveform.ChannelNumber();
245 if (groups.size() <= channel) groups.resize(channel + 1);
246 groups[channel].push_back(&waveform);
256 struct ChannelSorter {
280 std::sort(waveforms.begin(), waveforms.end(), ChannelSorter());
pure virtual base interface for detector clocks
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
BEGIN_PROLOG vertical distance to the surface Name
std::string to_string(WindowPattern const &pattern)