13 if (ps.
exists(
"RandomizedParameters")) {
14 std::vector<edm::ParameterSet> randomizedParameters =
15 ps.
getParameter<std::vector<edm::ParameterSet> >(
"RandomizedParameters");
19 for (
unsigned int irand = 0; irand < randomizedParameters.size(); ++irand) {
20 randomInitWeights_[irand] = randomizedParameters[irand].getParameter<
double>(
"ConfigWeight");
21 if (randomizedParameters[irand].exists(
"ConfigDescription")) {
23 randomizedParameters[irand].getParameter<
std::string>(
"ConfigDescription");
25 if (randomizedParameters[irand].exists(
"GridpackPath")) {
30 if (ps.
exists(
"GridpackPath")) {
41 auto genLumiInfoHeader = std::make_unique<GenLumiInfoHeader>();
49 return genLumiInfoHeader;
58 std::vector<long unsigned int>
seeds = rengine->put();
59 seeds.push_back(lumi.
id().
run());
61 std::seed_seq seedseq(seeds.begin(), seeds.end());
62 std::mt19937 randgen(seedseq);
70 CLHEP::HepRandomEngine* rengine,
78 std::vector<long unsigned int>
seeds = rengine->put();
79 seeds.push_back(lumi.
id().
run());
81 std::seed_seq seedseq(seeds.begin(), seeds.end());
82 std::array<unsigned int, 1> lheseed;
83 seedseq.generate(lheseed.begin(), lheseed.end());
85 constexpr
unsigned int maxseed = 30081 * 30081;
86 unsigned int seedval = lheseed[0] % (maxseed + 1);
90 ->getParameter<edm::ParameterSet>(
"@main_input")
91 .getUntrackedParameter<
unsigned int>(
"numberEventsInLuminosityBlock");
93 std::ostringstream nevStream;
96 std::ostringstream randomStream;
97 randomStream << seedval;
102 std::array<std::string, 5> argStrs;
105 argStrs[2] = nevStream.str();
106 argStrs[3] = randomStream.str();
107 argStrs[4] = std::to_string(ncpu);
108 std::array<char*, 6>
args{
109 {&argStrs[0][0], &argStrs[1][0], &argStrs[2][0], &argStrs[3][0], &argStrs[4][0],
nullptr}};
115 throw cms::Exception(
"BaseHadronizer::generateLHE") <<
"Unable to fork a child";
116 }
else if (pid == 0) {
123 waitpid(pid, &status, 0);
125 throw cms::Exception(
"BaseHadronizer::generateLHE") <<
"Failed to execute script";
128 FILE* lhef = std::fopen(outfilename,
"r");
130 throw cms::Exception(
"BaseHadronizer::generateLHE") <<
"Output file " << outfilename <<
" not found.";
const_reverse_iterator rbegin() const
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > randomInitWeights_
void generateLHE(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
void setFilterEfficiency(double effic)
BaseHadronizer(edm::ParameterSet const &ps)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void randomizeIndex(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
GenRunInfoProduct & runInfo()
ProcessHistory const & processHistory() const
const std::string & randomInitConfigDescription() const
bool getMapped(key_type const &k, value_type &result) const
std::vector< std::string > gridpackPaths_
std::vector< std::string > randomInitConfigDescriptions_
virtual std::unique_ptr< GenLumiInfoHeader > getGenLumiInfoHeader() const
T getParameter(std::string const &) const
LuminosityBlockNumber_t luminosityBlock() const
const std::string & gridpackPath() const
std::string fullPath() const
void setExternalXSecNLO(const XSec &xsec)
void setExternalXSecLO(const XSec &xsec)
static const std::vector< std::string > theSharedResources
static Registry * instance()