LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
BranchDescription.cc
Go to the documentation of this file.
2 // vim: set sw=2:
3 
11 
12 #include <cassert>
13 #include <cstdlib>
14 #include <ostream>
15 #include <sstream>
16 
18 
19 namespace {
20  void
21  throwExceptionWithText(char const* txt)
22  {
24  << "Problem using an incomplete BranchDescription\n"
25  << txt << "\nPlease report this error to the ART developers\n";
26  }
27 }
28 
29 namespace art {
30 
32  TypeLabel const& tl,
33  ModuleDescription const& md)
34  : branchType_{bt}
35  , moduleLabel_{tl.hasEmulatedModule() ? tl.emulatedModule() :
36  md.moduleLabel()}
37  , processName_{md.processName()}
38  , producedClassName_{tl.className()}
39  , friendlyClassName_{tl.friendlyClassName()}
40  , productInstanceName_{tl.productInstanceName()}
41  , supportsView_{tl.supportsView()}
42  {
44  guts().transient_ = tl.transient();
45  psetIDs_.insert(md.parameterSetID());
46  processConfigurationIDs_.insert(md.processConfigurationID());
50  }
51 
52  void
54  {
55  if (!transientsFluffed_()) {
56  return;
57  }
58  if (!productID_.isValid()) {
59  productID_.setID(guts().branchName_);
60  }
61  }
62 
63  void
65  {
66  if (transientsFluffed_()) {
67  return;
68  }
69  transients_.get().branchName_ = canonicalProductName(
71  transients_.get().wrappedName_ = wrappedClassName(producedClassName_);
72  }
73 
74  ParameterSetID const&
76  {
77  assert(!psetIDs().empty());
78  if (psetIDs().size() != 1) {
79  throw Exception(errors::Configuration, "AmbiguousProvenance")
80  << "Your application requires all events on Branch '"
81  << guts().branchName_
82  << "'\n to have the same provenance. This file has events with "
83  "mixed provenance\n"
84  << "on this branch. Use a different input file.\n";
85  }
86  return *psetIDs().begin();
87  }
88 
89  void
91  {
92  psetIDs_.insert(other.psetIDs().begin(), other.psetIDs().end());
94  other.processConfigurationIDs().end());
96  guts().splitLevel_ = other.guts().splitLevel_;
97  }
98  if (guts().basketSize_ == invalidBasketSize) {
99  guts().basketSize_ = other.guts().basketSize_;
100  }
101  // FIXME: This is probably wrong! We are going from defaulted compression
102  // to a possibly different compression, bad.
103  if (guts().compression_ == invalidCompression) {
104  guts().compression_ = other.guts().compression_;
105  }
106  }
107 
108  void
109  BranchDescription::write(std::ostream& os) const
110  {
111  os << "Branch Type = " << branchType_ << std::endl;
112  os << "Process Name = " << processName() << std::endl;
113  os << "ModuleLabel = " << moduleLabel() << std::endl;
114  os << "Product ID = " << productID() << '\n';
115  os << "Class Name = " << producedClassName() << '\n';
116  os << "Friendly Class Name = " << friendlyClassName() << '\n';
117  os << "Product Instance Name = " << productInstanceName() << std::endl;
118  }
119 
120  void
122  {
123  using std::swap;
124  swap(branchType_, other.branchType_);
127  swap(productID_, other.productID_);
132  swap(psetIDs_, other.psetIDs_);
134  swap(transients_, other.transients_);
135  }
136 
137  void
139  {
140  constexpr char underscore{'_'};
141  if (transientsFluffed_()) {
142  return;
143  }
144  if (branchType_ >= NumBranchTypes) {
145  throwExceptionWithText("Illegal BranchType detected");
146  }
147  if (moduleLabel_.empty()) {
148  throwExceptionWithText("Module label is not allowed to be empty");
149  }
150  if (processName_.empty()) {
151  throwExceptionWithText("Process name is not allowed to be empty");
152  }
153  if (producedClassName_.empty()) {
154  throwExceptionWithText("Full class name is not allowed to be empty");
155  }
156  if (friendlyClassName_.empty()) {
157  throwExceptionWithText("Friendly class name is not allowed to be empty");
158  }
159  if (friendlyClassName_.find(underscore) != std::string::npos) {
160  throw Exception(errors::LogicError, "IllegalCharacter")
161  << "Class name '" << friendlyClassName()
162  << "' contains an underscore ('_'), which is illegal in the "
163  << "name of a product.\n";
164  }
165  if (moduleLabel_.find(underscore) != std::string::npos) {
166  throw Exception(errors::Configuration, "IllegalCharacter")
167  << "Module label '" << moduleLabel()
168  << "' contains an underscore ('_'), which is illegal in a "
169  << "module label.\n";
170  }
171  if (productInstanceName_.find(underscore) != std::string::npos) {
172  throw Exception(errors::Configuration, "IllegalCharacter")
173  << "Product instance name '" << productInstanceName()
174  << "' contains an underscore ('_'), which is illegal in a "
175  << "product instance name.\n";
176  }
177  if (processName_.find(underscore) != std::string::npos) {
178  throw Exception(errors::Configuration, "IllegalCharacter")
179  << "Process name '" << processName()
180  << "' contains an underscore ('_'), which is illegal in a "
181  << "process name.\n";
182  }
183  }
184 
185  bool
187  {
188  if (a.processName() < b.processName()) {
189  return true;
190  }
191  if (b.processName() < a.processName()) {
192  return false;
193  }
194  if (a.producedClassName() < b.producedClassName()) {
195  return true;
196  }
197  if (b.producedClassName() < a.producedClassName()) {
198  return false;
199  }
200  if (a.friendlyClassName() < b.friendlyClassName()) {
201  return true;
202  }
203  if (b.friendlyClassName() < a.friendlyClassName()) {
204  return false;
205  }
207  return true;
208  }
210  return false;
211  }
212  if (a.moduleLabel() < b.moduleLabel()) {
213  return true;
214  }
215  if (b.moduleLabel() < a.moduleLabel()) {
216  return false;
217  }
218  if (a.branchType() < b.branchType()) {
219  return true;
220  }
221  if (b.branchType() < a.branchType()) {
222  return false;
223  }
224  if (a.productID() < b.productID()) {
225  return true;
226  }
227  if (b.productID() < a.productID()) {
228  return false;
229  }
230  if (a.psetIDs() < b.psetIDs()) {
231  return true;
232  }
233  if (b.psetIDs() < a.psetIDs()) {
234  return false;
235  }
237  return true;
238  }
240  return false;
241  }
242  return false;
243  }
244 
245  bool
247  {
248  return (a.branchType() == b.branchType()) &&
249  (a.processName() == b.processName()) &&
250  (a.producedClassName() == b.producedClassName()) &&
251  (a.friendlyClassName() == b.friendlyClassName()) &&
253  (a.moduleLabel() == b.moduleLabel()) &&
254  (a.productID() == b.productID());
255  }
256 
257  bool
259  {
260  return combinable(a, b) && (a.psetIDs() == b.psetIDs()) &&
262  }
263 
264  std::ostream&
265  operator<<(std::ostream& os, BranchDescription const& p)
266  {
267  p.write(os);
268  return os;
269  }
270 
271 } // namespace art
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
fhicl::ParameterSetID const & psetID() const
bool transientsFluffed_() const
std::set< fhicl::ParameterSetID > const & psetIDs() const
void merge(BranchDescription const &other)
void fluffTransients_() const
std::string wrappedClassName(std::string const &className)
static int constexpr invalidCompression
friend bool operator<(BranchDescription const &, BranchDescription const &)
std::set< ProcessConfigurationID > processConfigurationIDs_
std::string const & producedClassName() const
bool isValid() const
Definition: ProductID.h:33
std::string const & moduleLabel() const
BranchType branchType() const
static int constexpr invalidSplitLevel
void swap(BranchDescription &other)
std::string canonicalProductName(std::string const &friendlyClassName, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName)
ProductID productID() const
void setID(std::string const &canonicalProductName)
Definition: ProductID.cc:15
void write(std::ostream &os) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::set< fhicl::ParameterSetID > psetIDs_
std::string const & productInstanceName() const
BranchType
Definition: BranchType.h:18
HLT enums.
std::set< ProcessConfigurationID > const & processConfigurationIDs() const
std::string const & processName() const
friend bool combinable(BranchDescription const &, BranchDescription const &)
static int constexpr invalidBasketSize
friend bool operator==(BranchDescription const &, BranchDescription const &)
Transient< Transients > transients_
std::string const & friendlyClassName() const