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 
83 
84 #include <map>
85 #include <memory>
86 #include <set>
87 #include <string>
88 #include <vector>
89 #include <sstream>
90 #include <utility>
91 
92 namespace edm {
93 
94  namespace service {
95  class TriggerNamesService;
96  }
97  class ActivityRegistry;
98  class BranchIDListHelper;
99  class EventSetup;
100  class ExceptionCollector;
101  class OutputModuleCommunicator;
102  class ProcessContext;
103  class ProductRegistry;
104  class PreallocationConfiguration;
105  class StreamSchedule;
106  class GlobalSchedule;
107  struct TriggerTimingReport;
108  class ModuleRegistry;
109  class ThinnedAssociationsHelper;
110  class SubProcessParentageHelper;
111  class TriggerResultInserter;
112  class WaitingTaskHolder;
113 
114 
115  class Schedule {
116  public:
117  typedef std::vector<std::string> vstring;
118  typedef std::vector<Worker*> AllWorkers;
119  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
120 
121  typedef std::vector<Worker*> Workers;
122 
123  Schedule(ParameterSet& proc_pset,
125  ProductRegistry& pregistry,
126  BranchIDListHelper& branchIDListHelper,
127  ThinnedAssociationsHelper& thinnedAssociationsHelper,
128  SubProcessParentageHelper const* subProcessParentageHelper,
130  std::shared_ptr<ActivityRegistry> areg,
131  std::shared_ptr<ProcessConfiguration> processConfiguration,
132  bool hasSubprocesses,
134  ProcessContext const* processContext);
135 
136  void processOneEventAsync(WaitingTaskHolder iTask,
137  unsigned int iStreamID,
139  EventSetup const& eventSetup);
140 
141  template <typename T>
142  void processOneGlobal(typename T::MyPrincipal& principal,
143  EventSetup const& eventSetup,
144  bool cleaningUpAfterException = false);
145 
146  template <typename T>
147  void processOneGlobalAsync(WaitingTaskHolder iTask,
148  typename T::MyPrincipal& principal,
149  EventSetup const& eventSetup,
150  bool cleaningUpAfterException = false);
151 
152  template <typename T>
153  void processOneStream(unsigned int iStreamID,
154  typename T::MyPrincipal& principal,
155  EventSetup const& eventSetup,
156  bool cleaningUpAfterException = false);
157 
158  template <typename T>
159  void processOneStreamAsync(WaitingTaskHolder iTask,
160  unsigned int iStreamID,
161  typename T::MyPrincipal& principal,
162  EventSetup const& eventSetup,
163  bool cleaningUpAfterException = false);
164 
165  void beginJob(ProductRegistry const&);
166  void endJob(ExceptionCollector & collector);
167 
168  void beginStream(unsigned int);
169  void endStream(unsigned int);
170 
171  // Write the luminosity block
172  void writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const*);
173 
174  // Write the run
175  void writeRun(RunPrincipal const& rp, ProcessContext const*);
176 
177  // Call closeFile() on all OutputModules.
178  void closeOutputFiles();
179 
180  // Call openNewFileIfNeeded() on all OutputModules
181  void openNewOutputFilesIfNeeded();
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 
195  void preForkReleaseResources();
196  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
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,
219  std::vector<std::string>& oLabelsToFill) const;
220 
223  void moduleDescriptionsInPath(std::string const& iPathLabel,
224  std::vector<ModuleDescription const*>& descriptions,
225  unsigned int hint) const;
226 
229  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
230  std::vector<ModuleDescription const*>& descriptions,
231  unsigned int hint) const;
232 
233  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
234  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
235  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
236  ProductRegistry const& preg) const;
237 
241  int totalEvents() const;
242 
245  int totalEventsPassed() const;
246 
249  int totalEventsFailed() const;
250 
253  void enableEndPaths(bool active);
254 
257  bool endPathsEnabled() const;
258 
261  void getTriggerReport(TriggerReport& rep) const;
262 
265  void getTriggerTimingReport(TriggerTimingReport& rep) const;
266 
268  bool terminate() const;
269 
271  void clearCounters();
272 
275  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
276 
278  AllWorkers const& allWorkers() const;
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 
293  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
294  //In the future, we will have one GlobalSchedule per simultaneous transition
296 
297  AllOutputModuleCommunicators all_output_communicators_;
299 
301 
303 
304  volatile bool endpathsAreActive_;
305  };
306 
307 
308  template <typename T>
309  void Schedule::processOneStream(unsigned int iStreamID,
310  typename T::MyPrincipal& ep,
311  EventSetup const& es,
312  bool cleaningUpAfterException) {
313  assert(iStreamID<streamSchedules_.size());
314  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
315  }
316 
317  template <typename T>
319  unsigned int iStreamID,
320  typename T::MyPrincipal& ep,
321  EventSetup const& es,
322  bool cleaningUpAfterException) {
323  assert(iStreamID<streamSchedules_.size());
324  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,cleaningUpAfterException);
325  }
326 
327  template <typename T>
328  void
329  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
330  EventSetup const& es,
331  bool cleaningUpAfterException) {
332  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
333  }
334 
335  template <typename T>
336  void
338  typename T::MyPrincipal& ep,
339  EventSetup const& es,
340  bool cleaningUpAfterException) {
341  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder,ep,es,cleaningUpAfterException);
342  }
343 
344 }
345 #endif
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:337
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:118
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:300
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:295
void beginJob()
Definition: Breakpoints.cc:15
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:287
def principal(options)
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:291
std::vector< std::string > vstring
Definition: Schedule.h:117
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:292
rep
Definition: cuy.py:1188
std::vector< Worker * > Workers
Definition: Schedule.h:121
void processOneGlobal(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:329
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:298
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:293
volatile bool endpathsAreActive_
Definition: Schedule.h:304
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:286
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:297
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:119
bool wantSummary_
Definition: Schedule.h:302
HLT enums.
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:309
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:318
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
def move(src, dest)
Definition: eostools.py:510