CMS 3D CMS Logo

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 
00005 namespace edm {
00006 
00007   LuminosityBlockPrincipal::LuminosityBlockPrincipal(LuminosityBlockAuxiliary const& aux,
00008         boost::shared_ptr<ProductRegistry const> reg,
00009         ProcessConfiguration const& pc,
00010         ProcessHistoryID const& hist,
00011         boost::shared_ptr<BranchMapper> mapper, 
00012         boost::shared_ptr<DelayedReader> rtrv) :
00013           Base(reg, pc, hist, mapper, rtrv),
00014           runPrincipal_(),
00015           aux_(aux) {}
00016 
00017   void
00018   LuminosityBlockPrincipal::addOrReplaceGroup(std::auto_ptr<Group> g) {
00019 
00020     Group* group = getExistingGroup(*g);
00021     if (group != 0) {
00022 
00023       if (!group->productUnavailable()) {
00024         assert(group->product() != 0);
00025       }
00026       if (!g->productUnavailable()) {
00027         assert(g->product() != 0);
00028       }
00029 
00030       group->mergeGroup(g.get());
00031     } else {
00032       addGroup_(g);
00033     }
00034   }
00035 
00036   void
00037   LuminosityBlockPrincipal::addGroup(ConstBranchDescription const& bd) {
00038     std::auto_ptr<Group> g(new Group(bd));
00039     addOrReplaceGroup(g);
00040   }
00041 
00042   void
00043   LuminosityBlockPrincipal::addGroup(std::auto_ptr<EDProduct> prod,
00044         ConstBranchDescription const& bd,
00045         std::auto_ptr<EventEntryInfo> entryInfo) {
00046     std::auto_ptr<Group> g(new Group(prod, bd, entryInfo));
00047     addOrReplaceGroup(g);
00048   }
00049 
00050   void
00051   LuminosityBlockPrincipal::addGroup(ConstBranchDescription const& bd,
00052         std::auto_ptr<EventEntryInfo> entryInfo) {
00053     std::auto_ptr<Group> g(new Group(bd, entryInfo));
00054     addOrReplaceGroup(g);
00055   }
00056 
00057   void 
00058   LuminosityBlockPrincipal::put(std::auto_ptr<EDProduct> edp,
00059                 ConstBranchDescription const& bd,
00060                 std::auto_ptr<EventEntryInfo> entryInfo) {
00061 
00062     if (edp.get() == 0) {
00063       throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
00064         << "put: Cannot put because auto_ptr to product is null."
00065         << "\n";
00066     }
00067     this->addToProcessHistory();
00068     branchMapperPtr()->insert(*entryInfo);
00069     // Group assumes ownership
00070     this->addGroup(edp, bd, entryInfo);
00071   }
00072 
00073   Provenance
00074   LuminosityBlockPrincipal::getProvenance(BranchID const& bid) const {
00075     SharedConstGroupPtr const& g = getGroup(bid, false, true, true);
00076     if (g.get() == 0) {
00077       throw edm::Exception(edm::errors::ProductNotFound,"InvalidID")
00078         << "getProvenance: no product with given branch id: "<< bid << "\n";
00079     }
00080 
00081     if (g->onDemand()) {
00082       unscheduledFill(g->productDescription().moduleLabel());
00083     }
00084     // We already tried to produce the unscheduled products above
00085     // If they still are not there, then throw
00086     if (g->onDemand()) {
00087       throw edm::Exception(edm::errors::ProductNotFound)
00088         << "getProvenance: no product with given BranchID: "<< bid <<"\n";
00089     }
00090 
00091     return *g->provenance();
00092   }
00093 
00094   // This one is mostly for test printout purposes
00095   // No attempt to trigger on demand execution
00096   // Skips provenance when the EDProduct is not there
00097   void
00098   LuminosityBlockPrincipal::getAllProvenance(std::vector<Provenance const*> & provenances) const {
00099     provenances.clear();
00100     for (Base::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
00101       if (i->second->provenanceAvailable()) {
00102         resolveProvenance(*i->second);
00103         if (i->second->provenance()->branchEntryInfoSharedPtr() &&
00104             i->second->provenance()->isPresent() &&
00105             i->second->provenance()->product().present())
00106            provenances.push_back(i->second->provenance());
00107         }
00108     }
00109   }
00110 
00111   void
00112   LuminosityBlockPrincipal::resolveProvenance(Group const& g) const {
00113     if (!g.entryInfoPtr()) {
00114       // Now fix up the Group
00115       g.setProvenance(branchMapperPtr()->branchToEntryInfo(g.productDescription(). branchID()));
00116     }
00117   }
00118 
00119   void
00120   LuminosityBlockPrincipal::mergeLuminosityBlock(boost::shared_ptr<LuminosityBlockPrincipal> lbp) {
00121 
00122     aux_.mergeAuxiliary(lbp->aux());
00123 
00124     for (Base::const_iterator i = lbp->begin(), iEnd = lbp->end(); i != iEnd; ++i) {
00125  
00126       std::auto_ptr<Group> g(new Group());
00127       g->swap(*i->second);
00128 
00129       addOrReplaceGroup(g);
00130     }
00131   }
00132 }
00133 

Generated on Tue Jun 9 17:36:11 2009 for CMSSW by  doxygen 1.5.4