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  ServiceToken const& token);
144 
145  template <typename T>
146  void processOneGlobalAsync(WaitingTaskHolder iTask,
147  typename T::MyPrincipal& principal,
148  EventSetup const& eventSetup,
149  ServiceToken const& token,
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  ServiceToken const& token,
158  bool cleaningUpAfterException = false);
159 
160  void beginJob(ProductRegistry const&);
161  void endJob(ExceptionCollector & collector);
162 
163  void beginStream(unsigned int);
164  void endStream(unsigned int);
165 
166  // Write the luminosity block
167  void writeLumiAsync(WaitingTaskHolder iTask,
168  LuminosityBlockPrincipal const& lbp,
169  ProcessContext const*,
171 
172  // Write the run
173  void writeRunAsync(WaitingTaskHolder iTask,
174  RunPrincipal const& rp,
175  ProcessContext const*,
177 
178  // Call closeFile() on all OutputModules.
179  void closeOutputFiles();
180 
181  // Call openFiles() on all OutputModules
182  void openOutputFiles(FileBlock& fb);
183 
184  // Call respondToOpenInputFile() on all Modules
185  void respondToOpenInputFile(FileBlock const& fb);
186 
187  // Call respondToCloseInputFile() on all Modules
188  void respondToCloseInputFile(FileBlock const& fb);
189 
190  // Call shouldWeCloseFile() on all OutputModules.
191  bool shouldWeCloseOutput() const;
192 
195 
199  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
200 
202  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
203 
207  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
208 
210  void endPaths(std::vector<std::string>& oLabelsToFill) const;
211 
213  void modulesInPath(std::string const& iPathLabel,
214  std::vector<std::string>& oLabelsToFill) const;
215 
218  void moduleDescriptionsInPath(std::string const& iPathLabel,
219  std::vector<ModuleDescription const*>& descriptions,
220  unsigned int hint) const;
221 
224  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
225  std::vector<ModuleDescription const*>& descriptions,
226  unsigned int hint) const;
227 
228  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
229  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
230  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
231  ProductRegistry const& preg) const;
232 
236  int totalEvents() const;
237 
240  int totalEventsPassed() const;
241 
244  int totalEventsFailed() const;
245 
248  void enableEndPaths(bool active);
249 
252  bool endPathsEnabled() const;
253 
256  void getTriggerReport(TriggerReport& rep) const;
257 
260  void getTriggerTimingReport(TriggerTimingReport& rep) const;
261 
263  bool terminate() const;
264 
266  void clearCounters();
267 
270  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
271 
273  AllWorkers const& allWorkers() const;
274 
276  void convertCurrentProcessAlias(std::string const& processName);
277 
278  private:
279 
280  void limitOutput(ParameterSet const& proc_pset,
281  BranchIDLists const& branchIDLists,
282  SubProcessParentageHelper const* subProcessParentageHelper);
283 
284  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
285  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
286  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
287  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
288 
290  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
291  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
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 
302  std::vector<std::string> const* pathNames_;
303  std::vector<std::string> const* endPathNames_;
305 
306  volatile bool endpathsAreActive_;
307  };
308 
309 
310  template <typename T>
312  unsigned int iStreamID,
313  typename T::MyPrincipal& ep,
314  EventSetup const& es,
315  ServiceToken const& token,
316  bool cleaningUpAfterException) {
317  assert(iStreamID<streamSchedules_.size());
318  streamSchedules_[iStreamID]->processOneStreamAsync<T>(std::move(iTaskHolder),ep,es,token,cleaningUpAfterException);
319  }
320 
321  template <typename T>
322  void
324  typename T::MyPrincipal& ep,
325  EventSetup const& es,
326  ServiceToken const& token,
327  bool cleaningUpAfterException) {
328  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder,ep,es,token,cleaningUpAfterException);
329  }
330 
331 }
332 #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:286
std::vector< Worker * > AllWorkers
Definition: Schedule.h:121
std::vector< std::string > const * pathNames_
Definition: Schedule.h:302
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:285
def principal(options)
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:290
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:289
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:311
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:292
rep
Definition: cuy.py:1189
std::vector< Worker * > Workers
Definition: Schedule.h:124
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:306
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:284
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:291
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:297
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:122
bool wantSummary_
Definition: Schedule.h:304
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:303
HLT enums.
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:287
long double T
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:323
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
def move(src, dest)
Definition: eostools.py:510