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 processOneGlobal(typename T::MyPrincipal& principal,
146  EventSetup const& eventSetup,
147  bool cleaningUpAfterException = false);
148 
149  template <typename T>
150  void processOneGlobalAsync(WaitingTaskHolder iTask,
151  typename T::MyPrincipal& principal,
152  EventSetup const& eventSetup,
153  bool cleaningUpAfterException = false);
154 
155  template <typename T>
156  void processOneStream(unsigned int iStreamID,
157  typename T::MyPrincipal& principal,
158  EventSetup const& eventSetup,
159  bool cleaningUpAfterException = false);
160 
161  template <typename T>
162  void processOneStreamAsync(WaitingTaskHolder iTask,
163  unsigned int iStreamID,
164  typename T::MyPrincipal& principal,
165  EventSetup const& eventSetup,
166  bool cleaningUpAfterException = false);
167 
168  void beginJob(ProductRegistry const&);
169  void endJob(ExceptionCollector & collector);
170 
171  void beginStream(unsigned int);
172  void endStream(unsigned int);
173 
174  // Write the luminosity block
175  void writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const*);
176 
177  // Write the run
178  void writeRun(RunPrincipal const& rp, 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>
313  void Schedule::processOneStream(unsigned int iStreamID,
314  typename T::MyPrincipal& ep,
315  EventSetup const& es,
316  bool cleaningUpAfterException) {
317  assert(iStreamID<streamSchedules_.size());
318  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
319  }
320 
321  template <typename T>
323  unsigned int iStreamID,
324  typename T::MyPrincipal& ep,
325  EventSetup const& es,
326  bool cleaningUpAfterException) {
327  assert(iStreamID<streamSchedules_.size());
328  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,cleaningUpAfterException);
329  }
330 
331  template <typename T>
332  void
333  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
334  EventSetup const& es,
335  bool cleaningUpAfterException) {
336  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
337  }
338 
339  template <typename T>
340  void
342  typename T::MyPrincipal& ep,
343  EventSetup const& es,
344  bool cleaningUpAfterException) {
345  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder,ep,es,cleaningUpAfterException);
346  }
347 
348 }
349 #endif
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:341
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:121
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
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:294
rep
Definition: cuy.py:1188
std::vector< Worker * > Workers
Definition: Schedule.h:124
void processOneGlobal(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:333
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:122
bool wantSummary_
Definition: Schedule.h:306
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:305
HLT enums.
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:313
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:289
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:322
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
def move(src, dest)
Definition: eostools.py:510