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 
83 
84 #include <map>
85 #include <memory>
86 #include <set>
87 #include <string>
88 #include <vector>
89 #include <sstream>
90 #include <utility>
91 
92 namespace edm {
93 
94  namespace service {
95  class TriggerNamesService;
96  }
97  namespace evetnsetup {
99  }
100 
101  class ActivityRegistry;
102  class BranchIDListHelper;
103  class EventTransitionInfo;
104  class ExceptionCollector;
107  class ProcessContext;
108  class ProductRegistry;
110  class StreamSchedule;
111  class GlobalSchedule;
112  struct TriggerTimingReport;
113  class ModuleRegistry;
116  class TriggerResultInserter;
117  class PathStatusInserter;
118  class EndPathStatusInserter;
119  class WaitingTaskHolder;
120 
121  class Schedule {
122  public:
123  typedef std::vector<std::string> vstring;
124  typedef std::vector<Worker*> AllWorkers;
125  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
126 
127  typedef std::vector<Worker*> Workers;
128 
129  Schedule(ParameterSet& proc_pset,
130  service::TriggerNamesService const& tns,
131  ProductRegistry& pregistry,
132  BranchIDListHelper& branchIDListHelper,
133  ThinnedAssociationsHelper& thinnedAssociationsHelper,
134  SubProcessParentageHelper const* subProcessParentageHelper,
136  std::shared_ptr<ActivityRegistry> areg,
137  std::shared_ptr<ProcessConfiguration> processConfiguration,
138  bool hasSubprocesses,
140  ProcessContext const* processContext);
141 
143  unsigned int iStreamID,
145  ServiceToken const& token);
146 
147  template <typename T>
149  typename T::TransitionInfoType& transitionInfo,
150  ServiceToken const& token,
151  bool cleaningUpAfterException = false);
152 
153  template <typename T>
155  unsigned int iStreamID,
156  typename T::TransitionInfoType& transitionInfo,
157  ServiceToken const& token,
158  bool cleaningUpAfterException = false);
159 
161  void endJob(ExceptionCollector& collector);
162 
163  void beginStream(unsigned int);
164  void endStream(unsigned int);
165 
166  // Write the luminosity block
168  LuminosityBlockPrincipal const& lbp,
169  ProcessContext const*,
171 
172  // Write the run
173  void writeRunAsync(WaitingTaskHolder iTask,
174  RunPrincipal const& rp,
175  ProcessContext const*,
178 
180  ProcessBlockPrincipal const&,
181  ProcessContext const*,
183 
184  // Call closeFile() on all OutputModules.
185  void closeOutputFiles();
186 
187  // Call openFiles() on all OutputModules
189 
190  // Call respondToOpenInputFile() on all Modules
191  void respondToOpenInputFile(FileBlock const& fb);
192 
193  // Call respondToCloseInputFile() on all Modules
194  void respondToCloseInputFile(FileBlock const& fb);
195 
196  // Call shouldWeCloseFile() on all OutputModules.
197  bool shouldWeCloseOutput() const;
198 
201 
205  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
206 
208  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
209 
213  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
214 
216  void endPaths(std::vector<std::string>& oLabelsToFill) const;
217 
219  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
220 
223  void moduleDescriptionsInPath(std::string const& iPathLabel,
224  std::vector<ModuleDescription const*>& descriptions,
225  unsigned int hint) const;
226 
229  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
230  std::vector<ModuleDescription const*>& descriptions,
231  unsigned int hint) const;
232 
234  std::vector<ModuleDescription const*>& allModuleDescriptions,
235  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
236  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
237  modulesWhoseProductsAreConsumedBy,
238  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
239  ProductRegistry const& preg) const;
240 
244  int totalEvents() const;
245 
248  int totalEventsPassed() const;
249 
252  int totalEventsFailed() const;
253 
256  void enableEndPaths(bool active);
257 
260  bool endPathsEnabled() const;
261 
264  void getTriggerReport(TriggerReport& rep) const;
265 
269 
271  bool terminate() const;
272 
274  void clearCounters();
275 
278  bool changeModule(std::string const& iLabel,
279  ParameterSet const& iPSet,
280  const ProductRegistry& iRegistry,
282 
284  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
285 
287  AllWorkers const& allWorkers() const;
288 
291 
292  private:
293  void limitOutput(ParameterSet const& proc_pset,
294  BranchIDLists const& branchIDLists,
295  SubProcessParentageHelper const* subProcessParentageHelper);
296 
297  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
299  }
300  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
301  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
302  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
303 
305  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
306  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
308  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
309  //In the future, we will have one GlobalSchedule per simultaneous transition
311 
314 
316 
317  std::vector<std::string> const* pathNames_;
318  std::vector<std::string> const* endPathNames_;
320 
321  volatile bool endpathsAreActive_;
322  };
323 
324  template <typename T>
326  unsigned int iStreamID,
327  typename T::TransitionInfoType& transitionInfo,
328  ServiceToken const& token,
329  bool cleaningUpAfterException) {
330  assert(iStreamID < streamSchedules_.size());
331  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
332  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
333  }
334 
335  template <typename T>
337  typename T::TransitionInfoType& transitionInfo,
338  ServiceToken const& token,
339  bool cleaningUpAfterException) {
340  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
341  }
342 
343 } // namespace edm
344 #endif
edm::Schedule::beginJob
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1355
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::Schedule::Schedule
Schedule(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, SubProcessParentageHelper const *subProcessParentageHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool hasSubprocesses, PreallocationConfiguration const &config, ProcessContext const *processContext)
Definition: Schedule.cc:657
WorkerManager.h
service
Definition: service.py:1
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:336
edm::Schedule::vstring
std::vector< std::string > vstring
Definition: Schedule.h:123
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:300
edm::Schedule::limitOutput
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:874
edm::SubProcessParentageHelper
Definition: SubProcessParentageHelper.h:21
edm::Schedule::fillModuleAndConsumesInfo
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:1477
edm::Schedule::pathNames_
std::vector< std::string > const * pathNames_
Definition: Schedule.h:317
MessageLogger.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::Schedule::endStream
void endStream(unsigned int)
Definition: Schedule.cc:1364
BranchType.h
edm::Schedule::writeRunAsync
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1223
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:301
propagate_const.h
edm::Schedule::modulesInPath
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:1461
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProcessContext
Definition: ProcessContext.h:27
edm::Schedule::clearCounters
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1578
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
Algorithms.h
cms::cuda::assert
assert(be >=bs)
edm::Schedule::openOutputFiles
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1218
mps_check.array
array
Definition: mps_check.py:216
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
PreallocationConfiguration.h
edm::Schedule::moduleDescriptionsInEndPath
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1471
edm::Schedule::endPathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:306
edm::Schedule::totalEvents
int totalEvents() const
Definition: Schedule.cc:1554
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:325
edm::Schedule::totalEventsFailed
int totalEventsFailed() const
Definition: Schedule.cc:1570
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::Schedule::closeOutputFiles
void closeOutputFiles()
Definition: Schedule.cc:1213
edm::Schedule::wantSummary_
bool wantSummary_
Definition: Schedule.h:319
edm::NumBranchTypes
Definition: BranchType.h:11
edm::Schedule::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name.
Definition: Schedule.cc:1447
edm::ProductRegistry
Definition: ProductRegistry.h:37
ModuleDescription.h
edm::Schedule::availablePaths
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1453
edm::FileBlock
Definition: FileBlock.h:20
config
Definition: config.py:1
edm::ServiceToken
Definition: ServiceToken.h:42
edm::propagate_const
Definition: propagate_const.h:32
edm::ExceptionCollector
Definition: ExceptionCollector.h:33
Service.h
edm::Schedule
Definition: Schedule.h:121
edm::Schedule::shouldWeCloseOutput
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1336
edm::Schedule::endJob
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:930
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
edm::TriggerTimingReport
Definition: TriggerTimingReport.h:52
edm::Schedule::changeModule
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1377
edm::MergeableRunProductMetadata
Definition: MergeableRunProductMetadata.h:52
edm::OutputModuleCommunicator
Definition: OutputModuleCommunicator.h:39
edm::EndPathStatusInserter
Definition: EndPathStatusInserter.h:14
edm::Schedule::AllOutputModuleCommunicators
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:125
edm::Schedule::beginStream
void beginStream(unsigned int)
Definition: Schedule.cc:1359
edm::GlobalSchedule
Definition: GlobalSchedule.h:80
ConvertException.h
edm::BranchIDLists
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Schedule::getTriggerReport
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1537
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
StreamSchedule.h
edm::Schedule::streamSchedules_
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:308
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Schedule::endPathsEnabled
bool endPathsEnabled() const
Definition: Schedule.cc:1535
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
GlobalSchedule.h
edm::Schedule::terminate
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:915
edm::Schedule::pathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:305
ExceptionMessages.h
edm::Schedule::writeProcessBlockAsync
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1261
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
ESRecordsToProxyIndices
edm::BranchIDListHelper
Definition: BranchIDListHelper.h:15
edm::Schedule::endpathsAreActive_
volatile bool endpathsAreActive_
Definition: Schedule.h:321
edm::Schedule::respondToCloseInputFile
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1350
cuy.rep
rep
Definition: cuy.py:1190
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
ExceptionActions.h
edm::Schedule::AllWorkers
std::vector< Worker * > AllWorkers
Definition: Schedule.h:124
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::Schedule::all_output_communicators_
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:312
edm::TriggerReport
Definition: TriggerReport.h:56
edm::TriggerResultInserter
Definition: TriggerResultInserter.h:30
edm::Schedule::respondToOpenInputFile
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1345
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::Schedule::endPaths
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1459
edm::Schedule::totalEventsPassed
int totalEventsPassed() const
Definition: Schedule.cc:1562
edm::service::TriggerNamesService
Definition: TriggerNamesService.h:42
edm::Schedule::enableEndPaths
void enableEndPaths(bool active)
Definition: Schedule.cc:1528
edm::Schedule::endPathNames_
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:318
OccurrenceTraits.h
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::Schedule::allWorkers
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1445
edm::ModuleRegistry
Definition: ModuleRegistry.h:40
edm::Schedule::moduleDescriptionsInPath
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1465
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:297
ExceptionHelpers.h
Frameworkfwd.h
edm::Schedule::summaryTimeKeeper_
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:315
T
long double T
Definition: Basic3DVectorLD.h:48
Worker.h
edm::Schedule::processOneEventAsync
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1369
WorkerRegistry.h
SystemTimeKeeper.h
edm::Schedule::writeLumiAsync
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1299
Exception.h
edm::Schedule::globalSchedule_
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:310
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
edm::Schedule::deleteModule
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1426
JobReport.h
edm::Schedule::moduleRegistry_
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:307
edm::StreamSchedule
Definition: StreamSchedule.h:152
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Schedule::getAllModuleDescriptions
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1434
edm::Schedule::triggerPaths
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1457
get_underlying_safe.h
edm::Schedule::Workers
std::vector< Worker * > Workers
Definition: Schedule.h:127
StreamID.h
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:302
edm::Schedule::preallocConfig_
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:313
edm::Schedule::getTriggerTimingReport
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1547
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14
edm::Schedule::resultsInserter_
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:304
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316