CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/FWCore/Framework/src/LuminosityBlockPrincipal.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
00002 #include "FWCore/Framework/interface/RunPrincipal.h"
00003 #include "FWCore/Framework/interface/Group.h"
00004 #include "FWCore/Utilities/interface/EDMException.h"
00005 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00006 
00007 namespace edm {
00008 
00009   LuminosityBlockPrincipal::LuminosityBlockPrincipal(
00010       boost::shared_ptr<LuminosityBlockAuxiliary> aux,
00011       boost::shared_ptr<ProductRegistry const> reg,
00012       ProcessConfiguration const& pc,
00013       boost::shared_ptr<RunPrincipal> rp) :
00014         Base(reg, pc, InLumi),
00015         runPrincipal_(rp),
00016         aux_(aux) {
00017   }
00018 
00019   void
00020   LuminosityBlockPrincipal::fillLuminosityBlockPrincipal(
00021       boost::shared_ptr<BranchMapper> mapper,
00022       boost::shared_ptr<DelayedReader> rtrv) {
00023 
00024     fillPrincipal(aux_->processHistoryID(), mapper, rtrv);
00025     if (runPrincipal_) {
00026       setProcessHistory(*runPrincipal_);
00027     }
00028     mapper->processHistoryID() = processHistoryID();
00029     for (const_iterator i = this->begin(), iEnd = this->end(); i != iEnd; ++i) {
00030       (*i)->setProvenance(mapper);
00031     }
00032   }
00033 
00034   void 
00035   LuminosityBlockPrincipal::put(
00036         ConstBranchDescription const& bd,
00037         std::auto_ptr<EDProduct> edp,
00038         std::auto_ptr<ProductProvenance> productProvenance) {
00039 
00040     assert(bd.produced());
00041     if (edp.get() == 0) {
00042       throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
00043         << "put: Cannot put because auto_ptr to product is null."
00044         << "\n";
00045     }
00046     branchMapperPtr()->insert(*productProvenance);
00047     Group *g = getExistingGroup(bd.branchID());
00048     assert(g);
00049     // Group assumes ownership
00050     putOrMerge(edp, productProvenance, g);
00051   }
00052 
00053   void
00054   LuminosityBlockPrincipal::readImmediate() const {
00055     for (Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
00056       Group const& g = **i;
00057       if (!g.branchDescription().produced()) {
00058         if (!g.productUnavailable()) {
00059           resolveProductImmediate(g);
00060         }
00061       }
00062     }
00063     branchMapperPtr()->setDelayedRead(false);
00064   }
00065 
00066   void
00067   LuminosityBlockPrincipal::resolveProductImmediate(Group const& g) const {
00068     if (g.branchDescription().produced()) return; // nothing to do.
00069 
00070     // must attempt to load from persistent store
00071     BranchKey const bk = BranchKey(g.branchDescription());
00072     std::auto_ptr<EDProduct> edp(store()->getProduct(bk, this));
00073 
00074     // Now fix up the Group
00075     if (edp.get() != 0) {
00076       putOrMerge(edp, &g);
00077     }
00078   }
00079 
00080   void
00081   LuminosityBlockPrincipal::swap(LuminosityBlockPrincipal& iOther) {
00082     swapBase(iOther);
00083     std::swap(runPrincipal_,iOther.runPrincipal_);
00084     std::swap(aux_, iOther.aux_);
00085   }
00086   
00087 }
00088