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