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 EventSetupImpl;
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,
134  ThinnedAssociationsHelper& thinnedAssociationsHelper,
135  SubProcessParentageHelper const* subProcessParentageHelper,
137  std::shared_ptr<ActivityRegistry> areg,
138  std::shared_ptr<ProcessConfiguration> processConfiguration,
139  bool hasSubprocesses,
141  ProcessContext const* processContext);
142 
144  unsigned int iStreamID,
145  EventPrincipal& principal,
146  EventSetupImpl const& eventSetup,
147  ServiceToken const& token);
148 
149  template <typename T>
151  typename T::MyPrincipal& principal,
152  EventSetupImpl const& eventSetup,
153  ServiceToken const& token,
154  bool cleaningUpAfterException = false);
155 
156  template <typename T>
158  unsigned int iStreamID,
159  typename T::MyPrincipal& principal,
160  EventSetupImpl const& eventSetup,
161  ServiceToken const& token,
162  bool cleaningUpAfterException = false);
163 
165  void endJob(ExceptionCollector& collector);
166 
167  void beginStream(unsigned int);
168  void endStream(unsigned int);
169 
170  // Write the luminosity block
172  LuminosityBlockPrincipal const& lbp,
173  ProcessContext const*,
175 
176  // Write the run
177  void writeRunAsync(WaitingTaskHolder iTask,
178  RunPrincipal const& rp,
179  ProcessContext const*,
182 
183  // Call closeFile() on all OutputModules.
184  void closeOutputFiles();
185 
186  // Call openFiles() on all OutputModules
188 
189  // Call respondToOpenInputFile() on all Modules
190  void respondToOpenInputFile(FileBlock const& fb);
191 
192  // Call respondToCloseInputFile() on all Modules
193  void respondToCloseInputFile(FileBlock const& fb);
194 
195  // Call shouldWeCloseFile() on all OutputModules.
196  bool shouldWeCloseOutput() const;
197 
200 
204  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
205 
207  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
208 
212  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
213 
215  void endPaths(std::vector<std::string>& oLabelsToFill) const;
216 
218  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
219 
222  void moduleDescriptionsInPath(std::string const& iPathLabel,
223  std::vector<ModuleDescription const*>& descriptions,
224  unsigned int hint) const;
225 
228  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
229  std::vector<ModuleDescription const*>& descriptions,
230  unsigned int hint) const;
231 
232  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
233  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
234  std::vector<std::vector<ModuleDescription const*>>& modulesWhoseProductsAreConsumedBy,
235  ProductRegistry const& preg) const;
236 
240  int totalEvents() const;
241 
244  int totalEventsPassed() const;
245 
248  int totalEventsFailed() const;
249 
252  void enableEndPaths(bool active);
253 
256  bool endPathsEnabled() const;
257 
260  void getTriggerReport(TriggerReport& rep) const;
261 
265 
267  bool terminate() const;
268 
270  void clearCounters();
271 
274  bool changeModule(std::string const& iLabel,
275  ParameterSet const& iPSet,
276  const ProductRegistry& iRegistry,
278 
280  AllWorkers const& allWorkers() const;
281 
284 
285  private:
286  void limitOutput(ParameterSet const& proc_pset,
287  BranchIDLists const& branchIDLists,
288  SubProcessParentageHelper const* subProcessParentageHelper);
289 
290  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
292  }
293  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
294  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
295  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
296 
298  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
299  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
301  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
302  //In the future, we will have one GlobalSchedule per simultaneous transition
304 
307 
309 
310  std::vector<std::string> const* pathNames_;
311  std::vector<std::string> const* endPathNames_;
313 
314  volatile bool endpathsAreActive_;
315  };
316 
317  template <typename T>
319  unsigned int iStreamID,
320  typename T::MyPrincipal& ep,
321  EventSetupImpl const& es,
322  ServiceToken const& token,
323  bool cleaningUpAfterException) {
324  assert(iStreamID < streamSchedules_.size());
325  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
326  std::move(iTaskHolder), ep, es, token, cleaningUpAfterException);
327  }
328 
329  template <typename T>
331  typename T::MyPrincipal& ep,
332  EventSetupImpl const& es,
333  ServiceToken const& token,
334  bool cleaningUpAfterException) {
335  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, ep, es, token, cleaningUpAfterException);
336  }
337 
338 } // namespace edm
339 #endif
edm::Schedule::beginJob
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1243
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:584
WorkerManager.h
service
Definition: service.py:1
edm::Schedule::vstring
std::vector< std::string > vstring
Definition: Schedule.h:124
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:293
edm::Schedule::limitOutput
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:800
edm::SubProcessParentageHelper
Definition: SubProcessParentageHelper.h:21
edm::Schedule::pathNames_
std::vector< std::string > const * pathNames_
Definition: Schedule.h:310
MessageLogger.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::Schedule::endStream
void endStream(unsigned int)
Definition: Schedule.cc:1252
BranchType.h
edm::Schedule::writeRunAsync
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1147
edm::Schedule::moduleRegistry
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:294
propagate_const.h
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
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:1338
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProcessContext
Definition: ProcessContext.h:27
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:318
edm::Schedule::clearCounters
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1436
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
Algorithms.h
cms::cuda::assert
assert(be >=bs)
edm::Schedule::openOutputFiles
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1142
PreallocationConfiguration.h
edm::Schedule::moduleDescriptionsInEndPath
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1348
edm::Schedule::endPathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:299
edm::Schedule::totalEvents
int totalEvents() const
Definition: Schedule.cc:1412
edm::Schedule::totalEventsFailed
int totalEventsFailed() const
Definition: Schedule.cc:1428
edm::Schedule::closeOutputFiles
void closeOutputFiles()
Definition: Schedule.cc:1137
edm::Schedule::wantSummary_
bool wantSummary_
Definition: Schedule.h:312
edm::Schedule::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name.
Definition: Schedule.cc:1324
edm::ProductRegistry
Definition: ProductRegistry.h:34
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:1330
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::EventPrincipal
Definition: EventPrincipal.h:46
edm::ExceptionCollector
Definition: ExceptionCollector.h:33
EventPrincipal.h
Service.h
edm::Schedule
Definition: Schedule.h:122
edm::Schedule::shouldWeCloseOutput
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1224
edm::Schedule::endJob
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:856
edm::ActivityRegistry
Definition: ActivityRegistry.h:132
edm::TriggerTimingReport
Definition: TriggerTimingReport.h:52
edm::Schedule::processOneEventAsync
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token)
Definition: Schedule.cc:1257
edm::Schedule::changeModule
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1266
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:126
edm::Schedule::beginStream
void beginStream(unsigned int)
Definition: Schedule.cc:1247
edm::GlobalSchedule
Definition: GlobalSchedule.h:77
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:1395
edm::get_underlying_safe
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:40
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:35
StreamSchedule.h
edm::Schedule::streamSchedules_
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:301
edm::ParameterSet
Definition: ParameterSet.h:36
edm::Schedule::endPathsEnabled
bool endPathsEnabled() const
Definition: Schedule.cc:1393
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:841
edm::Schedule::pathStatusInserters_
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:298
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:1354
ExceptionMessages.h
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
ESRecordsToProxyIndices
edm::BranchIDListHelper
Definition: BranchIDListHelper.h:15
edm::Schedule::endpathsAreActive_
volatile bool endpathsAreActive_
Definition: Schedule.h:314
edm::Schedule::respondToCloseInputFile
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1238
cuy.rep
rep
Definition: cuy.py:1190
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:305
edm::Schedule::processOneGlobalAsync
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330
edm::TriggerReport
Definition: TriggerReport.h:56
edm::TriggerResultInserter
Definition: TriggerResultInserter.h:30
edm::Schedule::respondToOpenInputFile
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1233
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:1336
edm::Schedule::totalEventsPassed
int totalEventsPassed() const
Definition: Schedule.cc:1420
edm::service::TriggerNamesService
Definition: TriggerNamesService.h:42
edm::Schedule::enableEndPaths
void enableEndPaths(bool active)
Definition: Schedule.cc:1386
edm::Schedule::endPathNames_
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:311
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:1322
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:1342
edm::Schedule::resultsInserter
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:290
ExceptionHelpers.h
Frameworkfwd.h
edm::Schedule::summaryTimeKeeper_
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:308
T
long double T
Definition: Basic3DVectorLD.h:48
Worker.h
WorkerRegistry.h
SystemTimeKeeper.h
edm::Schedule::writeLumiAsync
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1186
Exception.h
edm::Schedule::globalSchedule_
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:303
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:300
edm::StreamSchedule
Definition: StreamSchedule.h:152
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Schedule::getAllModuleDescriptions
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1311
edm::Schedule::triggerPaths
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1334
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:295
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::Schedule::preallocConfig_
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:306
edm::Schedule::getTriggerTimingReport
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1405
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14
edm::Schedule::resultsInserter_
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:297
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316