Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-31 02:19:22

0001 #ifndef FWCore_Framework_RunPrincipal_h
0002 #define FWCore_Framework_RunPrincipal_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 RunPrincipal: This is the class responsible for management of
0007 per run EDProducts. It is not seen by reconstruction code;
0008 such code sees the Run class, which is a proxy for RunPrincipal.
0009 
0010 The major internal component of the RunPrincipal
0011 is the DataBlock.
0012 
0013 ----------------------------------------------------------------------*/
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 #include <memory>
0019 
0020 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
0021 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0022 #include "FWCore/Utilities/interface/propagate_const.h"
0023 #include "FWCore/Utilities/interface/RunIndex.h"
0024 #include "FWCore/Framework/interface/Principal.h"
0025 #include "FWCore/Framework/interface/ProductResolversFactory.h"
0026 
0027 namespace edm {
0028 
0029   class HistoryAppender;
0030   class MergeableRunProductProcesses;
0031   class MergeableRunProductMetadata;
0032   class ModuleCallingContext;
0033   class ProcessHistoryRegistry;
0034 
0035   class RunPrincipal : public Principal {
0036   public:
0037     typedef RunAuxiliary Auxiliary;
0038     typedef Principal Base;
0039 
0040     template <ProductResolversFactory FACTORY>
0041     RunPrincipal(std::shared_ptr<ProductRegistry const> reg,
0042                  FACTORY&& iFactory,
0043                  ProcessConfiguration const& pc,
0044                  HistoryAppender* historyAppender,
0045                  unsigned int iRunIndex,
0046                  MergeableRunProductProcesses const* mergeableRunProductProcesses = nullptr)
0047         : RunPrincipal(reg,
0048                        iFactory(InRun, pc.processName(), *reg),
0049                        pc,
0050                        historyAppender,
0051                        iRunIndex,
0052                        mergeableRunProductProcesses) {}
0053     ~RunPrincipal() override;
0054 
0055     void fillRunPrincipal(ProcessHistoryRegistry const& processHistoryRegistry, DelayedReader* reader = nullptr);
0056 
0057     /** Multiple Runs may be processed simultaneously. The
0058      return value can be used to identify a particular Run.
0059      The value will range from 0 to one less than
0060      the maximum number of allowed simultaneous Runs. A particular
0061      value will be reused once the processing of the previous Run
0062      using that index has been completed.
0063      */
0064     RunIndex index() const { return index_; }
0065 
0066     void setAux(RunAuxiliary iAux) { aux_ = iAux; }
0067     RunAuxiliary const& aux() const { return aux_; }
0068 
0069     RunNumber_t run() const { return aux().run(); }
0070 
0071     ProcessHistoryID const& reducedProcessHistoryID() const { return m_reducedHistoryID; }
0072 
0073     RunID const& id() const { return aux().id(); }
0074 
0075     Timestamp const& beginTime() const { return aux().beginTime(); }
0076 
0077     Timestamp const& endTime() const { return aux().endTime(); }
0078 
0079     void setEndTime(Timestamp const& time) { aux_.setEndTime(time); }
0080 
0081     void mergeAuxiliary(RunAuxiliary const& aux) { return aux_.mergeAuxiliary(aux); }
0082 
0083     void put(ProductDescription const& bd, std::unique_ptr<WrapperBase> edp) const;
0084 
0085     void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp) const;
0086 
0087     void putOrMerge(ProductDescription const& bd, std::unique_ptr<WrapperBase> edp) const;
0088 
0089     MergeableRunProductMetadata* mergeableRunProductMetadata() { return mergeableRunProductMetadataPtr_.get(); }
0090 
0091     void preReadFile();
0092 
0093     enum ShouldWriteRun { kUninitialized, kNo, kYes };
0094     ShouldWriteRun shouldWriteRun() const { return shouldWriteRun_; }
0095     void setShouldWriteRun(ShouldWriteRun value) { shouldWriteRun_ = value; }
0096 
0097   private:
0098     RunPrincipal(std::shared_ptr<ProductRegistry const> reg,
0099                  std::vector<std::shared_ptr<ProductResolverBase>>&& resolvers,
0100                  ProcessConfiguration const& pc,
0101                  HistoryAppender* historyAppender,
0102                  unsigned int iRunIndex,
0103                  MergeableRunProductProcesses const* mergeableRunProductProcesses);
0104     unsigned int transitionIndex_() const override;
0105 
0106     RunAuxiliary aux_;
0107     ProcessHistoryID m_reducedHistoryID;
0108     RunIndex index_;
0109 
0110     // For the primary input RunPrincipals created by the EventProcessor,
0111     // there should be one MergeableRunProductMetadata object created
0112     // per concurrent run. In all other cases, this should just be null.
0113     edm::propagate_const<std::unique_ptr<MergeableRunProductMetadata>> mergeableRunProductMetadataPtr_;
0114 
0115     ShouldWriteRun shouldWriteRun_ = kUninitialized;
0116   };
0117 }  // namespace edm
0118 #endif