For processes that use the
SamplingInput source, access to event products is supported in the same manner as it is for (e.g.) the
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 is provided. Consider the following input datasets:
|Type||Module label||Instance name||Process name|
If the "Signal" and "Background" datasets were inputs to a job using
SamplingInput, (sub)run products can be accessed by using the
// 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 for the products and (sub)runs listed above.
art::Sampled<T> class template is not able to support
art::Ptr-based products due to
Ptr-reseeding issues. A run-time exception will be thrown if an attempt is made to create a product that explicitly mentions either
art::Ptr in its name. No diagnostic error can be emitted for attempts to created a sampled product that implicitly depends on
art::Ptrs. Please contact email@example.com for guidance.
Due to the complicated nature of forming sampled products, for each
art::Sampled<MyProduct> object to be persisted to disk, additional dictionaries must be formed. For those who use
classes_def.xml files, the following should be added:
<lcgdict> ... <class name="std::map<art::SubRunID,MyProduct>"/> <class name="std::map<std::string,std::map<art::SubRunID,MyProduct>>"/> <class name="art::Sampled<MyProduct>"/> <class name="art::Wrapper<art::Sampled<MyProduct>>"/> ... </lcgdict>
classes.h file the following line header dependencies should appear:
#include "canvas/Persistency/Common/Sampled.h" #include "canvas/Persistency/Common/Wrapper.h"