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:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

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

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 DumpOpDetWaveforms (Parameters const &config)
 
void analyze (const art::Event &evt)
 Does the printing. More...
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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::TimeLabelMakerfTimeLabel
 The object used to print tick labels. More...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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

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 =
173  fTimeLabel = std::make_unique<TimestampLabelMaker>(clock_data.OpticalClock().TickPeriod());
174  }
175  else {
177  << "Invalid choice '" << tickLabelStr << "' for time label.\n";
178  }
179 
180  } // DumpOpDetWaveforms::DumpOpDetWaveforms()
std::string string
Definition: nybbler.cc:12
std::string fOutputCategory
Category for mf::LogInfo output.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::unique_ptr< dump::raw::OpDetWaveformDumper::TimeLabelMaker > fTimeLabel
The object used to print tick labels.
static Config * config
Definition: config.cpp:1054
raw::ADC_Count_t fPedestal
ADC pedestal (subtracted from readings).
Unsorted: same order as the input data product.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
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) {
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) {
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 
223  << " optical detector channel #" << channel << " has "
224  << channelWaveforms.size() << " waveforms:";
225 
226  for (raw::OpDetWaveform const* pWaveform : channelWaveforms) {
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()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string fOutputCategory
Category for mf::LogInfo output.
uint8_t channel
Definition: CRTFragment.hh:201
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.
def dump(input_file, output_file)
Definition: dumpTree.py:102
raw::ADC_Count_t fPedestal
ADC pedestal (subtracted from readings).
Collection of utilities for dumping data on screen.
Definition: DumperBase.h:30
Unsorted: same order as the input data product.
Prints the content of optical detector waveforms on screen.
Definition: OpDetWaveform.h:45
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()
uint8_t channel
Definition: CRTFragment.hh:201
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()
Channel_t ChannelNumber() const
Definition: OpDetWaveform.h:65
TimeStamp_t TimeStamp() const
Definition: OpDetWaveform.h:66
const double a
static bool * b
Definition: config.cpp:1043

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: