Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:05

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 
0026 namespace edm {
0027 
0028   class HistoryAppender;
0029   class MergeableRunProductProcesses;
0030   class MergeableRunProductMetadata;
0031   class ModuleCallingContext;
0032   class ProcessHistoryRegistry;
0033 
0034   class RunPrincipal : public Principal {
0035   public:
0036     typedef RunAuxiliary Auxiliary;
0037     typedef Principal Base;
0038 
0039     RunPrincipal(std::shared_ptr<ProductRegistry const> reg,
0040                  ProcessConfiguration const& pc,
0041                  HistoryAppender* historyAppender,
0042                  unsigned int iRunIndex,
0043                  bool isForPrimaryProcess = true,
0044                  MergeableRunProductProcesses const* mergeableRunProductProcesses = nullptr);
0045     ~RunPrincipal() override;
0046 
0047     void fillRunPrincipal(ProcessHistoryRegistry const& processHistoryRegistry, DelayedReader* reader = nullptr);
0048 
0049     /** Multiple Runs may be processed simultaneously. The
0050      return value can be used to identify a particular Run.
0051      The value will range from 0 to one less than
0052      the maximum number of allowed simultaneous Runs. A particular
0053      value will be reused once the processing of the previous Run
0054      using that index has been completed.
0055      */
0056     RunIndex index() const { return index_; }
0057 
0058     void setAux(RunAuxiliary iAux) { aux_ = iAux; }
0059     RunAuxiliary const& aux() const { return aux_; }
0060 
0061     RunNumber_t run() const { return aux().run(); }
0062 
0063     ProcessHistoryID const& reducedProcessHistoryID() const { return m_reducedHistoryID; }
0064 
0065     RunID const& id() const { return aux().id(); }
0066 
0067     Timestamp const& beginTime() const { return aux().beginTime(); }
0068 
0069     Timestamp const& endTime() const { return aux().endTime(); }
0070 
0071     void setEndTime(Timestamp const& time) { aux_.setEndTime(time); }
0072 
0073     void mergeAuxiliary(RunAuxiliary const& aux) { return aux_.mergeAuxiliary(aux); }
0074 
0075     void put(BranchDescription const& bd, std::unique_ptr<WrapperBase> edp) const;
0076 
0077     void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp) const;
0078 
0079     void putOrMerge(BranchDescription const& bd, std::unique_ptr<WrapperBase> edp) const;
0080 
0081     MergeableRunProductMetadata* mergeableRunProductMetadata() { return mergeableRunProductMetadataPtr_.get(); }
0082 
0083     void preReadFile();
0084 
0085     enum ShouldWriteRun { kUninitialized, kNo, kYes };
0086     ShouldWriteRun shouldWriteRun() const { return shouldWriteRun_; }
0087     void setShouldWriteRun(ShouldWriteRun value) { shouldWriteRun_ = value; }
0088 
0089   private:
0090     unsigned int transitionIndex_() const override;
0091 
0092     RunAuxiliary aux_;
0093     ProcessHistoryID m_reducedHistoryID;
0094     RunIndex index_;
0095 
0096     // For the primary input RunPrincipals created by the EventProcessor,
0097     // there should be one MergeableRunProductMetadata object created
0098     // per concurrent run. In all other cases, this should just be null.
0099     edm::propagate_const<std::unique_ptr<MergeableRunProductMetadata>> mergeableRunProductMetadataPtr_;
0100 
0101     ShouldWriteRun shouldWriteRun_ = kUninitialized;
0102   };
0103 }  // namespace edm
0104 #endif