CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SubProcess.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_SubProcess_h
2 #define FWCore_Framework_SubProcess_h
3 
15 
17 
18 #include "boost/shared_ptr.hpp"
19 
20 #include <map>
21 #include <memory>
22 
23 namespace edm {
24  class BranchIDListHelper;
25  class HistoryAppender;
26  class IOVSyncValue;
27  class ParameterSet;
28  class ProductRegistry;
29  class PreallocationConfiguration;
30 
31  namespace eventsetup {
32  class EventSetupsController;
33  }
34  class SubProcess {
35  public:
37  ParameterSet const& topLevelParameterSet,
38  std::shared_ptr<ProductRegistry const> parentProductRegistry,
39  std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
41  ActivityRegistry& parentActReg,
42  ServiceToken const& token,
44  PreallocationConfiguration const& preallocConfig,
45  ProcessContext const* parentProcessContext);
46 
47  virtual ~SubProcess();
48 
49  SubProcess(SubProcess const&) = delete; // Disallow copying and moving
50  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying and moving
51 
52  //From OutputModule
53  void selectProducts(ProductRegistry const& preg);
55 
56  void doBeginJob();
57  void doEndJob();
58 
59  void doEvent(EventPrincipal const& principal);
60 
61  void doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts);
62 
63  void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
64 
66 
67  void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
68 
69 
70  void doBeginStream(unsigned int);
71  void doEndStream(unsigned int);
72  void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);
73 
74  void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
75 
76  void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
77 
78  void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
79 
80 
81  // Write the luminosity block
82  void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
83 
84  void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
85 
86  // Write the run
87  void writeRun(ProcessHistoryID const& parentPhID, int runNumber);
88 
89  void deleteRunFromCache(ProcessHistoryID const& parentPhID, int runNumber);
90 
91  // Call closeFile() on all OutputModules.
94  schedule_->closeOutputFiles();
95  if(subProcess_.get()) subProcess_->closeOutputFiles();
96  }
97 
98  // Call openNewFileIfNeeded() on all OutputModules
101  schedule_->openNewOutputFilesIfNeeded();
102  if(subProcess_.get()) subProcess_->openNewOutputFilesIfNeeded();
103  }
104 
105  // Call openFiles() on all OutputModules
108  schedule_->openOutputFiles(fb);
109  if(subProcess_.get()) subProcess_->openOutputFiles(fb);
110  }
111 
113 
114  // Call respondToOpenInputFile() on all Modules
115  void respondToOpenInputFile(FileBlock const& fb);
116 
117  // Call respondToCloseInputFile() on all Modules
120  schedule_->respondToCloseInputFile(fb);
121  if(subProcess_.get()) subProcess_->respondToCloseInputFile(fb);
122  }
123 
124  // Call shouldWeCloseFile() on all OutputModules.
125  bool shouldWeCloseOutput() const {
127  return schedule_->shouldWeCloseOutput() || (subProcess_.get() ? subProcess_->shouldWeCloseOutput() : false);
128  }
129 
132  schedule_->preForkReleaseResources();
133  if(subProcess_.get()) subProcess_->preForkReleaseResources();
134  }
135 
136  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
138  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
139  if(subProcess_.get()) subProcess_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
140  }
141 
143 
147  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
148 
152  int totalEvents() const {
153  return schedule_->totalEvents();
154  }
155 
157  int totalEventsPassed() const {
159  return schedule_->totalEventsPassed();
160  }
161 
164  int totalEventsFailed() const {
166  return schedule_->totalEventsFailed();
167  }
168 
171  void enableEndPaths(bool active) {
173  schedule_->enableEndPaths(active);
174  if(subProcess_.get()) subProcess_->enableEndPaths(active);
175  }
176 
178  bool endPathsEnabled() const {
180  return schedule_->endPathsEnabled();
181  }
182 
187  schedule_->getTriggerReport(rep);
188  }
189 
192  bool terminate() const {
194  return subProcess_.get() ? subProcess_->terminate() : schedule_->terminate();
195  }
196 
198  void clearCounters() {
200  schedule_->clearCounters();
201  if(subProcess_.get()) subProcess_->clearCounters();
202  }
203 
204  private:
205  void beginJob();
206  void endJob();
207  void process(EventPrincipal const& e);
208  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
209  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
211  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
212 
213  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
214  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
215 
216  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
218  }
219 
220 
222  std::shared_ptr<ProductRegistry const> parentPreg_;
223  std::shared_ptr<ProductRegistry const> preg_;
224  std::shared_ptr<BranchIDListHelper> branchIDListHelper_;
225  std::unique_ptr<ExceptionToActionTable const> act_table_;
226  std::shared_ptr<ProcessConfiguration const> processConfiguration_;
228  //We require 1 history for each Run, Lumi and Stream
229  // The vectors first hold Stream info, then Lumi then Run
230  unsigned int historyLumiOffset_;
231  unsigned int historyRunOffset_;
232  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
233  std::vector<HistoryAppender> historyAppenders_;
235  boost::shared_ptr<eventsetup::EventSetupProvider> esp_;
236  std::auto_ptr<Schedule> schedule_;
237  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
238  std::auto_ptr<SubProcess> subProcess_;
239  std::unique_ptr<ParameterSet> processParameterSet_;
240 
241  // keptProducts_ are pointers to the BranchDescription objects describing
242  // the branches we are to write.
243  //
244  // We do not own the BranchDescriptions to which we point.
248 
249 
250  //EventSelection
254 
255  // needed because of possible EDAliases.
256  // filled in only if key and value are different.
257  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
258 
259  };
260 
261  // free function
262  std::auto_ptr<ParameterSet> popSubProcessParameterSet(ParameterSet& parameterSet);
263 }
264 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:231
unsigned int historyLumiOffset_
Definition: SubProcess.h:230
ParameterSetID selector_config_id_
Definition: SubProcess.h:252
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
void enableEndPaths(bool active)
Definition: SubProcess.h:171
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:538
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:487
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:325
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:423
int totalEventsFailed() const
Definition: SubProcess.h:164
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:232
int totalEvents() const
Definition: SubProcess.h:152
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:546
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
Definition: SubProcess.h:235
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:331
virtual ~SubProcess()
Definition: SubProcess.cc:173
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:529
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:54
void doEndStream(unsigned int)
Definition: SubProcess.cc:447
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:278
bool terminate() const
Definition: SubProcess.h:192
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:106
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:136
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:385
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:216
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:157
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:178
BranchType
Definition: BranchType.h:11
void selectProducts(ProductRegistry const &preg)
Definition: SubProcess.cc:208
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:99
ServiceToken serviceToken_
Definition: SubProcess.h:221
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:377
bool shouldWeCloseOutput() const
Definition: SubProcess.h:125
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:245
void process(EventPrincipal const &e)
Definition: SubProcess.cc:296
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:246
void closeOutputFiles()
Definition: SubProcess.h:92
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Return a vector allowing const access to all the ModuleDescriptions for this SubProcess.
SubProcess(ParameterSet &parameterSet, ParameterSet const &topLevelParameterSet, std::shared_ptr< ProductRegistry const > parentProductRegistry, std::shared_ptr< BranchIDListHelper const > parentBranchIDListHelper, eventsetup::EventSetupsController &esController, ActivityRegistry &parentActReg, ServiceToken const &token, serviceregistry::ServiceLegacy iLegacy, PreallocationConfiguration const &preallocConfig, ProcessContext const *parentProcessContext)
Definition: SubProcess.cc:35
void beginLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts)
Definition: SubProcess.cc:391
std::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: SubProcess.h:224
void preForkReleaseResources()
Definition: SubProcess.h:130
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:225
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:353
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:257
ProductSelector productSelector_
Definition: SubProcess.h:247
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:253
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:476
std::auto_ptr< Schedule > schedule_
Definition: SubProcess.h:236
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:465
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
Definition: SubProcess.h:237
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:118
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:432
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:359
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:185
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:233
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:414
std::unique_ptr< ParameterSet > processParameterSet_
Definition: SubProcess.h:239
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:499
void doBeginStream(unsigned int)
Definition: SubProcess.cc:440
std::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:222
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:263
ProcessContext processContext_
Definition: SubProcess.h:227
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:368
preg
Definition: Schedule.cc:368
std::auto_ptr< SubProcess > subProcess_
Definition: SubProcess.h:238
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:198
std::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:223
PrincipalCache principalCache_
Definition: SubProcess.h:234
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:454
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:408
std::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:226