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

Extracts PMT baseline settings from PMT readout configuration. More...

Inheritance diagram for icarus::PMTWaveformBaselinesFromReadoutConfiguration:

Classes

struct  Config
 

Public Types

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

Public Member Functions

 PMTWaveformBaselinesFromReadoutConfiguration (Parameters const &config)
 
virtual void beginJob () override
 Prepares the plots to be filled. More...
 
virtual void beginRun (art::Run &run) override
 Reads the PMT readout configuration. More...
 
virtual void produce (art::Event &event) override
 Creates the data products. More...
 

Private Types

using Baseline_t = signed short int
 Type for baseline (same as V1730channelConfiguration::baseline) More...
 

Private Member Functions

void setupPlots ()
 Creates all the plots to be filled by the module. More...
 
Baseline_t getBaseline (raw::Channel_t channel) const
 
std::pair< unsigned int,
std::vector< Baseline_t > > 
extractBaselinesFromConfiguration (sbn::PMTconfiguration const &PMTconfig) const
 Returns the number of channels in configuration and a baseline map. More...
 
unsigned int nChannelsWithBaseline () const
 Returns the number of channels currently configured with a baseline. More...
 
void printBaselines () const
 Prints the current baselines on maesage facility (INFO level). More...
 

Private Attributes

art::InputTag const fOpDetWaveformTag
 Input optical waveform tag. More...
 
art::InputTag const fPMTconfigurationTag
 Input PMT readout config tag. More...
 
bool const fPlotBaselines
 Whether to produce plots. More...
 
bool const fPrintBaselines
 Whether to print baselines on each run. More...
 
std::string const fLogCategory
 Category name for the console output stream. More...
 
unsigned int fConfigured = 0U
 Number of channels in PMT configuration. More...
 
std::vector< short signed int > fBaselines
 PMT baselines configured in the current run, indexed by channel. More...
 
TH2 * fHBaselines = nullptr
 All baselines, per channel. More...
 

Static Private Attributes

static constexpr Baseline_t NoBaseline = std::numeric_limits<Baseline_t>::min()
 Mnemonic value for channels without baseline information. More...
 

Detailed Description

Extracts PMT baseline settings from PMT readout configuration.

This module produces a baseline data product for each optical detector waveform. The content is the same for all the events in each run, and it is read from the specified PMT configuration data product.

Each waveform is associated with the baseline configured for its channel. If there is no information for a given channel and that channel is requested, an exception is thrown.

This module is interchangeable with PMTWaveformBaselines, which instead extracts the baseline dynamically from each waveform.

Output data products

Output plots

Input data products

Note
This module needs only the information of the channel of each waveform; because art is not capable of selective readout, though, the whole optical detector readout data is loaded. When this module is the first one in the job accessing the PMT waveforms, the data loading time is accounted to it; the time the module needs to perform its specific operations is tiny in comparison. Anyway, since it is likely that another module in the job will then use PMT waveform data, this loading time is not wasted.

Service requirements

Configuration parameters

A terse description of the parameters is printed by running lar --print-description PMTWaveformBaselinesFromReadoutConfiguration.

Definition at line 132 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

Member Typedef Documentation

Type for baseline (same as V1730channelConfiguration::baseline)

Definition at line 199 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

Constructor & Destructor Documentation

icarus::PMTWaveformBaselinesFromReadoutConfiguration::PMTWaveformBaselinesFromReadoutConfiguration ( Parameters const &  config)
explicit

Definition at line 286 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

287  : art::EDProducer(config)
288  // configuration
289  , fOpDetWaveformTag(config().OpticalWaveforms())
290  , fPMTconfigurationTag(config().PMTconfigurationTag())
291  , fPlotBaselines(config().PlotBaselines())
292  , fPrintBaselines(config().PrintBaselines())
293  , fLogCategory(config().OutputCategory())
294 {
295  //
296  // optional configuration parameters
297  //
298 
299  //
300  // configuration report (currently, more like a placeholder)
301  //
302  mf::LogInfo(fLogCategory)
303  << "Using configured baselines from '" << fPMTconfigurationTag.encode()
304  << "', waveform by waveform, on '" << fOpDetWaveformTag.encode() << "'.";
305 
306  //
307  // declaration of input
308  //
309  consumes<sbn::PMTconfiguration, art::InRun>(fPMTconfigurationTag);
310  consumes<std::vector<raw::OpDetWaveform>>(fOpDetWaveformTag);
311 
312  //
313  // declaration of output
314  //
315  produces<std::vector<icarus::WaveformBaseline>>();
316  produces<art::Assns<icarus::WaveformBaseline, raw::OpDetWaveform>>();
317 
318 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::PMTWaveformBaselinesFromReadoutConfiguration()
std::string const fLogCategory
Category name for the console output stream.
physics producers discrimopdaq OpticalWaveforms

Member Function Documentation

void icarus::PMTWaveformBaselinesFromReadoutConfiguration::beginJob ( )
overridevirtual

Prepares the plots to be filled.

Definition at line 322 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

322  {
323 
324  //
325  // set up the plots, if needed
326  //
327  if (fPlotBaselines) setupPlots();
328 
329 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::beginJob()
void icarus::PMTWaveformBaselinesFromReadoutConfiguration::beginRun ( art::Run &  run)
overridevirtual

Reads the PMT readout configuration.

Definition at line 334 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

335 {
336  auto const& PMTconfig
337  = run.getProduct<sbn::PMTconfiguration>(fPMTconfigurationTag);
338 
339  std::vector<Baseline_t> newBaselines;
340  std::tie(fConfigured, newBaselines)
342 
343  bool const changed = (fBaselines != newBaselines);
344  fBaselines = std::move(newBaselines);
345 
346  if (fHBaselines) {
347  for (auto const& [ channel, baseline ]: util::enumerate(fBaselines)) {
348  if (baseline != NoBaseline)
349  fHBaselines->Fill(double(channel), double(baseline));
350  } // for
351  } // if plots
352 
353  if (fPrintBaselines && changed) printBaselines();
354 
355 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::beginRun()
std::pair< unsigned int, std::vector< Baseline_t > > extractBaselinesFromConfiguration(sbn::PMTconfiguration const &PMTconfig) const
Returns the number of channels in configuration and a baseline map.
std::vector< short signed int > fBaselines
PMT baselines configured in the current run, indexed by channel.
static constexpr Baseline_t NoBaseline
Mnemonic value for channels without baseline information.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
void printBaselines() const
Prints the current baselines on maesage facility (INFO level).
process_name PMTconfig
BEGIN_PROLOG baseline
Class containing configuration for PMT readout.
auto icarus::PMTWaveformBaselinesFromReadoutConfiguration::extractBaselinesFromConfiguration ( sbn::PMTconfiguration const &  PMTconfig) const
private

Returns the number of channels in configuration and a baseline map.

Definition at line 459 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

461 {
462  constexpr auto NoChannelID = sbn::V1730channelConfiguration::NoChannelID;
463 
464  unsigned int nConfigured = 0U;
465  std::vector<Baseline_t> baselines;
466 
467  for (sbn::V1730Configuration const& boardConfig: PMTconfig.boards) {
468  for (sbn::V1730channelConfiguration const& channelConfig
469  : boardConfig.channels
470  ) {
471 
472  ++nConfigured;
473 
474  raw::Channel_t const channelID = channelConfig.channelID;
475  if (channelID == NoChannelID) continue;
476 
477  auto const channelSlot = static_cast<std::size_t>(channelID);
478  if (baselines.size() <= channelSlot)
479  baselines.resize(channelSlot + 1U, NoBaseline);
480 
481  Baseline_t const baseline = channelConfig.baseline;
482  if (baseline == NoBaseline) {
483  // if this exception is thrown, it means we need a different way than
484  // a special baseline value (`NoBaseline`) to track the missing channels
485  // (e.g. a map or a std::vector<std::optional<...>>)
486  throw art::Exception(art::errors::LogicError)
487  << "A configured baseline actually matches the special value "
488  << "`NoBaseline` (" << NoBaseline << ")\n";
489  } // if bad luck
490 
491  baselines[channelSlot] = baseline;
492 
493  } // for all channels on a board
494  } // for all boards
495 
496  return { nConfigured, std::move(baselines) };
497 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::extractBaselinesFromConfiguration()
signed short int Baseline_t
Type for baseline (same as V1730channelConfiguration::baseline)
static constexpr Baseline_t NoBaseline
Mnemonic value for channels without baseline information.
process_name PMTconfig
BEGIN_PROLOG baseline
short signed int baseline
Baseline (BaselineCh&lt;N+1&gt;).
static constexpr auto NoChannelID
Special value for unassigned channel ID.
raw::Channel_t channelID
Offline channel ID.
std::vector< sbn::V1730channelConfiguration > channels
Configuration of each channel.
Class containing configuration for a V1730 channel.
Class containing configuration for a V1730 board.
auto icarus::PMTWaveformBaselinesFromReadoutConfiguration::getBaseline ( raw::Channel_t  channel) const
private

Returns the configured baseline.

Exceptions
cet::exception(category: "PMTWaveformBaselinesFromReadoutConfiguration") if channel is not present in the configuration

Definition at line 441 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

442 {
443 
444  auto const channelSlot = static_cast<std::size_t>(channel);
445  if (channelSlot < fBaselines.size()) {
446  Baseline_t const baseline = fBaselines[channelSlot];
447  if (baseline != NoBaseline) return baseline;
448  }
449  throw cet::exception("PMTWaveformBaselinesFromReadoutConfiguration")
450  << "No baseline configured for channel " << channel << ".\n";
451 
452 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::getBaseline()
signed short int Baseline_t
Type for baseline (same as V1730channelConfiguration::baseline)
std::vector< short signed int > fBaselines
PMT baselines configured in the current run, indexed by channel.
static constexpr Baseline_t NoBaseline
Mnemonic value for channels without baseline information.
BEGIN_PROLOG baseline
unsigned int icarus::PMTWaveformBaselinesFromReadoutConfiguration::nChannelsWithBaseline ( ) const
private

Returns the number of channels currently configured with a baseline.

Definition at line 504 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

505 {
506  return fBaselines.size()
507  - std::count(fBaselines.begin(), fBaselines.end(), NoBaseline);
508 }
std::vector< short signed int > fBaselines
PMT baselines configured in the current run, indexed by channel.
static constexpr Baseline_t NoBaseline
Mnemonic value for channels without baseline information.
std::size_t count(Cont const &cont)
void icarus::PMTWaveformBaselinesFromReadoutConfiguration::printBaselines ( ) const
private

Prints the current baselines on maesage facility (INFO level).

Definition at line 511 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

513 {
514  mf::LogInfo log { fLogCategory };
515 
516  unsigned int const nChannels = nChannelsWithBaseline();
517  assert(nChannels <= fConfigured);
518  unsigned int const nMissing = fConfigured - nChannels;
519 
520  log << "Configuration has " << nChannels << " channels";
521  if (nMissing > 0U)
522  log << " (plus " << nMissing << " not associated to any channel ID)";
523  log << ":";
524  for (auto [ channelID, baseline ]: util::enumerate(fBaselines)) {
525  if (baseline == NoBaseline) continue;
526  log << "\n channel " << channelID << ": " << baseline;
527  } // for all channels
528 
529 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::printBaselines()
std::string const fLogCategory
Category name for the console output stream.
std::vector< short signed int > fBaselines
PMT baselines configured in the current run, indexed by channel.
static constexpr Baseline_t NoBaseline
Mnemonic value for channels without baseline information.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
BEGIN_PROLOG baseline
unsigned int nChannelsWithBaseline() const
Returns the number of channels currently configured with a baseline.
void icarus::PMTWaveformBaselinesFromReadoutConfiguration::produce ( art::Event &  event)
overridevirtual

Creates the data products.

Definition at line 360 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

361 {
362 
363  //
364  // fetch input
365  //
366  auto const& waveformHandle
367  = event.getValidHandle<std::vector<raw::OpDetWaveform>>(fOpDetWaveformTag);
368  auto const& waveforms = *waveformHandle;
369 
370  /*
371  * this may be needed in a future where processing happens per channel
372  * rather than per waveform:
373  // map address of waveform to art pointer to that waveform
374  auto const& opDetWavePtrs
375  = util::mapDataProductPointers(event, waveformHandle);
376  */
377 
378 
379  //
380  // compute all the baselines
381  //
382  std::vector<icarus::WaveformBaseline> baselines;
383  baselines.reserve(waveforms.size());
384 
385  art::Assns<icarus::WaveformBaseline, raw::OpDetWaveform> baselineToWaveforms;
386 
387  art::PtrMaker<icarus::WaveformBaseline> const makeBaselinePtr(event);
388 
389  for (auto const& [ iWaveform, waveform ]: util::enumerate(waveforms)) {
390  assert(iWaveform == baselines.size());
391 
393  { static_cast<float>(getBaseline(waveform.ChannelNumber())) };
394 
395  baselines.push_back(baseline);
396 
397  baselineToWaveforms.addSingle(
398  makeBaselinePtr(iWaveform),
399  art::Ptr<raw::OpDetWaveform>(waveformHandle, iWaveform)
400  );
401 
402  } // for waveforms
403 
404 
405  //
406  // output
407  //
408  event.put(
409  std::make_unique<std::vector<icarus::WaveformBaseline>>
410  (std::move(baselines))
411  );
412  event.put(
413  std::make_unique<art::Assns<icarus::WaveformBaseline, raw::OpDetWaveform>>
414  (std::move(baselineToWaveforms))
415  );
416 
417 
418 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::produce()
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
BEGIN_PROLOG baseline
Class containing a waveform baseline value.
void icarus::PMTWaveformBaselinesFromReadoutConfiguration::setupPlots ( )
private

Creates all the plots to be filled by the module.

Definition at line 422 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

422  {
423 
424  auto const& tfs = *(art::ServiceHandle<art::TFileService>());
425  auto const& geom = *(lar::providerFrom<geo::Geometry const>());
426 
427  unsigned int const nChannels = geom.NOpChannels();
428 
429  fHBaselines = tfs.make<TH2F>(
430  "Baselines",
431  "PMT baseline;channel;baseline per channel [ / 8 ADC ]",
432  nChannels, 0.0, double(nChannels),
433  256, 13312.0, 15360.0
434  );
435 
436 } // icarus::PMTWaveformBaselinesFromReadoutConfiguration::setupPlots()
art::ServiceHandle< art::TFileService > tfs

Member Data Documentation

std::vector<short signed int> icarus::PMTWaveformBaselinesFromReadoutConfiguration::fBaselines
private

PMT baselines configured in the current run, indexed by channel.

Definition at line 224 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

unsigned int icarus::PMTWaveformBaselinesFromReadoutConfiguration::fConfigured = 0U
private

Number of channels in PMT configuration.

Definition at line 221 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

TH2* icarus::PMTWaveformBaselinesFromReadoutConfiguration::fHBaselines = nullptr
private

All baselines, per channel.

Definition at line 231 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

std::string const icarus::PMTWaveformBaselinesFromReadoutConfiguration::fLogCategory
private

Category name for the console output stream.

Definition at line 213 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

art::InputTag const icarus::PMTWaveformBaselinesFromReadoutConfiguration::fOpDetWaveformTag
private

Input optical waveform tag.

Definition at line 208 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

bool const icarus::PMTWaveformBaselinesFromReadoutConfiguration::fPlotBaselines
private

Whether to produce plots.

Definition at line 210 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

art::InputTag const icarus::PMTWaveformBaselinesFromReadoutConfiguration::fPMTconfigurationTag
private

Input PMT readout config tag.

Definition at line 209 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

bool const icarus::PMTWaveformBaselinesFromReadoutConfiguration::fPrintBaselines
private

Whether to print baselines on each run.

Definition at line 211 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.

constexpr Baseline_t icarus::PMTWaveformBaselinesFromReadoutConfiguration::NoBaseline = std::numeric_limits<Baseline_t>::min()
staticprivate

Mnemonic value for channels without baseline information.

Definition at line 203 of file PMTWaveformBaselinesFromReadoutConfiguration_module.cc.


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