Project

General

Profile

User-specified range of validity

Although product aggregation is automatically performed by the art framework, the user may desire to create a product out of previously placed ones in a part of the workflow for which automatic aggregation cannot happen. The framework affords users this functionality through the SummedValue class, which provides users with the information necessary to create a product out of multiple products, even if the multiple products do not necessarily correspond to the same set of events.

Example

SummedValue

Consider the following modules, which is designed to create a new Run product based on the information from previously-put Run products. The module definition looks like:

class MyProducer : public art::EDProducer {
public:

  using Parameters = art::EDProducer::Table<MyConfig>;
  MyProducer(Parameters const&);

  void beginRun(art::Run&) override;
  ...

private:
  SummedValue<Numerator> num_;
  SummedValue<Denominator> denom_; 
};

To calculate the running sum, the SummedValue::update function is called, receiving the handle to the product of interest. For example:

void MyProducer::beginRun(art::Run& r)
{
  auto const& h1 = r.getValidHandle<Numerator>(runInputTag1_);
  auto const& h2 = r.getValidHandle<Denominator>(runInputTag2_);
  num_.update(h1);
  denom_.update(h2);

  if (art::same_ranges(num_, prod_) {
    auto const ratio = num_.dividedBy(denom_);
    auto eff = std::make_unique<double>(ratio);
    r.put(std::move(eff), art::runFragment(num_.rangeOfValidity()));
  }
}

A const reference to the object can be obtained via the SummedValue::value function call. Also, since a user would like to put a product onto the (Sub)Run once the ranges are the same, the art::same_ranges helper utility is provided (see below).

Auxiliary functions

art::same_ranges

The art::same_ranges function has three overloads:

  • art::same_ranges(RangeSet const&, RangeSet const&)
  • art::same_ranges(Handle<T> const&, Handle<T> const&)
  • art::same_ranges(SummedValue<T> const&, SummedValue<T> const&)

Returns true if the ranges of validity of the specified arguments are the same; false otherwise. If either or both ranges of validity are invalid, the returned value is false.

art::disjoint_ranges

The art::disjoint_ranges function has three overloads:

  • art::disjoint_ranges(RangeSet const&, RangeSet const&)
  • art::disjoint_ranges(Handle<T> const&, Handle<T> const&)
  • art::disjoint_ranges(SummedValue<T> const&, SummedValue<T> const&)

Returns true if the ranges of validity of the specified arguments are the disjoint; false otherwise. If either or both ranges of validity are invalid, the returned value is false.