Project

General

Profile

Feature #21432

Feature #21229: 'Shuffling' input module

Develop product that encapsulates (Sub)Run products from input datasets

Added by Kyle Knoepfel about 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Infrastructure
Target version:
Start date:
11/27/2018
Due date:
% Done:

100%

Estimated time:
8.00 h
Spent time:
Scope:
Internal
Experiment:
Mu2e
SSI Package:
art
Duration:

Description

The requirement is that for a given job that uses the event-shuffling input, only one run and one subrun are created. In order to allow modules to access (Sub)Run products from the various specified datasets, a product (template) must be developed so that a user can navigate to the product for the correct dataset.


Related issues

Blocks art - Feature #21433: Aggregate (Sub)Run products for event-shuffling inputClosed11/27/2018

History

#1 Updated by Kyle Knoepfel about 1 year ago

  • Blocks Feature #21433: Aggregate (Sub)Run products for event-shuffling input added

#2 Updated by Kyle Knoepfel 11 months ago

  • % Done changed from 0 to 100
  • Status changed from Assigned to Resolved

For any job that uses the SamplingInput source, only one run and one subrun will be generated. However, to access (sub)run products from the input datasets, the art::Sampled<T> template will be provided. Consider the following input datasets:

Dataset Run SubRun Products
Type Module label Instance name Process name
Signal 1 EventCount makeEventCount Gen
Calibration storeCalibration Reco
2 DetIndices activeDets calo Sim
3 DetIndices activeDets calo Sim
Background 7 EventCount makeEventCount Gen
Calibration storeCalibration Reco
9 DetIndices activeDets calo Sim
DetIndices activeDets tracker Sim

If the "Signal" and "Background" datasets were inputs to a job using SamplingInput, (sub)run products can be accessed by using the get interface.

// For run products:
cet::exempt_ptr<T const> 
art::Sampled<T>::get(std::string const& dataset, RunID const& on_disk_id);

// For subrun products:
cet::exempt_ptr<T const> 
art::Sampled<T>::get(std::string const& dataset, SubRunID const& on_disk_id);

Note that the return type of exempt_ptr denotes that the returned type is a pointer that is non-owning. A null pointer is returned if a product corresponding to the provided dataset and on-disk ID is not available. This means that users must check the validity of the returned pointer before using it.

See below for examples of the use of art::Sampled<T>::get.

Accessing run products through art::Sampled<T>::get

void MyAnalyzer::beginRun(Run const& r) override
{
  // Get products made by 'makeEventCount' in process 'Gen'
  InputTag const tag_for_count{"makeEventCount", "", art::sampled_from("Gen")};
  auto const counts = r.getValidHandle<art::Sampled<EventCount>>(tag_for_count);

  // Now access the values corresponding to the Signal, and run 1
  auto count_for_signal = counts->get("Signal", RunID{1}); // Returns cet::exempt_ptr<EventCount const>
  assert(count_for_signal);  
  // Do *not* try to delete the memory pointed to by 'count_for_signal'.

  // Try accessing other values
  assert(counts->get("Background", RunID{7})); // Yes, this exists
  assert(!counts->get("Gibberish", RunID{7})); // "Gibberish" is not a dataset used in this job
  assert(!counts->get("Background", RunID{1}); // "Background" does not have a Run 1 product
}

A similar pattern can be used for accessing the Calibration data products.

Accessing subrun products through art::Sampled<T>::get

For accessing subrun products, the dataset string is still provided, but a SubRunID object is provided instead of the RunID object.

void MyAnalyzer::beginSubRun(SubRun const& sr) override
{
  InputTag const tag_for_calo_indices{"activeDets", "calo", art::sampled_from("Sim")};
  auto const calo_indices = 
    sr.getValidHandle<art::Sampled<DetIndices>>(tag_for_calo_indices);

  assert(calo_indices->get("Signal", SubRun{1, 2}));
  assert(calo_indices->get("Signal", SubRun{1, 3}));
  assert(calo_indices->get("Background", SubRun{7, 9}));
}

#3 Updated by Kyle Knoepfel 11 months ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF