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 
172  void beginJob(ProductRegistry const&,
174  ProcessBlockHelperBase const&);
175  void endJob(ExceptionCollector& collector);
176 
177  void beginStream(unsigned int);
178  void endStream(unsigned int);
179 
180  // Write the luminosity block
182  LuminosityBlockPrincipal const& lbp,
183  ProcessContext const*,
185 
186  // Write the run
187  void writeRunAsync(WaitingTaskHolder iTask,
188  RunPrincipal const& rp,
189  ProcessContext const*,
192 
194  ProcessBlockPrincipal const&,
195  ProcessContext const*,
197 
198  // Call closeFile() on all OutputModules.
199  void closeOutputFiles();
200 
201  // Call openFiles() on all OutputModules
202  void openOutputFiles(FileBlock& fb);
203 
204  // Call respondToOpenInputFile() on all Modules
205  void respondToOpenInputFile(FileBlock const& fb);
206 
207  // Call respondToCloseInputFile() on all Modules
208  void respondToCloseInputFile(FileBlock const& fb);
209 
210  // Call shouldWeCloseFile() on all OutputModules.
211  bool shouldWeCloseOutput() const;
212 
215 
219  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
220 
222  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
223 
227  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
228 
230  void endPaths(std::vector<std::string>& oLabelsToFill) const;
231 
233  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
234 
237  void moduleDescriptionsInPath(std::string const& iPathLabel,
238  std::vector<ModuleDescription const*>& descriptions,
239  unsigned int hint) const;
240 
243  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
244  std::vector<ModuleDescription const*>& descriptions,
245  unsigned int hint) const;
246 
248  std::vector<ModuleDescription const*>& allModuleDescriptions,
249  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
250  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
251  modulesWhoseProductsAreConsumedBy,
252  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
253  ProductRegistry const& preg) const;
254 
258  int totalEvents() const;
259 
262  int totalEventsPassed() const;
263 
266  int totalEventsFailed() const;
267 
270  void getTriggerReport(TriggerReport& rep) const;
271 
275 
277  bool terminate() const;
278 
280  void clearCounters();
281 
284  bool changeModule(std::string const& iLabel,
285  ParameterSet const& iPSet,
286  const ProductRegistry& iRegistry,
288 
290  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
291 
292  void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly,
293  std::multimap<std::string, std::string> const& referencesToBranches,
294  std::vector<std::string> const& modulesToSkip,
295  edm::ProductRegistry const& preg);
296 
298  AllWorkers const& allWorkers() const;
299 
302 
303  private:
304  void limitOutput(ParameterSet const& proc_pset,
305  BranchIDLists const& branchIDLists,
306  SubProcessParentageHelper const* subProcessParentageHelper);
307 
308  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
310  }
311  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
312  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
313  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
314 
316  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
317  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
319  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
320  //In the future, we will have one GlobalSchedule per simultaneous transition
322 
325 
327 
328  std::vector<std::string> const* pathNames_;
329  std::vector<std::string> const* endPathNames_;
331  };
332 
333  template <typename T>
335  unsigned int iStreamID,
336  typename T::TransitionInfoType& transitionInfo,
337  ServiceToken const& token,
338  bool cleaningUpAfterException) {
339  assert(iStreamID < streamSchedules_.size());
340  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
341  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
342  }
343 
344  template <typename T>
346  typename T::TransitionInfoType& transitionInfo,
347  ServiceToken const& token,
348  bool cleaningUpAfterException) {
349  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
350  }
351 
352 } // namespace edm
353 #endif
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1297
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:768
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1376
roAction_t actions[nactions]
Definition: GenABIO.cc:181
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1103
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1176
int totalEvents() const
Definition: Schedule.cc:1383
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:334
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:345
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1303
std::vector< std::string > const * pathNames_
Definition: Schedule.h:328
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1366
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
Definition: Schedule.cc:1285
void endStream(unsigned int)
Definition: Schedule.cc:1192
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:326
assert(be >=bs)
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1197
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:321
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:311
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1254
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1272
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProductResolverIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1181
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:316
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProductResolverIndices const &)
Definition: Schedule.cc:1205
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:1315
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:315
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1407
std::vector< std::string > vstring
Definition: Schedule.h:126
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:727
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1171
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:318
rep
Definition: cuy.py:1189
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1070
int totalEventsPassed() const
Definition: Schedule.cc:1391
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:312
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:1291
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:324
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:319
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1283
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1162
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1309
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:317
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:323
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:128
void beginStream(unsigned int)
Definition: Schedule.cc:1187
bool wantSummary_
Definition: Schedule.h:330
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:329
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:1299
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:578
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:313
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:308
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1065
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1133
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:1262
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:783
int totalEventsFailed() const
Definition: Schedule.cc:1399
def move(src, dest)
Definition: eostools.py:511
void closeOutputFiles()
Definition: Schedule.cc:1057
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1295