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