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 EDLooperBase;
26  class HistoryAppender;
27  class IOVSyncValue;
28  class ParameterSet;
29  class ProductRegistry;
30  class PreallocationConfiguration;
31 
32  namespace eventsetup {
33  class EventSetupsController;
34  }
35  class SubProcess {
36  public:
38  ParameterSet const& topLevelParameterSet,
39  boost::shared_ptr<ProductRegistry const> parentProductRegistry,
40  boost::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
42  ActivityRegistry& parentActReg,
43  ServiceToken const& token,
45  PreallocationConfiguration const& preallocConfig,
46  ProcessContext const* parentProcessContext);
47 
48  virtual ~SubProcess();
49 
50  SubProcess(SubProcess const&) = delete; // Disallow copying and moving
51  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying and moving
52 
53  //From OutputModule
54  void selectProducts(ProductRegistry const& preg);
56 
57  void doBeginJob();
58  void doEndJob();
59 
60  void doEvent(EventPrincipal const& principal);
61 
62  void doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts);
63 
64  void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
65 
67 
68  void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
69 
70 
71  void doBeginStream(unsigned int);
72  void doEndStream(unsigned int);
73  void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);
74 
75  void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
76 
77  void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
78 
79  void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
80 
81 
82  // Write the luminosity block
83  void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
84 
85  void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
86 
87  // Write the run
88  void writeRun(ProcessHistoryID const& parentPhID, int runNumber);
89 
90  void deleteRunFromCache(ProcessHistoryID const& parentPhID, int runNumber);
91 
92  // Call closeFile() on all OutputModules.
95  schedule_->closeOutputFiles();
96  if(subProcess_.get()) subProcess_->closeOutputFiles();
97  }
98 
99  // Call openNewFileIfNeeded() on all OutputModules
102  schedule_->openNewOutputFilesIfNeeded();
103  if(subProcess_.get()) subProcess_->openNewOutputFilesIfNeeded();
104  }
105 
106  // Call openFiles() on all OutputModules
109  schedule_->openOutputFiles(fb);
110  if(subProcess_.get()) subProcess_->openOutputFiles(fb);
111  }
112 
114 
115  // Call respondToOpenInputFile() on all Modules
116  void respondToOpenInputFile(FileBlock const& fb);
117 
118  // Call respondToCloseInputFile() on all Modules
121  schedule_->respondToCloseInputFile(fb);
122  if(subProcess_.get()) subProcess_->respondToCloseInputFile(fb);
123  }
124 
125  // Call shouldWeCloseFile() on all OutputModules.
126  bool shouldWeCloseOutput() const {
128  return schedule_->shouldWeCloseOutput() || (subProcess_.get() ? subProcess_->shouldWeCloseOutput() : false);
129  }
130 
133  schedule_->preForkReleaseResources();
134  if(subProcess_.get()) subProcess_->preForkReleaseResources();
135  }
136 
137  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
139  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
140  if(subProcess_.get()) subProcess_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
141  }
142 
144 
148  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
149 
153  int totalEvents() const {
154  return schedule_->totalEvents();
155  }
156 
158  int totalEventsPassed() const {
160  return schedule_->totalEventsPassed();
161  }
162 
165  int totalEventsFailed() const {
167  return schedule_->totalEventsFailed();
168  }
169 
172  void enableEndPaths(bool active) {
174  schedule_->enableEndPaths(active);
175  if(subProcess_.get()) subProcess_->enableEndPaths(active);
176  }
177 
179  bool endPathsEnabled() const {
181  return schedule_->endPathsEnabled();
182  }
183 
188  schedule_->getTriggerReport(rep);
189  }
190 
193  bool terminate() const {
195  return subProcess_.get() ? subProcess_->terminate() : schedule_->terminate();
196  }
197 
199  void clearCounters() {
201  schedule_->clearCounters();
202  if(subProcess_.get()) subProcess_->clearCounters();
203  }
204 
205  private:
206  void beginJob();
207  void endJob();
208  void process(EventPrincipal const& e);
209  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
210  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
212  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
213 
214  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
215  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
216 
217  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
219  }
220 
221 
223  boost::shared_ptr<ProductRegistry const> parentPreg_;
224  boost::shared_ptr<ProductRegistry const> preg_;
225  boost::shared_ptr<BranchIDListHelper> branchIDListHelper_;
226  std::unique_ptr<ExceptionToActionTable const> act_table_;
227  boost::shared_ptr<ProcessConfiguration const> processConfiguration_;
229  //We require 1 history for each Run, Lumi and Stream
230  // The vectors first hold Stream info, then Lumi then Run
231  unsigned int historyLumiOffset_;
232  unsigned int historyRunOffset_;
233  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
234  std::vector<HistoryAppender> historyAppenders_;
236  boost::shared_ptr<eventsetup::EventSetupProvider> esp_;
237  std::auto_ptr<Schedule> schedule_;
238  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
239  std::auto_ptr<SubProcess> subProcess_;
240  std::unique_ptr<ParameterSet> processParameterSet_;
241 
242  // keptProducts_ are pointers to the BranchDescription objects describing
243  // the branches we are to write.
244  //
245  // We do not own the BranchDescriptions to which we point.
249 
250 
251  //EventSelection
255 
256  // needed because of possible EDAliases.
257  // filled in only if key and value are different.
258  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
259 
260  };
261 
262  // free function
263  std::auto_ptr<ParameterSet> popSubProcessParameterSet(ParameterSet& parameterSet);
264 }
265 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:232
unsigned int historyLumiOffset_
Definition: SubProcess.h:231
ParameterSetID selector_config_id_
Definition: SubProcess.h:253
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
boost::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:223
void enableEndPaths(bool active)
Definition: SubProcess.h:172
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:542
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:491
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:329
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:427
int totalEventsFailed() const
Definition: SubProcess.h:165
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:233
int totalEvents() const
Definition: SubProcess.h:153
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:550
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
Definition: SubProcess.h:236
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:335
virtual ~SubProcess()
Definition: SubProcess.cc:177
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:533
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:55
void doEndStream(unsigned int)
Definition: SubProcess.cc:451
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:282
bool terminate() const
Definition: SubProcess.h:193
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:107
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:137
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:389
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:217
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:158
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:179
BranchType
Definition: BranchType.h:11
void selectProducts(ProductRegistry const &preg)
Definition: SubProcess.cc:212
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:100
ServiceToken serviceToken_
Definition: SubProcess.h:222
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:381
bool shouldWeCloseOutput() const
Definition: SubProcess.h:126
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:246
void process(EventPrincipal const &e)
Definition: SubProcess.cc:300
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:247
void closeOutputFiles()
Definition: SubProcess.h:93
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, boost::shared_ptr< ProductRegistry const > parentProductRegistry, boost::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:395
void preForkReleaseResources()
Definition: SubProcess.h:131
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:226
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:357
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:258
ProductSelector productSelector_
Definition: SubProcess.h:248
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:254
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:480
std::auto_ptr< Schedule > schedule_
Definition: SubProcess.h:237
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:469
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
Definition: SubProcess.h:238
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:119
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:436
boost::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: SubProcess.h:225
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:363
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:186
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:234
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:418
std::unique_ptr< ParameterSet > processParameterSet_
Definition: SubProcess.h:240
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:503
void doBeginStream(unsigned int)
Definition: SubProcess.cc:444
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:267
ProcessContext processContext_
Definition: SubProcess.h:228
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:372
preg
Definition: Schedule.cc:369
std::auto_ptr< SubProcess > subProcess_
Definition: SubProcess.h:239
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:199
boost::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:227
boost::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:224
PrincipalCache principalCache_
Definition: SubProcess.h:235
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:458
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:412