CMS 3D CMS Logo

Schedule.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_Schedule_h
2 #define FWCore_Framework_Schedule_h
3 
4 /*
5  Author: Jim Kowalkowski 28-01-06
6 
7  A class for creating a schedule based on paths in the configuration file.
8  The schedule is maintained as a sequence of paths.
9  After construction, events can be fed to the object and passed through
10  all the modules in the schedule. All accounting about processing
11  of events by modules and paths is contained here or in object held
12  by containment.
13 
14  The trigger results producer and product are generated and managed here.
15  This class also manages endpaths and calls to endjob and beginjob.
16  Endpaths are just treated as a simple list of modules that need to
17  do processing of the event and do not participate in trigger path
18  activities.
19 
20  This class requires the high-level process pset. It uses @process_name.
21  If the high-level pset contains an "options" pset, then the
22  following optional parameter can be present:
23  bool wantSummary = true/false # default false
24 
25  wantSummary indicates whether or not the pass/fail/error stats
26  for modules and paths should be printed at the end-of-job.
27 
28  A TriggerResults object will always be inserted into the event
29  for any schedule. The producer of the TriggerResults EDProduct
30  is always the first module in the endpath. The TriggerResultInserter
31  is given a fixed label of "TriggerResults".
32 
33  Processing of an event happens by pushing the event through the Paths.
34  The scheduler performs the reset() on each of the workers independent
35  of the Path objects.
36 
37  ------------------------
38 
39  About Paths:
40  Paths fit into two categories:
41  1) trigger paths that contribute directly to saved trigger bits
42  2) end paths
43  The Schedule holds these paths in two data structures:
44  1) main path list
45  2) end path list
46 
47  Trigger path processing always precedes endpath processing.
48  The order of the paths from the input configuration is
49  preserved in the main paths list.
50 
51  ------------------------
52 
53  The Schedule uses the TriggerNamesService to get the names of the
54  trigger paths and end paths. When a TriggerResults object is created
55  the results are stored in the same order as the trigger names from
56  TriggerNamesService.
57 
58 */
59 
84 
85 #include <array>
86 #include <map>
87 #include <memory>
88 #include <set>
89 #include <string>
90 #include <vector>
91 #include <sstream>
92 #include <utility>
93 
94 namespace edm {
95 
96  namespace service {
97  class TriggerNamesService;
98  }
99  namespace evetnsetup {
101  }
102 
103  class ActivityRegistry;
104  class BranchIDListHelper;
105  class EventTransitionInfo;
106  class ExceptionCollector;
109  class ProcessContext;
110  class ProductRegistry;
112  class StreamSchedule;
113  class GlobalSchedule;
114  struct TriggerTimingReport;
115  class ModuleRegistry;
119  class TriggerResultInserter;
120  class PathStatusInserter;
121  class EndPathStatusInserter;
122  class WaitingTaskHolder;
123 
124  class Schedule {
125  public:
126  typedef std::vector<std::string> vstring;
127  typedef std::vector<Worker*> AllWorkers;
128  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
129 
130  typedef std::vector<Worker*> Workers;
131 
132  Schedule(ParameterSet& proc_pset,
133  service::TriggerNamesService const& tns,
134  ProductRegistry& pregistry,
136  std::shared_ptr<ActivityRegistry> areg,
137  std::shared_ptr<ProcessConfiguration const> processConfiguration,
139  ProcessContext const* processContext,
140  ModuleTypeResolverMaker const* resolverMaker);
141  void finishSetup(ParameterSet& proc_pset,
142  service::TriggerNamesService const& tns,
143  ProductRegistry& preg,
144  BranchIDListHelper& branchIDListHelper,
145  ProcessBlockHelperBase& processBlockHelper,
146  ThinnedAssociationsHelper& thinnedAssociationsHelper,
147  SubProcessParentageHelper const* subProcessParentageHelper,
148  std::shared_ptr<ActivityRegistry> areg,
149  std::shared_ptr<ProcessConfiguration> processConfiguration,
150  bool hasSubprocesses,
151  PreallocationConfiguration const& prealloc,
152  ProcessContext const* processContext);
153 
155  unsigned int iStreamID,
157  ServiceToken const& token);
158 
159  template <typename T>
161  typename T::TransitionInfoType& transitionInfo,
162  ServiceToken const& token,
163  bool cleaningUpAfterException = false);
164 
165  template <typename T>
167  unsigned int iStreamID,
168  typename T::TransitionInfoType& transitionInfo,
169  ServiceToken const& token,
170  bool cleaningUpAfterException = false);
171 
173  void endJob(ExceptionCollector& collector);
174 
175  void beginStream(unsigned int);
176  void endStream(unsigned int);
177 
178  // Write the luminosity block
180  LuminosityBlockPrincipal const& lbp,
181  ProcessContext const*,
183 
184  // Write the run
185  void writeRunAsync(WaitingTaskHolder iTask,
186  RunPrincipal const& rp,
187  ProcessContext const*,
190 
192  ProcessBlockPrincipal const&,
193  ProcessContext const*,
195 
196  // Call closeFile() on all OutputModules.
197  void closeOutputFiles();
198 
199  // Call openFiles() on all OutputModules
200  void openOutputFiles(FileBlock& fb);
201 
202  // Call respondToOpenInputFile() on all Modules
203  void respondToOpenInputFile(FileBlock const& fb);
204 
205  // Call respondToCloseInputFile() on all Modules
206  void respondToCloseInputFile(FileBlock const& fb);
207 
208  // Call shouldWeCloseFile() on all OutputModules.
209  bool shouldWeCloseOutput() const;
210 
213 
217  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
218 
220  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
221 
225  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
226 
228  void endPaths(std::vector<std::string>& oLabelsToFill) const;
229 
231  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
232 
235  void moduleDescriptionsInPath(std::string const& iPathLabel,
236  std::vector<ModuleDescription const*>& descriptions,
237  unsigned int hint) const;
238 
241  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
242  std::vector<ModuleDescription const*>& descriptions,
243  unsigned int hint) const;
244 
246  std::vector<ModuleDescription const*>& allModuleDescriptions,
247  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
248  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
249  modulesWhoseProductsAreConsumedBy,
250  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
251  ProductRegistry const& preg) const;
252 
256  int totalEvents() const;
257 
260  int totalEventsPassed() const;
261 
264  int totalEventsFailed() const;
265 
268  void getTriggerReport(TriggerReport& rep) const;
269 
273 
275  bool terminate() const;
276 
278  void clearCounters();
279 
282  bool changeModule(std::string const& iLabel,
283  ParameterSet const& iPSet,
284  const ProductRegistry& iRegistry,
286 
288  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
289 
290  void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly,
291  std::multimap<std::string, std::string> const& referencesToBranches,
292  std::vector<std::string> const& modulesToSkip,
293  edm::ProductRegistry const& preg);
294 
296  AllWorkers const& allWorkers() const;
297 
300 
301  private:
302  void limitOutput(ParameterSet const& proc_pset,
303  BranchIDLists const& branchIDLists,
304  SubProcessParentageHelper const* subProcessParentageHelper);
305 
306  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
308  }
309  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
310  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
311  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
312 
314  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
315  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
317  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
318  //In the future, we will have one GlobalSchedule per simultaneous transition
320 
323 
325 
326  std::vector<std::string> const* pathNames_;
327  std::vector<std::string> const* endPathNames_;
329  };
330 
331  template <typename T>
333  unsigned int iStreamID,
334  typename T::TransitionInfoType& transitionInfo,
335  ServiceToken const& token,
336  bool cleaningUpAfterException) {
337  assert(iStreamID < streamSchedules_.size());
338  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
339  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
340  }
341 
342  template <typename T>
344  typename T::TransitionInfoType& transitionInfo,
345  ServiceToken const& token,
346  bool cleaningUpAfterException) {
347  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
348  }
349 
350 } // namespace edm
351 #endif
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1301
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:765
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1380
roAction_t actions[nactions]
Definition: GenABIO.cc:181
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1107
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1180
int totalEvents() const
Definition: Schedule.cc:1387
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:332
std::vector< Worker * > AllWorkers
Definition: Schedule.h:127
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:343
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1307
std::vector< std::string > const * pathNames_
Definition: Schedule.h:326
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1370
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
Definition: Schedule.cc:1289
void endStream(unsigned int)
Definition: Schedule.cc:1196
Definition: config.py:1
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:324
assert(be >=bs)
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1201
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:319
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:309
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1258
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1276
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1185
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:314
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const *> &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int >> &moduleIDToIndex, std::array< std::vector< std::vector< ModuleDescription const *>>, NumBranchTypes > &modulesWhoseProductsAreConsumedBy, std::vector< std::vector< ModuleProcessName >> &modulesInPreviousProcessesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
Definition: Schedule.cc:1319
Schedule(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &pregistry, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration const > processConfiguration, PreallocationConfiguration const &config, ProcessContext const *processContext, ModuleTypeResolverMaker const *resolverMaker)
Definition: Schedule.cc:486
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:313
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1411
std::vector< std::string > vstring
Definition: Schedule.h:126
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:724
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1175
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:316
rep
Definition: cuy.py:1189
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1074
int totalEventsPassed() const
Definition: Schedule.cc:1395
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:310
std::vector< Worker * > Workers
Definition: Schedule.h:130
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1295
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:322
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:317
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1287
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1166
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1313
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:315
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:321
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:128
void beginStream(unsigned int)
Definition: Schedule.cc:1191
bool wantSummary_
Definition: Schedule.h:328
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:327
HLT enums.
void modulesInPath(std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
Definition: Schedule.cc:1303
void finishSetup(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &preg, BranchIDListHelper &branchIDListHelper, ProcessBlockHelperBase &processBlockHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, SubProcessParentageHelper const *subProcessParentageHelper, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool hasSubprocesses, PreallocationConfiguration const &prealloc, ProcessContext const *processContext)
Definition: Schedule.cc:575
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:311
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:306
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1069
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1137
long double T
void initializeEarlyDelete(std::vector< std::string > const &branchesToDeleteEarly, std::multimap< std::string, std::string > const &referencesToBranches, std::vector< std::string > const &modulesToSkip, edm::ProductRegistry const &preg)
Definition: Schedule.cc:1266
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:780
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1209
int totalEventsFailed() const
Definition: Schedule.cc:1403
def move(src, dest)
Definition: eostools.py:511
void closeOutputFiles()
Definition: Schedule.cc:1061
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1299