LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ProductTables.cc
Go to the documentation of this file.
4 #include "cetlib/container_algorithms.h"
5 
6 using namespace art;
7 
8 namespace {
9  auto
10  descriptions_for_branch_type(BranchType const bt,
11  ProductDescriptions const& descriptions)
12  {
13  ProductDescriptions result;
14  cet::copy_if_all(descriptions, back_inserter(result), [bt](auto const& pd) {
15  return pd.branchType() == bt;
16  });
17  return result;
18  }
19 
20  auto
21  available_products(ProductDescriptions const& descriptions)
22  {
23  AvailableProducts_t result;
24  cet::transform_all(descriptions,
25  inserter(result, begin(result)),
26  [](auto const& pd) { return pd.productID(); });
27  return result;
28  }
29 
30  using ProductTables_t = std::array<ProductTable, NumBranchTypes>;
31  auto
32  createProductTables(ProductDescriptions const& descriptions)
33  {
34  ProductTables_t result{{}};
35  for (std::size_t bt{}; bt < NumBranchTypes; ++bt) {
36  result[bt] = ProductTable{descriptions, static_cast<BranchType>(bt)};
37  }
38  return result;
39  }
40 
41  auto
42  createProductTables(
43  ProductDescriptions const& descriptions,
44  std::array<AvailableProducts_t, NumBranchTypes> const& availableProducts)
45  {
46  ProductTables_t result{{}};
47  for (std::size_t bt{}; bt < NumBranchTypes; ++bt) {
48  result[bt] = ProductTable{
49  descriptions, static_cast<BranchType>(bt), availableProducts[bt]};
50  }
51  return result;
52  }
53 }
54 
55 // =======================================================================
56 
58  BranchType const bt)
59  : ProductTable{
60  descriptions,
61  bt,
62  available_products(descriptions_for_branch_type(bt, descriptions))}
63 {}
64 
66  BranchType const bt,
68  : isValid{true}
70  descriptions_for_branch_type(bt, descriptions))}
72  descriptions_for_branch_type(bt, descriptions))}
74 {}
75 
78 {
79  return ProductTables{};
80 }
81 
83  : tables_{createProductTables(descriptions)}
84 {}
85 
87  ProductDescriptions const& descriptions,
88  std::array<AvailableProducts_t, NumBranchTypes> const& availableProducts)
89  : tables_{createProductTables(descriptions, availableProducts)}
90 {}
ProductTable()=default
std::array< ProductTable, NumBranchTypes > tables_
Definition: ProductTables.h:55
AvailableProducts_t availableProducts
Definition: ProductTables.h:28
std::vector< BranchDescription > ProductDescriptions
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
ProductLookup_t createProductLookups(ProductDescriptions const &descriptions)
ViewLookup_t viewLookup
Definition: ProductTables.h:27
static ProductTables invalid()
ProductTables()=default
BranchType
Definition: BranchType.h:18
HLT enums.
std::unordered_set< ProductID, ProductID::Hash > AvailableProducts_t
Definition: type_aliases.h:21
ProductLookup_t productLookup
Definition: ProductTables.h:26
ViewLookup_t createViewLookups(ProductDescriptions const &descriptions)