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;
118  class TriggerResultInserter;
119  class PathStatusInserter;
120  class EndPathStatusInserter;
121  class WaitingTaskHolder;
122 
123  class Schedule {
124  public:
125  typedef std::vector<std::string> vstring;
126  typedef std::vector<Worker*> AllWorkers;
127  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
128 
129  typedef std::vector<Worker*> Workers;
130 
131  Schedule(ParameterSet& proc_pset,
132  service::TriggerNamesService const& tns,
133  ProductRegistry& pregistry,
135  std::shared_ptr<ActivityRegistry> areg,
136  std::shared_ptr<ProcessConfiguration const> processConfiguration,
138  ProcessContext const* processContext);
139  void finishSetup(ParameterSet& proc_pset,
140  service::TriggerNamesService const& tns,
141  ProductRegistry& preg,
142  BranchIDListHelper& branchIDListHelper,
143  ProcessBlockHelperBase& processBlockHelper,
144  ThinnedAssociationsHelper& thinnedAssociationsHelper,
145  SubProcessParentageHelper const* subProcessParentageHelper,
146  std::shared_ptr<ActivityRegistry> areg,
147  std::shared_ptr<ProcessConfiguration> processConfiguration,
148  bool hasSubprocesses,
149  PreallocationConfiguration const& prealloc,
150  ProcessContext const* processContext);
151 
153  unsigned int iStreamID,
155  ServiceToken const& token);
156 
157  template <typename T>
159  typename T::TransitionInfoType& transitionInfo,
160  ServiceToken const& token,
161  bool cleaningUpAfterException = false);
162 
163  template <typename T>
165  unsigned int iStreamID,
166  typename T::TransitionInfoType& transitionInfo,
167  ServiceToken const& token,
168  bool cleaningUpAfterException = false);
169 
171  void endJob(ExceptionCollector& collector);
172 
173  void beginStream(unsigned int);
174  void endStream(unsigned int);
175 
176  // Write the luminosity block
178  LuminosityBlockPrincipal const& lbp,
179  ProcessContext const*,
181 
182  // Write the run
183  void writeRunAsync(WaitingTaskHolder iTask,
184  RunPrincipal const& rp,
185  ProcessContext const*,
188 
190  ProcessBlockPrincipal const&,
191  ProcessContext const*,
193 
194  // Call closeFile() on all OutputModules.
195  void closeOutputFiles();
196 
197  // Call openFiles() on all OutputModules
198  void openOutputFiles(FileBlock& fb);
199 
200  // Call respondToOpenInputFile() on all Modules
201  void respondToOpenInputFile(FileBlock const& fb);
202 
203  // Call respondToCloseInputFile() on all Modules
204  void respondToCloseInputFile(FileBlock const& fb);
205 
206  // Call shouldWeCloseFile() on all OutputModules.
207  bool shouldWeCloseOutput() const;
208 
211 
215  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
216 
218  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
219 
223  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
224 
226  void endPaths(std::vector<std::string>& oLabelsToFill) const;
227 
229  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
230 
233  void moduleDescriptionsInPath(std::string const& iPathLabel,
234  std::vector<ModuleDescription const*>& descriptions,
235  unsigned int hint) const;
236 
239  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
240  std::vector<ModuleDescription const*>& descriptions,
241  unsigned int hint) const;
242 
244  std::vector<ModuleDescription const*>& allModuleDescriptions,
245  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
246  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
247  modulesWhoseProductsAreConsumedBy,
248  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
249  ProductRegistry const& preg) const;
250 
254  int totalEvents() const;
255 
258  int totalEventsPassed() const;
259 
262  int totalEventsFailed() const;
263 
266  void getTriggerReport(TriggerReport& rep) const;
267 
271 
273  bool terminate() const;
274 
276  void clearCounters();
277 
280  bool changeModule(std::string const& iLabel,
281  ParameterSet const& iPSet,
282  const ProductRegistry& iRegistry,
284 
286  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
287 
288  void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly,
289  std::multimap<std::string, std::string> const& referencesToBranches,
290  std::vector<std::string> const& modulesToSkip,
291  edm::ProductRegistry const& preg);
292 
294  AllWorkers const& allWorkers() const;
295 
298 
299  private:
300  void limitOutput(ParameterSet const& proc_pset,
301  BranchIDLists const& branchIDLists,
302  SubProcessParentageHelper const* subProcessParentageHelper);
303 
304  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
306  }
307  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
308  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
309  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
310 
312  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
313  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
315  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
316  //In the future, we will have one GlobalSchedule per simultaneous transition
318 
321 
323 
324  std::vector<std::string> const* pathNames_;
325  std::vector<std::string> const* endPathNames_;
327  };
328 
329  template <typename T>
331  unsigned int iStreamID,
332  typename T::TransitionInfoType& transitionInfo,
333  ServiceToken const& token,
334  bool cleaningUpAfterException) {
335  assert(iStreamID < streamSchedules_.size());
336  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
337  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
338  }
339 
340  template <typename T>
342  typename T::TransitionInfoType& transitionInfo,
343  ServiceToken const& token,
344  bool cleaningUpAfterException) {
345  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
346  }
347 
348 } // namespace edm
349 #endif
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1293
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:757
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1372
roAction_t actions[nactions]
Definition: GenABIO.cc:181
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1099
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1172
int totalEvents() const
Definition: Schedule.cc:1379
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330
std::vector< Worker * > AllWorkers
Definition: Schedule.h:126
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:341
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1299
std::vector< std::string > const * pathNames_
Definition: Schedule.h:324
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1362
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
Definition: Schedule.cc:1281
void endStream(unsigned int)
Definition: Schedule.cc:1188
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)
Definition: Schedule.cc:479
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:322
assert(be >=bs)
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1193
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:317
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:307
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1250
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1268
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1177
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:312
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:1311
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:311
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1403
std::vector< std::string > vstring
Definition: Schedule.h:125
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:716
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1167
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:314
rep
Definition: cuy.py:1189
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1066
int totalEventsPassed() const
Definition: Schedule.cc:1387
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:308
std::vector< Worker * > Workers
Definition: Schedule.h:129
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1287
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:320
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:315
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1279
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1158
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const *> &descriptions, unsigned int hint) const
Definition: Schedule.cc:1305
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:313
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:319
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:127
void beginStream(unsigned int)
Definition: Schedule.cc:1183
bool wantSummary_
Definition: Schedule.h:326
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:325
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:1295
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:567
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:309
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:304
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1061
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1129
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:1258
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:772
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1201
int totalEventsFailed() const
Definition: Schedule.cc:1395
def move(src, dest)
Definition: eostools.py:511
void closeOutputFiles()
Definition: Schedule.cc:1053
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1291