Go to the documentation of this file.00001 #include "FWCore/Framework/interface/ScheduleItems.h"
00002
00003 #include "DataFormats/Provenance/interface/BranchDescription.h"
00004 #include "DataFormats/Provenance/interface/BranchID.h"
00005 #include "DataFormats/Provenance/interface/BranchIDListHelper.h"
00006 #include "DataFormats/Provenance/interface/Selections.h"
00007 #include "FWCore/Framework/interface/Actions.h"
00008 #include "FWCore/Framework/interface/CommonParams.h"
00009 #include "FWCore/Framework/interface/ConstProductRegistry.h"
00010 #include "FWCore/Framework/interface/OutputModule.h"
00011 #include "FWCore/Framework/interface/Schedule.h"
00012 #include "FWCore/Framework/interface/TriggerNamesService.h"
00013 #include "FWCore/Framework/src/SignallingProductRegistry.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
00016 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
00017 #include "FWCore/Utilities/interface/BranchType.h"
00018 #include "FWCore/Utilities/interface/GetPassID.h"
00019 #include "FWCore/Version/interface/GetReleaseVersion.h"
00020
00021 #include <set>
00022
00023 namespace edm {
00024 ScheduleItems::ScheduleItems() :
00025 actReg_(new ActivityRegistry),
00026 preg_(new SignallingProductRegistry),
00027 branchIDListHelper_(new BranchIDListHelper()),
00028 act_table_(),
00029 processConfiguration_() {
00030 }
00031
00032 ScheduleItems::ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, OutputModule const& om) :
00033 actReg_(new ActivityRegistry),
00034 preg_(new SignallingProductRegistry(preg)),
00035 branchIDListHelper_(new BranchIDListHelper(branchIDListHelper)),
00036 act_table_(),
00037 processConfiguration_() {
00038 for(ProductRegistry::ProductList::iterator it = preg_->productListUpdator().begin(), itEnd = preg_->productListUpdator().end(); it != itEnd; ++it) {
00039 it->second.onDemand() = false;
00040 it->second.produced() = false;
00041 }
00042
00043
00044 std::set<BranchID> keptBranches;
00045 Selections const& keptVectorR = om.keptProducts()[InRun];
00046 for(Selections::const_iterator it = keptVectorR.begin(), itEnd = keptVectorR.end(); it != itEnd; ++it) {
00047 keptBranches.insert((*it)->branchID());
00048 }
00049 Selections const& keptVectorL = om.keptProducts()[InLumi];
00050 for(Selections::const_iterator it = keptVectorL.begin(), itEnd = keptVectorL.end(); it != itEnd; ++it) {
00051 keptBranches.insert((*it)->branchID());
00052 }
00053 Selections const& keptVectorE = om.keptProducts()[InEvent];
00054 for(Selections::const_iterator it = keptVectorE.begin(), itEnd = keptVectorE.end(); it != itEnd; ++it) {
00055 keptBranches.insert((*it)->branchID());
00056 }
00057 for(ProductRegistry::ProductList::const_iterator it = preg_->productList().begin(), itEnd = preg_->productList().end(); it != itEnd; ++it) {
00058 if(keptBranches.find(it->second.branchID()) == keptBranches.end()) {
00059 it->second.setDropped();
00060 }
00061 }
00062 }
00063
00064 ServiceToken
00065 ScheduleItems::initServices(std::vector<ParameterSet>& pServiceSets,
00066 ParameterSet& parameterSet,
00067 ServiceToken const& iToken,
00068 serviceregistry::ServiceLegacy iLegacy,
00069 bool associate) {
00070
00071
00072 ServiceToken token(ServiceRegistry::createSet(pServiceSets, iToken, iLegacy, associate));
00073
00074
00075 for(std::vector<ParameterSet>::const_iterator it = pServiceSets.begin(), itEnd = pServiceSets.end();
00076 it != itEnd;
00077 ++it) {
00078 if(it->exists("@save_config")) {
00079 parameterSet.addParameter(it->getParameter<std::string>("@service_type"), *it);
00080 }
00081 }
00082
00083
00084 token.copySlotsTo(*actReg_);
00085 return token;
00086 }
00087
00088 ServiceToken
00089 ScheduleItems::addCPRandTNS(ParameterSet const& parameterSet, ServiceToken const& token) {
00090
00091
00092 typedef serviceregistry::ServiceWrapper<ConstProductRegistry> w_CPR;
00093 boost::shared_ptr<w_CPR>
00094 reg(new w_CPR(std::auto_ptr<ConstProductRegistry>(new ConstProductRegistry(*preg_))));
00095 ServiceToken tempToken(ServiceRegistry::createContaining(reg,
00096 token,
00097 serviceregistry::kOverlapIsError));
00098
00099
00100
00101
00102 typedef service::TriggerNamesService TNS;
00103 typedef serviceregistry::ServiceWrapper<TNS> w_TNS;
00104
00105 boost::shared_ptr<w_TNS> tnsptr
00106 (new w_TNS(std::auto_ptr<TNS>(new TNS(parameterSet))));
00107
00108 return ServiceRegistry::createContaining(tnsptr,
00109 tempToken,
00110 serviceregistry::kOverlapIsError);
00111 }
00112
00113 boost::shared_ptr<CommonParams>
00114 ScheduleItems::initMisc(ParameterSet& parameterSet) {
00115 act_table_.reset(new ActionTable(parameterSet));
00116 std::string processName = parameterSet.getParameter<std::string>("@process_name");
00117 processConfiguration_.reset(new ProcessConfiguration(processName, getReleaseVersion(), getPassID()));
00118 boost::shared_ptr<CommonParams>
00119 common(new CommonParams(parameterSet.getUntrackedParameterSet(
00120 "maxEvents", ParameterSet()).getUntrackedParameter<int>("input", -1),
00121 parameterSet.getUntrackedParameterSet(
00122 "maxLuminosityBlocks", ParameterSet()).getUntrackedParameter<int>("input", -1)));
00123 return common;
00124 }
00125
00126 std::auto_ptr<Schedule>
00127 ScheduleItems::initSchedule(ParameterSet& parameterSet,
00128 ParameterSet const* subProcessPSet) {
00129 std::auto_ptr<Schedule> schedule(
00130 new Schedule(parameterSet,
00131 ServiceRegistry::instance().get<service::TriggerNamesService>(),
00132 *preg_,
00133 *branchIDListHelper_,
00134 *act_table_,
00135 actReg_,
00136 processConfiguration_,
00137 subProcessPSet));
00138 return schedule;
00139 }
00140
00141 void
00142 ScheduleItems::clear() {
00143 actReg_.reset();
00144 preg_.reset();
00145 branchIDListHelper_.reset();
00146 processConfiguration_.reset();
00147 }
00148 }
00149