Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:57

0001 #include "FWCore/Framework/interface/getProducerParameterSet.h"
0002 
0003 #include "DataFormats/Provenance/interface/BranchDescription.h"
0004 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0005 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0006 #include "DataFormats/Provenance/interface/ProcessHistory.h"
0007 #include "DataFormats/Provenance/interface/Provenance.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/Registry.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 
0012 #include <string>
0013 
0014 namespace edm {
0015 
0016   ParameterSet const* getProducerParameterSet(Provenance const& provenance, ProcessHistory const& processHistory) {
0017     const std::shared_ptr<BranchDescription const>& branchDescription = provenance.constBranchDescriptionPtr();
0018 
0019     if (branchDescription) {
0020       std::string const& process = branchDescription->processName();
0021       std::string const& label = branchDescription->moduleLabel();
0022 
0023       for (ProcessConfiguration const& pc : processHistory) {
0024         if (pc.processName() == process) {
0025           ParameterSetID const& psetID = pc.parameterSetID();
0026           pset::Registry const* psetRegistry = pset::Registry::instance();
0027           ParameterSet const* processPset = psetRegistry->getMapped(psetID);
0028           if (processPset) {
0029             return &processPset->getParameterSet(label);
0030           }
0031         }
0032       }
0033     }
0034     // This should never happen
0035     throw cms::Exception("LogicError") << "getProducerParameterSet failed";
0036     return nullptr;
0037   }
0038 }  // namespace edm