CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/FWCore/Framework/src/ScheduleItems.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/ScheduleItems.h"
00002 
00003 #include "FWCore/Framework/interface/Actions.h"
00004 #include "FWCore/Framework/interface/CommonParams.h"
00005 #include "FWCore/Framework/interface/ConstProductRegistry.h"
00006 #include "FWCore/Framework/interface/Schedule.h"
00007 #include "FWCore/Framework/interface/TriggerNamesService.h"
00008 #include "FWCore/Framework/src/SignallingProductRegistry.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
00011 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
00012 #include "FWCore/Utilities/interface/GetPassID.h"
00013 #include "FWCore/Version/interface/GetReleaseVersion.h"
00014 
00015 namespace edm {
00016   ScheduleItems::ScheduleItems() :
00017       actReg_(new ActivityRegistry),
00018       preg_(new SignallingProductRegistry),
00019       act_table_(),
00020       processConfiguration_() {
00021   }
00022 
00023   ScheduleItems::ScheduleItems(ProductRegistry const& preg) :
00024       actReg_(new ActivityRegistry),
00025       preg_(new SignallingProductRegistry(preg)),
00026       act_table_(),
00027       processConfiguration_() {
00028     for(ProductRegistry::ProductList::iterator it = preg_->productListUpdator().begin(), itEnd = preg_->productListUpdator().end(); it != itEnd; ++it) {
00029       it->second.onDemand() = false;
00030       it->second.produced() = false;
00031     }
00032   }
00033 
00034   ServiceToken
00035   ScheduleItems::initServices(std::vector<ParameterSet>& pServiceSets,
00036                              ParameterSet& parameterSet,
00037                              ServiceToken const& iToken,
00038                              serviceregistry::ServiceLegacy iLegacy,
00039                              bool associate) {
00040 
00041     //create the services
00042     ServiceToken token(ServiceRegistry::createSet(pServiceSets, iToken, iLegacy, associate));
00043 
00044     //see if any of the Services have to have their PSets stored
00045     for(std::vector<ParameterSet>::const_iterator it = pServiceSets.begin(), itEnd = pServiceSets.end();
00046         it != itEnd;
00047         ++it) {
00048       if(it->exists("@save_config")) {
00049         parameterSet.addParameter(it->getParameter<std::string>("@service_type"), *it);
00050       }
00051     }
00052     // Copy slots that hold all the registered callback functions like
00053     // PostBeginJob into an ActivityRegistry
00054     token.copySlotsTo(*actReg_);
00055     return token;
00056   }
00057 
00058   ServiceToken
00059   ScheduleItems::addCPRandTNS(ParameterSet const& parameterSet, ServiceToken const& token) {
00060 
00061     //add the ProductRegistry as a service ONLY for the construction phase
00062     typedef serviceregistry::ServiceWrapper<ConstProductRegistry> w_CPR;
00063     boost::shared_ptr<w_CPR>
00064       reg(new w_CPR(std::auto_ptr<ConstProductRegistry>(new ConstProductRegistry(*preg_))));
00065     ServiceToken tempToken(ServiceRegistry::createContaining(reg,
00066                                                              token,
00067                                                              serviceregistry::kOverlapIsError));
00068 
00069     // the next thing is ugly: pull out the trigger path pset and
00070     // create a service and extra token for it
00071 
00072     typedef service::TriggerNamesService TNS;
00073     typedef serviceregistry::ServiceWrapper<TNS> w_TNS;
00074 
00075     boost::shared_ptr<w_TNS> tnsptr
00076       (new w_TNS(std::auto_ptr<TNS>(new TNS(parameterSet))));
00077 
00078     return ServiceRegistry::createContaining(tnsptr,
00079                                              tempToken,
00080                                              serviceregistry::kOverlapIsError);
00081   }
00082 
00083   boost::shared_ptr<CommonParams>
00084   ScheduleItems::initMisc(ParameterSet& parameterSet) {
00085     act_table_.reset(new ActionTable(parameterSet));
00086     std::string processName = parameterSet.getParameter<std::string>("@process_name");
00087     processConfiguration_.reset(new ProcessConfiguration(processName, getReleaseVersion(), getPassID()));
00088     boost::shared_ptr<CommonParams>
00089         common(new CommonParams(parameterSet.getUntrackedParameterSet(
00090                                    "maxEvents", ParameterSet()).getUntrackedParameter<int>("input", -1),
00091                                 parameterSet.getUntrackedParameterSet(
00092                                    "maxLuminosityBlocks", ParameterSet()).getUntrackedParameter<int>("input", -1)));
00093     return common;
00094   }
00095 
00096   std::auto_ptr<Schedule>
00097   ScheduleItems::initSchedule(ParameterSet& parameterSet,
00098                               ParameterSet const* subProcessPSet) {
00099     std::auto_ptr<Schedule> schedule(
00100         new Schedule(parameterSet,
00101                      ServiceRegistry::instance().get<service::TriggerNamesService>(),
00102                      *preg_,
00103                      *act_table_,
00104                      actReg_,
00105                      processConfiguration_,
00106                      subProcessPSet));
00107     return schedule;
00108   }
00109 
00110   void
00111   ScheduleItems::clear() {
00112     actReg_.reset();
00113     preg_.reset();
00114     processConfiguration_.reset();
00115   }
00116 }
00117