All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
detsim::DumpOpDetWaveforms Class Reference

Prints the content of all optical detector waveforms on screen. More...

Inheritance diagram for detsim::DumpOpDetWaveforms:

Classes

struct  Config
 
struct  TimestampLabelMaker
 Base functor for printing time according to tick number. More...
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 DumpOpDetWaveforms (Parameters const &config)
 
void analyze (const art::Event &evt)
 Does the printing. More...
 

Private Types

enum  sortMode { sortMode::DataProductOrder, sortMode::ChannelAndTime }
 

Static Private Member Functions

static std::vector
< std::vector
< raw::OpDetWaveform const * > > 
groupByChannel (std::vector< raw::OpDetWaveform > const &waveforms)
 Returns pointers to all waveforms in a vector with channel as index. More...
 
static void sortByTimestamp (std::vector< raw::OpDetWaveform const * > &waveforms)
 Sorts all the waveforms in the vector by growing timestamp. More...
 

Private Attributes

art::InputTag fOpDetWaveformsTag
 Input tag of data product to dump. More...
 
std::string fOutputCategory
 Category for mf::LogInfo output. More...
 
unsigned int fDigitsPerLine
 ADC readings per line in the output. More...
 
raw::ADC_Count_t fPedestal
 ADC pedestal (subtracted from readings). More...
 
sortMode fSortByChannelAndTime
 How to sort the waveforms in the dump. More...
 
std::unique_ptr
< dump::raw::OpDetWaveformDumper::TimeLabelMaker
fTimeLabel
 The object used to print tick labels. More...
 

Detailed Description

Prints the content of all optical detector waveforms on screen.

This analyser prints the content of all the raw digits into the LogInfo/LogVerbatim stream.

Configuration parameters

Definition at line 58 of file DumpOpDetWaveforms_module.cc.

Member Typedef Documentation

using detsim::DumpOpDetWaveforms::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 99 of file DumpOpDetWaveforms_module.cc.

Member Enumeration Documentation

Enumerator
DataProductOrder 

Unsorted: same order as the input data product.

ChannelAndTime 

Sort by PMT channel number, then timestamp.

Definition at line 108 of file DumpOpDetWaveforms_module.cc.

108  {
109  DataProductOrder, ///< Unsorted: same order as the input data product.
110  ChannelAndTime ///< Sort by PMT channel number, then timestamp.
111  }; // sortMode

Constructor & Destructor Documentation

detsim::DumpOpDetWaveforms::DumpOpDetWaveforms ( Parameters const &  config)
explicit

Definition at line 153 of file DumpOpDetWaveforms_module.cc.

154  : EDAnalyzer(config)
155  , fOpDetWaveformsTag(config().OpDetWaveformsTag())
156  , fOutputCategory(config().OutputCategory())
157  , fDigitsPerLine(config().DigitsPerLine())
158  , fPedestal(config().Pedestal())
159  , fSortByChannelAndTime(config().SortByChannelAndTime()
161  )
162  {
163  std::string const tickLabelStr = config().TickLabel();
164  if (tickLabelStr == "none") {
165  fTimeLabel.reset(); // not very useful, but let's be explicit
166  }
167  else if (tickLabelStr == "tick") {
168  fTimeLabel = std::make_unique<dump::raw::OpDetWaveformDumper::TickLabelMaker>();
169  }
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());
174  }
175  else {
176  throw art::Exception(art::errors::Configuration)
177  << "Invalid choice '" << tickLabelStr << "' for time label.\n";
178  }
179 
180  } // DumpOpDetWaveforms::DumpOpDetWaveforms()
std::string fOutputCategory
Category for mf::LogInfo output.
std::unique_ptr< dump::raw::OpDetWaveformDumper::TimeLabelMaker > fTimeLabel
The object used to print tick labels.
raw::ADC_Count_t fPedestal
ADC pedestal (subtracted from readings).
Unsorted: same order as the input data product.
sortMode fSortByChannelAndTime
How to sort the waveforms in the dump.
art::InputTag fOpDetWaveformsTag
Input tag of data product to dump.
unsigned int fDigitsPerLine
ADC readings per line in the output.
Sort by PMT channel number, then timestamp.

Member Function Documentation

void detsim::DumpOpDetWaveforms::analyze ( const art::Event &  evt)

Does the printing.

Definition at line 184 of file DumpOpDetWaveforms_module.cc.

185  {
186 
187  // fetch the data to be dumped on screen
188  auto const& Waveforms
189  = event.getProduct<std::vector<raw::OpDetWaveform>>(fOpDetWaveformsTag);
190 
192  dump.setTimeLabelMaker(fTimeLabel.get());
193 
194  mf::LogVerbatim(fOutputCategory) << "The event " << event.id() << " contains data for "
195  << Waveforms.size() << " optical detector channels";
196  if (fPedestal != 0) {
197  mf::LogVerbatim(fOutputCategory)
198  << "A pedestal of " << fPedestal << " counts will be subtracted from all ADC readings.";
199  } // if pedestal
200 
201  switch (fSortByChannelAndTime) {
203  {
204  dump.setIndent(" ");
205  for (raw::OpDetWaveform const& waveform : Waveforms) {
206  mf::LogVerbatim log(fOutputCategory);
207  dump(log, waveform);
208  } // for waveforms on channel
209  }
210  break; // sortMode::DataProductOrder
212  {
213  dump.setIndent(" ");
214 
215  auto groupedWaveforms = groupByChannel(Waveforms);
216  for (auto& channelWaveforms : groupedWaveforms) {
217  if (channelWaveforms.empty()) continue;
218 
219  sortByTimestamp(channelWaveforms);
220  auto const channel = channelWaveforms.front()->ChannelNumber();
221 
222  mf::LogVerbatim(fOutputCategory)
223  << " optical detector channel #" << channel << " has "
224  << channelWaveforms.size() << " waveforms:";
225 
226  for (raw::OpDetWaveform const* pWaveform : channelWaveforms) {
227  mf::LogVerbatim log(fOutputCategory);
228  dump(log, *pWaveform);
229  } // for waveforms on channel
230 
231  } // for all channels
232  }
233  break; // sortMode::ChannelAndTime
234  } // switch (fSortMode)
235 
236  } // DumpOpDetWaveforms::analyze()
std::string fOutputCategory
Category for mf::LogInfo output.
std::unique_ptr< dump::raw::OpDetWaveformDumper::TimeLabelMaker > fTimeLabel
The object used to print tick labels.
static std::vector< std::vector< raw::OpDetWaveform const * > > groupByChannel(std::vector< raw::OpDetWaveform > const &waveforms)
Returns pointers to all waveforms in a vector with channel as index.
raw::ADC_Count_t fPedestal
ADC pedestal (subtracted from readings).
Unsorted: same order as the input data product.
Prints the content of optical detector waveforms on screen.
static void sortByTimestamp(std::vector< raw::OpDetWaveform const * > &waveforms)
Sorts all the waveforms in the vector by growing timestamp.
sortMode fSortByChannelAndTime
How to sort the waveforms in the dump.
art::InputTag fOpDetWaveformsTag
Input tag of data product to dump.
unsigned int fDigitsPerLine
ADC readings per line in the output.
Sort by PMT channel number, then timestamp.
std::vector< std::vector< raw::OpDetWaveform const * > > detsim::DumpOpDetWaveforms::groupByChannel ( std::vector< raw::OpDetWaveform > const &  waveforms)
staticprivate

Returns pointers to all waveforms in a vector with channel as index.

Definition at line 240 of file DumpOpDetWaveforms_module.cc.

241  {
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);
247  } // for
248  return groups;
249  } // DumpOpDetWaveforms::groupByChannel()
void detsim::DumpOpDetWaveforms::sortByTimestamp ( std::vector< raw::OpDetWaveform const * > &  waveforms)
staticprivate

Sorts all the waveforms in the vector by growing timestamp.

Definition at line 253 of file DumpOpDetWaveforms_module.cc.

254  {
255 
256  struct ChannelSorter {
257 
258  static bool
259  sort(raw::OpDetWaveform const& a, raw::OpDetWaveform const& b)
260  {
261  if (a.ChannelNumber() < b.ChannelNumber()) return true;
262  if (a.ChannelNumber() > b.ChannelNumber()) return false;
263 
264  return (a.TimeStamp() < b.TimeStamp());
265  }
266 
267  bool
268  operator()(raw::OpDetWaveform const& a, raw::OpDetWaveform const& b) const
269  {
270  return sort(a, b);
271  }
272 
273  bool
274  operator()(raw::OpDetWaveform const* a, raw::OpDetWaveform const* b) const
275  {
276  return sort(*a, *b);
277  }
278 
279  }; // struct ChannelSorter
280  std::sort(waveforms.begin(), waveforms.end(), ChannelSorter());
281 
282  } // DumpOpDetWaveforms::sortByTimestamp()
process_name gaushit a

Member Data Documentation

unsigned int detsim::DumpOpDetWaveforms::fDigitsPerLine
private

ADC readings per line in the output.

Definition at line 131 of file DumpOpDetWaveforms_module.cc.

art::InputTag detsim::DumpOpDetWaveforms::fOpDetWaveformsTag
private

Input tag of data product to dump.

Definition at line 129 of file DumpOpDetWaveforms_module.cc.

std::string detsim::DumpOpDetWaveforms::fOutputCategory
private

Category for mf::LogInfo output.

Definition at line 130 of file DumpOpDetWaveforms_module.cc.

raw::ADC_Count_t detsim::DumpOpDetWaveforms::fPedestal
private

ADC pedestal (subtracted from readings).

Definition at line 132 of file DumpOpDetWaveforms_module.cc.

sortMode detsim::DumpOpDetWaveforms::fSortByChannelAndTime
private

How to sort the waveforms in the dump.

Definition at line 133 of file DumpOpDetWaveforms_module.cc.

std::unique_ptr<dump::raw::OpDetWaveformDumper::TimeLabelMaker> detsim::DumpOpDetWaveforms::fTimeLabel
private

The object used to print tick labels.

Definition at line 137 of file DumpOpDetWaveforms_module.cc.


The documentation for this class was generated from the following file: