CMS 3D CMS Logo

SubProcess.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_SubProcess_h
2 #define FWCore_Framework_SubProcess_h
3 
21 
23 
24 #include <map>
25 #include <memory>
26 #include <set>
27 #include <vector>
28 
29 namespace edm {
30  class ActivityRegistry;
31  class BranchDescription;
32  class BranchIDListHelper;
33  class EventPrincipal;
34  class EventSetupImpl;
35  class HistoryAppender;
36  class LuminosityBlockPrincipal;
37  class LumiTransitionInfo;
38  class MergeableRunProductMetadata;
39  class ModuleTypeResolverMaker;
40  class ParameterSet;
41  class Principal;
42  class ProcessBlockTransitionInfo;
43  class ProductRegistry;
44  class PreallocationConfiguration;
45  class RunTransitionInfo;
46  class ThinnedAssociationsHelper;
47  class SubProcessParentageHelper;
48  class WaitingTaskHolder;
49 
50  namespace eventsetup {
51  class EventSetupsController;
52  }
53  class SubProcess : public EDConsumerBase {
54  public:
56  ParameterSet const& topLevelParameterSet,
57  std::shared_ptr<ProductRegistry const> parentProductRegistry,
58  std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
59  ProcessBlockHelperBase const& parentProcessBlockHelper,
60  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
61  SubProcessParentageHelper const& parentSubProcessParentageHelper,
63  ActivityRegistry& parentActReg,
64  ServiceToken const& token,
66  PreallocationConfiguration const& preallocConfig,
67  ProcessContext const* parentProcessContext,
68  ModuleTypeResolverMaker const* typeResolverMaker);
69 
70  ~SubProcess() override;
71 
72  SubProcess(SubProcess const&) = delete; // Disallow copying
73  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying
74  SubProcess(SubProcess&&) = default; // Allow Moving
75  SubProcess& operator=(SubProcess&&) = delete; // Move not supported by PrincipalCache
76 
77  //From OutputModule
78  void selectProducts(ProductRegistry const& preg,
79  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
80  std::map<BranchID, bool>& keepAssociation);
81 
83 
84  // Returns the set of modules whose products may be consumed by
85  // modules in this SubProcess or its child SubProcesses
86  std::vector<ModuleProcessName> keepOnlyConsumedUnscheduledModules(bool deleteModules);
87 
88  void doBeginJob();
89  void doEndJob();
90 
91  void doEventAsync(WaitingTaskHolder iHolder,
92  EventPrincipal const& principal,
93  std::vector<std::shared_ptr<const EventSetupImpl>> const*);
94 
95  template <typename Traits>
97  ProcessBlockTransitionInfo const& iTransitionInfo,
98  bool cleaningUpAfterException);
99 
101  ProcessBlockTransitionInfo const& iTransitionInfo,
102  bool cleaningUpAfterException);
103 
104  void doBeginRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const& iTransitionInfo);
105 
106  void doEndRunAsync(WaitingTaskHolder iHolder,
107  RunTransitionInfo const& iTransitionInfo,
108  bool cleaningUpAfterException);
109 
110  void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const& iTransitionInfo);
111 
113  LumiTransitionInfo const& iTransitionInfo,
114  bool cleaningUpAfterException);
115 
116  void doBeginStream(unsigned int);
117  void doEndStream(unsigned int);
118  void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const&);
119 
121  unsigned int iID,
122  RunTransitionInfo const&,
123  bool cleaningUpAfterException);
124 
125  void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const&);
126 
128  unsigned int iID,
129  LumiTransitionInfo const&,
130  bool cleaningUpAfterException);
131 
133 
135 
138 
140 
142 
144 
145  // Call closeFile() on all OutputModules.
148  schedule_->closeOutputFiles();
149  for_all(subProcesses_, [](auto& subProcess) { subProcess.closeOutputFiles(); });
150  }
151 
152  // Call openFiles() on all OutputModules
155  schedule_->openOutputFiles(fb);
156  for_all(subProcesses_, [&fb](auto& subProcess) { subProcess.openOutputFiles(fb); });
157  }
158 
160 
161  // Call respondToOpenInputFile() on all Modules
162  void respondToOpenInputFile(FileBlock const& fb);
163 
164  // Call respondToCloseInputFile() on all Modules
167  schedule_->respondToCloseInputFile(fb);
168  for_all(subProcesses_, [&fb](auto& subProcess) { subProcess.respondToCloseInputFile(fb); });
169  }
170 
171  // Call shouldWeCloseFile() on all OutputModules.
172  bool shouldWeCloseOutput() const {
174  if (schedule_->shouldWeCloseOutput()) {
175  return true;
176  }
177  for (auto const& subProcess : subProcesses_) {
178  if (subProcess.shouldWeCloseOutput()) {
179  return true;
180  }
181  }
182  return false;
183  }
184 
186 
190  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
191 
195  int totalEvents() const { return schedule_->totalEvents(); }
196 
198  int totalEventsPassed() const {
200  return schedule_->totalEventsPassed();
201  }
202 
205  int totalEventsFailed() const {
207  return schedule_->totalEventsFailed();
208  }
209 
214  schedule_->getTriggerReport(rep);
215  }
216 
219  bool terminate() const {
221  if (schedule_->terminate()) {
222  return true;
223  }
224  for (auto const& subProcess : subProcesses_) {
225  if (subProcess.terminate()) {
226  return true;
227  }
228  }
229  return false;
230  }
231 
233  void clearCounters() {
235  schedule_->clearCounters();
236  for_all(subProcesses_, [](auto& subProcess) { subProcess.clearCounters(); });
237  }
238 
239  private:
240  void beginJob();
241  void endJob();
242  void processAsync(WaitingTaskHolder iHolder,
243  EventPrincipal const& e,
244  std::vector<std::shared_ptr<const EventSetupImpl>> const*);
245 
246  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
247  bool parentProducedProductIsKept(Principal const& parentPrincipal, Principal& principal) const;
249  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
251  std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
252  std::set<BranchID>& keptProductsInEvent);
253 
254  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
256  }
257 
258  std::shared_ptr<BranchIDListHelper const> branchIDListHelper() const {
260  }
261  std::shared_ptr<BranchIDListHelper>& branchIDListHelper() { return get_underlying_safe(branchIDListHelper_); }
262  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper() const {
264  }
265  std::shared_ptr<ThinnedAssociationsHelper> thinnedAssociationsHelper() {
267  }
268 
269  std::shared_ptr<ActivityRegistry> actReg_; // We do not use propagate_const because the registry itself is mutable.
271  std::shared_ptr<ProductRegistry const> parentPreg_;
272  std::shared_ptr<ProductRegistry const> preg_;
277  std::unique_ptr<ExceptionToActionTable const> act_table_;
278  std::shared_ptr<ProcessConfiguration const> processConfiguration_;
281  //We require 1 history for each Run, Lumi and Stream
282  // The vectors first hold Stream info, then Lumi then Run
283  unsigned int historyLumiOffset_;
284  unsigned int historyRunOffset_;
285  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
286  std::vector<HistoryAppender> historyAppenders_;
288  //vector index is principal's index value
289  std::vector<std::shared_ptr<RunPrincipal>> inUseRunPrincipals_;
290  std::vector<std::shared_ptr<LuminosityBlockPrincipal>> inUseLumiPrincipals_;
293  std::vector<SubProcess> subProcesses_;
295 
296  // keptProducts_ are pointers to the BranchDescription objects describing
297  // the branches we are to write.
298  //
299  // We do not own the BranchDescriptions to which we point.
303 
304  //EventSelection
308 
309  // needed because of possible EDAliases.
310  // filled in only if key and value are different.
311  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
312  };
313 
314  // free function
315  std::vector<ParameterSet> popSubProcessVParameterSet(ParameterSet& parameterSet);
316 } // namespace edm
317 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:284
void doStreamEndLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:745
unsigned int historyLumiOffset_
Definition: SubProcess.h:283
ParameterSetID selector_config_id_
Definition: SubProcess.h:306
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper()
Definition: SubProcess.h:265
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:797
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:82
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void clearLumiPrincipal(LuminosityBlockPrincipal &)
Definition: SubProcess.cc:682
bool parentProducedProductIsKept(Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:772
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:285
std::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
void clearProcessBlockPrincipal(ProcessBlockType)
Definition: SubProcess.cc:623
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
Definition: SubProcess.h:275
std::vector< SubProcess > subProcesses_
Definition: SubProcess.h:293
edm::propagate_const< std::shared_ptr< SubProcessBlockHelper > > processBlockHelper_
Definition: SubProcess.h:274
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Definition: SubProcess.h:258
void writeRunAsync(WaitingTaskHolder, RunPrincipal const &, MergeableRunProductMetadata const *)
Definition: SubProcess.cc:597
void doBeginProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
PathsAndConsumesOfModules pathsAndConsumesOfModules_
Definition: SubProcess.h:280
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:718
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:790
void processAsync(WaitingTaskHolder iHolder, EventPrincipal const &e, std::vector< std::shared_ptr< const EventSetupImpl >> const *)
Definition: SubProcess.cc:423
void doEndStream(unsigned int)
Definition: SubProcess.cc:698
SubProcess & operator=(SubProcess const &)=delete
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:153
SubProcess(ParameterSet &parameterSet, ParameterSet const &topLevelParameterSet, std::shared_ptr< ProductRegistry const > parentProductRegistry, std::shared_ptr< BranchIDListHelper const > parentBranchIDListHelper, ProcessBlockHelperBase const &parentProcessBlockHelper, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, SubProcessParentageHelper const &parentSubProcessParentageHelper, eventsetup::EventSetupsController &esController, ActivityRegistry &parentActReg, ServiceToken const &token, serviceregistry::ServiceLegacy iLegacy, PreallocationConfiguration const &preallocConfig, ProcessContext const *parentProcessContext, ModuleTypeResolverMaker const *typeResolverMaker)
Definition: SubProcess.cc:51
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:254
edm::propagate_const< std::unique_ptr< Schedule > > schedule_
Definition: SubProcess.h:292
void doEndProcessBlockAsync(WaitingTaskHolder iHolder, ProcessBlockTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:499
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:212
BranchType
Definition: BranchType.h:11
int totalEventsFailed() const
Definition: SubProcess.h:205
std::vector< std::shared_ptr< RunPrincipal > > inUseRunPrincipals_
Definition: SubProcess.h:289
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() const
Definition: SubProcess.h:262
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
void doEventAsync(WaitingTaskHolder iHolder, EventPrincipal const &principal, std::vector< std::shared_ptr< const EventSetupImpl >> const *)
Definition: SubProcess.cc:407
ServiceToken serviceToken_
Definition: SubProcess.h:270
std::vector< std::shared_ptr< LuminosityBlockPrincipal > > inUseLumiPrincipals_
Definition: SubProcess.h:290
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:631
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:198
~SubProcess() override
Definition: SubProcess.cc:238
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:300
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
Definition: SubProcess.cc:328
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:301
void closeOutputFiles()
Definition: SubProcess.h:146
bool terminate() const
Definition: SubProcess.h:219
edm::propagate_const< std::shared_ptr< eventsetup::EventSetupProvider > > esp_
Definition: SubProcess.h:291
edm::propagate_const< std::unique_ptr< ParameterSet > > processParameterSet_
Definition: SubProcess.h:294
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:757
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Return a vector allowing const access to all the ModuleDescriptions for this SubProcess.
rep
Definition: cuy.py:1189
void writeProcessBlockAsync(edm::WaitingTaskHolder task, ProcessBlockType)
Definition: SubProcess.cc:583
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:277
std::vector< ParameterSet > popSubProcessVParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:804
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:311
ProductSelector productSelector_
Definition: SubProcess.h:302
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:307
void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &)
Definition: SubProcess.cc:733
void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &)
Definition: SubProcess.cc:704
int totalEvents() const
Definition: SubProcess.h:195
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:165
std::shared_ptr< ActivityRegistry > actReg_
Definition: SubProcess.h:269
void doEndRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:569
void doBeginRunAsync(WaitingTaskHolder iHolder, RunTransitionInfo const &iTransitionInfo)
Definition: SubProcess.cc:547
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: SubProcess.h:273
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:286
HLT enums.
void clearRunPrincipal(RunPrincipal &)
Definition: SubProcess.cc:614
void doBeginStream(unsigned int)
Definition: SubProcess.cc:692
std::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:271
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:389
std::shared_ptr< BranchIDListHelper > & branchIDListHelper()
Definition: SubProcess.h:261
ProcessContext processContext_
Definition: SubProcess.h:279
bool shouldWeCloseOutput() const
Definition: SubProcess.h:172
std::vector< ModuleProcessName > keepOnlyConsumedUnscheduledModules(bool deleteModules)
Definition: SubProcess.cc:240
void keepThisBranch(BranchDescription const &desc, std::map< BranchID, BranchDescription const *> &trueBranchIDToKeptBranchDesc, std::set< BranchID > &keptProductsInEvent)
Definition: SubProcess.cc:370
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:233
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: SubProcess.cc:653
void writeLumiAsync(WaitingTaskHolder, LuminosityBlockPrincipal &)
Definition: SubProcess.cc:667
std::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:272
PrincipalCache principalCache_
Definition: SubProcess.h:287
edm::propagate_const< std::shared_ptr< SubProcessParentageHelper > > subProcessParentageHelper_
Definition: SubProcess.h:276
std::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:278