CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/src/Run.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/Run.h"
00002 #include "FWCore/Framework/interface/NoDelayedReader.h"
00003 #include "FWCore/Framework/interface/RunPrincipal.h"
00004 #include "FWCore/Utilities/interface/Algorithms.h"
00005 
00006 namespace edm {
00007 
00008   Run::Run(RunPrincipal& rp, ModuleDescription const& md) :
00009         provRecorder_(rp, md),
00010         aux_(rp.aux()) {
00011   }
00012 
00013   Run::~Run() {
00014     // anything left here must be the result of a failure
00015     // let's record them as failed attempts in the event principal
00016     for_all(putProducts_, principal_get_adapter_detail::deleter());
00017   }
00018 
00019   RunPrincipal&
00020   Run::runPrincipal() {
00021     return dynamic_cast<RunPrincipal&>(provRecorder_.principal());
00022   }
00023 
00024   RunPrincipal const&
00025   Run::runPrincipal() const {
00026     return dynamic_cast<RunPrincipal const&>(provRecorder_.principal());
00027   }
00028 
00029   Provenance
00030   Run::getProvenance(BranchID const& bid) const {
00031     return runPrincipal().getProvenance(bid);
00032   }
00033 
00034   void
00035   Run::getAllProvenance(std::vector<Provenance const*>& provenances) const {
00036     runPrincipal().getAllProvenance(provenances);
00037   }
00038 
00039 /* Not yet fully implemented
00040   bool
00041   Run::getProcessParameterSet(std::string const& processName, std::vector<ParameterSet>& psets) const {
00042     // Get the relevant ProcessHistoryIDs
00043     ProcessHistoryRegistry* phreg = ProcessHistoryRegistry::instance();
00044     // Need to fill these in.
00045     std::vector<ProcessHistoryID> historyIDs;
00046 
00047 
00048     // Get the relevant ParameterSetIDs.
00049     // Need to fill these in.
00050     std::vector<ParameterSetID> psetIdsUsed;
00051     for (std::vector<ProcessHistoryID>::const_iterator
00052            i = historyIDs.begin(),
00053            e = historyIDs.end();
00054          i != e;
00055          ++i) {
00056       ProcessHistory temp;
00057       phreg->getMapped(*i, temp);
00058     }
00059 
00060     // Look up the ParameterSets for these IDs.
00061     pset::Registry* psreg = pset::Registry::instance();
00062     for (std::vector<ParameterSetID>::const_iterator
00063            i = psetIdsUsed.begin(),
00064            e = psetIdsUsed.end();
00065          i != e;
00066          ++i) {
00067       ParameterSet temp;
00068       psreg->getMapped(*i, temp);
00069       psets.push_back(temp);
00070     }
00071 
00072     return false;
00073   }
00074 */
00075 
00076   void
00077   Run::commit_() {
00078     // fill in guts of provenance here
00079     RunPrincipal& rp = runPrincipal();
00080     ProductPtrVec::iterator pit(putProducts().begin());
00081     ProductPtrVec::iterator pie(putProducts().end());
00082 
00083     while(pit != pie) {
00084         // set provenance
00085         std::auto_ptr<ProductProvenance> runEntryInfoPtr(
00086                 new ProductProvenance(pit->second->branchID(),
00087                                     productstatus::present()));
00088         std::auto_ptr<EDProduct> pr(pit->first);
00089         // Ownership has passed, so clear the pointer.
00090         pit->first = 0;
00091         rp.put(*pit->second, pr, runEntryInfoPtr);
00092         ++pit;
00093     }
00094 
00095     // the cleanup is all or none
00096     putProducts().clear();
00097   }
00098 
00099   ProcessHistory const&
00100   Run::processHistory() const {
00101     return provRecorder_.processHistory();
00102   }
00103 
00104   void
00105   Run::addToGotBranchIDs(Provenance const& prov) const {
00106     gotBranchIDs_.insert(prov.branchID());
00107   }
00108 
00109   BasicHandle
00110   Run::getByLabelImpl(const std::type_info& iWrapperType, const std::type_info& iProductType, const InputTag& iTag) const {
00111     BasicHandle h = provRecorder_.getByLabel_(TypeID(iProductType),iTag);
00112     if (h.isValid()) {
00113       addToGotBranchIDs(*(h.provenance()));
00114     }
00115     return h;
00116   }
00117 
00118 
00119 }