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 <map>
86 #include <memory>
87 #include <set>
88 #include <string>
89 #include <vector>
90 #include <sstream>
91 #include <utility>
92 
93 namespace edm {
94 
95  namespace service {
96  class TriggerNamesService;
97  }
98  namespace evetnsetup {
100  }
101 
102  class ActivityRegistry;
103  class BranchIDListHelper;
104  class EventTransitionInfo;
105  class ExceptionCollector;
108  class ProcessContext;
109  class ProductRegistry;
111  class StreamSchedule;
112  class GlobalSchedule;
113  struct TriggerTimingReport;
114  class ModuleRegistry;
117  class TriggerResultInserter;
118  class PathStatusInserter;
119  class EndPathStatusInserter;
120  class WaitingTaskHolder;
121 
122  class Schedule {
123  public:
124  typedef std::vector<std::string> vstring;
125  typedef std::vector<Worker*> AllWorkers;
126  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
127 
128  typedef std::vector<Worker*> Workers;
129 
130  Schedule(ParameterSet& proc_pset,
131  service::TriggerNamesService const& tns,
132  ProductRegistry& pregistry,
133  BranchIDListHelper& branchIDListHelper,
135  ThinnedAssociationsHelper& thinnedAssociationsHelper,
136  SubProcessParentageHelper const* subProcessParentageHelper,
138  std::shared_ptr<ActivityRegistry> areg,
139  std::shared_ptr<ProcessConfiguration> processConfiguration,
140  bool hasSubprocesses,
142  ProcessContext const* processContext);
143 
145  unsigned int iStreamID,
147  ServiceToken const& token);
148 
149  template <typename T>
151  typename T::TransitionInfoType& transitionInfo,
152  ServiceToken const& token,
153  bool cleaningUpAfterException = false);
154 
155  template <typename T>
157  unsigned int iStreamID,
158  typename T::TransitionInfoType& transitionInfo,
159  ServiceToken const& token,
160  bool cleaningUpAfterException = false);
161 
163  void endJob(ExceptionCollector& collector);
164 
165  void beginStream(unsigned int);
166  void endStream(unsigned int);
167 
168  // Write the luminosity block
170  LuminosityBlockPrincipal const& lbp,
171  ProcessContext const*,
173 
174  // Write the run
175  void writeRunAsync(WaitingTaskHolder iTask,
176  RunPrincipal const& rp,
177  ProcessContext const*,
180 
182  ProcessBlockPrincipal const&,
183  ProcessContext const*,
185 
186  // Call closeFile() on all OutputModules.
187  void closeOutputFiles();
188 
189  // Call openFiles() on all OutputModules
190  void openOutputFiles(FileBlock& fb);
191 
192  // Call respondToOpenInputFile() on all Modules
193  void respondToOpenInputFile(FileBlock const& fb);
194 
195  // Call respondToCloseInputFile() on all Modules
196  void respondToCloseInputFile(FileBlock const& fb);
197 
198  // Call shouldWeCloseFile() on all OutputModules.
199  bool shouldWeCloseOutput() const;
200 
203 
207  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
208 
210  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
211 
215  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
216 
218  void endPaths(std::vector<std::string>& oLabelsToFill) const;
219 
221  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
222 
225  void moduleDescriptionsInPath(std::string const& iPathLabel,
226  std::vector<ModuleDescription const*>& descriptions,
227  unsigned int hint) const;
228 
231  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
232  std::vector<ModuleDescription const*>& descriptions,
233  unsigned int hint) const;
234 
236  std::vector<ModuleDescription const*>& allModuleDescriptions,
237  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
238  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
239  modulesWhoseProductsAreConsumedBy,
240  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
241  ProductRegistry const& preg) const;
242 
246  int totalEvents() const;
247 
250  int totalEventsPassed() const;
251 
254  int totalEventsFailed() const;
255 
258  void enableEndPaths(bool active);
259 
262  bool endPathsEnabled() 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 
289  AllWorkers const& allWorkers() const;
290 
293 
294  private:
295  void limitOutput(ParameterSet const& proc_pset,
296  BranchIDLists const& branchIDLists,
297  SubProcessParentageHelper const* subProcessParentageHelper);
298 
299  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
301  }
302  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
303  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
304  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
305 
307  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
308  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
310  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
311  //In the future, we will have one GlobalSchedule per simultaneous transition
313 
316 
318 
319  std::vector<std::string> const* pathNames_;
320  std::vector<std::string> const* endPathNames_;
322 
323  volatile bool endpathsAreActive_;
324  };
325 
326  template <typename T>
328  unsigned int iStreamID,
329  typename T::TransitionInfoType& transitionInfo,
330  ServiceToken const& token,
331  bool cleaningUpAfterException) {
332  assert(iStreamID < streamSchedules_.size());
333  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
334  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
335  }
336 
337  template <typename T>
339  typename T::TransitionInfoType& transitionInfo,
340  ServiceToken const& token,
341  bool cleaningUpAfterException) {
342  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
343  }
344 
345 } // namespace edm
346 #endif
edm::Schedule::Schedule
Schedule(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ProcessBlockHelperBase &, 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:658
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
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:338
edm::Schedule::vstring
std::vector< std::string > vstring
Definition: Schedule.h:124
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:302
edm::Schedule::limitOutput
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:878
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:1486
edm::Schedule::pathNames_
std::vector< std::string > const * pathNames_
Definition: Schedule.h:319
MessageLogger.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::Schedule::endStream
void endStream(unsigned int)
Definition: Schedule.cc:1373
BranchType.h
edm::Schedule::writeRunAsync
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1230
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:303
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:1470
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:1587
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
Algorithms.h
cms::cuda::assert
assert(be >=bs)
edm::Schedule::openOutputFiles
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1225
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:1480
edm::Schedule::endPathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:308
edm::Schedule::totalEvents
int totalEvents() const
Definition: Schedule.cc:1563
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:327
edm::Schedule::totalEventsFailed
int totalEventsFailed() const
Definition: Schedule.cc:1579
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::Schedule::closeOutputFiles
void closeOutputFiles()
Definition: Schedule.cc:1217
edm::Schedule::wantSummary_
bool wantSummary_
Definition: Schedule.h:321
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:1456
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:1462
edm::FileBlock
Definition: FileBlock.h:22
config
Definition: config.py:1
edm::ServiceToken
Definition: ServiceToken.h:42
edm::propagate_const
Definition: propagate_const.h:32
edm::Schedule::beginJob
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1362
edm::ExceptionCollector
Definition: ExceptionCollector.h:33
Service.h
edm::Schedule
Definition: Schedule.h:122
edm::Schedule::shouldWeCloseOutput
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1343
edm::Schedule::endJob
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:934
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:1386
edm::MergeableRunProductMetadata
Definition: MergeableRunProductMetadata.h:52
edm::OutputModuleCommunicator
Definition: OutputModuleCommunicator.h:40
edm::EndPathStatusInserter
Definition: EndPathStatusInserter.h:14
edm::Schedule::AllOutputModuleCommunicators
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:126
edm::Schedule::beginStream
void beginStream(unsigned int)
Definition: Schedule.cc:1368
edm::GlobalSchedule
Definition: GlobalSchedule.h:81
ConvertException.h
edm::BranchIDLists
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
edm::Schedule::getTriggerReport
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1546
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
StreamSchedule.h
edm::Schedule::streamSchedules_
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:310
edm::ProcessBlockHelperBase
Definition: ProcessBlockHelperBase.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Schedule::endPathsEnabled
bool endPathsEnabled() const
Definition: Schedule.cc:1544
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:919
edm::Schedule::pathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:307
ExceptionMessages.h
edm::Schedule::writeProcessBlockAsync
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1268
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
ESRecordsToProxyIndices
edm::BranchIDListHelper
Definition: BranchIDListHelper.h:15
edm::Schedule::endpathsAreActive_
volatile bool endpathsAreActive_
Definition: Schedule.h:323
edm::Schedule::respondToCloseInputFile
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1357
cuy.rep
rep
Definition: cuy.py:1189
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
ExceptionActions.h
edm::Schedule::AllWorkers
std::vector< Worker * > AllWorkers
Definition: Schedule.h:125
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::Schedule::all_output_communicators_
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:314
edm::TriggerReport
Definition: TriggerReport.h:56
edm::TriggerResultInserter
Definition: TriggerResultInserter.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Schedule::respondToOpenInputFile
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1352
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:1468
edm::Schedule::totalEventsPassed
int totalEventsPassed() const
Definition: Schedule.cc:1571
edm::service::TriggerNamesService
Definition: TriggerNamesService.h:42
edm::Schedule::enableEndPaths
void enableEndPaths(bool active)
Definition: Schedule.cc:1537
edm::Schedule::endPathNames_
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:320
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:1454
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:1474
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:299
ExceptionHelpers.h
Frameworkfwd.h
edm::Schedule::summaryTimeKeeper_
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:317
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:1378
WorkerRegistry.h
SystemTimeKeeper.h
edm::Schedule::writeLumiAsync
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1306
Exception.h
edm::Schedule::globalSchedule_
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:312
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:1435
JobReport.h
edm::Schedule::moduleRegistry_
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:309
edm::StreamSchedule
Definition: StreamSchedule.h:152
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Schedule::getAllModuleDescriptions
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1443
edm::Schedule::triggerPaths
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1466
get_underlying_safe.h
edm::Schedule::Workers
std::vector< Worker * > Workers
Definition: Schedule.h:128
StreamID.h
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:304
edm::Schedule::preallocConfig_
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:315
edm::Schedule::getTriggerTimingReport
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1556
edm::Schedule::resultsInserter_
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:306
FWCoreCommonFwd.h
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316