Go to the documentation of this file.00001 #include "FWCore/Framework/interface/RunPrincipal.h"
00002 #include "FWCore/Framework/interface/Group.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
00005 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00006
00007 namespace edm {
00008 RunPrincipal::RunPrincipal(
00009 boost::shared_ptr<RunAuxiliary> aux,
00010 boost::shared_ptr<ProductRegistry const> reg,
00011 ProcessConfiguration const& pc) :
00012 Base(reg, pc, InRun),
00013 aux_(aux) {
00014 }
00015
00016 void
00017 RunPrincipal::fillRunPrincipal(
00018 boost::shared_ptr<BranchMapper> mapper,
00019 boost::shared_ptr<DelayedReader> rtrv) {
00020 if (productRegistry().anyProductProduced()) {
00021 checkProcessHistory();
00022 }
00023 fillPrincipal(aux_->processHistoryID(), mapper, rtrv);
00024 if (productRegistry().anyProductProduced()) {
00025 addToProcessHistory();
00026 }
00027 mapper->processHistoryID() = processHistoryID();
00028 for (const_iterator i = this->begin(), iEnd = this->end(); i != iEnd; ++i) {
00029 (*i)->setProvenance(mapper);
00030 }
00031 }
00032
00033 void
00034 RunPrincipal::put(
00035 ConstBranchDescription const& bd,
00036 std::auto_ptr<EDProduct> edp,
00037 std::auto_ptr<ProductProvenance> productProvenance) {
00038
00039 assert(bd.produced());
00040 if (edp.get() == 0) {
00041 throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
00042 << "put: Cannot put because auto_ptr to product is null."
00043 << "\n";
00044 }
00045 branchMapperPtr()->insert(*productProvenance);
00046 Group *g = getExistingGroup(bd.branchID());
00047 assert(g);
00048
00049 putOrMerge(edp, productProvenance, g);
00050 }
00051
00052 void
00053 RunPrincipal::readImmediate() const {
00054 for (Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
00055 Group const& g = **i;
00056 if (!g.branchDescription().produced()) {
00057 if (!g.productUnavailable()) {
00058 resolveProductImmediate(g);
00059 }
00060 }
00061 }
00062 branchMapperPtr()->setDelayedRead(false);
00063 }
00064
00065 void
00066 RunPrincipal::resolveProductImmediate(Group const& g) const {
00067 if (g.branchDescription().produced()) return;
00068
00069
00070 BranchKey const bk = BranchKey(g.branchDescription());
00071 std::auto_ptr<EDProduct> edp(store()->getProduct(bk, this));
00072
00073
00074 if (edp.get() != 0) {
00075 putOrMerge(edp, &g);
00076 }
00077 }
00078
00079 void
00080 RunPrincipal::checkProcessHistory() const {
00081 ProcessHistory ph;
00082 ProcessHistoryRegistry::instance()->getMapped(aux_->processHistoryID(), ph);
00083 std::string const& processName = processConfiguration().processName();
00084 for (ProcessHistory::const_iterator it = ph.begin(), itEnd = ph.end(); it != itEnd; ++it) {
00085 if (processName == it->processName()) {
00086 throw edm::Exception(errors::Configuration, "Duplicate Process")
00087 << "The process name " << processName << " was previously used on these products.\n"
00088 << "Please modify the configuration file to use a distinct process name.\n";
00089 }
00090 }
00091 }
00092
00093 void
00094 RunPrincipal::addToProcessHistory() {
00095 ProcessHistory& ph = processHistoryUpdate();
00096 ph.push_back(processConfiguration());
00097
00098
00099
00100
00101
00102
00103
00104
00105 ProcessHistoryRegistry::instance()->insertMapped(ph);
00106 setProcessHistory(*this);
00107 }
00108
00109 void
00110 RunPrincipal::swap(RunPrincipal& iOther) {
00111 swapBase(iOther);
00112 std::swap(aux_, iOther.aux_);
00113 }
00114 }