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 
143  void processOneEventAsync(WaitingTaskHolder iTask,
144  unsigned int iStreamID,
146  EventSetupImpl const& eventSetup,
147  ServiceToken const& token);
148 
149  template <typename T>
150  void processOneGlobalAsync(WaitingTaskHolder iTask,
151  typename T::MyPrincipal& principal,
152  EventSetupImpl const& eventSetup,
153  ServiceToken const& token,
154  bool cleaningUpAfterException = false);
155 
156  template <typename T>
157  void processOneStreamAsync(WaitingTaskHolder iTask,
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
171  void writeLumiAsync(WaitingTaskHolder iTask,
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
187  void openOutputFiles(FileBlock& fb);
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 
264  void getTriggerTimingReport(TriggerTimingReport& rep) const;
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 
283  void convertCurrentProcessAlias(std::string const& processName);
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 {
291  return get_underlying_safe(resultsInserter_);
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 
305  AllOutputModuleCommunicators all_output_communicators_;
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
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
roAction_t actions[nactions]
Definition: GenABIO.cc:181
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:294
std::vector< Worker * > AllWorkers
Definition: Schedule.h:125
std::vector< std::string > const * pathNames_
Definition: Schedule.h:310
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:308
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:303
void beginJob()
Definition: Breakpoints.cc:14
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:293
def principal(options)
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:298
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:297
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:318
std::vector< std::string > vstring
Definition: Schedule.h:124
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:300
rep
Definition: cuy.py:1190
std::vector< Worker * > Workers
Definition: Schedule.h:128
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:306
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:301
volatile bool endpathsAreActive_
Definition: Schedule.h:314
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:290
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:299
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:305
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:126
bool wantSummary_
Definition: Schedule.h:312
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:311
HLT enums.
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:295
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:46
def move(src, dest)
Definition: eostools.py:511
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetupImpl const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:330