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

Rewrites a set collection of beam gates into each event. More...

Inheritance diagram for icarus::trigger::FixBeamGateInfo:

Classes

struct  BeamChangeRecipe
 All directions to change a beam gate. More...
 
struct  Config
 

Public Types

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

Public Member Functions

 FixBeamGateInfo (Parameters const &config, art::ProcessingFrame const &)
 
virtual void produce (art::Event &event, art::ProcessingFrame const &) override
 

Private Types

using simulation_time = detinfo::timescales::simulation_time
 

Private Member Functions

sim::BeamGateInfo fixBeamGate (sim::BeamGateInfo const &beamGate) const
 Returns a "fixed" beam gate based on the input beamGate one. More...
 

Static Private Member Functions

static bool acceptGate (sim::BeamGateInfo const &gate, BeamChangeRecipe::GateSelector_t const &selection)
 Returns whether gate passes the specified selection. More...
 
template<typename T , typename P , typename I >
static T & applyRecipe (T &target, std::optional< BeamChangeRecipe::ChangeRecipe_t< P, I >> const &recipe)
 Applies the changes in recipe on the target value. More...
 

Private Attributes

art::InputTag const fBeamGateTag
 Input beam gate data product. More...
 
std::vector< BeamChangeRecipe >
const 
fChanges
 Changes on beam gate. More...
 
std::string const fInstanceName
 Instance name for the output product. More...
 
std::string const fLogCategory
 Message facility stream category for output. More...
 

Friends

struct dumpRecipe
 
BeamChangeRecipe convert (Config::ChangeGate const &config)
 

Detailed Description

Rewrites a set collection of beam gates into each event.

This module allows to perform fixed transformations to an existing beam gate data product (sim::BeamGateInfo), producing a new set of gates.

Output data products

Configuration parameters

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

Times must be specified as strings with their unit, e.g. "0.6 us" for 0.6 microseconds.

Definition at line 97 of file FixBeamGateInfo_module.cc.

Member Typedef Documentation

using icarus::trigger::FixBeamGateInfo::Parameters = art::SharedProducer::Table<Config>

Definition at line 269 of file FixBeamGateInfo_module.cc.

Definition at line 99 of file FixBeamGateInfo_module.cc.

Constructor & Destructor Documentation

icarus::trigger::FixBeamGateInfo::FixBeamGateInfo ( Parameters const &  config,
art::ProcessingFrame const &   
)
explicit

Definition at line 408 of file FixBeamGateInfo_module.cc.

409  : art::SharedProducer(config)
410  // configuration
411  , fBeamGateTag{ config().BeamGateTag() }
412  , fChanges{ config().Changes() }
413  , fInstanceName{
414  config().KeepInstanceName()
415  ? fBeamGateTag.instance(): config().OutputInstanceName()
416  }
417  , fLogCategory(config().LogCategory())
418 {
419  using namespace util::quantities::time_literals;
420 
421  //
422  // parameter validation
423  //
424  if (config().KeepInstanceName() && !config().OutputInstanceName().empty()) {
425  throw art::Exception{ art::errors::Configuration }
426  << "Can't set both '" << config().KeepInstanceName.name()
427  << " (" << std::boolalpha << config().KeepInstanceName() << ")"
428  << "' and '" << config().OutputInstanceName.name() << "' ('"
429  << config().OutputInstanceName() << "') at the same time.\n";
430  }
431 
432  for (auto const& [ iChange, change ]: util::enumerate(fChanges)) {
433  if (change.valid()) continue;
434  throw art::Exception{ art::errors::Configuration }
435  << "Incompatible requests for '" << config().Changes.name()
436  << "' item [" << iChange << "] " << dumpRecipe(change, " ", "")
437  << "\n";
438  } // for changes
439 
440  //
441  // input data declaration
442  //
443  consumes<std::vector<sim::BeamGateInfo>>(fBeamGateTag);
444 
445  //
446  // output data declaration
447  //
448  produces<std::vector<sim::BeamGateInfo>>(fInstanceName);
449 
450  async<art::InEvent>();
451 
452  //
453  // configuration report (short)
454  //
455  {
456  mf::LogInfo log { fLogCategory };
457  log << "New beam gates based on '" << fBeamGateTag.encode()
458  << "' following " << fChanges.size() << " rules:";
459  for (auto const& [iChange, change]: util::enumerate(fChanges)) {
460  log << "\n[" << iChange << "] " << dumpRecipe(change, " ", "");
461  } // for all change sets
462  }
463 
464 } // icarus::trigger::FixBeamGateInfo::FixBeamGateInfo()
std::string const fInstanceName
Instance name for the output product.
std::string const fLogCategory
Message facility stream category for output.
std::vector< BeamChangeRecipe > const fChanges
Changes on beam gate.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
art::InputTag const fBeamGateTag
Input beam gate data product.
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555

Member Function Documentation

bool icarus::trigger::FixBeamGateInfo::acceptGate ( sim::BeamGateInfo const &  gate,
BeamChangeRecipe::GateSelector_t const &  selection 
)
staticprivate

Returns whether gate passes the specified selection.

Definition at line 526 of file FixBeamGateInfo_module.cc.

527 {
528  if (!selection.beamTypes.empty()) {
529  if (!contains(selection.beamTypes, gate.BeamType())) return false;
530  }
531  return true;
532 } // icarus::trigger::FixBeamGateInfo::acceptGate()
template<typename T , typename P , typename I >
T & icarus::trigger::FixBeamGateInfo::applyRecipe ( T &  target,
std::optional< BeamChangeRecipe::ChangeRecipe_t< P, I >> const &  recipe 
)
staticprivate

Applies the changes in recipe on the target value.

Definition at line 537 of file FixBeamGateInfo_module.cc.

539  {
540  if (recipe) {
541  if (recipe->setValue) target = *recipe->setValue;
542  if (recipe->addValue) target += *recipe->addValue;
543  }
544  return target;
545 } // icarus::trigger::FixBeamGateInfo::applyRecipe()
sim::BeamGateInfo icarus::trigger::FixBeamGateInfo::fixBeamGate ( sim::BeamGateInfo const &  beamGate) const
private

Returns a "fixed" beam gate based on the input beamGate one.

Definition at line 500 of file FixBeamGateInfo_module.cc.

501 {
504 
505  // beamGate is supposed to be stored in simulation_time units (nanoseconds)
506  simulation_time start { nanosecond{ beamGate.Start() }};
507  simulation_time::interval_t width { nanoseconds{ beamGate.Width() }};
508 
509  for (BeamChangeRecipe const& change: fChanges) {
510  if (!acceptGate(beamGate, change.selectGates)) continue;
511  applyRecipe(start, change.start);
512  applyRecipe(width, change.width);
513  } // for all changes
514 
515  return sim::BeamGateInfo{
516  nanosecond{ start }.value(),
517  nanoseconds{ width }.value(),
518  beamGate.BeamType()
519  };
520 
521 } // icarus::trigger::FixBeamGateInfo::fixBeamGate()
static bool acceptGate(sim::BeamGateInfo const &gate, BeamChangeRecipe::GateSelector_t const &selection)
Returns whether gate passes the specified selection.
constexpr value_t value() const
Returns the value of the quantity.
Definition: quantities.h:609
std::vector< BeamChangeRecipe > const fChanges
Changes on beam gate.
static T & applyRecipe(T &target, std::optional< BeamChangeRecipe::ChangeRecipe_t< P, I >> const &recipe)
Applies the changes in recipe on the target value.
nanoseconds_as<> nanoseconds
Type of time interval stored in nanoseconds, in double precision.
Definition: spacetime.h:270
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
Definition: spacetime.h:136
nanosecond_as<> nanosecond
Type of time point stored in nanoseconds, in double precision.
Definition: spacetime.h:339
detinfo::timescales::simulation_time simulation_time
nanosecond nanoseconds
Alias for common language habits.
Definition: spacetime.h:139
void icarus::trigger::FixBeamGateInfo::produce ( art::Event &  event,
art::ProcessingFrame const &   
)
overridevirtual

Definition at line 469 of file FixBeamGateInfo_module.cc.

470 {
471 
472  //
473  // read input data product
474  //
475  auto const& beamGates
476  = event.getProduct<std::vector<sim::BeamGateInfo>>(fBeamGateTag);
477 
478  //
479  // "fix"
480  //
481  std::vector<sim::BeamGateInfo> fixedBeamGates;
482  fixedBeamGates.reserve(beamGates.size());
483  for (sim::BeamGateInfo const& beamGate: beamGates)
484  fixedBeamGates.push_back(fixBeamGate(beamGate));
485 
486  //
487  // put into the event
488  //
489  event.put(
490  std::make_unique<std::vector<sim::BeamGateInfo>>
491  (std::move(fixedBeamGates)),
493  );
494 
495 } // icarus::trigger::FixBeamGateInfo::produce()
std::string const fInstanceName
Instance name for the output product.
sim::BeamGateInfo fixBeamGate(sim::BeamGateInfo const &beamGate) const
Returns a &quot;fixed&quot; beam gate based on the input beamGate one.
art::InputTag const fBeamGateTag
Input beam gate data product.

Friends And Related Function Documentation

BeamChangeRecipe convert ( Config::ChangeGate const &  config)
friend

Definition at line 364 of file FixBeamGateInfo_module.cc.

365  {
366  using ChangeGate = FixBeamGateInfo::Config::ChangeGate;
367  return FixBeamGateInfo::BeamChangeRecipe{
368  ChangeGate::convert(config.Select()) // selectGates
369  , ChangeGate::convert(config.Start()) // start
370  , ChangeGate::convert(config.Width()) // width
371  };
372  } // convert(FixBeamGateInfo::Config::ChangeGate)
TimeTrackTreeStorage::TriggerInputSpec_t convert(TimeTrackTreeStorage::Config::TriggerSpecConfig const &config)
friend struct dumpRecipe
friend

Definition at line 326 of file FixBeamGateInfo_module.cc.

Member Data Documentation

art::InputTag const icarus::trigger::FixBeamGateInfo::fBeamGateTag
private

Input beam gate data product.

Definition at line 294 of file FixBeamGateInfo_module.cc.

std::vector<BeamChangeRecipe> const icarus::trigger::FixBeamGateInfo::fChanges
private

Changes on beam gate.

Definition at line 297 of file FixBeamGateInfo_module.cc.

std::string const icarus::trigger::FixBeamGateInfo::fInstanceName
private

Instance name for the output product.

Definition at line 299 of file FixBeamGateInfo_module.cc.

std::string const icarus::trigger::FixBeamGateInfo::fLogCategory
private

Message facility stream category for output.

Definition at line 302 of file FixBeamGateInfo_module.cc.


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