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 
113  // Call respondToOpenInputFile() on all Modules
114  void respondToOpenInputFile(FileBlock const& fb);
115 
116  // Call respondToCloseInputFile() on all Modules
119  schedule_->respondToCloseInputFile(fb);
120  if(subProcess_.get()) subProcess_->respondToCloseInputFile(fb);
121  }
122 
123  // Call shouldWeCloseFile() on all OutputModules.
124  bool shouldWeCloseOutput() const {
126  return schedule_->shouldWeCloseOutput() || (subProcess_.get() ? subProcess_->shouldWeCloseOutput() : false);
127  }
128 
131  schedule_->preForkReleaseResources();
132  if(subProcess_.get()) subProcess_->preForkReleaseResources();
133  }
134 
135  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
137  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
138  if(subProcess_.get()) subProcess_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
139  }
140 
142 
146  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
147 
151  int totalEvents() const {
152  return schedule_->totalEvents();
153  }
154 
156  int totalEventsPassed() const {
158  return schedule_->totalEventsPassed();
159  }
160 
163  int totalEventsFailed() const {
165  return schedule_->totalEventsFailed();
166  }
167 
170  void enableEndPaths(bool active) {
172  schedule_->enableEndPaths(active);
173  if(subProcess_.get()) subProcess_->enableEndPaths(active);
174  }
175 
177  bool endPathsEnabled() const {
179  return schedule_->endPathsEnabled();
180  }
181 
186  schedule_->getTriggerReport(rep);
187  }
188 
191  bool terminate() const {
193  return subProcess_.get() ? subProcess_->terminate() : schedule_->terminate();
194  }
195 
197  void clearCounters() {
199  schedule_->clearCounters();
200  if(subProcess_.get()) subProcess_->clearCounters();
201  }
202 
203  private:
204  void beginJob();
205  void endJob();
206  void process(EventPrincipal const& e);
207  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
208  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
210  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
211 
212  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
213  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
214 
215  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
217  }
218 
219 
221  boost::shared_ptr<ProductRegistry const> parentPreg_;
222  boost::shared_ptr<ProductRegistry const> preg_;
223  boost::shared_ptr<BranchIDListHelper> branchIDListHelper_;
224  std::unique_ptr<ExceptionToActionTable const> act_table_;
225  boost::shared_ptr<ProcessConfiguration const> processConfiguration_;
227  //We require 1 history for each Run, Lumi and Stream
228  // The vectors first hold Stream info, then Lumi then Run
229  unsigned int historyLumiOffset_;
230  unsigned int historyRunOffset_;
231  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
232  std::vector<HistoryAppender> historyAppenders_;
234  boost::shared_ptr<eventsetup::EventSetupProvider> esp_;
235  std::auto_ptr<Schedule> schedule_;
236  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
237  std::auto_ptr<SubProcess> subProcess_;
238  std::unique_ptr<ParameterSet> processParameterSet_;
239 
240  // keptProducts_ are pointers to the BranchDescription objects describing
241  // the branches we are to write.
242  //
243  // We do not own the BranchDescriptions to which we point.
247 
248 
249  //EventSelection
253 
254  // needed because of possible EDAliases.
255  // filled in only if key and value are different.
256  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
257 
258  };
259 
260  // free function
261  std::auto_ptr<ParameterSet> popSubProcessParameterSet(ParameterSet& parameterSet);
262 }
263 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:230
unsigned int historyLumiOffset_
Definition: SubProcess.h:229
ParameterSetID selector_config_id_
Definition: SubProcess.h:251
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
boost::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:221
void enableEndPaths(bool active)
Definition: SubProcess.h:170
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:531
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:487
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:163
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:231
int totalEvents() const
Definition: SubProcess.h:151
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:540
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
Definition: SubProcess.h:234
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:331
virtual ~SubProcess()
Definition: SubProcess.cc:174
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:55
void doEndStream(unsigned int)
Definition: SubProcess.cc:447
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:279
bool terminate() const
Definition: SubProcess.h:191
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:107
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:135
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:215
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:156
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:177
BranchType
Definition: BranchType.h:11
void selectProducts(ProductRegistry const &preg)
Definition: SubProcess.cc:209
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:100
ServiceToken serviceToken_
Definition: SubProcess.h:220
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:377
bool shouldWeCloseOutput() const
Definition: SubProcess.h:124
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:244
void process(EventPrincipal const &e)
Definition: SubProcess.cc:297
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:245
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:391
void preForkReleaseResources()
Definition: SubProcess.h:129
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:224
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:256
ProductSelector productSelector_
Definition: SubProcess.h:246
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:252
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:476
std::auto_ptr< Schedule > schedule_
Definition: SubProcess.h:235
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:236
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:117
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:432
boost::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: SubProcess.h:223
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:359
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:184
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:232
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:414
std::unique_ptr< ParameterSet > processParameterSet_
Definition: SubProcess.h:238
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:499
void doBeginStream(unsigned int)
Definition: SubProcess.cc:440
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:264
ProcessContext processContext_
Definition: SubProcess.h:226
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:368
preg
Definition: Schedule.cc:362
std::auto_ptr< SubProcess > subProcess_
Definition: SubProcess.h:237
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:197
boost::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:225
boost::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:222
PrincipalCache principalCache_
Definition: SubProcess.h:233
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