CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/FWCore/Framework/src/LuminosityBlockPrincipal.cc

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