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 
17 
19 
20 #include "boost/shared_ptr.hpp"
21 
22 #include <map>
23 #include <memory>
24 #include <set>
25 
26 namespace edm {
27  class ActivityRegistry;
28  class BranchDescription;
29  class BranchIDListHelper;
30  class HistoryAppender;
31  class IOVSyncValue;
32  class ParameterSet;
33  class ProductRegistry;
34  class PreallocationConfiguration;
35  class ThinnedAssociationsHelper;
36 
37  namespace eventsetup {
38  class EventSetupsController;
39  }
40  class SubProcess {
41  public:
43  ParameterSet const& topLevelParameterSet,
44  std::shared_ptr<ProductRegistry const> parentProductRegistry,
45  std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
46  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
48  ActivityRegistry& parentActReg,
49  ServiceToken const& token,
51  PreallocationConfiguration const& preallocConfig,
52  ProcessContext const* parentProcessContext);
53 
54  virtual ~SubProcess();
55 
56  SubProcess(SubProcess const&) = delete; // Disallow copying and moving
57  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying and moving
58 
59  //From OutputModule
60  void selectProducts(ProductRegistry const& preg,
61  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
62  std::map<BranchID, bool>& keepAssociation);
63 
65 
66  void doBeginJob();
67  void doEndJob();
68 
69  void doEvent(EventPrincipal const& principal);
70 
71  void doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts);
72 
73  void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
74 
76 
77  void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
78 
79 
80  void doBeginStream(unsigned int);
81  void doEndStream(unsigned int);
82  void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);
83 
84  void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
85 
86  void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
87 
88  void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
89 
90 
91  // Write the luminosity block
92  void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
93 
94  void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
95 
96  // Write the run
97  void writeRun(ProcessHistoryID const& parentPhID, int runNumber);
98 
99  void deleteRunFromCache(ProcessHistoryID const& parentPhID, int runNumber);
100 
101  // Call closeFile() on all OutputModules.
104  schedule_->closeOutputFiles();
105  if(subProcess_.get()) subProcess_->closeOutputFiles();
106  }
107 
108  // Call openNewFileIfNeeded() on all OutputModules
111  schedule_->openNewOutputFilesIfNeeded();
112  if(subProcess_.get()) subProcess_->openNewOutputFilesIfNeeded();
113  }
114 
115  // Call openFiles() on all OutputModules
118  schedule_->openOutputFiles(fb);
119  if(subProcess_.get()) subProcess_->openOutputFiles(fb);
120  }
121 
123 
124  // Call respondToOpenInputFile() on all Modules
125  void respondToOpenInputFile(FileBlock const& fb);
126 
127  // Call respondToCloseInputFile() on all Modules
130  schedule_->respondToCloseInputFile(fb);
131  if(subProcess_.get()) subProcess_->respondToCloseInputFile(fb);
132  }
133 
134  // Call shouldWeCloseFile() on all OutputModules.
135  bool shouldWeCloseOutput() const {
137  return schedule_->shouldWeCloseOutput() || (subProcess_.get() ? subProcess_->shouldWeCloseOutput() : false);
138  }
139 
142  schedule_->preForkReleaseResources();
143  if(subProcess_.get()) subProcess_->preForkReleaseResources();
144  }
145 
146  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
148  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
149  if(subProcess_.get()) subProcess_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
150  }
151 
153 
157  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
158 
162  int totalEvents() const {
163  return schedule_->totalEvents();
164  }
165 
167  int totalEventsPassed() const {
169  return schedule_->totalEventsPassed();
170  }
171 
174  int totalEventsFailed() const {
176  return schedule_->totalEventsFailed();
177  }
178 
181  void enableEndPaths(bool active) {
183  schedule_->enableEndPaths(active);
184  if(subProcess_.get()) subProcess_->enableEndPaths(active);
185  }
186 
188  bool endPathsEnabled() const {
190  return schedule_->endPathsEnabled();
191  }
192 
197  schedule_->getTriggerReport(rep);
198  }
199 
202  bool terminate() const {
204  return subProcess_.get() ? subProcess_->terminate() : schedule_->terminate();
205  }
206 
208  void clearCounters() {
210  schedule_->clearCounters();
211  if(subProcess_.get()) subProcess_->clearCounters();
212  }
213 
214  private:
215  void beginJob();
216  void endJob();
217  void process(EventPrincipal const& e);
218  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
219  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
221  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
222 
223  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
224  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
225  void keepThisBranch(BranchDescription const& desc,
226  std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
227  std::set<BranchID>& keptProductsInEvent);
228 
229  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
231  }
232 
233 
234  std::shared_ptr<ActivityRegistry> actReg_;
236  std::shared_ptr<ProductRegistry const> parentPreg_;
237  std::shared_ptr<ProductRegistry const> preg_;
238  std::shared_ptr<BranchIDListHelper> branchIDListHelper_;
239  std::shared_ptr<ThinnedAssociationsHelper> thinnedAssociationsHelper_;
240  std::unique_ptr<ExceptionToActionTable const> act_table_;
241  std::shared_ptr<ProcessConfiguration const> processConfiguration_;
244  //We require 1 history for each Run, Lumi and Stream
245  // The vectors first hold Stream info, then Lumi then Run
246  unsigned int historyLumiOffset_;
247  unsigned int historyRunOffset_;
248  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
249  std::vector<HistoryAppender> historyAppenders_;
251  boost::shared_ptr<eventsetup::EventSetupProvider> esp_;
252  std::auto_ptr<Schedule> schedule_;
253  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
254  std::auto_ptr<SubProcess> subProcess_;
255  std::unique_ptr<ParameterSet> processParameterSet_;
256 
257  // keptProducts_ are pointers to the BranchDescription objects describing
258  // the branches we are to write.
259  //
260  // We do not own the BranchDescriptions to which we point.
264 
265 
266  //EventSelection
270 
271  // needed because of possible EDAliases.
272  // filled in only if key and value are different.
273  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
274 
275  };
276 
277  // free function
278  std::auto_ptr<ParameterSet> popSubProcessParameterSet(ParameterSet& parameterSet);
279 }
280 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:247
unsigned int historyLumiOffset_
Definition: SubProcess.h:246
ParameterSetID selector_config_id_
Definition: SubProcess.h:268
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
void enableEndPaths(bool active)
Definition: SubProcess.h:181
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:553
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:502
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:340
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:438
int totalEventsFailed() const
Definition: SubProcess.h:174
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:248
int totalEvents() const
Definition: SubProcess.h:162
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:561
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
Definition: SubProcess.h:251
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:346
PathsAndConsumesOfModules pathsAndConsumesOfModules_
Definition: SubProcess.h:243
virtual ~SubProcess()
Definition: SubProcess.cc:183
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:544
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:64
void doEndStream(unsigned int)
Definition: SubProcess.cc:462
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:296
bool terminate() const
Definition: SubProcess.h:202
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:116
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:146
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:400
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:229
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:167
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:188
BranchType
Definition: BranchType.h:11
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:109
ServiceToken serviceToken_
Definition: SubProcess.h:235
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:392
bool shouldWeCloseOutput() const
Definition: SubProcess.h:135
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:261
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
Definition: SubProcess.cc:220
void process(EventPrincipal const &e)
Definition: SubProcess.cc:311
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:262
void closeOutputFiles()
Definition: SubProcess.h:102
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Return a vector allowing const access to all the ModuleDescriptions for this SubProcess.
void keepThisBranch(BranchDescription const &desc, std::map< BranchID, BranchDescription const * > &trueBranchIDToKeptBranchDesc, std::set< BranchID > &keptProductsInEvent)
Definition: SubProcess.cc:262
void beginLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts)
Definition: SubProcess.cc:406
std::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: SubProcess.h:238
void preForkReleaseResources()
Definition: SubProcess.h:140
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:240
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:368
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:273
ProductSelector productSelector_
Definition: SubProcess.h:263
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:269
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:491
std::auto_ptr< Schedule > schedule_
Definition: SubProcess.h:252
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:480
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
Definition: SubProcess.h:253
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:128
std::shared_ptr< ActivityRegistry > actReg_
Definition: SubProcess.h:234
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:447
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:374
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:195
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:249
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper_
Definition: SubProcess.h:239
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:429
std::unique_ptr< ParameterSet > processParameterSet_
Definition: SubProcess.h:255
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:514
void doBeginStream(unsigned int)
Definition: SubProcess.cc:455
std::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:236
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:281
ProcessContext processContext_
Definition: SubProcess.h:242
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:383
SubProcess(ParameterSet &parameterSet, ParameterSet const &topLevelParameterSet, std::shared_ptr< ProductRegistry const > parentProductRegistry, std::shared_ptr< BranchIDListHelper const > parentBranchIDListHelper, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, eventsetup::EventSetupsController &esController, ActivityRegistry &parentActReg, ServiceToken const &token, serviceregistry::ServiceLegacy iLegacy, PreallocationConfiguration const &preallocConfig, ProcessContext const *parentProcessContext)
Definition: SubProcess.cc:37
preg
Definition: Schedule.cc:369
std::auto_ptr< SubProcess > subProcess_
Definition: SubProcess.h:254
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:208
std::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:237
PrincipalCache principalCache_
Definition: SubProcess.h:250
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:469
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:423
std::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:241