CMS 3D CMS Logo

ScheduleItems.cc
Go to the documentation of this file.
2 
25 
26 #include <memory>
27 
28 #include <set>
29 #include <string>
30 #include <vector>
31 
32 namespace edm {
34  : actReg_(std::make_shared<ActivityRegistry>()),
35  preg_(std::make_shared<SignallingProductRegistry>()),
36  branchIDListHelper_(std::make_shared<BranchIDListHelper>()),
37  thinnedAssociationsHelper_(std::make_shared<ThinnedAssociationsHelper>()),
38  subProcessParentageHelper_(),
39  act_table_(),
40  processConfiguration_() {}
41 
43  SubProcess const& om,
44  SubProcessBlockHelper& subProcessBlockHelper,
45  ProcessBlockHelperBase const& parentProcessBlockHelper)
46  : actReg_(std::make_shared<ActivityRegistry>()),
47  preg_(std::make_shared<SignallingProductRegistry>(preg)),
48  branchIDListHelper_(std::make_shared<BranchIDListHelper>()),
49  thinnedAssociationsHelper_(std::make_shared<ThinnedAssociationsHelper>()),
50  subProcessParentageHelper_(std::make_shared<SubProcessParentageHelper>()),
51  act_table_(),
52  processConfiguration_() {
53  for (auto& item : preg_->productListUpdator()) {
54  BranchDescription& prod = item.second;
55  prod.setOnDemand(false);
56  prod.setProduced(false);
57  }
58 
59  // Mark dropped branches as dropped in the product registry.
60  std::set<BranchID> keptBranches;
61  SelectedProducts const& keptVectorP = om.keptProducts()[InProcess];
62  for (auto const& item : keptVectorP) {
63  BranchDescription const& desc = *item.first;
64  keptBranches.insert(desc.branchID());
65  }
66  SelectedProducts const& keptVectorR = om.keptProducts()[InRun];
67  for (auto const& item : keptVectorR) {
68  BranchDescription const& desc = *item.first;
69  keptBranches.insert(desc.branchID());
70  }
71  SelectedProducts const& keptVectorL = om.keptProducts()[InLumi];
72  for (auto const& item : keptVectorL) {
73  BranchDescription const& desc = *item.first;
74  keptBranches.insert(desc.branchID());
75  }
76  SelectedProducts const& keptVectorE = om.keptProducts()[InEvent];
77  for (auto const& item : keptVectorE) {
78  BranchDescription const& desc = *item.first;
79  keptBranches.insert(desc.branchID());
80  }
81  for (auto& item : preg_->productListUpdator()) {
82  BranchDescription& prod = item.second;
83  if (keptBranches.find(prod.branchID()) == keptBranches.end()) {
84  prod.setDropped(true);
85  }
86  }
87  subProcessBlockHelper.updateFromParentProcess(parentProcessBlockHelper, *preg_);
88  }
89 
90  ServiceToken ScheduleItems::initServices(std::vector<ParameterSet>& pServiceSets,
92  ServiceToken const& iToken,
94  bool associate) {
95  //create the services
96  ServiceToken token(ServiceRegistry::createSet(pServiceSets, iToken, iLegacy, associate));
97 
98  //see if any of the Services have to have their PSets stored
99  for (auto const& item : pServiceSets) {
100  if (item.exists("@save_config")) {
101  parameterSet.addParameter(item.getParameter<std::string>("@service_type"), item);
102  }
103  }
104  // Copy slots that hold all the registered callback functions like
105  // PostBeginJob into an ActivityRegistry
106  token.copySlotsTo(*actReg_);
107  return token;
108  }
109 
111  //add the ProductRegistry as a service ONLY for the construction phase
113  auto reg = std::make_shared<w_CPR>(std::make_unique<ConstProductRegistry>(*preg_));
115 
116  // the next thing is ugly: pull out the trigger path pset and
117  // create a service and extra token for it
118 
119  typedef service::TriggerNamesService TNS;
121 
122  auto tnsptr = std::make_shared<w_TNS>(std::make_unique<TNS>(parameterSet));
123 
125  }
126 
127  std::shared_ptr<CommonParams> ScheduleItems::initMisc(ParameterSet& parameterSet) {
128  edm::Service<edm::ResourceInformation> resourceInformationService;
129  if (resourceInformationService.isAvailable()) {
130  auto const& selectedAccelerators =
131  parameterSet.getUntrackedParameter<std::vector<std::string>>("@selected_accelerators");
132  resourceInformationService->initializeAcceleratorTypes(selectedAccelerators);
133  }
134 
135  act_table_ = std::make_unique<ExceptionToActionTable>(parameterSet);
137  processConfiguration_ = std::make_shared<ProcessConfiguration>(
138  processName, getReleaseVersion(), getPassID()); // propagate_const<T> has no reset() function
139  auto common = std::make_shared<CommonParams>(
141  parameterSet.getUntrackedParameterSet("maxLuminosityBlocks").getUntrackedParameter<int>("input"),
142  parameterSet.getUntrackedParameterSet("maxSecondsUntilRampdown").getUntrackedParameter<int>("input"));
143  return common;
144  }
145 
147  bool hasSubprocesses,
149  ProcessContext const* processContext,
150  ModuleTypeResolverMaker const* typeResolverMaker,
151  ProcessBlockHelperBase& processBlockHelper) {
153  auto ret = std::make_unique<Schedule>(parameterSet,
154  tns,
155  *preg_,
156  *act_table_,
157  actReg_,
159  config,
160  processContext,
161  typeResolverMaker);
162  ret->finishSetup(parameterSet,
163  tns,
164  *preg_,
166  processBlockHelper,
169  actReg_,
171  hasSubprocesses,
172  config,
173  processContext);
174  return ret;
175  }
176 
178  service::TriggerNamesService const& tns,
180  ProcessContext const* processContext,
181  ModuleTypeResolverMaker const* typeResolverMaker) {
182  return MadeModules(std::make_unique<Schedule>(parameterSet,
183  tns,
184  *preg_,
185  *act_table_,
186  actReg_,
188  config,
189  processContext,
190  typeResolverMaker));
191  }
192 
193  std::unique_ptr<Schedule> ScheduleItems::finishSchedule(MadeModules madeModules,
195  service::TriggerNamesService const& tns,
196  bool hasSubprocesses,
198  ProcessContext const* processContext,
199  ProcessBlockHelperBase& processBlockHelper) {
200  auto sched = std::move(madeModules.m_schedule);
201  sched->finishSetup(parameterSet,
202  tns,
203  *preg_,
205  processBlockHelper,
208  actReg_,
210  hasSubprocesses,
211  config,
212  processContext);
213  return sched;
214  }
215 
216 } // namespace edm
virtual void initializeAcceleratorTypes(std::vector< std::string > const &selectedAccelerators)=0
std::shared_ptr< ActivityRegistry > actReg_
std::string getPassID()
Definition: GetPassID.h:7
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:85
std::unique_ptr< Schedule > initSchedule(ParameterSet &parameterSet, bool hasSubprocesses, PreallocationConfiguration const &iAllocConfig, ProcessContext const *, ModuleTypeResolverMaker const *, ProcessBlockHelperBase &processBlockHelper)
std::unique_ptr< ExceptionToActionTable const > act_table_
ret
prodAgent to be discontinued
edm::propagate_const< std::shared_ptr< SignallingProductRegistry > > preg_
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Definition: config.py:1
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
void updateFromParentProcess(ProcessBlockHelperBase const &parentProcessBlockHelper, ProductRegistry const &)
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
T getUntrackedParameter(std::string const &, T const &) const
MadeModules initModules(ParameterSet &parameterSet, service::TriggerNamesService const &tns, PreallocationConfiguration const &iAllocConfig, ProcessContext const *, ModuleTypeResolverMaker const *typeResolverMaker)
std::shared_ptr< ProcessConfiguration const > processConfiguration() const
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
std::shared_ptr< CommonParams > initMisc(ParameterSet &parameterSet)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
static ServiceRegistry & instance()
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
static ServiceToken createSet(std::vector< ParameterSet > &)
std::string getReleaseVersion()
Definition: common.py:1
edm::propagate_const< std::shared_ptr< ProcessConfiguration > > processConfiguration_
ServiceToken initServices(std::vector< ParameterSet > &servicePSets, ParameterSet &processPSet, ServiceToken const &iToken, serviceregistry::ServiceLegacy iLegacy, bool associate)
std::unique_ptr< Schedule > m_schedule
Definition: ScheduleItems.h:66
edm::propagate_const< std::shared_ptr< SubProcessParentageHelper > > subProcessParentageHelper_
ServiceToken addCPRandTNS(ParameterSet const &parameterSet, ServiceToken const &token)
HLT enums.
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
bool isAvailable() const
Definition: Service.h:40
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< Schedule > finishSchedule(MadeModules, ParameterSet &parameterSet, service::TriggerNamesService const &tns, bool hasSubprocesses, PreallocationConfiguration const &iAllocConfig, ProcessContext const *, ProcessBlockHelperBase &processBlockHelper)