CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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 TriggerResultInserter;
111 
112  class Schedule {
113  public:
114  typedef std::vector<std::string> vstring;
115  typedef std::vector<Worker*> AllWorkers;
116  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
117 
118  typedef std::vector<Worker*> Workers;
119 
120  Schedule(ParameterSet& proc_pset,
122  ProductRegistry& pregistry,
123  BranchIDListHelper& branchIDListHelper,
124  ThinnedAssociationsHelper& thinnedAssociationsHelper,
126  std::shared_ptr<ActivityRegistry> areg,
127  std::shared_ptr<ProcessConfiguration> processConfiguration,
128  bool hasSubprocesses,
130  ProcessContext const* processContext);
131 
132  template <typename T>
133  void processOneEvent(unsigned int iStreamID,
134  typename T::MyPrincipal& principal,
135  EventSetup const& eventSetup,
136  bool cleaningUpAfterException = false);
137 
138  template <typename T>
139  void processOneGlobal(typename T::MyPrincipal& principal,
140  EventSetup const& eventSetup,
141  bool cleaningUpAfterException = false);
142 
143  template <typename T>
144  void processOneStream(unsigned int iStreamID,
145  typename T::MyPrincipal& principal,
146  EventSetup const& eventSetup,
147  bool cleaningUpAfterException = false);
148 
149  void beginJob(ProductRegistry const&);
150  void endJob(ExceptionCollector & collector);
151 
152  void beginStream(unsigned int);
153  void endStream(unsigned int);
154 
155  // Write the luminosity block
156  void writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const*);
157 
158  // Write the run
159  void writeRun(RunPrincipal const& rp, ProcessContext const*);
160 
161  // Call closeFile() on all OutputModules.
162  void closeOutputFiles();
163 
164  // Call openNewFileIfNeeded() on all OutputModules
166 
167  // Call openFiles() on all OutputModules
169 
170  // Call respondToOpenInputFile() on all Modules
171  void respondToOpenInputFile(FileBlock const& fb);
172 
173  // Call respondToCloseInputFile() on all Modules
174  void respondToCloseInputFile(FileBlock const& fb);
175 
176  // Call shouldWeCloseFile() on all OutputModules.
177  bool shouldWeCloseOutput() const;
178 
180  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
181 
184 
188  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
189 
191  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
192 
196  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
197 
199  void endPaths(std::vector<std::string>& oLabelsToFill) const;
200 
202  void modulesInPath(std::string const& iPathLabel,
203  std::vector<std::string>& oLabelsToFill) const;
204 
207  void moduleDescriptionsInPath(std::string const& iPathLabel,
208  std::vector<ModuleDescription const*>& descriptions,
209  unsigned int hint) const;
210 
213  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
214  std::vector<ModuleDescription const*>& descriptions,
215  unsigned int hint) const;
216 
217  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
218  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
219  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
220  ProductRegistry const& preg) const;
221 
225  int totalEvents() const;
226 
229  int totalEventsPassed() const;
230 
233  int totalEventsFailed() const;
234 
237  void enableEndPaths(bool active);
238 
241  bool endPathsEnabled() const;
242 
245  void getTriggerReport(TriggerReport& rep) const;
246 
250 
252  bool terminate() const;
253 
255  void clearCounters();
256 
259  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
260 
262  AllWorkers const& allWorkers() const;
263 
264  private:
265 
267  void checkForCorrectness() const;
268 
269  void limitOutput(ParameterSet const& proc_pset, BranchIDLists const& branchIDLists);
270 
271  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
272  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
273  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
274  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
275 
278  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
279  //In the future, we will have one GlobalSchedule per simultaneous transition
281 
284 
286 
289 
290  volatile bool endpathsAreActive_;
291  };
292 
293 
294  template <typename T>
295  void Schedule::processOneEvent(unsigned int iStreamID,
296  typename T::MyPrincipal& ep,
297  EventSetup const& es,
298  bool cleaningUpAfterException) {
299  assert(iStreamID<streamSchedules_.size());
300  streamSchedules_[iStreamID]->processOneEvent<T>(ep,es,cleaningUpAfterException);
301  }
302 
303  template <typename T>
304  void Schedule::processOneStream(unsigned int iStreamID,
305  typename T::MyPrincipal& ep,
306  EventSetup const& es,
307  bool cleaningUpAfterException) {
308  assert(iStreamID<streamSchedules_.size());
309  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
310  }
311  template <typename T>
312  void
313  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
314  EventSetup const& es,
315  bool cleaningUpAfterException) {
316  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
317  }
318 }
319 #endif
string rep
Definition: cuy.py:1188
void checkForCorrectness() const
Check that the schedule is actually runable.
Definition: Schedule.cc:1296
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int > > &moduleIDToIndex, std::vector< std::vector< ModuleDescription const * > > &modulesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
Definition: Schedule.cc:1010
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
Definition: Schedule.cc:970
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: Schedule.cc:975
bool endPathsEnabled() const
Definition: Schedule.cc:1050
void respondToCloseInputFile(FileBlock const &fb)
Definition: Schedule.cc:892
std::shared_ptr< ModuleRegistry const > moduleRegistry() const
Definition: Schedule.h:273
std::vector< Worker * > AllWorkers
Definition: Schedule.h:115
assert(m_qm.get())
void writeRun(RunPrincipal const &rp, ProcessContext const *)
Definition: Schedule.cc:869
void endStream(unsigned int)
Definition: Schedule.cc:908
void processOneEvent(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:295
void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)
Definition: Schedule.cc:874
void enableEndPaths(bool active)
Definition: Schedule.cc:1042
processConfiguration
Definition: Schedule.cc:374
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:1003
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:285
actions
Definition: Schedule.cc:374
int totalEventsFailed() const
Definition: Schedule.cc:1091
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:280
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry)
Definition: Schedule.cc:922
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:272
int totalEventsPassed() const
Definition: Schedule.cc:1082
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
Definition: Schedule.cc:980
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists)
Definition: Schedule.cc:514
int totalEvents() const
Definition: Schedule.cc:1073
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:276
void clearCounters()
Clear all the counters in the trigger report.
Definition: Schedule.cc:1101
std::vector< std::string > vstring
Definition: Schedule.h:114
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
bool terminate() const
Return whether each output module has reached its maximum count.
Definition: Schedule.cc:553
bool printDependencies_
Definition: Schedule.h:288
void respondToOpenInputFile(FileBlock const &fb)
Definition: Schedule.cc:887
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
Definition: Schedule.h:277
areg
Definition: Schedule.cc:374
std::vector< Worker * > Workers
Definition: Schedule.h:118
void getTriggerReport(TriggerReport &rep) const
Definition: Schedule.cc:1055
void processOneGlobal(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:313
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:283
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:278
volatile bool endpathsAreActive_
Definition: Schedule.h:290
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:271
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:282
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:990
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:116
void beginStream(unsigned int)
Definition: Schedule.cc:903
bool wantSummary_
Definition: Schedule.h:287
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: Schedule.cc:917
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Definition: Schedule.cc:958
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:304
void beginJob(ProductRegistry const &)
Definition: Schedule.cc:897
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:274
void openNewOutputFilesIfNeeded()
Definition: Schedule.cc:859
void preForkReleaseResources()
Definition: Schedule.cc:913
void openOutputFiles(FileBlock &fb)
Definition: Schedule.cc:864
preg
Definition: Schedule.cc:374
Schedule(ParameterSet &proc_pset, service::TriggerNamesService &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool hasSubprocesses, PreallocationConfiguration const &config, ProcessContext const *processContext)
Definition: Schedule.cc:362
long double T
void endJob(ExceptionCollector &collector)
Definition: Schedule.cc:569
void getTriggerTimingReport(TriggerTimingReport &rep) const
Definition: Schedule.cc:1065
bool shouldWeCloseOutput() const
Definition: Schedule.cc:879
void closeOutputFiles()
Definition: Schedule.cc:854
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
Definition: Schedule.cc:985
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
Definition: Schedule.cc:996