#include <FWCore/ParameterSet/interface/ProcessDesc.h>
Public Types | |
typedef std::vector < WrapperNodePtr > | PathContainer |
Public Member Functions | |
void | addDefaultService (const std::string &service) |
add a service if it's not already there | |
void | addPathFragment (const WrapperNodePtr &wn) |
void | addService (const std::string &service) |
add a service as an empty pset | |
void | addService (const ParameterSet &pset) |
void | addServices (std::vector< std::string > const &defaultServices, std::vector< std::string > const &forcedServices) |
add some defaults services, and some forced | |
void | fillPaths () |
std::string | getDependencies (const std::string &modulename) |
get the dependencies for this module | |
boost::shared_ptr< ParameterSet > | getProcessPSet () const |
get the ParameterSet that describes the process | |
boost::shared_ptr< std::vector < ParameterSet > > | getServicesPSets () const |
get the descriptions of the services | |
PathContainer | pathFragments () const |
ProcessDesc (const std::string &config) | |
construct from the configuration language string | |
ProcessDesc (const ParameterSet &pset) | |
void | record (const std::string &index, const std::string &name) |
makes an entry in the bookkeeping table under this index | |
void | setRegistry () const |
void | writeBookkeeping (const std::string &index) |
puts bookkeeping information into the ParameterSet | |
~ProcessDesc () | |
Private Types | |
typedef std::map< std::string, std::vector< std::string > > | Bookkeeping |
typedef boost::shared_ptr < pset::Node > | NodePtr |
typedef std::map< std::string, edm::WrapperNodePtr > | SeqMap |
typedef std::vector< std::string > | Strs |
Private Member Functions | |
void | dumpTree (NodePtr &node) |
diagnostic function | |
void | fillPath (WrapperNodePtr n, Strs &paths) |
Take a path Wrapper node and extract names. | |
Strs | findSchedule (Strs &triggerPaths, Strs &endPaths) const |
if there's a schedule found, override triggerPaths and endpaths if not, schedule = input triggerpaths + endPaths | |
void | getNames (const pset::Node *n, Strs &out) const |
recursively extract names of modules and store them in Strs; | |
void | sequenceSubstitution (NodePtr &node, SeqMap &sequences) |
perform sequence substitution for this node | |
Private Attributes | |
Bookkeeping | bookkeeping_ |
PathContainer | pathFragments_ |
boost::shared_ptr< ParameterSet > | pset_ |
boost::shared_ptr< std::vector < ParameterSet > > | services_ |
ScheduleValidator * | validator_ |
the validation object |
Definition at line 15 of file ProcessDesc.h.
typedef std::map<std::string, std::vector<std::string> > edm::ProcessDesc::Bookkeeping [private] |
Definition at line 95 of file ProcessDesc.h.
typedef boost::shared_ptr<pset::Node> edm::ProcessDesc::NodePtr [private] |
Definition at line 66 of file ProcessDesc.h.
typedef std::vector< WrapperNodePtr > edm::ProcessDesc::PathContainer |
Definition at line 50 of file ProcessDesc.h.
typedef std::map<std::string, edm::WrapperNodePtr > edm::ProcessDesc::SeqMap [private] |
Definition at line 65 of file ProcessDesc.h.
typedef std::vector<std::string> edm::ProcessDesc::Strs [private] |
Definition at line 64 of file ProcessDesc.h.
edm::ProcessDesc::ProcessDesc | ( | const ParameterSet & | pset | ) | [explicit] |
Definition at line 28 of file ProcessDesc.cc.
References setRegistry().
00029 : validator_(0), 00030 pathFragments_(), 00031 pset_(new ParameterSet(pset)), 00032 services_(new std::vector<ParameterSet>()), 00033 bookkeeping_() 00034 { 00035 setRegistry(); 00036 // std::cout << pset << std::endl; 00037 }
edm::ProcessDesc::ProcessDesc | ( | const std::string & | config | ) | [explicit] |
construct from the configuration language string
Definition at line 44 of file ProcessDesc.cc.
References fillPaths(), pathFragments_, pset_, setRegistry(), edm::ScheduleValidator::validate(), validator_, and writeBookkeeping().
00045 : validator_(0), 00046 pathFragments_(), 00047 pset_(new ParameterSet), 00048 services_(new std::vector<ParameterSet>()), 00049 bookkeeping_() 00050 { 00051 edm::pset::ParseTree parsetree(config.c_str()); 00052 parsetree.getProcessNode()->fillProcess(*this); 00053 00054 00055 writeBookkeeping("@all_modules"); 00056 writeBookkeeping("@all_sources"); 00057 writeBookkeeping("@all_loopers"); 00058 writeBookkeeping("@all_esmodules"); 00059 writeBookkeeping("@all_essources"); 00060 writeBookkeeping("@all_esprefers"); 00061 00062 fillPaths(); 00063 00064 validator_= 00065 new ScheduleValidator(pathFragments_,*pset_); 00066 validator_->validate(); 00067 00068 setRegistry(); 00069 // std::cout << *pset_ << std::endl; 00070 00071 }
edm::ProcessDesc::~ProcessDesc | ( | ) |
Definition at line 39 of file ProcessDesc.cc.
References validator_.
00040 { 00041 delete validator_; 00042 }
void edm::ProcessDesc::addDefaultService | ( | const std::string & | service | ) |
add a service if it's not already there
Definition at line 256 of file ProcessDesc.cc.
References addService(), it, name, and services_.
Referenced by addServices().
00257 { 00258 typedef std::vector<edm::ParameterSet>::iterator Iter; 00259 for(Iter it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) { 00260 std::string name = it->getParameter<std::string>("@service_type"); 00261 00262 if (name == service) { 00263 // If the service is already there move it to the end so 00264 // it will be created before all the others already there 00265 // This means we use the order from the default services list 00266 // and the parameters from the configuration file 00267 while (true) { 00268 Iter iterNext = it + 1; 00269 if (iterNext == itEnd) return; 00270 iter_swap(it, iterNext); 00271 ++it; 00272 } 00273 } 00274 } 00275 addService(service); 00276 }
void edm::ProcessDesc::addPathFragment | ( | const WrapperNodePtr & | wn | ) | [inline] |
Definition at line 52 of file ProcessDesc.h.
References pathFragments_.
Referenced by edm::pset::WrapperNode::insertInto().
00052 { pathFragments_.push_back(wn);}
void edm::ProcessDesc::addService | ( | const std::string & | service | ) |
add a service as an empty pset
Definition at line 249 of file ProcessDesc.cc.
References edm::ParameterSet::addParameter(), and addService().
00250 { 00251 ParameterSet newpset; 00252 newpset.addParameter<std::string>("@service_type",service); 00253 addService(newpset); 00254 }
void edm::ProcessDesc::addService | ( | const ParameterSet & | pset | ) |
Definition at line 240 of file ProcessDesc.cc.
References edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), and services_.
Referenced by addDefaultService(), addService(), addServices(), and edm::pset::ModuleNode::insertInto().
00241 { 00242 services_->push_back(pset); 00243 // Load into the Registry 00244 pset::Registry* reg = pset::Registry::instance(); 00245 reg->insertMapped(pset); 00246 }
void edm::ProcessDesc::addServices | ( | std::vector< std::string > const & | defaultServices, | |
std::vector< std::string > const & | forcedServices | |||
) |
add some defaults services, and some forced
Definition at line 279 of file ProcessDesc.cc.
References addDefaultService(), addService(), i, j, and services_.
00281 { 00282 // Add the forced and default services to services_. 00283 // In services_, we want the default services first, then the forced 00284 // services, then the services from the configuration. It is efficient 00285 // and convenient to add them in reverse order. Then after we are done 00286 // adding, we reverse the std::vector again to get the desired order. 00287 std::reverse(services_->begin(), services_->end()); 00288 for(std::vector<std::string>::const_reverse_iterator j = forcedServices.rbegin(), 00289 jEnd = forcedServices.rend(); 00290 j != jEnd; ++j) { 00291 addService(*j); 00292 } 00293 for(std::vector<std::string>::const_reverse_iterator i = defaultServices.rbegin(), 00294 iEnd = defaultServices.rend(); 00295 i != iEnd; ++i) { 00296 addDefaultService(*i); 00297 } 00298 std::reverse(services_->begin(), services_->end()); 00299 }
diagnostic function
Definition at line 208 of file ProcessDesc.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::pset::Node::getParent(), edm::pset::OperatorNode::left(), edm::pset::Node::name(), edm::pset::OperatorNode::right(), and edm::pset::OperatorNode::type().
00208 { 00209 if(node->type() == "operand") { 00210 std::cout << " Operand " << node->name() << " p:"; 00211 if (node->getParent()) std::cout << node->getParent()->name(); std::cout<< std::endl; 00212 } else { 00213 edm::pset::OperatorNode* op = dynamic_cast<edm::pset::OperatorNode*>(node.get()); 00214 std::cout << " Operator: " << op->name() << "[" << op->type() << "]" 00215 << " l:" << op->left() << " r:" << op->right() << " p:"; 00216 if (op->getParent()) std::cout << op->getParent()->name() << std::endl; 00217 dumpTree(op->left()); 00218 dumpTree(op->right()); 00219 } 00220 } // dumpTree
void edm::ProcessDesc::fillPath | ( | WrapperNodePtr | n, | |
Strs & | paths | |||
) | [private] |
Take a path Wrapper node and extract names.
put the name of this path in
paths | and put the names of the modules for this path in | |
out |
Definition at line 163 of file ProcessDesc.cc.
References getNames(), names, and pset_.
Referenced by fillPaths().
00164 { 00165 00166 Strs names; 00167 getNames(n->wrapped().get(),names); 00168 pset_->addParameter(n->name(),names); 00169 paths.push_back(n->name()); // add to the list of paths 00170 00171 } // fillPath(..)
void edm::ProcessDesc::fillPaths | ( | ) |
Definition at line 80 of file ProcessDesc.cc.
References edm::ParameterSet::addParameter(), TestMuL1L2Filter_cff::cerr, edm::copy_all(), edm::debugit, fillPath(), findSchedule(), pathFragments_, pset_, schedule(), and sequenceSubstitution().
Referenced by ProcessDesc().
00081 { 00082 SeqMap sequences; 00083 00084 // loop on path fragments 00085 Strs endpaths, triggerpaths; 00086 00087 for(ProcessDesc::PathContainer::iterator pathIt = pathFragments_.begin(), 00088 pathItEnd = pathFragments_.end(); 00089 pathIt != pathItEnd; 00090 ++pathIt) { 00091 00092 if ((*pathIt)->type() == "sequence") { 00093 sequences[(*pathIt)->name()]= (*pathIt); 00094 } 00095 00096 if ((*pathIt)->type() == "path") { 00097 //FIXME order-dependent 00098 sequenceSubstitution((*pathIt)->wrapped(), sequences); 00099 fillPath((*pathIt),triggerpaths); 00100 } 00101 00102 00103 if ((*pathIt)->type() == "endpath") { 00104 sequenceSubstitution((*pathIt)->wrapped(), sequences); 00105 fillPath((*pathIt),endpaths); 00106 } 00107 00108 00109 } // loop on path fragments 00110 00111 Strs schedule(findSchedule(triggerpaths, endpaths)); 00112 00113 if(1 <= edm::debugit()) 00114 { 00115 std::cerr << "\nschedule=\n "; 00116 copy_all(schedule, std::ostream_iterator<std::string>(std::cerr,",")); 00117 std::cerr << "\ntriggernames=\n "; 00118 copy_all(triggerpaths, std::ostream_iterator<std::string>(std::cerr,",")); 00119 std::cerr << "\nendpaths=\n "; 00120 copy_all(endpaths, std::ostream_iterator<std::string>(std::cerr,",")); 00121 std::cerr << "\n"; 00122 } 00123 00124 // It is very important that the @trigger_paths parameter set only 00125 // contain one parameter because the streamer input module needs to 00126 // be able to recreate it based on the header in the streamer files. 00127 // The recreated version must have the same ParameterSetID 00128 ParameterSet paths_trig; 00129 paths_trig.addParameter("@trigger_paths", triggerpaths); 00130 00131 pset_->addUntrackedParameter("@trigger_paths",paths_trig); 00132 pset_->addParameter("@end_paths", endpaths); 00133 pset_->addParameter("@paths",schedule); 00134 00135 }
ProcessDesc::Strs edm::ProcessDesc::findSchedule | ( | ProcessDesc::Strs & | triggerPaths, | |
ProcessDesc::Strs & | endPaths | |||
) | const [private] |
if there's a schedule found, override triggerPaths and endpaths if not, schedule = input triggerpaths + endPaths
else
Definition at line 302 of file ProcessDesc.cc.
References edm::errors::Configuration, getNames(), pathFragments_, and HLT_VtxMuL3::result.
Referenced by fillPaths().
00304 { 00305 Strs result; 00306 bool found = false; 00307 00308 for(ProcessDesc::PathContainer::const_iterator pathIt = pathFragments_.begin(), 00309 pathItEnd = pathFragments_.end(); 00310 pathIt != pathItEnd; ++pathIt) 00311 { 00312 00313 if ((*pathIt)->type() == "schedule") 00314 { 00315 // no duplicates 00316 if(found) 00317 { 00318 throw edm::Exception(errors::Configuration,"duplicate schedule") 00319 << "Second schedule statement found at " << (*pathIt)->traceback(); 00320 } 00321 else 00322 { 00323 found = true; 00324 getNames((*pathIt)->wrapped().get(), result); 00325 // now override triggerPaths with everything that 00326 // was in the schedule before the first endpath 00327 //endOfTriggerPaths = std::find(result.begin(), result.end(), *(endPaths.begin()) ); 00328 Strs::iterator endOfTriggerPaths = std::find_first_of(result.begin(), result.end(), 00329 endPaths.begin(), endPaths.end()); 00330 // override trigger_paths and endpaths 00331 triggerPaths = Strs(result.begin(), endOfTriggerPaths); 00332 endPaths = Strs(endOfTriggerPaths, result.end()); 00333 } 00334 } 00335 } 00336 00337 if(!found) 00338 { 00339 // only take defaults if there's only one path and at most one endpath 00340 // if(triggerPaths.size() > 1 || endPaths.size() > triggerPaths.size()) 00341 // { 00342 // throw edm::Exception(errors::Configuration,"No schedule") 00343 // << "More than one path found, so a schedule statement is needed."; 00344 // } 00346 // { 00347 // just take defaults 00348 result = triggerPaths; 00349 result.insert(result.end(), endPaths.begin(), endPaths.end()); 00350 // } 00351 } 00352 return result; 00353 }
std::string edm::ProcessDesc::getDependencies | ( | const std::string & | modulename | ) |
get the dependencies for this module
the return string is a list of comma-separated names of the modules on which modulename depends
Definition at line 223 of file ProcessDesc.cc.
References edm::ScheduleValidator::dependencies(), and validator_.
00223 { 00224 return validator_->dependencies(modulename); 00225 }
void edm::ProcessDesc::getNames | ( | const pset::Node * | n, | |
Strs & | out | |||
) | const [private] |
recursively extract names of modules and store them in Strs;
Definition at line 152 of file ProcessDesc.cc.
References edm::pset::OperatorNode::left(), edm::pset::Node::name(), edm::pset::OperatorNode::right(), and edm::pset::Node::type().
Referenced by fillPath(), and findSchedule().
00152 { 00153 if(n->type() == "operand") { 00154 out.push_back(n->name()); 00155 } else { 00156 const edm::pset::OperatorNode& op = dynamic_cast<const edm::pset::OperatorNode&>(*n); 00157 getNames(op.left().get(),out); 00158 getNames(op.right().get(),out); 00159 } 00160 } // getNames
boost::shared_ptr< edm::ParameterSet > edm::ProcessDesc::getProcessPSet | ( | ) | const |
get the ParameterSet that describes the process
Definition at line 229 of file ProcessDesc.cc.
References pset_.
Referenced by edm::pset::PSetNode::fillProcess(), edm::pset::ModuleNode::insertInto(), edm::pset::VPSetNode::insertInto(), and edm::pset::PSetNode::insertInto().
00229 { 00230 return pset_; 00231 00232 }
boost::shared_ptr< std::vector< ParameterSet > > edm::ProcessDesc::getServicesPSets | ( | ) | const |
get the descriptions of the services
Definition at line 235 of file ProcessDesc.cc.
References services_.
00235 { 00236 return services_; 00237 }
PathContainer edm::ProcessDesc::pathFragments | ( | ) | const [inline] |
Definition at line 51 of file ProcessDesc.h.
References pathFragments_.
00051 {return pathFragments_;}
void edm::ProcessDesc::record | ( | const std::string & | index, | |
const std::string & | name | |||
) |
makes an entry in the bookkeeping table under this index
Definition at line 138 of file ProcessDesc.cc.
References bookkeeping_.
Referenced by edm::pset::ModuleNode::insertInto().
00139 { 00140 bookkeeping_[index].push_back(name); 00141 }
perform sequence substitution for this node
Definition at line 175 of file ProcessDesc.cc.
References edm::pset::OperatorNode::left(), and edm::pset::OperatorNode::right().
Referenced by fillPaths().
00176 { 00177 00178 if (node->type() == "operand") { 00179 SeqMap::iterator seqIt = sequences.find(node->name()); 00180 if (seqIt != sequences.end()) { 00181 node = seqIt->second->wrapped(); 00182 sequenceSubstitution(node, sequences); 00183 } 00184 } // if operator 00185 else { 00186 edm::pset::OperatorNode* onode = dynamic_cast<edm::pset::OperatorNode*>(node.get()); 00187 00188 SeqMap::iterator seqIt = sequences.find(onode->left()->name()); 00189 if (seqIt != sequences.end()) { 00190 //onode->left()= seqIt->second->wrapped(); 00191 onode->left()= NodePtr(seqIt->second->wrapped()->clone()); 00192 onode->left()->setParent(onode); 00193 } 00194 seqIt = sequences.find(onode->right()->name()); 00195 if (seqIt != sequences.end()) { 00196 //onode->right()= seqIt->second->wrapped(); 00197 onode->right()= NodePtr(seqIt->second->wrapped()->clone()); 00198 onode->right()->setParent(onode); 00199 } 00200 sequenceSubstitution(onode->left(), sequences); 00201 sequenceSubstitution(onode->right(),sequences); 00202 00203 }// else (operand) 00204 00205 } // sequenceSubstitution
void edm::ProcessDesc::setRegistry | ( | ) | const |
Definition at line 73 of file ProcessDesc.cc.
References edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), edm::pset::loadAllNestedParameterSets(), and pset_.
Referenced by ProcessDesc().
00074 { 00075 // Load every ParameterSet into the Registry 00076 pset::Registry* reg = pset::Registry::instance(); 00077 pset::loadAllNestedParameterSets(reg, *pset_); 00078 }
void edm::ProcessDesc::writeBookkeeping | ( | const std::string & | index | ) |
puts bookkeeping information into the ParameterSet
Definition at line 143 of file ProcessDesc.cc.
References bookkeeping_, pset_, and python::multivaluedict::sort().
Referenced by ProcessDesc().
00144 { 00145 std::vector<std::string> sortedString = bookkeeping_[name]; 00146 std::sort(sortedString.begin(), sortedString.end()); 00147 pset_->addParameter(name, sortedString); 00148 }
Bookkeeping edm::ProcessDesc::bookkeeping_ [private] |
Definition at line 91 of file ProcessDesc.h.
Referenced by addPathFragment(), fillPaths(), findSchedule(), pathFragments(), and ProcessDesc().
boost::shared_ptr<ParameterSet> edm::ProcessDesc::pset_ [private] |
Definition at line 92 of file ProcessDesc.h.
Referenced by fillPath(), fillPaths(), getProcessPSet(), ProcessDesc(), setRegistry(), and writeBookkeeping().
boost::shared_ptr<std::vector< ParameterSet> > edm::ProcessDesc::services_ [private] |
Definition at line 93 of file ProcessDesc.h.
Referenced by addDefaultService(), addService(), addServices(), and getServicesPSets().
ScheduleValidator* edm::ProcessDesc::validator_ [private] |
the validation object
Definition at line 87 of file ProcessDesc.h.
Referenced by getDependencies(), ProcessDesc(), and ~ProcessDesc().