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  class ActivityRegistry;
99  class BranchIDListHelper;
100  class EventSetup;
101  class ExceptionCollector;
102  class MergeableRunProductMetadata;
103  class OutputModuleCommunicator;
104  class ProcessContext;
105  class ProductRegistry;
106  class PreallocationConfiguration;
107  class StreamSchedule;
108  class GlobalSchedule;
109  struct TriggerTimingReport;
110  class ModuleRegistry;
111  class ThinnedAssociationsHelper;
112  class SubProcessParentageHelper;
113  class TriggerResultInserter;
114  class PathStatusInserter;
115  class EndPathStatusInserter;
116  class WaitingTaskHolder;
117 
118 
119  class Schedule {
120  public:
121  typedef std::vector<std::string> vstring;
122  typedef std::vector<Worker*> AllWorkers;
123  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
124 
125  typedef std::vector<Worker*> Workers;
126 
127  Schedule(ParameterSet& proc_pset,
128  service::TriggerNamesService const& tns,
129  ProductRegistry& pregistry,
130  BranchIDListHelper& branchIDListHelper,
131  ThinnedAssociationsHelper& thinnedAssociationsHelper,
132  SubProcessParentageHelper const* subProcessParentageHelper,
134  std::shared_ptr<ActivityRegistry> areg,
135  std::shared_ptr<ProcessConfiguration> processConfiguration,
136  bool hasSubprocesses,
138  ProcessContext const* processContext);
139 
140  void processOneEventAsync(WaitingTaskHolder iTask,
141  unsigned int iStreamID,
143  EventSetup const& eventSetup,
144  ServiceToken const& token);
145 
146  template <typename T>
147  void processOneGlobalAsync(WaitingTaskHolder iTask,
148  typename T::MyPrincipal& principal,
149  EventSetup const& eventSetup,
150  ServiceToken const& token,
151  bool cleaningUpAfterException = false);
152 
153  template <typename T>
154  void processOneStreamAsync(WaitingTaskHolder iTask,
155  unsigned int iStreamID,
156  typename T::MyPrincipal& principal,
157  EventSetup const& eventSetup,
158  ServiceToken const& token,
159  bool cleaningUpAfterException = false);
160 
161  void beginJob(ProductRegistry const&);
162  void endJob(ExceptionCollector & collector);
163 
164  void beginStream(unsigned int);
165  void endStream(unsigned int);
166 
167  // Write the luminosity block
168  void writeLumiAsync(WaitingTaskHolder iTask,
169  LuminosityBlockPrincipal const& lbp,
170  ProcessContext const*,
172 
173  // Write the run
174  void writeRunAsync(WaitingTaskHolder iTask,
175  RunPrincipal const& rp,
176  ProcessContext const*,
179 
180  // Call closeFile() on all OutputModules.
181  void closeOutputFiles();
182 
183  // Call openFiles() on all OutputModules
184  void openOutputFiles(FileBlock& fb);
185 
186  // Call respondToOpenInputFile() on all Modules
187  void respondToOpenInputFile(FileBlock const& fb);
188 
189  // Call respondToCloseInputFile() on all Modules
190  void respondToCloseInputFile(FileBlock const& fb);
191 
192  // Call shouldWeCloseFile() on all OutputModules.
193  bool shouldWeCloseOutput() const;
194 
197 
201  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
202 
204  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
205 
209  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
210 
212  void endPaths(std::vector<std::string>& oLabelsToFill) const;
213 
215  void modulesInPath(std::string const& iPathLabel,
216  std::vector<std::string>& oLabelsToFill) const;
217 
220  void moduleDescriptionsInPath(std::string const& iPathLabel,
221  std::vector<ModuleDescription const*>& descriptions,
222  unsigned int hint) const;
223 
226  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
227  std::vector<ModuleDescription const*>& descriptions,
228  unsigned int hint) const;
229 
230  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
231  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
232  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
233  ProductRegistry const& preg) const;
234 
238  int totalEvents() const;
239 
242  int totalEventsPassed() const;
243 
246  int totalEventsFailed() const;
247 
250  void enableEndPaths(bool active);
251 
254  bool endPathsEnabled() const;
255 
258  void getTriggerReport(TriggerReport& rep) const;
259 
262  void getTriggerTimingReport(TriggerTimingReport& rep) const;
263 
265  bool terminate() const;
266 
268  void clearCounters();
269 
272  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
273 
275  AllWorkers const& allWorkers() const;
276 
278  void convertCurrentProcessAlias(std::string const& processName);
279 
280  private:
281 
282  void limitOutput(ParameterSet const& proc_pset,
283  BranchIDLists const& branchIDLists,
284  SubProcessParentageHelper const* subProcessParentageHelper);
285 
286  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
287  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
288  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
289  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
290 
292  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
293  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
295  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
296  //In the future, we will have one GlobalSchedule per simultaneous transition
298 
299  AllOutputModuleCommunicators all_output_communicators_;
301 
303 
304  std::vector<std::string> const* pathNames_;
305  std::vector<std::string> const* endPathNames_;
307 
308  volatile bool endpathsAreActive_;
309  };
310 
311 
312  template <typename T>
314  unsigned int iStreamID,
315  typename T::MyPrincipal& ep,
316  EventSetup const& es,
317  ServiceToken const& token,
318  bool cleaningUpAfterException) {
319  assert(iStreamID<streamSchedules_.size());
320  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,token,cleaningUpAfterException);
321  }
322 
323  template <typename T>
324  void
326  typename T::MyPrincipal& ep,
327  EventSetup const& es,
328  ServiceToken const& token,
329  bool cleaningUpAfterException) {
330  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder,ep,es,token,cleaningUpAfterException);
331  }
332 
333 }
334 #endif
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
roAction_t actions[nactions]
Definition: GenABIO.cc:187
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:288
std::vector< Worker * > AllWorkers
Definition: Schedule.h:122
std::vector< std::string > const * pathNames_
Definition: Schedule.h:304
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:302
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:297
void beginJob()
Definition: Breakpoints.cc:15
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:287
def principal(options)
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:292
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:291
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:313
std::vector< std::string > vstring
Definition: Schedule.h:121
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:294
rep
Definition: cuy.py:1190
std::vector< Worker * > Workers
Definition: Schedule.h:125
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:300
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:295
volatile bool endpathsAreActive_
Definition: Schedule.h:308
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:286
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:293
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:299
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:123
bool wantSummary_
Definition: Schedule.h:306
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:305
HLT enums.
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:289
long double T
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:325
static std::string const triggerPaths
Definition: EdmProvDump.cc:43
def move(src, dest)
Definition: eostools.py:511