10 #include "boost/filesystem.hpp"
11 #include "boost/filesystem/path.hpp"
33 if (ps.
exists(
"useEvtGenPlugin")) {
35 string evtgenpath(std::getenv(
"EVTGENDATA"));
39 if (ps.
exists(
"evtgenDecFile")) {
44 if (ps.
exists(
"evtgenPdlFile")) {
49 if (ps.
exists(
"evtgenUserFile")) {
50 std::vector<std::string> user_decays = ps.
getParameter<std::vector<std::string> >(
"evtgenUserFile");
51 for (
unsigned int i = 0;
i < user_decays.size();
i++) {
58 if (ps.
exists(
"evtgenUserFileEmbedded")) {
59 std::vector<std::string> user_decay_lines =
60 ps.
getParameter<std::vector<std::string> >(
"evtgenUserFileEmbedded");
61 auto tmp_dir = boost::filesystem::temp_directory_path();
62 tmp_dir +=
"/%%%%-%%%%-%%%%-%%%%";
63 auto tmp_path = boost::filesystem::unique_path(tmp_dir);
65 FILE* tmpf = std::fopen(user_decay_tmp.c_str(),
"w");
68 <<
"Py8InterfaceBase::Py8InterfaceBase fails when trying to open a temporary file for embedded user.dec "
69 "for EvtGenPlugin. Terminating program ";
72 for (
unsigned int i = 0;
i < user_decay_lines.size();
i++) {
73 user_decay_lines.at(
i) +=
"\n";
74 std::fputs(user_decay_lines.at(
i).c_str(), tmpf);
85 fDecayer = std::make_unique<Pythia>();
88 fMasterGen->settings.addFlag(
"BiasedTauDecayer:filter",
false);
89 fMasterGen->settings.addFlag(
"BiasedTauDecayer:eDecays",
true);
90 fMasterGen->settings.addFlag(
"BiasedTauDecayer:muDecays",
true);
93 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:filter",
false);
94 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:exclusive",
false);
95 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:eMuAsEquivalent",
false);
96 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:eMuTauAsEquivalent",
false);
97 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:allNuAsEquivalent",
false);
98 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:udscAsEquivalent",
false);
99 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:udscbAsEquivalent",
false);
100 fMasterGen->settings.addFlag(
"ResonanceDecayFilter:wzAsEquivalent",
false);
101 fMasterGen->settings.addMVec(
"ResonanceDecayFilter:mothers", std::vector<int>(),
false,
false, 0, 0);
102 fMasterGen->settings.addMVec(
"ResonanceDecayFilter:daughters", std::vector<int>(),
false,
false, 0, 0);
105 fMasterGen->settings.addFlag(
"PTFilter:filter",
false);
106 fMasterGen->settings.addMode(
"PTFilter:quarkToFilter", 5,
true,
true, 3, 6);
107 fMasterGen->settings.addParm(
"PTFilter:scaleToFilter", 0.4,
true,
true, 0.0, 10.);
108 fMasterGen->settings.addParm(
"PTFilter:quarkRapidity", 10.0,
true,
true, 0.0, 10.);
109 fMasterGen->settings.addParm(
"PTFilter:quarkPt", -.1,
true,
true, -.1, 100.);
112 fMasterGen->settings.addFlag(
"POWHEGres:calcScales",
false);
113 fMasterGen->settings.addFlag(
"POWHEG:bb4l",
false);
114 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:onlyDistance1",
false);
115 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:veto",
false);
116 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:dryRun",
false);
117 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:vetoAtPL",
false);
118 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:vetoQED",
false);
119 fMasterGen->settings.addFlag(
"POWHEG:bb4l:PartonLevel:veto",
false);
120 fMasterGen->settings.addFlag(
"POWHEG:bb4l:PartonLevel:excludeFSRConflicting",
false);
121 fMasterGen->settings.addFlag(
"POWHEG:bb4l:DEBUG",
false);
122 fMasterGen->settings.addFlag(
"POWHEG:bb4l:ScaleResonance:veto",
false);
123 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:vetoDipoleFrame",
false);
124 fMasterGen->settings.addFlag(
"POWHEG:bb4l:FSREmission:pTpythiaVeto",
false);
125 fMasterGen->settings.addParm(
"POWHEG:bb4l:pTminVeto", 10.0,
true,
true, 0.0, 10.);
130 fMasterGen->readString(
"Next:numberShowEvent = 0");
131 fDecayer->readString(
"Next:numberShowEvent = 0");
135 std::vector<edm::ParameterSet> randomizedParameters =
137 currentParameters = randomizedParameters[
randomIndex()];
145 if (
line->find(
"Random:") != std::string::npos)
146 throw cms::Exception(
"PythiaError") <<
"Attempted to set random number "
147 "using Pythia commands. Please use "
148 "the RandomNumberGeneratorService."
152 throw cms::Exception(
"PythiaError") <<
"Pythia 8 did not accept \"" << *
line <<
"\"." << std::endl;
154 if (
line->find(
"ParticleDecays:") != std::string::npos) {
156 throw cms::Exception(
"PythiaError") <<
"Pythia 8 Decayer did not accept \"" << *
line <<
"\"." << std::endl;
162 if (currentParameters.
exists(
"SLHAFileForPythia8")) {
166 fMasterGen->settings.mode(
"SLHA:readFrom", 2);
168 }
else if (currentParameters.
exists(
"SLHATableForPythia8")) {
172 }
else if (currentParameters.
exists(
"SLHATreeForPythia8")) {
174 std::unique_ptr<SLHAReaderBase>
reader =
184 char tempslhaname[] =
"pythia8SLHAtableXXXXXX";
185 int fd = mkstemp(tempslhaname);
186 write(
fd, slhatable.c_str(), slhatable.size());
191 fMasterGen->settings.mode(
"SLHA:readFrom", 2);
196 for (
size_t i = 0;
i <
pdgIds.size();
i++) {
204 std::ostringstream pyCard;
205 pyCard << PyID <<
":mayDecay=false";
207 if (
fMasterGen->particleData.isParticle(PyID)) {
211 <<
"recognize particle id = " << PyID << std::endl;
223 for (
unsigned int iss = 0; iss < settings.size(); iss++) {
224 if (settings[iss].
find(
"QED-brem-off") != std::string::npos) {
225 fMasterGen->readString(
"TimeShower:QEDshowerByL=off");
227 size_t fnd1 = settings[iss].find(
"Pythia8:");
228 if (fnd1 != std::string::npos) {