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 
65  std::string const& moduleLabel,
66  std::string const& processName,
67  std::string const& producedClassName,
68  std::string const& productInstanceName,
69  fhicl::ParameterSetID const& psetID,
70  ProcessConfigurationID const& processConfigurationID,
71  bool supportsView,
72  bool transient);
73 
74  void write(std::ostream& os) const;
75 
76  std::string const&
77  moduleLabel() const
78  {
79  return moduleLabel_;
80  }
81  std::string const&
82  processName() const
83  {
84  return processName_;
85  }
86  std::string const&
88  {
89  return producedClassName_;
90  }
91  std::string const&
93  {
94  return friendlyClassName_;
95  }
96  std::string const&
98  {
99  return productInstanceName_;
100  }
101 
102  InputTag
103  inputTag() const
104  {
105  return InputTag{moduleLabel(), productInstanceName(), processName()};
106  }
107 
108  bool
109  produced() const
110  {
111  return guts().validity_ == Transients::Produced;
112  }
113  bool
114  present() const
115  {
116  return guts().validity_ == Transients::PresentFromSource;
117  }
118  bool
119  dropped() const
120  {
121  return guts().validity_ == Transients::Dropped;
122  }
123  bool
124  transient() const
125  {
126  return guts().transient_;
127  }
128 
129  int
130  splitLevel() const
131  {
132  return guts().splitLevel_;
133  }
134  int
135  basketSize() const
136  {
137  return guts().basketSize_;
138  }
139  int
140  compression() const
141  {
142  return guts().compression_;
143  }
144 
145  std::set<fhicl::ParameterSetID> const&
146  psetIDs() const
147  {
148  return psetIDs_;
149  }
150 
151  ProductID
152  productID() const
153  {
154  return productID_;
155  }
156  BranchType
157  branchType() const
158  {
159  return branchType_;
160  }
161  bool
162  supportsView() const
163  {
164  return supportsView_;
165  }
166  std::string const&
167  branchName() const
168  {
169  return guts().branchName_;
170  }
171  std::string const&
172  wrappedName() const
173  {
174  return guts().wrappedName_;
175  }
176 
177  void merge(BranchDescription const& other);
178  void swap(BranchDescription& other);
179 
180  friend bool combinable(BranchDescription const&, BranchDescription const&);
181  friend bool operator<(BranchDescription const&, BranchDescription const&);
182  friend bool operator==(BranchDescription const&, BranchDescription const&);
183 
184  struct Transients {
185  Transients() = default;
186 
187  enum validity_state { Produced, PresentFromSource, Dropped, Invalid };
188 
189  // The branch name, which is currently derivable from the other
190  // attributes.
191  std::string branchName_{};
192 
193  // The wrapped class name, which is currently derivable from the
194  // other attributes.
195  std::string wrappedName_{};
196 
197  // Was this branch produced in this process rather than in a
198  // previous process
199  validity_state validity_{PresentFromSource};
200 
201  // Is the class of the branch marked as transient in the data
202  // dictionary
203  bool transient_{false};
204 
205  // N.B. ROOT-specific transient information will be fluffed by the
206  // BranchDescriptionStreamer::fluffRootTransients function.
207 
208  // The split level of the branch, as marked in the data
209  // dictionary.
210  int splitLevel_{};
211 
212  // The basket size of the branch, as marked in the data
213  // dictionary.
214  int basketSize_{};
215 
216  // The compression of the branch, as marked in the data
217  // dictionary.
218  int compression_{invalidCompression};
219  };
220 
221  void
223  {
224  guts().validity_ = state;
225  }
226 
227 private:
228  friend class detail::BranchDescriptionStreamer;
229 
230  bool
232  {
233  return !guts().branchName_.empty();
234  }
235  void initProductID_();
236  void fluffTransients_() const;
237 
238  fhicl::ParameterSetID const& psetID() const;
239  bool
241  {
242  return psetIDs().size() == 1;
243  }
244  std::set<ProcessConfigurationID> const&
246  {
247  return processConfigurationIDs_;
248  }
249 
250  Transients&
252  {
253  return transients_.get();
254  }
255  Transients const&
256  guts() const
257  {
258  return transients_.get();
259  }
260 
261  void throwIfInvalid_() const;
262 
263  // What tree is the branch in?
264  BranchType branchType_{InEvent};
265 
266  // A human friendly string that uniquely identifies the EDProducer
267  // and becomes part of the identity of a product that it produces
268  std::string moduleLabel_{};
269 
270  // the physical process that this program was part of (e.g. production)
271  std::string processName_{};
272 
273  // An ID uniquely identifying the product
274  ProductID productID_{};
275 
276  // the full name of the type of product this is
277  std::string producedClassName_{};
278 
279  // a readable name of the type of product this is
280  std::string friendlyClassName_{};
281 
282  // a user-supplied name to distinguish multiple products of the same type
283  // that are produced by the same producer
284  std::string productInstanceName_{};
285 
286  // Does this product support the concept of a view?
287  bool supportsView_{false};
288 
289  // ID's of parameter set of the creators of products
290  // on this branch
291  std::set<fhicl::ParameterSetID> psetIDs_{};
292 
293  // ID's of process configurations for products
294  // on this branch
295  std::set<ProcessConfigurationID> processConfigurationIDs_{};
296 
297  mutable Transient<Transients> transients_{};
298 }; // BranchDescription
299 
300 namespace art {
301  using ProductDescriptions = std::vector<BranchDescription>;
302 }
303 
304 #endif /* canvas_Persistency_Provenance_BranchDescription_h */
305 
306 // Local Variables:
307 // mode: c++
308 // 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
const char * p
Definition: xmltok.h:285
std::vector< BranchDescription > ProductDescriptions
InputTag inputTag() const
std::string const & producedClassName() const
write
Run ND cosmics.
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
const double a
BranchType branchType() const
ProductID productID() const
bool combinable(BranchDescription const &a, BranchDescription const &b)
void setValidity(Transients::validity_state const state)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string const & productInstanceName() const
const hit & b
Definition: hits.cxx:21
BranchType
Definition: BranchType.h:18
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
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
Definition: Hash.h:32