Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:59

0001 
0002 // This will return the ParameterSetID of the parameter set
0003 // defined in the python file or configuration string.
0004 // Warning, this may not be the same as the ParameterSetID
0005 // of a cmsRun process, because validation code may insert
0006 // additional parameters into the configuration.
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 
0012 #include <memory>
0013 
0014 #include <iostream>
0015 #include <string>
0016 
0017 int main(int argc, char** argv) try {
0018   // config can either be a name or a string
0019   std::string config;
0020   std::vector<std::string> pythonArgs;
0021 
0022   if (argc == 1) {
0023     // Read input from cin into configstring..
0024     std::string line;
0025     while (std::getline(std::cin, line)) {
0026       config += line;
0027       config += '\n';
0028     }
0029   } else {
0030     config = std::string(argv[1]);
0031     pythonArgs.reserve(argc - 1);
0032     for (int iarg = 1; iarg < argc; ++iarg) {
0033       pythonArgs.push_back(argv[iarg]);
0034     }
0035   }
0036 
0037   std::shared_ptr<edm::ParameterSet> parameterSet = edm::readConfig(config, pythonArgs);
0038   parameterSet->registerIt();
0039   std::cout << parameterSet->id() << std::endl;
0040   return 0;
0041 } catch (cms::Exception const& e) {
0042   std::cout << e.explainSelf() << std::endl;
0043   return 1;
0044 } catch (std::exception const& e) {
0045   std::cout << e.what() << std::endl;
0046   return 1;
0047 }