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 
281  void convertCurrentProcessAlias(std::string const& processName);
282 
283  private:
284 
285  void limitOutput(ParameterSet const& proc_pset,
286  BranchIDLists const& branchIDLists,
287  SubProcessParentageHelper const* subProcessParentageHelper);
288 
289  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
290  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
291  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
292  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
293 
296  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
297  //In the future, we will have one GlobalSchedule per simultaneous transition
299 
300  AllOutputModuleCommunicators all_output_communicators_;
302 
304 
306 
307  volatile bool endpathsAreActive_;
308  };
309 
310 
311  template <typename T>
312  void Schedule::processOneStream(unsigned int iStreamID,
313  typename T::MyPrincipal& ep,
314  EventSetup const& es,
315  bool cleaningUpAfterException) {
316  assert(iStreamID<streamSchedules_.size());
317  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
318  }
319 
320  template <typename T>
322  unsigned int iStreamID,
323  typename T::MyPrincipal& ep,
324  EventSetup const& es,
325  bool cleaningUpAfterException) {
326  assert(iStreamID<streamSchedules_.size());
327  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,cleaningUpAfterException);
328  }
329 
330  template <typename T>
331  void
332  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
333  EventSetup const& es,
334  bool cleaningUpAfterException) {
335  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
336  }
337 
338  template <typename T>
339  void
341  typename T::MyPrincipal& ep,
342  EventSetup const& es,
343  bool cleaningUpAfterException) {
344  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder,ep,es,cleaningUpAfterException);
345  }
346 
347 }
348 #endif
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:340
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:291
std::vector< Worker * > AllWorkers
Definition: Schedule.h:118
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:303
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:298
void beginJob()
Definition: Breakpoints.cc:15
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:290
def principal(options)
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:294
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:295
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:332
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:301
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:296
volatile bool endpathsAreActive_
Definition: Schedule.h:307
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:289
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:300
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:119
bool wantSummary_
Definition: Schedule.h:305
HLT enums.
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:312
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:292
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:321
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
def move(src, dest)
Definition: eostools.py:510