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 TriggerResultInserter;
111  class WaitingTaskHolder;
112 
113 
114  class Schedule {
115  public:
116  typedef std::vector<std::string> vstring;
117  typedef std::vector<Worker*> AllWorkers;
118  typedef std::vector<edm::propagate_const<std::shared_ptr<OutputModuleCommunicator>>> AllOutputModuleCommunicators;
119 
120  typedef std::vector<Worker*> Workers;
121 
122  Schedule(ParameterSet& proc_pset,
124  ProductRegistry& pregistry,
125  BranchIDListHelper& branchIDListHelper,
126  ThinnedAssociationsHelper& thinnedAssociationsHelper,
128  std::shared_ptr<ActivityRegistry> areg,
129  std::shared_ptr<ProcessConfiguration> processConfiguration,
130  bool hasSubprocesses,
132  ProcessContext const* processContext);
133 
134  void processOneEventAsync(WaitingTaskHolder iTask,
135  unsigned int iStreamID,
137  EventSetup const& eventSetup);
138 
139  template <typename T>
140  void processOneGlobal(typename T::MyPrincipal& principal,
141  EventSetup const& eventSetup,
142  bool cleaningUpAfterException = false);
143 
144  template <typename T>
145  void processOneStream(unsigned int iStreamID,
146  typename T::MyPrincipal& principal,
147  EventSetup const& eventSetup,
148  bool cleaningUpAfterException = false);
149 
150  void beginJob(ProductRegistry const&);
151  void endJob(ExceptionCollector & collector);
152 
153  void beginStream(unsigned int);
154  void endStream(unsigned int);
155 
156  // Write the luminosity block
157  void writeLumi(LuminosityBlockPrincipal const& lbp, ProcessContext const*);
158 
159  // Write the run
160  void writeRun(RunPrincipal const& rp, ProcessContext const*);
161 
162  // Call closeFile() on all OutputModules.
163  void closeOutputFiles();
164 
165  // Call openNewFileIfNeeded() on all OutputModules
166  void openNewOutputFilesIfNeeded();
167 
168  // Call openFiles() on all OutputModules
169  void openOutputFiles(FileBlock& fb);
170 
171  // Call respondToOpenInputFile() on all Modules
172  void respondToOpenInputFile(FileBlock const& fb);
173 
174  // Call respondToCloseInputFile() on all Modules
175  void respondToCloseInputFile(FileBlock const& fb);
176 
177  // Call shouldWeCloseFile() on all OutputModules.
178  bool shouldWeCloseOutput() const;
179 
180  void preForkReleaseResources();
181  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
182 
185 
189  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
190 
192  void availablePaths(std::vector<std::string>& oLabelsToFill) const;
193 
197  void triggerPaths(std::vector<std::string>& oLabelsToFill) const;
198 
200  void endPaths(std::vector<std::string>& oLabelsToFill) const;
201 
203  void modulesInPath(std::string const& iPathLabel,
204  std::vector<std::string>& oLabelsToFill) const;
205 
208  void moduleDescriptionsInPath(std::string const& iPathLabel,
209  std::vector<ModuleDescription const*>& descriptions,
210  unsigned int hint) const;
211 
214  void moduleDescriptionsInEndPath(std::string const& iEndPathLabel,
215  std::vector<ModuleDescription const*>& descriptions,
216  unsigned int hint) const;
217 
218  void fillModuleAndConsumesInfo(std::vector<ModuleDescription const*>& allModuleDescriptions,
219  std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
220  std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
221  ProductRegistry const& preg) const;
222 
226  int totalEvents() const;
227 
230  int totalEventsPassed() const;
231 
234  int totalEventsFailed() const;
235 
238  void enableEndPaths(bool active);
239 
242  bool endPathsEnabled() const;
243 
246  void getTriggerReport(TriggerReport& rep) const;
247 
250  void getTriggerTimingReport(TriggerTimingReport& rep) const;
251 
253  bool terminate() const;
254 
256  void clearCounters();
257 
260  bool changeModule(std::string const& iLabel, ParameterSet const& iPSet, const ProductRegistry& iRegistry);
261 
263  AllWorkers const& allWorkers() const;
264 
265  private:
266 
267  void limitOutput(ParameterSet const& proc_pset, BranchIDLists const& branchIDLists);
268 
269  std::shared_ptr<TriggerResultInserter const> resultsInserter() const {return get_underlying_safe(resultsInserter_);}
270  std::shared_ptr<TriggerResultInserter>& resultsInserter() {return get_underlying_safe(resultsInserter_);}
271  std::shared_ptr<ModuleRegistry const> moduleRegistry() const {return get_underlying_safe(moduleRegistry_);}
272  std::shared_ptr<ModuleRegistry>& moduleRegistry() {return get_underlying_safe(moduleRegistry_);}
273 
276  std::vector<edm::propagate_const<std::shared_ptr<StreamSchedule>>> streamSchedules_;
277  //In the future, we will have one GlobalSchedule per simultaneous transition
279 
280  AllOutputModuleCommunicators all_output_communicators_;
282 
284 
286 
287  volatile bool endpathsAreActive_;
288  };
289 
290 
291  template <typename T>
292  void Schedule::processOneStream(unsigned int iStreamID,
293  typename T::MyPrincipal& ep,
294  EventSetup const& es,
295  bool cleaningUpAfterException) {
296  assert(iStreamID<streamSchedules_.size());
297  streamSchedules_[iStreamID]->processOneStream<T>(ep,es,cleaningUpAfterException);
298  }
299  template <typename T>
300  void
301  Schedule::processOneGlobal(typename T::MyPrincipal& ep,
302  EventSetup const& es,
303  bool cleaningUpAfterException) {
304  globalSchedule_->processOneGlobal<T>(ep,es,cleaningUpAfterException);
305  }
306 }
307 #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:271
std::vector< Worker * > AllWorkers
Definition: Schedule.h:117
Definition: config.py:1
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
Definition: Schedule.h:283
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
Definition: Schedule.h:278
void beginJob()
Definition: Breakpoints.cc:15
std::shared_ptr< TriggerResultInserter > & resultsInserter()
Definition: Schedule.h:270
def principal(options)
edm::propagate_const< std::shared_ptr< TriggerResultInserter > > resultsInserter_
Definition: Schedule.h:274
std::vector< std::string > vstring
Definition: Schedule.h:116
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:275
rep
Definition: cuy.py:1188
std::vector< Worker * > Workers
Definition: Schedule.h:120
void processOneGlobal(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:301
PreallocationConfiguration preallocConfig_
Definition: Schedule.h:281
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
Definition: Schedule.h:276
volatile bool endpathsAreActive_
Definition: Schedule.h:287
std::shared_ptr< TriggerResultInserter const > resultsInserter() const
Definition: Schedule.h:269
AllOutputModuleCommunicators all_output_communicators_
Definition: Schedule.h:280
std::vector< edm::propagate_const< std::shared_ptr< OutputModuleCommunicator > > > AllOutputModuleCommunicators
Definition: Schedule.h:118
bool wantSummary_
Definition: Schedule.h:285
HLT enums.
void processOneStream(unsigned int iStreamID, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
Definition: Schedule.h:292
std::shared_ptr< ModuleRegistry > & moduleRegistry()
Definition: Schedule.h:272
long double T
static std::string const triggerPaths
Definition: EdmProvDump.cc:42