CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/FWCore/Framework/src/PrincipalCache.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_PrincipalCache_h
00002 #define FWCore_Framework_PrincipalCache_h
00003 
00004 /*
00005 Contains a shared pointer to the RunPrincipal,
00006 LuminosityBlockPrincipal, and EventPrincipal.
00007 Manages merging of run and luminosity block
00008 principals when there is more than one principal
00009 from the same run or luminosity block and having
00010 the same reduced ProcessHistoryID.
00011 
00012 The EventPrincipal is reused each event and is created
00013 by the EventProcessor or SubProcess which contains
00014 an object of this type as a data member.
00015 
00016 The RunPrincipal and LuminosityBlockPrincipal is
00017 created by the InputSource each time a different
00018 run or luminosity block is encountered.
00019 
00020 Performs checks that process history IDs or runs and
00021 lumis, run numbers, and luminosity numbers are consistent.
00022 
00023 Original Author: W. David Dagenhart
00024 */
00025 
00026 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
00027 #include "DataFormats/Provenance/interface/RunID.h"
00028 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00029 
00030 #include "boost/shared_ptr.hpp"
00031 
00032 namespace edm {
00033 
00034   class RunPrincipal;
00035   class LuminosityBlockPrincipal;
00036   class EventPrincipal;
00037   class RunAuxiliary;
00038   class LuminosityBlockAuxiliary;
00039   class ProductRegistry;
00040 
00041   class PrincipalCache {
00042   public:
00043 
00044     PrincipalCache();
00045     ~PrincipalCache();
00046 
00047     RunPrincipal& runPrincipal(ProcessHistoryID const& phid, RunNumber_t run) const;
00048     boost::shared_ptr<RunPrincipal> const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const;
00049     RunPrincipal& runPrincipal() const;
00050     boost::shared_ptr<RunPrincipal> const& runPrincipalPtr() const;
00051 
00052     LuminosityBlockPrincipal& lumiPrincipal(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const;
00053     boost::shared_ptr<LuminosityBlockPrincipal> const& lumiPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const;
00054     LuminosityBlockPrincipal& lumiPrincipal() const;
00055     boost::shared_ptr<LuminosityBlockPrincipal> const& lumiPrincipalPtr() const;
00056 
00057     EventPrincipal& eventPrincipal() const { return *eventPrincipal_; }
00058 
00059     void merge(boost::shared_ptr<RunAuxiliary> aux, boost::shared_ptr<ProductRegistry const> reg);
00060     void merge(boost::shared_ptr<LuminosityBlockAuxiliary> aux, boost::shared_ptr<ProductRegistry const> reg);
00061 
00062     void insert(boost::shared_ptr<RunPrincipal> rp);
00063     void insert(boost::shared_ptr<LuminosityBlockPrincipal> lbp);
00064     void insert(boost::shared_ptr<EventPrincipal> ep) { eventPrincipal_ = ep; }
00065 
00066     void deleteRun(ProcessHistoryID const& phid, RunNumber_t run);
00067     void deleteLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi);
00068 
00069     void adjustEventToNewProductRegistry(boost::shared_ptr<ProductRegistry const> reg);
00070 
00071     void adjustIndexesAfterProductRegistryAddition();
00072 
00073   private:
00074 
00075     void throwRunMissing() const;
00076     void throwLumiMissing() const;
00077 
00078     // These are explicitly cleared when finished with the run,
00079     // lumi, or event
00080     boost::shared_ptr<RunPrincipal> runPrincipal_;
00081     boost::shared_ptr<LuminosityBlockPrincipal> lumiPrincipal_;
00082     boost::shared_ptr<EventPrincipal> eventPrincipal_;
00083 
00084     // These are intentionally not cleared so that when inserting
00085     // the next principal the conversion from full ProcessHistoryID_
00086     // to reduced ProcessHistoryID_ is still in memory and does
00087     // not need to be recalculated if the ID does not change. I
00088     // expect that very often these ID's will not change from one
00089     // principal to the next and a good amount of CPU can be saved
00090     // by not recalculating.
00091     ProcessHistoryID inputProcessHistoryID_;
00092     ProcessHistoryID reducedInputProcessHistoryID_;
00093     RunNumber_t run_;
00094     LuminosityBlockNumber_t lumi_;
00095   };
00096 }
00097 
00098 #endif