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 
16 
18 
19 #include "boost/shared_ptr.hpp"
20 
21 #include <map>
22 #include <memory>
23 #include <set>
24 
25 namespace edm {
26  class BranchDescription;
27  class BranchIDListHelper;
28  class HistoryAppender;
29  class IOVSyncValue;
30  class ParameterSet;
31  class ProductRegistry;
32  class PreallocationConfiguration;
33  class ThinnedAssociationsHelper;
34 
35  namespace eventsetup {
36  class EventSetupsController;
37  }
38  class SubProcess {
39  public:
41  ParameterSet const& topLevelParameterSet,
42  std::shared_ptr<ProductRegistry const> parentProductRegistry,
43  std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
44  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
46  ActivityRegistry& parentActReg,
47  ServiceToken const& token,
49  PreallocationConfiguration const& preallocConfig,
50  ProcessContext const* parentProcessContext);
51 
52  virtual ~SubProcess();
53 
54  SubProcess(SubProcess const&) = delete; // Disallow copying and moving
55  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying and moving
56 
57  //From OutputModule
58  void selectProducts(ProductRegistry const& preg,
59  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
60  std::map<BranchID, bool>& keepAssociation);
61 
63 
64  void doBeginJob();
65  void doEndJob();
66 
67  void doEvent(EventPrincipal const& principal);
68 
69  void doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts);
70 
71  void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
72 
74 
75  void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
76 
77 
78  void doBeginStream(unsigned int);
79  void doEndStream(unsigned int);
80  void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);
81 
82  void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
83 
84  void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
85 
86  void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
87 
88 
89  // Write the luminosity block
90  void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
91 
92  void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
93 
94  // Write the run
95  void writeRun(ProcessHistoryID const& parentPhID, int runNumber);
96 
97  void deleteRunFromCache(ProcessHistoryID const& parentPhID, int runNumber);
98 
99  // Call closeFile() on all OutputModules.
102  schedule_->closeOutputFiles();
103  if(subProcess_.get()) subProcess_->closeOutputFiles();
104  }
105 
106  // Call openNewFileIfNeeded() on all OutputModules
109  schedule_->openNewOutputFilesIfNeeded();
110  if(subProcess_.get()) subProcess_->openNewOutputFilesIfNeeded();
111  }
112 
113  // Call openFiles() on all OutputModules
116  schedule_->openOutputFiles(fb);
117  if(subProcess_.get()) subProcess_->openOutputFiles(fb);
118  }
119 
121 
122  // Call respondToOpenInputFile() on all Modules
123  void respondToOpenInputFile(FileBlock const& fb);
124 
125  // Call respondToCloseInputFile() on all Modules
128  schedule_->respondToCloseInputFile(fb);
129  if(subProcess_.get()) subProcess_->respondToCloseInputFile(fb);
130  }
131 
132  // Call shouldWeCloseFile() on all OutputModules.
133  bool shouldWeCloseOutput() const {
135  return schedule_->shouldWeCloseOutput() || (subProcess_.get() ? subProcess_->shouldWeCloseOutput() : false);
136  }
137 
140  schedule_->preForkReleaseResources();
141  if(subProcess_.get()) subProcess_->preForkReleaseResources();
142  }
143 
144  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
146  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
147  if(subProcess_.get()) subProcess_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
148  }
149 
151 
155  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
156 
160  int totalEvents() const {
161  return schedule_->totalEvents();
162  }
163 
165  int totalEventsPassed() const {
167  return schedule_->totalEventsPassed();
168  }
169 
172  int totalEventsFailed() const {
174  return schedule_->totalEventsFailed();
175  }
176 
179  void enableEndPaths(bool active) {
181  schedule_->enableEndPaths(active);
182  if(subProcess_.get()) subProcess_->enableEndPaths(active);
183  }
184 
186  bool endPathsEnabled() const {
188  return schedule_->endPathsEnabled();
189  }
190 
195  schedule_->getTriggerReport(rep);
196  }
197 
200  bool terminate() const {
202  return subProcess_.get() ? subProcess_->terminate() : schedule_->terminate();
203  }
204 
206  void clearCounters() {
208  schedule_->clearCounters();
209  if(subProcess_.get()) subProcess_->clearCounters();
210  }
211 
212  private:
213  void beginJob();
214  void endJob();
215  void process(EventPrincipal const& e);
216  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
217  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
219  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
220 
221  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
222  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
223  void keepThisBranch(BranchDescription const& desc,
224  std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
225  std::set<BranchID>& keptProductsInEvent);
226 
227  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
229  }
230 
231 
233  std::shared_ptr<ProductRegistry const> parentPreg_;
234  std::shared_ptr<ProductRegistry const> preg_;
235  std::shared_ptr<BranchIDListHelper> branchIDListHelper_;
236  std::shared_ptr<ThinnedAssociationsHelper> thinnedAssociationsHelper_;
237  std::unique_ptr<ExceptionToActionTable const> act_table_;
238  std::shared_ptr<ProcessConfiguration const> processConfiguration_;
240  //We require 1 history for each Run, Lumi and Stream
241  // The vectors first hold Stream info, then Lumi then Run
242  unsigned int historyLumiOffset_;
243  unsigned int historyRunOffset_;
244  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
245  std::vector<HistoryAppender> historyAppenders_;
247  boost::shared_ptr<eventsetup::EventSetupProvider> esp_;
248  std::auto_ptr<Schedule> schedule_;
249  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
250  std::auto_ptr<SubProcess> subProcess_;
251  std::unique_ptr<ParameterSet> processParameterSet_;
252 
253  // keptProducts_ are pointers to the BranchDescription objects describing
254  // the branches we are to write.
255  //
256  // We do not own the BranchDescriptions to which we point.
260 
261 
262  //EventSelection
266 
267  // needed because of possible EDAliases.
268  // filled in only if key and value are different.
269  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
270 
271  };
272 
273  // free function
274  std::auto_ptr<ParameterSet> popSubProcessParameterSet(ParameterSet& parameterSet);
275 }
276 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:243
unsigned int historyLumiOffset_
Definition: SubProcess.h:242
ParameterSetID selector_config_id_
Definition: SubProcess.h:264
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
void enableEndPaths(bool active)
Definition: SubProcess.h:179
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:552
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:501
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:339
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:437
int totalEventsFailed() const
Definition: SubProcess.h:172
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:244
int totalEvents() const
Definition: SubProcess.h:160
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:560
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
Definition: SubProcess.h:247
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:345
virtual ~SubProcess()
Definition: SubProcess.cc:181
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:543
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:62
void doEndStream(unsigned int)
Definition: SubProcess.cc:461
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:292
bool terminate() const
Definition: SubProcess.h:200
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:114
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:144
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:399
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:227
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:165
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:186
BranchType
Definition: BranchType.h:11
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:107
ServiceToken serviceToken_
Definition: SubProcess.h:232
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:391
bool shouldWeCloseOutput() const
Definition: SubProcess.h:133
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:257
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
Definition: SubProcess.cc:216
void process(EventPrincipal const &e)
Definition: SubProcess.cc:310
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:258
void closeOutputFiles()
Definition: SubProcess.h:100
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:258
void beginLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts)
Definition: SubProcess.cc:405
std::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: SubProcess.h:235
void preForkReleaseResources()
Definition: SubProcess.h:138
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:237
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:367
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:269
ProductSelector productSelector_
Definition: SubProcess.h:259
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:265
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:490
std::auto_ptr< Schedule > schedule_
Definition: SubProcess.h:248
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:479
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
Definition: SubProcess.h:249
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:126
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:446
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:373
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:193
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:245
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper_
Definition: SubProcess.h:236
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:428
std::unique_ptr< ParameterSet > processParameterSet_
Definition: SubProcess.h:251
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:513
void doBeginStream(unsigned int)
Definition: SubProcess.cc:454
std::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:233
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:277
ProcessContext processContext_
Definition: SubProcess.h:239
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:382
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:36
preg
Definition: Schedule.cc:370
std::auto_ptr< SubProcess > subProcess_
Definition: SubProcess.h:250
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:206
std::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:234
PrincipalCache principalCache_
Definition: SubProcess.h:246
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:468
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:422
std::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:238