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 processOneStream(unsigned int iStreamID,
148  typename T::MyPrincipal& principal,
149  EventSetup const& eventSetup,
150  bool cleaningUpAfterException = false);
151 
152  template <typename T>
153  void processOneStreamAsync(WaitingTaskHolder iTask,
154  unsigned int iStreamID,
155  typename T::MyPrincipal& principal,
156  EventSetup const& eventSetup,
157  bool cleaningUpAfterException = false);
158 
159  void beginJob(ProductRegistry const&);
160  void endJob(ExceptionCollector & collector);
161 
162  void beginStream(unsigned int);
163  void endStream(unsigned int);
164 
165  // Write the luminosity block
166  void writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const*);
167 
168  // Write the run
169  void writeRun(RunPrincipal const& rp, ProcessContext const*);
170 
171  // Call closeFile() on all OutputModules.
172  void closeOutputFiles();
173 
174  // Call openNewFileIfNeeded() on all OutputModules
175  void openNewOutputFilesIfNeeded();
176 
177  // Call openFiles() on all OutputModules
178  void openOutputFiles(FileBlock& fb);
179 
180  // Call respondToOpenInputFile() on all Modules
181  void respondToOpenInputFile(FileBlock const& fb);
182 
183  // Call respondToCloseInputFile() on all Modules
184  void respondToCloseInputFile(FileBlock const& fb);
185 
186  // Call shouldWeCloseFile() on all OutputModules.
187  bool shouldWeCloseOutput() const;
188 
189  void preForkReleaseResources();
190  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
191 
194 
198  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
199 
201  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
202 
206  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
207 
209  void endPaths(std::vector<std::string>& oLabelsToFill) const;
210 
212  void modulesInPath(std::string const& iPathLabel,
213  std::vector<std::string>& oLabelsToFill) const;
214 
217  void moduleDescriptionsInPath(std::string const& iPathLabel,
218  std::vector<ModuleDescription const*>& descriptions,
219  unsigned int hint) const;
220 
223  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
224  std::vector<ModuleDescription const*>& descriptions,
225  unsigned int hint) const;
226 
227  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
228  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
229  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
230  ProductRegistry const& preg) const;
231 
235  int totalEvents() const;
236 
239  int totalEventsPassed() const;
240 
243  int totalEventsFailed() const;
244 
247  void enableEndPaths(bool active);
248 
251  bool endPathsEnabled() const;
252 
255  void getTriggerReport(TriggerReport& rep) const;
256 
259  void getTriggerTimingReport(TriggerTimingReport& rep) const;
260 
262  bool terminate() const;
263 
265  void clearCounters();
266 
269  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
270 
272  AllWorkers const& allWorkers() const;
273 
274  private:
275 
276  void limitOutput(ParameterSet const& proc_pset,
277  BranchIDLists const& branchIDLists,
278  SubProcessParentageHelper const* subProcessParentageHelper);
279 
280  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
281  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
282  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
283  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
284 
287  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
288  //In the future, we will have one GlobalSchedule per simultaneous transition
290 
291  AllOutputModuleCommunicators all_output_communicators_;
293 
295 
297 
298  volatile bool endpathsAreActive_;
299  };
300 
301 
302  template <typename T>
303  void Schedule::processOneStream(unsigned int iStreamID,
304  typename T::MyPrincipal& ep,
305  EventSetup const& es,
306  bool cleaningUpAfterException) {
307  assert(iStreamID<streamSchedules_.size());
308  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
309  }
310 
311  template <typename T>
313  unsigned int iStreamID,
314  typename T::MyPrincipal& ep,
315  EventSetup const& es,
316  bool cleaningUpAfterException) {
317  assert(iStreamID<streamSchedules_.size());
318  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,cleaningUpAfterException);
319  }
320 
321  template <typename T>
322  void
323  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
324  EventSetup const& es,
325  bool cleaningUpAfterException) {
326  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
327  }
328 }
329 #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:282
std::vector< Worker * > AllWorkers
Definition: Schedule.h:118
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:294
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:289
void beginJob()
Definition: Breakpoints.cc:15
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:281
def principal(options)
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:285
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:286
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:323
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:292
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:287
volatile bool endpathsAreActive_
Definition: Schedule.h:298
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:280
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:291
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:119
bool wantSummary_
Definition: Schedule.h:296
HLT enums.
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:303
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:283
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:312
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
def move(src, dest)
Definition: eostools.py:510