CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProcessBlockHelperBase.cc
Go to the documentation of this file.
2 
8 
9 #include <algorithm>
10 #include <iterator>
11 
12 namespace edm {
13 
15 
17  std::string const& processName) {
18  // Add the current process at the end if there are any
19  // process blocks produced in the current process.
20  for (auto const& product : productRegistry.productList()) {
21  auto const& desc = product.second;
22  if (desc.branchType() == InProcess && desc.produced() && !desc.transient()) {
23  processesWithProcessBlockProducts_.emplace_back(processName);
24  addedProcesses_.emplace_back(processName);
25  return;
26  }
27  }
28  }
29 
32  TypeID const& typeID) const {
33  std::string processName(productLabels.process);
34  std::string selectedProcess;
35 
36  unsigned int bestPosition = 0;
37  for (auto const& prod : productRegistry.productList()) {
38  BranchDescription const& desc = prod.second;
39  if (desc.branchType() == InProcess && !desc.produced() && desc.present() &&
40  desc.moduleLabel() == productLabels.module && desc.productInstanceName() == productLabels.productInstance &&
41  desc.unwrappedTypeID() == typeID && (processName.empty() || processName == desc.processName())) {
42  // This code is to select the latest matching process
43  auto found =
44  std::find_if(processesWithProcessBlockProducts_.begin(),
46  [&desc](auto const& processFromHelper) { return processFromHelper == desc.processName(); });
48  const unsigned int position = std::distance(processesWithProcessBlockProducts_.begin(), found);
49  if (position >= bestPosition) {
50  bestPosition = position;
51  selectedProcess = desc.processName();
52  }
53  }
54  }
55  }
56  return selectedProcess;
57  }
58 
59 } // namespace edm
std::vector< std::string > addedProcesses_
BranchType const & branchType() const
std::string const & processName() const
char const * process
Definition: ProductLabels.h:7
ProductList const & productList() const
void updateForNewProcess(ProductRegistry const &, std::string const &processName)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
TypeID unwrappedTypeID() const
char const * module
Definition: ProductLabels.h:5
std::vector< std::string > processesWithProcessBlockProducts_
std::string selectProcess(ProductRegistry const &, ProductLabels const &, TypeID const &) const
char const * productInstance
Definition: ProductLabels.h:6
static int position[264][3]
Definition: ReadPGInfo.cc:289