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 
233  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
234  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
235  std::vector<std::vector<ModuleDescription const*>>& modulesWhoseProductsAreConsumedBy,
236  ProductRegistry const& preg) const;
237 
241  int totalEvents() const;
242 
245  int totalEventsPassed() const;
246 
249  int totalEventsFailed() const;
250 
253  void enableEndPaths(bool active);
254 
257  bool endPathsEnabled() const;
258 
261  void getTriggerReport(TriggerReport& rep) const;
262 
266 
268  bool terminate() const;
269 
271  void clearCounters();
272 
275  bool changeModule(std::string const& iLabel,
276  ParameterSet const& iPSet,
277  const ProductRegistry& iRegistry,
279 
281  AllWorkers const& allWorkers() const;
282 
285 
286  private:
287  void limitOutput(ParameterSet const& proc_pset,
288  BranchIDLists const& branchIDLists,
289  SubProcessParentageHelper const* subProcessParentageHelper);
290 
291  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
293  }
294  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
295  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
296  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
297 
299  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
300  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
302  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
303  //In the future, we will have one GlobalSchedule per simultaneous transition
305 
308 
310 
311  std::vector<std::string> const* pathNames_;
312  std::vector<std::string> const* endPathNames_;
314 
315  volatile bool endpathsAreActive_;
316  };
317 
318  template <typename T>
320  unsigned int iStreamID,
321  typename T::TransitionInfoType& transitionInfo,
322  ServiceToken const& token,
323  bool cleaningUpAfterException) {
324  assert(iStreamID < streamSchedules_.size());
325  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
326  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
327  }
328 
329  template <typename T>
331  typename T::TransitionInfoType& transitionInfo,
332  ServiceToken const& token,
333  bool cleaningUpAfterException) {
334  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
335  }
336 
337 } // namespace edm
338 #endif
edm::Schedule::beginJob
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1356
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:330
edm::Schedule::vstring
std::vector< std::string > vstring
Definition: Schedule.h:123
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:294
edm::Schedule::limitOutput
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:872
edm::SubProcessParentageHelper
Definition: SubProcessParentageHelper.h:21
edm::Schedule::pathNames_
std::vector< std::string > const * pathNames_
Definition: Schedule.h:311
MessageLogger.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::Schedule::endStream
void endStream(unsigned int)
Definition: Schedule.cc:1365
BranchType.h
edm::Schedule::writeRunAsync
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1221
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:295
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:1454
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:1558
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
Algorithms.h
cms::cuda::assert
assert(be >=bs)
edm::Schedule::openOutputFiles
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1216
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:1464
edm::Schedule::endPathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:300
edm::Schedule::totalEvents
int totalEvents() const
Definition: Schedule.cc:1534
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:319
edm::Schedule::totalEventsFailed
int totalEventsFailed() const
Definition: Schedule.cc:1550
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::Schedule::closeOutputFiles
void closeOutputFiles()
Definition: Schedule.cc:1211
edm::Schedule::wantSummary_
bool wantSummary_
Definition: Schedule.h:313
edm::Schedule::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name.
Definition: Schedule.cc:1440
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:1446
edm::FileBlock
Definition: FileBlock.h:20
config
Definition: config.py:1
edm::ServiceToken
Definition: ServiceToken.h:40
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:1337
edm::Schedule::endJob
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:928
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
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:1378
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:1360
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:1517
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
StreamSchedule.h
edm::Schedule::streamSchedules_
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:302
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Schedule::endPathsEnabled
bool endPathsEnabled() const
Definition: Schedule.cc:1515
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:30
GlobalSchedule.h
edm::Schedule::terminate
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:913
edm::Schedule::pathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:299
edm::Schedule::fillModuleAndConsumesInfo
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int >> &moduleIDToIndex, std::vector< std::vector< ModuleDescription const * >> &modulesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
Definition: Schedule.cc:1470
ExceptionMessages.h
edm::Schedule::writeProcessBlockAsync
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1260
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
ESRecordsToProxyIndices
edm::BranchIDListHelper
Definition: BranchIDListHelper.h:15
edm::Schedule::endpathsAreActive_
volatile bool endpathsAreActive_
Definition: Schedule.h:315
edm::Schedule::respondToCloseInputFile
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1351
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:306
edm::TriggerReport
Definition: TriggerReport.h:56
edm::TriggerResultInserter
Definition: TriggerResultInserter.h:30
edm::Schedule::respondToOpenInputFile
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1346
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:1452
edm::Schedule::totalEventsPassed
int totalEventsPassed() const
Definition: Schedule.cc:1542
edm::service::TriggerNamesService
Definition: TriggerNamesService.h:42
edm::Schedule::enableEndPaths
void enableEndPaths(bool active)
Definition: Schedule.cc:1508
edm::Schedule::endPathNames_
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:312
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:1438
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:1458
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:291
ExceptionHelpers.h
Frameworkfwd.h
edm::Schedule::summaryTimeKeeper_
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:309
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:1370
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:304
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
JobReport.h
edm::Schedule::moduleRegistry_
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:301
edm::StreamSchedule
Definition: StreamSchedule.h:152
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Schedule::getAllModuleDescriptions
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1427
edm::Schedule::triggerPaths
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1450
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:296
edm::Schedule::preallocConfig_
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:307
edm::Schedule::getTriggerTimingReport
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1527
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14
edm::Schedule::resultsInserter_
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:298
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318