CMS 3D CMS Logo

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