LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
BranchDescription.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_BranchDescription_h
2 #define canvas_Persistency_Provenance_BranchDescription_h
3 // vim: set sw=2 expandtab :
4 
5 // ================================================================================
6 // BranchDescription: The full description of a data-product branch.
7 // Equivalently,
8 // the event-independent description of an EDProduct.
9 // This description also applies to every product instance on the branch.
10 //
11 // FIXME: A better design would be:
12 //
13 // BranchDescription --owns--> ProductDescription --owns--> TypeDescription
14 //
15 // The BranchDescription class is what retains information necessary for
16 // interactions with ROOT. The ProductDescription contains information
17 // that is relevant for core framework processing.
18 // ================================================================================
19 
27 
28 #include <iosfwd>
29 #include <map>
30 #include <set>
31 #include <string>
32 #include <vector>
33 
34 namespace art {
35  class TypeLabel;
36 
37  namespace detail {
38  class BranchDescriptionStreamer;
39  }
40 
42 
43  friend bool combinable(BranchDescription const&, BranchDescription const&);
44  friend bool operator<(BranchDescription const&, BranchDescription const&);
45  friend bool operator==(BranchDescription const&, BranchDescription const&);
46 
47  friend class detail::BranchDescriptionStreamer;
48 
49  public: // TYPES
50  static int constexpr invalidSplitLevel{-1};
51  static int constexpr invalidBasketSize{0};
52  static int constexpr invalidCompression{-1};
53 
54  struct Transients {
55 
56  Transients() = default;
57 
58  enum validity_state { Produced, PresentFromSource, Dropped, Invalid };
59 
60  // The branch name, which is currently derivable from the other
61  // attributes.
62  std::string branchName_{};
63 
64  // The wrapped class name, which is currently derivable from the
65  // other attributes.
66  std::string wrappedName_{};
67 
68  // Is the class of the branch marked as transient in the data
69  // dictionary
70  bool transient_{false};
71 
72  // Was this branch produced in this process rather than in a
73  // previous process
74  validity_state validity_{PresentFromSource};
75 
76  // N.B. ROOT-specific transient information will be fluffed by the
77  // BranchDescriptionStreamer::fluffRootTransients function.
78 
79  // The split level of the branch, as marked in the data
80  // dictionary.
81  int splitLevel_{};
82 
83  // The basket size of the branch, as marked in the data
84  // dictionary.
85  int basketSize_{};
86 
87  // The compression of the branch, as marked in the data
88  // dictionary.
89  int compression_{invalidCompression};
90  };
91 
95  BranchDescription& operator=(BranchDescription const&);
98 
100  TypeLabel const& tl,
101  std::string const& moduleLabel,
102  fhicl::ParameterSetID const& modulePSetID,
103  ProcessConfiguration const& processConfig);
104 
106  std::string const& moduleLabel,
107  std::string const& processName,
108  std::string const& producedClassName,
109  std::string const& productInstanceName,
110  fhicl::ParameterSetID const& psetID,
111  ProcessConfigurationID const& processConfigurationID,
113  bool supportsView,
114  bool transient);
115 
116  void write(std::ostream& os) const;
117 
118  std::string const&
119  moduleLabel() const noexcept
120  {
121  return moduleLabel_;
122  }
123  std::string const&
124  processName() const noexcept
125  {
126  return processName_;
127  }
128  std::string const&
129  producedClassName() const noexcept
130  {
131  return producedClassName_;
132  }
133  std::string const&
134  friendlyClassName() const noexcept
135  {
136  return friendlyClassName_;
137  }
138  std::string const&
139  productInstanceName() const noexcept
140  {
141  return productInstanceName_;
142  }
143  InputTag
144  inputTag() const
145  {
146  return InputTag{moduleLabel(), productInstanceName(), processName()};
147  }
148 
149  bool
150  produced() const noexcept
151  {
152  return guts().validity_ == Transients::Produced;
153  }
154  bool
155  present() const noexcept
156  {
157  return guts().validity_ == Transients::PresentFromSource;
158  }
159  bool
160  dropped() const noexcept
161  {
162  return guts().validity_ == Transients::Dropped;
163  }
164  bool
165  transient() const noexcept
166  {
167  return guts().transient_;
168  }
169 
170  int
171  splitLevel() const noexcept
172  {
173  return guts().splitLevel_;
174  }
175  int
176  basketSize() const noexcept
177  {
178  return guts().basketSize_;
179  }
180  int
181  compression() const noexcept
182  {
183  return guts().compression_;
184  }
185 
186  std::set<fhicl::ParameterSetID> const&
187  psetIDs() const noexcept
188  {
189  return psetIDs_;
190  }
191 
192  ProductID
193  productID() const noexcept
194  {
195  return productID_;
196  }
197  BranchType
198  branchType() const noexcept
199  {
200  return branchType_;
201  }
202  bool
203  supportsView() const noexcept
204  {
205  return supportsView_;
206  }
207  std::string const&
208  branchName() const noexcept
209  {
210  return guts().branchName_;
211  }
212  std::string const&
213  wrappedName() const noexcept
214  {
215  return guts().wrappedName_;
216  }
217 
218  void merge(BranchDescription const& other);
219  void swap(BranchDescription& other);
220 
221  void
223  {
224  guts().validity_ = state;
225  }
226 
227  private:
228  fhicl::ParameterSetID const& psetID() const;
229 
230  void initProductID_();
231  void fluffTransients_() const;
232  bool transientsFluffed_() const noexcept;
233  bool isPsetIDUnique() const noexcept;
234 
235  std::set<ProcessConfigurationID> const& processConfigurationIDs()
236  const noexcept;
237 
238  Transients& guts() noexcept;
239  Transients const& guts() const noexcept;
240 
241  void throwIfInvalid_() const;
242 
243  // What tree is the branch in?
244  BranchType branchType_{InEvent};
245 
246  // A human-friendly string that uniquely identifies the EDProducer
247  // and becomes part of the identity of a product that it produces
248  std::string moduleLabel_{};
249 
250  // the physical process that this program was part of (e.g. production)
251  std::string processName_{};
252 
253  // An ID uniquely identifying the product
254  ProductID productID_{};
255 
256  // the full name of the type of product this is
257  std::string producedClassName_{};
258 
259  // a readable name of the type of product this is
260  std::string friendlyClassName_{};
261 
262  // a user-supplied name to distinguish multiple products of the same type
263  // that are produced by the same producer
264  std::string productInstanceName_{};
265 
266  // Does this product support the concept of a view?
267  bool supportsView_{false};
268 
269  // ID's of parameter set of the creators of products
270  // on this branch
271  std::set<fhicl::ParameterSetID> psetIDs_{};
272 
273  // ID's of process configurations for products
274  // on this branch
275  std::set<ProcessConfigurationID> processConfigurationIDs_{};
276 
277  // The things we do not want saved to disk.
278  mutable Transient<Transients> transients_{};
279  };
280 
281  std::ostream& operator<<(std::ostream&, BranchDescription const&);
282 
283  bool operator<(BranchDescription const&, BranchDescription const&);
284 
285  bool operator==(BranchDescription const&, BranchDescription const&);
286 
287  bool combinable(BranchDescription const&, BranchDescription const&);
288 
289  using ProductDescriptions = std::vector<BranchDescription>;
290  using ProductDescriptionsByID = std::map<ProductID, BranchDescription>;
291 
292 } // namespace art
293 
294 #endif /* canvas_Persistency_Provenance_BranchDescription_h */
295 
296 // Local Variables:
297 // mode: c++
298 // End:
bool produced() const noexcept
std::set< fhicl::ParameterSetID > const & psetIDs() const noexcept
std::string const & wrappedName() const noexcept
int basketSize() const noexcept
std::vector< BranchDescription > ProductDescriptions
bool supportsView() const noexcept
InputTag inputTag() const
bool present() const noexcept
std::string const & processName() const noexcept
BranchType branchType() const noexcept
bool operator<(ProductInfo const &a, ProductInfo const &b)
Definition: ProductInfo.cc:51
void swap(Handle< T > &a, Handle< T > &b)
bool dropped() const noexcept
int splitLevel() const noexcept
int compression() const noexcept
std::ostream & operator<<(std::ostream &os, Analyzer::Table< T > const &t)
Definition: Analyzer.h:135
bool combinable(BranchDescription const &a, BranchDescription const &b)
std::string const & moduleLabel() const noexcept
void setValidity(Transients::validity_state const state)
std::string const & productInstanceName() const noexcept
BranchType
Definition: BranchType.h:20
std::string const & producedClassName() const noexcept
Definition: MVAAlg.h:12
std::map< ProductID, BranchDescription > ProductDescriptionsByID
std::string const & friendlyClassName() const noexcept
std::string const & branchName() const noexcept
ProductID productID() const noexcept
Definition: Hash.h:34
bool operator==(ModuleKeyAndType const &a, ModuleKeyAndType const &b) noexcept