CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  namespace evetnsetup {
100  }
101 
102  class ActivityRegistry;
103  class BranchIDListHelper;
104  class EventTransitionInfo;
105  class ExceptionCollector;
108  class ProcessContext;
109  class ProductRegistry;
111  class StreamSchedule;
112  class GlobalSchedule;
113  struct TriggerTimingReport;
114  class ModuleRegistry;
117  class TriggerResultInserter;
118  class PathStatusInserter;
119  class EndPathStatusInserter;
120  class WaitingTaskHolder;
121 
122  class Schedule {
123  public:
124  typedef std::vector<std::string> vstring;
125  typedef std::vector<Worker*> AllWorkers;
126  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
127 
128  typedef std::vector<Worker*> Workers;
129 
130  Schedule(ParameterSet& proc_pset,
132  ProductRegistry& pregistry,
133  BranchIDListHelper& branchIDListHelper,
135  ThinnedAssociationsHelper& thinnedAssociationsHelper,
136  SubProcessParentageHelper const* subProcessParentageHelper,
138  std::shared_ptr<ActivityRegistry> areg,
139  std::shared_ptr<ProcessConfiguration> processConfiguration,
140  bool hasSubprocesses,
142  ProcessContext const* processContext);
143 
145  unsigned int iStreamID,
147  ServiceToken const& token);
148 
149  template <typename T>
151  typename T::TransitionInfoType& transitionInfo,
152  ServiceToken const& token,
153  bool cleaningUpAfterException = false);
154 
155  template <typename T>
157  unsigned int iStreamID,
158  typename T::TransitionInfoType& transitionInfo,
159  ServiceToken const& token,
160  bool cleaningUpAfterException = false);
161 
163  void endJob(ExceptionCollector& collector);
164 
165  void beginStream(unsigned int);
166  void endStream(unsigned int);
167 
168  // Write the luminosity block
170  LuminosityBlockPrincipal const& lbp,
171  ProcessContext const*,
173 
174  // Write the run
175  void writeRunAsync(WaitingTaskHolder iTask,
176  RunPrincipal const& rp,
177  ProcessContext const*,
180 
182  ProcessBlockPrincipal const&,
183  ProcessContext const*,
185 
186  // Call closeFile() on all OutputModules.
187  void closeOutputFiles();
188 
189  // Call openFiles() on all OutputModules
190  void openOutputFiles(FileBlock& fb);
191 
192  // Call respondToOpenInputFile() on all Modules
193  void respondToOpenInputFile(FileBlock const& fb);
194 
195  // Call respondToCloseInputFile() on all Modules
196  void respondToCloseInputFile(FileBlock const& fb);
197 
198  // Call shouldWeCloseFile() on all OutputModules.
199  bool shouldWeCloseOutput() const;
200 
203 
207  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
208 
210  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
211 
215  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
216 
218  void endPaths(std::vector<std::string>& oLabelsToFill) const;
219 
221  void modulesInPath(std::string const& iPathLabel, std::vector<std::string>& oLabelsToFill) const;
222 
225  void moduleDescriptionsInPath(std::string const& iPathLabel,
226  std::vector<ModuleDescription const*>& descriptions,
227  unsigned int hint) const;
228 
231  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
232  std::vector<ModuleDescription const*>& descriptions,
233  unsigned int hint) const;
234 
236  std::vector<ModuleDescription const*>& allModuleDescriptions,
237  std::vector<std::pair<unsigned int, unsigned int>>& moduleIDToIndex,
238  std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes>&
239  modulesWhoseProductsAreConsumedBy,
240  std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
241  ProductRegistry const& preg) const;
242 
246  int totalEvents() const;
247 
250  int totalEventsPassed() const;
251 
254  int totalEventsFailed() const;
255 
258  void getTriggerReport(TriggerReport& rep) const;
259 
263 
265  bool terminate() const;
266 
268  void clearCounters();
269 
272  bool changeModule(std::string const& iLabel,
273  ParameterSet const& iPSet,
274  const ProductRegistry& iRegistry,
276 
278  void deleteModule(std::string const& iLabel, ActivityRegistry* areg);
279 
281  AllWorkers const& allWorkers() const;
282 
285 
286  private:
287  void limitOutput(ParameterSet const& proc_pset,
288  BranchIDLists const& branchIDLists,
289  SubProcessParentageHelper const* subProcessParentageHelper);
290 
291  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {
293  }
294  std::shared_ptr<TriggerResultInserter>& resultsInserter() { return get_underlying_safe(resultsInserter_); }
295  std::shared_ptr<ModuleRegistry const> moduleRegistry() const { return get_underlying_safe(moduleRegistry_); }
296  std::shared_ptr<ModuleRegistry>& moduleRegistry() { return get_underlying_safe(moduleRegistry_); }
297 
299  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>> pathStatusInserters_;
300  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>> endPathStatusInserters_;
302  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
303  //In the future, we will have one GlobalSchedule per simultaneous transition
305 
308 
310 
311  std::vector<std::string> const* pathNames_;
312  std::vector<std::string> const* endPathNames_;
314  };
315 
316  template <typename T>
318  unsigned int iStreamID,
319  typename T::TransitionInfoType& transitionInfo,
320  ServiceToken const& token,
321  bool cleaningUpAfterException) {
322  assert(iStreamID < streamSchedules_.size());
323  streamSchedules_[iStreamID]->processOneStreamAsync<T>(
324  std::move(iTaskHolder), transitionInfo, token, cleaningUpAfterException);
325  }
326 
327  template <typename T>
329  typename T::TransitionInfoType& transitionInfo,
330  ServiceToken const& token,
331  bool cleaningUpAfterException) {
332  globalSchedule_->processOneGlobalAsync<T>(iTaskHolder, transitionInfo, token, cleaningUpAfterException);
333  }
334 
335 } // namespace edm
336 #endif
string rep
Definition: cuy.py:1189
pathNames_ & tns()), endPathNames_(&tns.getEndPaths()), wantSummary_(tns.wantSummary()
Definition: Schedule.cc:691
tuple array
Definition: mps_check.py:216
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:1445
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:1453
void writeProcessBlockAsync(WaitingTaskHolder iTask, ProcessBlockPrincipal const &, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1275
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:1348
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:295
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:317
std::vector< Worker * > AllWorkers
Definition: Schedule.h:125
void processOneGlobalAsync(WaitingTaskHolder iTask, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:328
std::vector< std::string > const * pathNames_
Definition: Schedule.h:311
void convertCurrentProcessAlias(std::string const &processName)
Convert &quot;@currentProcess&quot; in InputTag process names to the actual current process name...
Definition: Schedule.cc:1447
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int >> &moduleIDToIndex, std::array< std::vector< std::vector< ModuleDescription const * >>, NumBranchTypes > &modulesWhoseProductsAreConsumedBy, std::vector< std::vector< ModuleProcessName >> &modulesInPreviousProcessesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
Definition: Schedule.cc:1477
void endStream(unsigned int)
Definition: Schedule.cc:1364
processConfiguration
Definition: Schedule.cc:687
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1471
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:309
assert(be >=bs)
actions
Definition: Schedule.cc:687
void processOneEventAsync(WaitingTaskHolder iTask, unsigned int iStreamID, EventTransitionInfo &, ServiceToken const &token)
Definition: Schedule.cc:1369
int totalEventsFailed() const
Definition: Schedule.cc:1561
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:304
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:294
void deleteModule(std::string const &iLabel, ActivityRegistry *areg)
Deletes module with label iLabel.
Definition: Schedule.cc:1426
int totalEventsPassed() const
Definition: Schedule.cc:1553
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:1457
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
Definition: Schedule.cc:1353
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter > > > pathStatusInserters_
Definition: Schedule.h:299
int totalEvents() const
Definition: Schedule.cc:1545
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:298
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1569
def move
Definition: eostools.py:511
std::vector< std::string > vstring
Definition: Schedule.h:124
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists, SubProcessParentageHelper const *subProcessParentageHelper)
Definition: Schedule.cc:890
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:931
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:1343
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:301
void writeRunAsync(WaitingTaskHolder iTask, RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *, MergeableRunProductMetadata const *)
Definition: Schedule.cc:1242
areg
Definition: Schedule.cc:687
std::vector< Worker * > Workers
Definition: Schedule.h:128
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1528
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:307
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:302
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:291
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter > > > endPathStatusInserters_
Definition: Schedule.h:300
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:306
void modulesInPath(std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
Definition: Schedule.cc:1461
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:126
void beginStream(unsigned int)
Definition: Schedule.cc:1359
tuple config
parse the configuration file
bool wantSummary_
Definition: Schedule.h:313
std::vector< std::string > const * endPathNames_
Definition: Schedule.h:312
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:1434
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:296
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:1237
preg
Definition: Schedule.cc:687
void writeLumiAsync(WaitingTaskHolder iTask, LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *)
Definition: Schedule.cc:1305
long double T
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:946
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1538
Schedule(ParameterSet &proc_pset, service::TriggerNamesService const &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ProcessBlockHelperBase &, ThinnedAssociationsHelper &thinnedAssociationsHelper, SubProcessParentageHelper const *subProcessParentageHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool hasSubprocesses, PreallocationConfiguration const &config, ProcessContext const *processContext)
Definition: Schedule.cc:671
bool shouldWeCloseOutput() const
Definition: Schedule.cc:1334
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry, eventsetup::ESRecordsToProxyIndices const &)
Definition: Schedule.cc:1377
void closeOutputFiles()
Definition: Schedule.cc:1229
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:1459
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1465