CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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/ProductHolder.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       HistoryAppender* historyAppender) :
00016     Base(reg, reg->productLookup(InLumi), pc, InLumi, historyAppender),
00017         runPrincipal_(),
00018         aux_(aux),
00019         complete_(false) {
00020   }
00021 
00022   void
00023   LuminosityBlockPrincipal::fillLuminosityBlockPrincipal(
00024       DelayedReader* reader) {
00025 
00026     complete_ = false;
00027 
00028     fillPrincipal(aux_->processHistoryID(), reader);
00029 
00030     for(const_iterator i = this->begin(), iEnd = this->end(); i != iEnd; ++i) {
00031       (*i)->setProcessHistoryID(processHistoryID());
00032     }
00033   }
00034 
00035   void
00036   LuminosityBlockPrincipal::put(
00037         ConstBranchDescription const& bd,
00038         WrapperOwningHolder const& edp) {
00039 
00040     assert(bd.produced());
00041     if(!edp.isValid()) {
00042       throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
00043         << "put: Cannot put because auto_ptr to product is null."
00044         << "\n";
00045     }
00046     ProductHolderBase* phb = getExistingProduct(bd.branchID());
00047     assert(phb);
00048     // ProductHolder assumes ownership
00049     putOrMerge(edp, phb);
00050   }
00051 
00052   void
00053   LuminosityBlockPrincipal::readImmediate() const {
00054     for(Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
00055       ProductHolderBase const& phb = **i;
00056       if(phb.singleProduct() && !phb.branchDescription().produced()) {
00057         if(!phb.productUnavailable()) {
00058           resolveProductImmediate(phb);
00059         }
00060       }
00061     }
00062   }
00063 
00064   void
00065   LuminosityBlockPrincipal::resolveProductImmediate(ProductHolderBase const& phb) const {
00066     if(phb.branchDescription().produced()) return; // nothing to do.
00067     if(!reader()) return; // nothing to do.
00068 
00069     // must attempt to load from persistent store
00070     BranchKey const bk = BranchKey(phb.branchDescription());
00071     WrapperOwningHolder edp(reader()->getProduct(bk, phb.productData().getInterface(), this));
00072 
00073     // Now fix up the ProductHolder
00074     if(edp.isValid()) {
00075       putOrMerge(edp, &phb);
00076     }
00077   }
00078 }