Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
art::SamplingInput Class Reference
Inheritance diagram for art::SamplingInput:
art::InputSource

Classes

struct  Config
 

Public Types

using Parameters = WrappedTable< Config, Config::KeysToIgnore >
 
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Public Member Functions

 SamplingInput (Parameters const &config, InputSourceDescription &isd)
 
template<typename T >
std::enable_if_t< art::detail::RangeSetsSupported< T::branch_type >::valueputSampledProductsInto_ (T &principal, Products_t read_products, RangeSet &&rs) const
 
auto const & moduleDescription () const
 
auto const & processConfiguration () const
 
virtual void skipEvents (int n)
 
virtual void rewind ()
 
virtual void doBeginJob ()
 
virtual void doEndJob ()
 

Private Member Functions

template<typename T >
std::enable_if_t< detail::RangeSetsSupported< T::branch_type >::valueputSampledProductsInto_ (T &principal, Products_t read_products, RangeSet &&rs) const
 
input::ItemType nextItemType () override
 
std::unique_ptr< FileBlockreadFile () override
 
void closeFile () override
 
std::unique_ptr< RunPrincipalreadRun () override
 
std::unique_ptr< SubRunPrincipalreadSubRun (cet::exempt_ptr< RunPrincipal const > rp) override
 
std::unique_ptr< EventPrincipalreadEvent (cet::exempt_ptr< SubRunPrincipal const > srp) override
 
std::unique_ptr< RangeSetHandlerrunRangeSetHandler () override
 
std::unique_ptr< RangeSetHandlersubRunRangeSetHandler () override
 

Private Attributes

ModuleDescription const md_
 
ProcessConfiguration const & pc_
 
RunID runID_
 
SubRunID subRunID_
 
EventID nextEventID_
 
input::ItemType currentItemType_ {input::IsInvalid}
 
unsigned eventsLeft_
 
unsigned totalCounts_ {}
 
detail::DataSetBroker dataSetBroker_
 
bool const summary_
 
bool const delayedReadEventProducts_
 
std::map< BranchKey, BranchDescriptionoldKeyToSampledProductDescription_
 
BranchDescription sampledRunInfoDesc_
 
BranchDescription sampledSubRunInfoDesc_
 
BranchDescription sampledEventInfoDesc_
 
ProcessConfigurations sampledProcessConfigs_ {}
 
ProcessHistoryID sampledProcessHistoryID_ {}
 
ProductTable presentSubRunProducts_
 
ProductTable presentRunProducts_
 

Detailed Description

Definition at line 128 of file SamplingInput_source.cc.

Member Typedef Documentation

Definition at line 207 of file SamplingInput_source.cc.

Member Enumeration Documentation

Enumerator
Runs 
RunsAndSubRuns 
RunsSubRunsAndEvents 

Definition at line 52 of file InputSource.h.

Constructor & Destructor Documentation

art::SamplingInput::SamplingInput ( Parameters const &  config,
art::InputSourceDescription isd 
)
explicit

Definition at line 267 of file SamplingInput_source.cc.

References gen_flatrecord::config, dataSetBroker_, delayedReadEventProducts_, eventsLeft_, art::EventID::firstEvent(), art::RunID::firstRun(), art::SubRunID::firstSubRun(), art::InEvent, art::InRun, art::InSubRun, md_, art::InputSourceDescription::moduleDescription, nextEventID_, oldKeyToSampledProductDescription_, art::detail::DataSetBroker::openInputFiles(), pc_, gammaraytel::pr, presentRunProducts_, presentSubRunProducts_, art::ModuleDescription::processConfiguration(), r(), runID_, sampledEventInfoDesc_, sampledProcessConfigs_, sampledProcessHistoryID_, sampledRunInfoDesc_, sampledSubRunInfoDesc_, sr, subRunID_, and summary_.

270  , md_{isd.moduleDescription}
272  , eventsLeft_{config().maxEvents()}
273  , dataSetBroker_{config().dataSets.get<ParameterSet>()}
274  , summary_{config().summary()}
275  , delayedReadEventProducts_{config().delayedReadEventProducts()}
276 {
277  auto const readParameterSets = config().readParameterSets();
278  if (!readParameterSets) {
279  mf::LogWarning("PROVENANCE")
280  << "Source parameter readParameterSets was set to false: parameter set "
281  "provenance\n"
282  << "will NOT be available in this or subsequent jobs using output from "
283  "this job.\n"
284  << "Check your experiment's policy on this issue to avoid future "
285  "problems\n"
286  << "with analysis reproducibility.";
287  }
288 
289  RunNumber_t r{};
290  bool const haveFirstRun = config().run(r);
291  runID_ = haveFirstRun ? RunID{r} : RunID::firstRun();
292 
293  SubRunNumber_t sr{};
294  bool const haveFirstSubRun = config().subRun(sr);
295  subRunID_ =
296  haveFirstSubRun ? SubRunID{runID_, sr} : SubRunID::firstSubRun(runID_);
297 
298  EventNumber_t event{};
299  bool const haveFirstEvent = config().firstEvent(event);
300  nextEventID_ =
301  haveFirstEvent ? EventID{subRunID_, event} : EventID::firstEvent(subRunID_);
302 
303  // Register SampledRunInfo, SampledSubRunInfo, and SampledEventInfo data
304  ProductDescriptions presentSampledProducts;
305  auto const emulated_module_name = "SamplingInput"s;
306  presentSampledProducts.emplace_back(
307  InEvent,
308  type_label_for<SampledEventInfo>(emulated_module_name),
309  isd.moduleDescription);
310  sampledEventInfoDesc_ = presentSampledProducts.back();
311  presentSampledProducts.emplace_back(
312  InSubRun,
313  type_label_for<SampledSubRunInfo>(emulated_module_name),
314  isd.moduleDescription);
315  sampledSubRunInfoDesc_ = presentSampledProducts.back();
316  presentSampledProducts.emplace_back(
317  InRun,
318  type_label_for<SampledRunInfo>(emulated_module_name),
319  isd.moduleDescription);
320  sampledRunInfoDesc_ = presentSampledProducts.back();
321 
323  dataSetBroker_.openInputFiles(config().inputCommands(),
324  config().dropDescendantsOfDroppedBranches(),
325  config().treeCacheSize(),
326  config().treeMaxVirtualSize(),
327  config().saveMemoryObjectThreshold(),
329  config().compactRanges(),
330  md_,
331  readParameterSets,
332  isd.productRegistry);
333 
335  sampled_process_configurations(oldKeyToSampledProductDescription_, pc_);
336  sampledProcessHistoryID_ = sampled_process_history_id(sampledProcessConfigs_);
337 
338  for (auto const& pr : oldKeyToSampledProductDescription_) {
339  presentSampledProducts.push_back(pr.second);
340  }
341 
342  // Specify present products for SubRuns and Runs. Only the
343  // Sampled(Sub)RunInfo products are present for the (Sub)Runs.
344  presentSubRunProducts_ = ProductTable{presentSampledProducts, InSubRun};
345  presentRunProducts_ = ProductTable{presentSampledProducts, InRun};
346 
348  ProductDescriptions{presentSampledProducts});
349 }
BranchDescription sampledRunInfoDesc_
MasterProductRegistry & productRegistry
bool const delayedReadEventProducts_
static EventID firstEvent()
Definition: EventID.h:190
std::vector< BranchDescription > ProductDescriptions
ProcessConfigurations sampledProcessConfigs_
ProductTable presentRunProducts_
detail::DataSetBroker dataSetBroker_
const XML_Char * s
Definition: expat.h:262
BranchDescription sampledEventInfoDesc_
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
caf::StandardRecord * sr
static SubRunID firstSubRun()
Definition: SubRunID.h:151
std::map< BranchKey, BranchDescription > openInputFiles(std::vector< std::string > const &inputCommands, bool dropDescendants, unsigned int treeCacheSize, int64_t treeMaxVirtualSize, int64_t saveMemoryObjectThreshold, BranchDescription const &sampledEventInfoDesc, bool const compactRangeSetsForReading, ModuleDescription const &md, bool const readParameterSets, MasterProductRegistry &preg)
ProcessConfiguration const & pc_
std::map< BranchKey, BranchDescription > oldKeyToSampledProductDescription_
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
ModuleDescription const & moduleDescription
TRandom3 r(0)
ProcessHistoryID sampledProcessHistoryID_
ModuleDescription const md_
static RunID firstRun()
Definition: RunID.h:114
BranchDescription sampledSubRunInfoDesc_
void addProductsFromModule(ProductDescriptions &&)
ProductTable presentSubRunProducts_
ProcessConfiguration const & processConfiguration() const
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119

Member Function Documentation

void art::SamplingInput::closeFile ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 359 of file SamplingInput_source.cc.

References art::detail::DataSetBroker::countSummary(), dataSetBroker_, and summary_.

360 {
361  if (!summary_)
362  return;
363 
365 }
detail::DataSetBroker dataSetBroker_
virtual void art::InputSource::doBeginJob ( )
virtualinherited
virtual void art::InputSource::doEndJob ( )
virtualinherited
auto const& art::InputSource::moduleDescription ( ) const
inlineinherited

Definition at line 59 of file InputSource.h.

Referenced by art::EmptyEvent::readRun_(), and art::EmptyEvent::readSubRun_().

60  {
61  return moduleDescription_;
62  }
ModuleDescription moduleDescription_
Definition: InputSource.h:93
art::input::ItemType art::SamplingInput::nextItemType ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 368 of file SamplingInput_source.cc.

References art::detail::DataSetBroker::canReadEvent(), currentItemType_, dataSetBroker_, eventsLeft_, art::input::IsEvent, art::input::IsFile, art::input::IsInvalid, art::input::IsRun, art::input::IsStop, art::input::IsSubRun, totalCounts_, and submit_hadd::u.

369 {
370  switch (currentItemType_) {
371  case input::IsInvalid: {
373  }
374  case input::IsFile: {
376  }
377  case input::IsRun: {
379  }
380  case input::IsSubRun: {
381  // Do not return prematurely when moving to the event.
383  }
384  default: {} // Handle other transitions below.
385  }
386 
387  if (eventsLeft_ == 0u) {
388  return input::IsStop;
389  }
390 
391  bool const inputExhausted = !dataSetBroker_.canReadEvent();
392 
393  if (inputExhausted) {
394  return input::IsStop;
395  }
396 
397  --eventsLeft_;
398  ++totalCounts_;
399  return input::IsEvent;
400 }
input::ItemType currentItemType_
detail::DataSetBroker dataSetBroker_
auto const& art::InputSource::processConfiguration ( ) const
inlineinherited

Definition at line 64 of file InputSource.h.

References getGoodRuns4SAM::n.

Referenced by art::EmptyEvent::readRun_(), art::EmptyEvent::readSubRun_(), art::EmptyEvent::reallyReadEvent(), and art::RootInput::RootInput().

65  {
67  }
ModuleDescription moduleDescription_
Definition: InputSource.h:93
ProcessConfiguration const & processConfiguration() const
template<typename T >
std::enable_if_t<detail::RangeSetsSupported<T::branch_type>::value> art::SamplingInput::putSampledProductsInto_ ( T principal,
Products_t  read_products,
RangeSet &&  rs 
) const
private

Referenced by readRun(), and readSubRun().

template<typename T >
std::enable_if_t<art::detail::RangeSetsSupported<T::branch_type>::value> art::SamplingInput::putSampledProductsInto_ ( T principal,
Products_t  read_products,
RangeSet &&  rs 
) const

Definition at line 404 of file SamplingInput_source.cc.

References oldKeyToSampledProductDescription_, gammaraytel::pr, and art::productstatus::present().

407 {
408  for (auto const& pr : oldKeyToSampledProductDescription_) {
409  auto const& old_key = pr.first;
410  if (old_key.branchType_ != principal.branchType())
411  continue;
412 
413  auto const& sampled_pd = pr.second;
414 
415  principal.put(make_sampled_product(read_products, old_key),
416  sampled_pd,
417  std::make_unique<ProductProvenance const>(
418  sampled_pd.productID(), productstatus::present()),
419  std::move(rs));
420  }
421 }
std::map< BranchKey, BranchDescription > oldKeyToSampledProductDescription_
constexpr ProductStatus present() noexcept
Definition: ProductStatus.h:10
std::unique_ptr< art::EventPrincipal > art::SamplingInput::readEvent ( cet::exempt_ptr< SubRunPrincipal const >  srp)
overrideprivatevirtual

Implements art::InputSource.

Definition at line 476 of file SamplingInput_source.cc.

References dataSetBroker_, delayedReadEventProducts_, lem_server::ep, art::detail::issue_reports(), art::EventID::next(), nextEventID_, pc_, art::detail::DataSetBroker::readNextEvent(), sampledProcessConfigs_, and totalCounts_.

477 {
479 
480  auto ep =
482  ep->setSubRunPrincipal(srp);
484  ep->readImmediate();
485  }
487  return ep;
488 }
bool const delayedReadEventProducts_
ProcessConfigurations sampledProcessConfigs_
detail::DataSetBroker dataSetBroker_
void issue_reports(unsigned count, EventID const &id)
EventID next() const
Definition: EventID.h:134
ProcessConfiguration const & pc_
std::unique_ptr< EventPrincipal > readNextEvent(EventID const &id, ProcessConfigurations const &sampled_pcs, ProcessConfiguration const &current_pc)
std::unique_ptr< art::FileBlock > art::SamplingInput::readFile ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 352 of file SamplingInput_source.cc.

353 {
354  return std::make_unique<art::FileBlock>(
355  art::FileFormatVersion{1, "SamplingInput_2018"}, "SamplingInput");
356 }
std::unique_ptr< art::RunPrincipal > art::SamplingInput::readRun ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 424 of file SamplingInput_source.cc.

References dataSetBroker_, art::RangeSet::forRun(), cet::make_exempt_ptr(), pc_, art::productstatus::present(), presentRunProducts_, art::BranchDescription::productID(), putSampledProductsInto_(), art::detail::DataSetBroker::readAllRunProducts(), runID_, sampledProcessHistoryID_, and sampledRunInfoDesc_.

425 {
426  Products_t read_products;
427  auto sampledRunInfo = dataSetBroker_.readAllRunProducts(read_products);
428 
429  art::RunAuxiliary aux{runID_, nullTimestamp(), nullTimestamp()};
430  aux.setProcessHistoryID(sampledProcessHistoryID_);
431 
432  auto rp = std::make_unique<art::RunPrincipal>(
434 
436  *rp, std::move(read_products), RangeSet::forRun(runID_));
437 
438  // Place sampled run info onto the run
439  auto wp = std::make_unique<Wrapper<SampledRunInfo>>(move(sampledRunInfo));
440  rp->put(std::move(wp),
442  std::make_unique<ProductProvenance const>(
445  return rp;
446 }
BranchDescription sampledRunInfoDesc_
std::enable_if_t< detail::RangeSetsSupported< T::branch_type >::value > putSampledProductsInto_(T &principal, Products_t read_products, RangeSet &&rs) const
std::unique_ptr< SampledRunInfo > readAllRunProducts(Products_t &read_products)
ProductTable presentRunProducts_
detail::DataSetBroker dataSetBroker_
static RangeSet forRun(RunID)
exempt_ptr< E > make_exempt_ptr(E *) noexcept
ProductID productID() const
std::map< BranchKey, ProductsForDataset_t > Products_t
Definition: DataSetBroker.h:19
ProcessConfiguration const & pc_
ProcessHistoryID sampledProcessHistoryID_
constexpr ProductStatus present() noexcept
Definition: ProductStatus.h:10
std::unique_ptr< art::SubRunPrincipal > art::SamplingInput::readSubRun ( cet::exempt_ptr< RunPrincipal const >  rp)
overrideprivatevirtual

Implements art::InputSource.

Definition at line 449 of file SamplingInput_source.cc.

References dataSetBroker_, art::RangeSet::forSubRun(), cet::make_exempt_ptr(), pc_, art::productstatus::present(), presentSubRunProducts_, art::BranchDescription::productID(), putSampledProductsInto_(), art::detail::DataSetBroker::readAllSubRunProducts(), sampledProcessHistoryID_, sampledSubRunInfoDesc_, and subRunID_.

450 {
451  Products_t read_products;
452  auto sampledSubRunInfo = dataSetBroker_.readAllSubRunProducts(read_products);
453 
454  art::SubRunAuxiliary aux{subRunID_, nullTimestamp(), nullTimestamp()};
455  aux.setProcessHistoryID(sampledProcessHistoryID_);
456 
457  auto srp = std::make_unique<SubRunPrincipal>(
459  srp->setRunPrincipal(rp);
460 
462  *srp, std::move(read_products), RangeSet::forSubRun(subRunID_));
463 
464  // Place sampled run info onto the run
465  auto wp =
466  std::make_unique<Wrapper<SampledSubRunInfo>>(move(sampledSubRunInfo));
467  srp->put(std::move(wp),
469  std::make_unique<ProductProvenance const>(
472  return srp;
473 }
std::enable_if_t< detail::RangeSetsSupported< T::branch_type >::value > putSampledProductsInto_(T &principal, Products_t read_products, RangeSet &&rs) const
static RangeSet forSubRun(SubRunID)
detail::DataSetBroker dataSetBroker_
std::unique_ptr< SampledSubRunInfo > readAllSubRunProducts(Products_t &read_products)
exempt_ptr< E > make_exempt_ptr(E *) noexcept
ProductID productID() const
std::map< BranchKey, ProductsForDataset_t > Products_t
Definition: DataSetBroker.h:19
ProcessConfiguration const & pc_
ProcessHistoryID sampledProcessHistoryID_
BranchDescription sampledSubRunInfoDesc_
ProductTable presentSubRunProducts_
constexpr ProductStatus present() noexcept
Definition: ProductStatus.h:10
virtual void art::InputSource::rewind ( )
virtualinherited
std::unique_ptr< art::RangeSetHandler > art::SamplingInput::runRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 491 of file SamplingInput_source.cc.

References art::RunID::run(), and runID_.

492 {
493  return std::make_unique<art::OpenRangeSetHandler>(runID_.run());
494 }
RunNumber_t run() const
Definition: RunID.h:62
virtual void art::InputSource::skipEvents ( int  n)
virtualinherited
std::unique_ptr< art::RangeSetHandler > art::SamplingInput::subRunRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 497 of file SamplingInput_source.cc.

References DEFINE_ART_INPUT_SOURCE, art::SubRunID::run(), and subRunID_.

498 {
499  return std::make_unique<art::OpenRangeSetHandler>(subRunID_.run());
500 }
RunNumber_t run() const
Definition: SubRunID.h:83

Member Data Documentation

input::ItemType art::SamplingInput::currentItemType_ {input::IsInvalid}
private

Definition at line 234 of file SamplingInput_source.cc.

Referenced by nextItemType().

detail::DataSetBroker art::SamplingInput::dataSetBroker_
private
bool const art::SamplingInput::delayedReadEventProducts_
private

Definition at line 239 of file SamplingInput_source.cc.

Referenced by readEvent(), and SamplingInput().

unsigned art::SamplingInput::eventsLeft_
private

Definition at line 235 of file SamplingInput_source.cc.

Referenced by nextItemType(), and SamplingInput().

ModuleDescription const art::SamplingInput::md_
private

Definition at line 229 of file SamplingInput_source.cc.

Referenced by SamplingInput().

EventID art::SamplingInput::nextEventID_
private

Definition at line 233 of file SamplingInput_source.cc.

Referenced by readEvent(), and SamplingInput().

std::map<BranchKey, BranchDescription> art::SamplingInput::oldKeyToSampledProductDescription_
private

Definition at line 240 of file SamplingInput_source.cc.

Referenced by putSampledProductsInto_(), and SamplingInput().

ProcessConfiguration const& art::SamplingInput::pc_
private

Definition at line 230 of file SamplingInput_source.cc.

Referenced by readEvent(), readRun(), readSubRun(), and SamplingInput().

ProductTable art::SamplingInput::presentRunProducts_
private

Definition at line 247 of file SamplingInput_source.cc.

Referenced by readRun(), and SamplingInput().

ProductTable art::SamplingInput::presentSubRunProducts_
private

Definition at line 246 of file SamplingInput_source.cc.

Referenced by readSubRun(), and SamplingInput().

RunID art::SamplingInput::runID_
private

Definition at line 231 of file SamplingInput_source.cc.

Referenced by readRun(), runRangeSetHandler(), and SamplingInput().

BranchDescription art::SamplingInput::sampledEventInfoDesc_
private

Definition at line 243 of file SamplingInput_source.cc.

Referenced by SamplingInput().

ProcessConfigurations art::SamplingInput::sampledProcessConfigs_ {}
private

Definition at line 244 of file SamplingInput_source.cc.

Referenced by readEvent(), and SamplingInput().

ProcessHistoryID art::SamplingInput::sampledProcessHistoryID_ {}
private

Definition at line 245 of file SamplingInput_source.cc.

Referenced by readRun(), readSubRun(), and SamplingInput().

BranchDescription art::SamplingInput::sampledRunInfoDesc_
private

Definition at line 241 of file SamplingInput_source.cc.

Referenced by readRun(), and SamplingInput().

BranchDescription art::SamplingInput::sampledSubRunInfoDesc_
private

Definition at line 242 of file SamplingInput_source.cc.

Referenced by readSubRun(), and SamplingInput().

SubRunID art::SamplingInput::subRunID_
private

Definition at line 232 of file SamplingInput_source.cc.

Referenced by readSubRun(), SamplingInput(), and subRunRangeSetHandler().

bool const art::SamplingInput::summary_
private

Definition at line 238 of file SamplingInput_source.cc.

Referenced by closeFile(), and SamplingInput().

unsigned art::SamplingInput::totalCounts_ {}
private

Definition at line 236 of file SamplingInput_source.cc.

Referenced by nextItemType(), and readEvent().


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