test
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 
18 
20 
21 #include <map>
22 #include <memory>
23 #include <set>
24 
25 namespace edm {
26  class ActivityRegistry;
27  class BranchDescription;
28  class BranchIDListHelper;
29  class HistoryAppender;
30  class IOVSyncValue;
31  class ParameterSet;
32  class ProductRegistry;
33  class PreallocationConfiguration;
34  class ThinnedAssociationsHelper;
35 
36  namespace eventsetup {
37  class EventSetupsController;
38  }
39  class SubProcess {
40  public:
42  ParameterSet const& topLevelParameterSet,
43  std::shared_ptr<ProductRegistry const> parentProductRegistry,
44  std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
45  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
47  ActivityRegistry& parentActReg,
48  ServiceToken const& token,
50  PreallocationConfiguration const& preallocConfig,
51  ProcessContext const* parentProcessContext);
52 
53  virtual ~SubProcess();
54 
55  SubProcess(SubProcess const&) = delete; // Disallow copying
56  SubProcess& operator=(SubProcess const&) = delete; // Disallow copying
57  SubProcess(SubProcess&&) = default; // Allow Moving
58  SubProcess& operator=(SubProcess&&) = default; // Allow moving
59 
60  //From OutputModule
61  void selectProducts(ProductRegistry const& preg,
62  ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
63  std::map<BranchID, bool>& keepAssociation);
64 
66 
67  void doBeginJob();
68  void doEndJob();
69 
70  void doEvent(EventPrincipal const& principal);
71 
72  void doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts);
73 
74  void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
75 
77 
78  void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
79 
80 
81  void doBeginStream(unsigned int);
82  void doEndStream(unsigned int);
83  void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);
84 
85  void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
86 
87  void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
88 
89  void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
90 
91 
92  // Write the luminosity block
93  void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
94 
95  void deleteLumiFromCache(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);
96 
97  // Write the run
98  void writeRun(ProcessHistoryID const& parentPhID, int runNumber);
99 
100  void deleteRunFromCache(ProcessHistoryID const& parentPhID, int runNumber);
101 
102  // Call closeFile() on all OutputModules.
105  schedule_->closeOutputFiles();
106  if(hasSubProcesses()) {
107  for(auto& subProcess : *subProcesses_) {
108  subProcess.closeOutputFiles();
109  }
110  }
111  }
112 
113  // Call openNewFileIfNeeded() on all OutputModules
116  schedule_->openNewOutputFilesIfNeeded();
117  if(hasSubProcesses()) {
118  for(auto& subProcess : *subProcesses_) {
119  subProcess.openNewOutputFilesIfNeeded();
120  }
121  }
122  }
123 
124  // Call openFiles() on all OutputModules
127  schedule_->openOutputFiles(fb);
128  if(hasSubProcesses()) {
129  for(auto& subProcess : *subProcesses_) {
130  subProcess.openOutputFiles(fb);
131  }
132  }
133  }
134 
136 
137  // Call respondToOpenInputFile() on all Modules
138  void respondToOpenInputFile(FileBlock const& fb);
139 
140  // Call respondToCloseInputFile() on all Modules
143  schedule_->respondToCloseInputFile(fb);
144  if(hasSubProcesses()) {
145  for(auto& subProcess : *subProcesses_) {
146  subProcess.respondToCloseInputFile(fb);
147  }
148  }
149  }
150 
151  // Call shouldWeCloseFile() on all OutputModules.
152  bool shouldWeCloseOutput() const {
154  if(schedule_->shouldWeCloseOutput()) {
155  return true;
156  }
157  if(hasSubProcesses()) {
158  for(auto const& subProcess : *subProcesses_) {
159  if(subProcess.shouldWeCloseOutput()) {
160  return true;
161  }
162  }
163  }
164  return false;
165  }
166 
169  schedule_->preForkReleaseResources();
170  if(hasSubProcesses()) {
171  for(auto& subProcess : *subProcesses_) {
172  subProcess.preForkReleaseResources();
173  }
174  }
175  }
176 
177  void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
179  schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
180  if(hasSubProcesses()) {
181  for(auto& subProcess : *subProcesses_) {
182  subProcess.postForkReacquireResources(iChildIndex, iNumberOfChildren);
183  }
184  }
185  }
186 
188 
192  std::vector<ModuleDescription const*> getAllModuleDescriptions() const;
193 
197  int totalEvents() const {
198  return schedule_->totalEvents();
199  }
200 
202  int totalEventsPassed() const {
204  return schedule_->totalEventsPassed();
205  }
206 
209  int totalEventsFailed() const {
211  return schedule_->totalEventsFailed();
212  }
213 
216  void enableEndPaths(bool active) {
218  schedule_->enableEndPaths(active);
219  if(hasSubProcesses()) {
220  for(auto& subProcess : *subProcesses_) {
221  subProcess.enableEndPaths(active);
222  }
223  }
224  }
225 
227  bool endPathsEnabled() const {
229  return schedule_->endPathsEnabled();
230  }
231 
236  schedule_->getTriggerReport(rep);
237  }
238 
241  bool terminate() const {
243  if(schedule_->terminate()) {
244  return true;
245  }
246  if(hasSubProcesses()) {
247  for(auto const& subProcess : *subProcesses_) {
248  if(subProcess.terminate()) {
249  return true;
250  }
251  }
252  }
253  return false;
254  }
255 
257  void clearCounters() {
259  schedule_->clearCounters();
260  if(hasSubProcesses()) {
261  for(auto& subProcess : *subProcesses_) {
262  subProcess.clearCounters();
263  }
264  }
265  }
266 
267  private:
268  void beginJob();
269  void endJob();
270  void process(EventPrincipal const& e);
271  void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
272  void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
274  void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
275 
276  void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
277  void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
278  void keepThisBranch(BranchDescription const& desc,
279  std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
280  std::set<BranchID>& keptProductsInEvent);
281 
282  std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
284  }
285 
286  bool hasSubProcesses() const {
287  return subProcesses_.get() != nullptr && !subProcesses_->empty();
288  }
289 
290  std::shared_ptr<BranchIDListHelper const> branchIDListHelper() const {return get_underlying_safe(branchIDListHelper_);}
291  std::shared_ptr<BranchIDListHelper>& branchIDListHelper() {return get_underlying_safe(branchIDListHelper_);}
292  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper() const {return get_underlying_safe(thinnedAssociationsHelper_);}
293  std::shared_ptr<ThinnedAssociationsHelper> thinnedAssociationsHelper() {return get_underlying_safe(thinnedAssociationsHelper_);}
294 
295  std::shared_ptr<ActivityRegistry> actReg_; // We do not use propagate_const because the registry itself is mutable.
297  std::shared_ptr<ProductRegistry const> parentPreg_;
298  std::shared_ptr<ProductRegistry const> preg_;
301  std::unique_ptr<ExceptionToActionTable const> act_table_;
302  std::shared_ptr<ProcessConfiguration const> processConfiguration_;
305  //We require 1 history for each Run, Lumi and Stream
306  // The vectors first hold Stream info, then Lumi then Run
307  unsigned int historyLumiOffset_;
308  unsigned int historyRunOffset_;
309  std::vector<ProcessHistoryRegistry> processHistoryRegistries_;
310  std::vector<HistoryAppender> historyAppenders_;
314  std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
317 
318  // keptProducts_ are pointers to the BranchDescription objects describing
319  // the branches we are to write.
320  //
321  // We do not own the BranchDescriptions to which we point.
325 
326 
327  //EventSelection
331 
332  // needed because of possible EDAliases.
333  // filled in only if key and value are different.
334  std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;
335 
336  };
337 
338  // free function
339  std::unique_ptr<std::vector<ParameterSet> > popSubProcessVParameterSet(ParameterSet& parameterSet);
340 }
341 #endif
unsigned int historyRunOffset_
Definition: SubProcess.h:308
unsigned int historyLumiOffset_
Definition: SubProcess.h:307
ParameterSetID selector_config_id_
Definition: SubProcess.h:329
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper()
Definition: SubProcess.h:293
type
Definition: HCALResponse.h:21
string rep
Definition: cuy.py:1188
void enableEndPaths(bool active)
Definition: SubProcess.h:216
void respondToOpenInputFile(FileBlock const &fb)
Definition: SubProcess.cc:628
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:582
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:368
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:490
int totalEventsFailed() const
Definition: SubProcess.h:209
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Definition: SubProcess.h:290
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
Definition: SubProcess.h:309
int totalEvents() const
Definition: SubProcess.h:197
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
Definition: SubProcess.h:300
void beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
Definition: SubProcess.cc:374
PathsAndConsumesOfModules pathsAndConsumesOfModules_
Definition: SubProcess.h:304
virtual ~SubProcess()
Definition: SubProcess.cc:195
void updateBranchIDListHelper(BranchIDLists const &)
Definition: SubProcess.cc:617
std::unique_ptr< std::vector< ParameterSet > > popSubProcessVParameterSet(ParameterSet &parameterSet)
Definition: SubProcess.cc:640
SelectedProductsForBranchType const & keptProducts() const
Definition: SubProcess.h:65
void doEndStream(unsigned int)
Definition: SubProcess.cc:526
SubProcess & operator=(SubProcess const &)=delete
void doEvent(EventPrincipal const &principal)
Definition: SubProcess.cc:320
bool terminate() const
Definition: SubProcess.h:241
void openOutputFiles(FileBlock &fb)
Definition: SubProcess.h:125
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
Definition: SubProcess.h:177
edm::propagate_const< std::unique_ptr< std::vector< SubProcess > > > subProcesses_
Definition: SubProcess.h:315
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:444
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
Definition: SubProcess.h:282
edm::propagate_const< std::unique_ptr< Schedule > > schedule_
Definition: SubProcess.h:313
int totalEventsPassed() const
Return the number of events which have been passed by one or more trigger paths.
Definition: SubProcess.h:202
bool endPathsEnabled() const
Return true if end_paths are active, and false if they are inactive.
Definition: SubProcess.h:227
BranchType
Definition: BranchType.h:11
void openNewOutputFilesIfNeeded()
Definition: SubProcess.h:114
ServiceToken serviceToken_
Definition: SubProcess.h:296
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:432
bool shouldWeCloseOutput() const
Definition: SubProcess.h:152
SelectedProductsForBranchType keptProducts_
Definition: SubProcess.h:322
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
Definition: SubProcess.cc:240
void process(EventPrincipal const &e)
Definition: SubProcess.cc:335
ProductSelectorRules productSelectorRules_
Definition: SubProcess.h:323
void closeOutputFiles()
Definition: SubProcess.h:103
edm::propagate_const< std::shared_ptr< eventsetup::EventSetupProvider > > esp_
Definition: SubProcess.h:312
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Return a vector allowing const access to all the ModuleDescriptions for this SubProcess.
edm::propagate_const< std::unique_ptr< ParameterSet > > processParameterSet_
Definition: SubProcess.h:316
void keepThisBranch(BranchDescription const &desc, std::map< BranchID, BranchDescription const * > &trueBranchIDToKeptBranchDesc, std::set< BranchID > &keptProductsInEvent)
Definition: SubProcess.cc:282
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void beginLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts)
Definition: SubProcess.cc:450
void preForkReleaseResources()
Definition: SubProcess.h:167
std::unique_ptr< ExceptionToActionTable const > act_table_
Definition: SubProcess.h:301
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:400
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
Definition: SubProcess.h:334
ProductSelector productSelector_
Definition: SubProcess.h:324
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
detail::TriggerResultsBasedEventSelector selectors_
Definition: SubProcess.h:330
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:567
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:552
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
Definition: SubProcess.h:314
void respondToCloseInputFile(FileBlock const &fb)
Definition: SubProcess.h:141
std::shared_ptr< ActivityRegistry > actReg_
Definition: SubProcess.h:295
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
Definition: SubProcess.cc:503
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: SubProcess.h:299
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:406
void getTriggerReport(TriggerReport &rep) const
Definition: SubProcess.h:234
std::vector< HistoryAppender > historyAppenders_
Definition: SubProcess.h:310
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:477
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
Definition: SubProcess.cc:598
void doBeginStream(unsigned int)
Definition: SubProcess.cc:515
bool hasSubProcesses() const
Definition: SubProcess.h:286
std::shared_ptr< ProductRegistry const > parentPreg_
Definition: SubProcess.h:297
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
Definition: SubProcess.cc:301
std::shared_ptr< BranchIDListHelper > & branchIDListHelper()
Definition: SubProcess.h:291
ProcessContext processContext_
Definition: SubProcess.h:303
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
Definition: SubProcess.cc:419
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() const
Definition: SubProcess.h:292
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:374
void clearCounters()
Clear all the counters in the trigger report.
Definition: SubProcess.h:257
std::shared_ptr< ProductRegistry const > preg_
Definition: SubProcess.h:298
PrincipalCache principalCache_
Definition: SubProcess.h:311
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
Definition: SubProcess.cc:537
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
Definition: SubProcess.cc:471
std::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: SubProcess.h:302