CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
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 getTriggerReport(TriggerReport& rep) const;
259 
263 
265  bool terminate() const;
266 
268  void clearCounters();
269 
272  bool changeModule(std::string const& iLabel,
273  ParameterSet const& iPSet,
274  const ProductRegistry& iRegistry,
276 
278  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
279 
280  void initializeEarlyDelete(std::vector<std::string> const& branchesToDeleteEarly, edm::ProductRegistry const& preg);
281 
283  AllWorkers const& allWorkers() const;
284 
287 
288  private:
289  void limitOutput(ParameterSet const& proc_pset,
290  BranchIDLists const& branchIDLists,
291  SubProcessParentageHelper const* subProcessParentageHelper);
292 
293  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
295  }
296  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
297  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
298  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
299 
301  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
302  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
304  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
305  //In the future, we will have one GlobalSchedule per simultaneous transition
307 
310 
312 
313  std::vector<std::string> const* pathNames_;
314  std::vector<std::string> const* endPathNames_;
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
string rep
Definition: cuy.py:1189
pathNames_ & tns()), endPathNames_(&tns.getEndPaths()), wantSummary_(tns.wantSummary()
Definition: Schedule.cc:691
tuple array
Definition: mps_check.py:216
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1451
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1459
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1274
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1347
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:297
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:319
std::vector< Worker * > AllWorkers
Definition: Schedule.h:125
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330
std::vector< std::string > const * pathNames_
Definition: Schedule.h:313
void convertCurrentProcessAlias(std::string const &processName)
Convert &quot;@currentProcess&quot; in InputTag process names to the actual current process name...
Definition: Schedule.cc:1453
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:1483
void endStream(unsigned int)
Definition: Schedule.cc:1363
processConfiguration
Definition: Schedule.cc:687
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1477
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:311
assert(be >=bs)
actions
Definition: Schedule.cc:687
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1368
int totalEventsFailed() const
Definition: Schedule.cc:1567
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:306
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:296
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1425
int totalEventsPassed() const
Definition: Schedule.cc:1559
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1463
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1352
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:301
int totalEvents() const
Definition: Schedule.cc:1551
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:300
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1575
def move
Definition: eostools.py:511
std::vector< std::string > vstring
Definition: Schedule.h:124
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:889
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:930
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1342
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:303
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1241
areg
Definition: Schedule.cc:687
std::vector< Worker * > Workers
Definition: Schedule.h:128
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1534
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:309
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:304
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:293
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:302
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:308
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:1467
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:126
void beginStream(unsigned int)
Definition: Schedule.cc:1358
tuple config
parse the configuration file
bool wantSummary_
Definition: Schedule.h:315
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:314
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1440
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:298
void initializeEarlyDelete(std::vector< std::string > const &branchesToDeleteEarly, edm::ProductRegistry const &preg)
Definition: Schedule.cc:1433
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1236
preg
Definition: Schedule.cc:687
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1304
long double T
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:945
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1544
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:671
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1333
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1376
void closeOutputFiles()
Definition: Schedule.cc:1228
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1465
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1471