42 #define DEBUG_PREFIX "DEBUG: OMP thread " << omp_get_thread_num() << ": " 51 template<
typename PythiaT,
typename EventT,
typename hepmc_writerT>
55 const str model_suffix,
60 static bool first =
true;
61 static str pythia_doc_path;
62 static double xsec_veto_fb;
69 const str be =
"Pythia" + model_suffix;
70 const str ver = Backends::backendInfo().default_version(be);
71 pythia_doc_path = Backends::backendInfo().path_dir(be, ver) +
"/../share/Pythia8/xmldoc/";
72 result.
banner(pythia_doc_path);
92 std::vector<str> pythiaOptions;
95 pythiaOptions.push_back(
"Print:quiet = on");
96 pythiaOptions.push_back(
"SLHA:verbose = 0");
99 const double xsec_veto_default = 0.0;
100 const bool partonOnly_default =
false;
101 const double antiktR_default = 0.4;
106 xsec_veto_fb = colOptions.getValueOrDef<
double>(xsec_veto_default,
"xsec_veto");
107 result.
partonOnly = colOptions.getValueOrDef<
bool>(partonOnly_default,
"partonOnly");
108 result.
antiktR = colOptions.getValueOrDef<
double>(antiktR_default,
"antiktR");
109 if (colOptions.hasKey(
"pythia_settings"))
111 std::vector<str> addPythiaOptions = colNode[
"pythia_settings"].as<std::vector<str> >();
112 pythiaOptions.insert(pythiaOptions.end(), addPythiaOptions.begin(), addPythiaOptions.end());
117 xsec_veto_fb = xsec_veto_default;
119 result.
antiktR = antiktR_default;
123 pythiaOptions.push_back(
"Init:showProcesses = on");
126 pythiaOptions.push_back(
"SLHA:file = slhaea");
129 std::stringstream processLevelOutput;
132 double xsec, totalxsec;
143 pythiaOptions.push_back(
"Random:seed = " + seed);
145 #ifdef COLLIDERBIT_DEBUG 146 cout <<
DEBUG_PREFIX <<
"getPythia"+model_suffix+
": My Pythia seed is: " << seed << endl;
151 result.
init(pythia_doc_path, pythiaOptions, &slha, processLevelOutput);
157 pythiaOptions.push_back(
"Random:seed = " + std::to_string(newSeedBase));
160 result.
init(pythia_doc_path, pythiaOptions, &slha, processLevelOutput);
164 #ifdef COLLIDERBIT_DEBUG 165 cout <<
DEBUG_PREFIX <<
"Py8Collider::InitializationError caught in getPy8Collider. Will discard this point." << endl;
181 std::getline(processLevelOutput, readline);
182 std::istringstream issPtr(readline);
183 issPtr.seekg(47, issPtr.beg);
185 if (!issPtr.good() && nxsec > 0)
break;
186 issPtr >> _junk >> xsec;
194 #ifdef COLLIDERBIT_DEBUG 195 cout <<
DEBUG_PREFIX <<
"totalxsec [fb] = " << totalxsec * 1e12 <<
", veto limit [fb] = " << xsec_veto_fb << endl;
199 if (Utils::isnan(totalxsec))
201 #ifdef COLLIDERBIT_DEBUG 202 cout <<
DEBUG_PREFIX <<
"Got NaN cross-section estimate from Pythia." << endl;
210 if (totalxsec * 1e12 < xsec_veto_fb)
212 #ifdef COLLIDERBIT_DEBUG 213 cout <<
DEBUG_PREFIX <<
"Cross-section veto applies. Will now call Loop::wrapup() to skip event generation for this collider." << endl;
219 EventT dummy_pythia_event;
228 #ifdef COLLIDERBIT_DEBUG 229 cout <<
DEBUG_PREFIX <<
"Failed to generate dummy test event during COLLIDER_INIT_OMP in getPy8Collider. Check the logs for event details." << endl;
231 #pragma omp critical (pythia_event_failure) 233 std::stringstream ss;
234 dummy_pythia_event.list(ss, 1);
235 logger() <<
LogTags::debug <<
"Failed to generate dummy test event during COLLIDER_INIT_OMP iteration in getPy8Collider. Pythia record for the event that failed:\n" << ss.str() <<
EOM;
247 #define GET_SPECTRUM_AND_DECAYS_FOR_PYTHIA_SUSY(NAME, SPECTRUM) \ 248 void NAME(SLHAstruct& result) \ 250 using namespace Pipes::NAME; \ 251 static const int slha_version = runOptions->getValueOrDef<int>(2, "slha_version"); \ 252 static const bool write_summary_to_log = \ 253 runOptions->getValueOrDef<bool>(false, "write_summary_to_log"); \ 255 if ((slha_version != 1) && (slha_version != 2)) \ 257 ColliderBit_error().raise(LOCAL_INFO, \ 258 "The option 'slha_version' must be set to 1 or 2 (default)."); \ 262 result = Dep::decay_rates->getSLHAea(slha_version, false, *Dep::SLHA_pseudonyms); \ 264 SLHAstruct slha_spectrum = Dep::SPECTRUM->getSLHAea(slha_version); \ 265 result.insert(result.begin(), slha_spectrum.begin(), slha_spectrum.end()); \ 267 if(result.find("MODSEL") == result.end()) \ 269 SLHAea::Block block("MODSEL"); \ 270 block.push_back("BLOCK MODSEL # Model selection"); \ 272 line << 1 << 0 << "# Tell Pythia that this is a SUSY model."; \ 273 block.push_back(line); \ 274 result.push_front(block); \ 277 if (write_summary_to_log) \ 279 std::stringstream SLHA_log_output; \ 280 SLHA_log_output << "SLHA" << slha_version << " input to Pythia:\n" << result.str() \ 282 logger() << SLHA_log_output.str() << EOM; \ 288 #define GET_SPECTRUM_AND_DECAYS_FOR_PYTHIA_NONSUSY(NAME, SPECTRUM) \ 289 void NAME(SLHAstruct& result) \ 291 using namespace Pipes::NAME; \ 294 result = Dep::decay_rates->getSLHAea(2); \ 296 SLHAstruct slha_spectrum = Dep::SPECTRUM->getSLHAea(2); \ 297 result.insert(result.begin(), slha_spectrum.begin(), slha_spectrum.end()); \ 303 #define HEPMC_TYPE(PYTHIA_NS) void 305 #define HEPMC_TYPE(PYTHIA_NS) PYTHIA_NS::Pythia8::GAMBIT_hepmc_writer 309 #define GET_SPECIFIC_PYTHIA(NAME, PYTHIA_NS, MODEL_EXTENSION) \ 310 void NAME(Py8Collider<PYTHIA_NS::Pythia8::Pythia, \ 311 PYTHIA_NS::Pythia8::Event, \ 312 HEPMC_TYPE(PYTHIA_NS)> &result) \ 314 using namespace Pipes::NAME; \ 315 static SLHAstruct slha; \ 317 if (*Loop::iteration == BASE_INIT) \ 321 slha = *Dep::SpectrumAndDecaysForPythia; \ 324 getPy8Collider(result, *Dep::RunMC, slha, #MODEL_EXTENSION, \ 325 *Loop::iteration, Loop::wrapup, *runOptions); \ 331 #define GET_SPECIFIC_PYTHIA_SLHA(NAME, PYTHIA_NS, MODEL_EXTENSION) \ 332 void NAME(Py8Collider<PYTHIA_NS::Pythia8::Pythia, \ 333 PYTHIA_NS::Pythia8::Event, \ 334 HEPMC_TYPE(PYTHIA_NS)> &result) \ 336 using namespace Pipes::NAME; \ 337 static SLHAstruct slha; \ 339 if (*Loop::iteration == COLLIDER_INIT) \ 341 const pair_str_SLHAstruct& filename_content_pair = *Dep::SLHAFileNameAndContent; \ 342 if (filename_content_pair.first.empty()) \ 344 piped_invalid_point.request("Got empty SLHA filename. Will invalidate point."); \ 348 getPy8Collider(result, *Dep::RunMC, Dep::SLHAFileNameAndContent->second, \ 349 #MODEL_EXTENSION, *Loop::iteration, Loop::wrapup, *runOptions); \ 354 #define GET_PYTHIA_AS_BASE_COLLIDER(NAME) \ 355 void NAME(const BaseCollider* &result) \ 357 result = &(*Pipes::NAME::Dep::HardScatteringSim); \ void clear()
Reset this instance for reuse, avoiding the need for "new" or "delete".
bool partonOnly
Flag indicating if events from this collider should be processed as parton-only or full events...
void nextEvent(EventT &event) const
Event generation for any Pythia interface to Gambit.
double antiktR
The jet radius used for the anti-kt jet clustering.
void getPy8Collider(Py8Collider< PythiaT, EventT, hepmc_writerT > &result, const MCLoopInfo &RunMC, const SLHAstruct &slha, const str model_suffix, const int iteration, void(*wrapup)(), const Options &runOptions)
Retrieve a Pythia hard-scattering Monte Carlo simulation.
void banner(const std::string pythiaDocPath)
Create a useless Pythia instance just to print the banner.
Piped_invalid_point piped_invalid_point
Global instance of piped invalid point class.
Declarations common to all ColliderBit event loop functions.
bool hasKey(const args &... keys) const
Getters for key/value pairs (which is all the options node should contain)
TYPE getValue(const args &... keys) const
An exception for when Pythia fails to initialize.
void init()
Initialize with no settings (error): override version.
SLHAea::Coll SLHAstruct
Less confusing name for SLHAea container class.
static double draw()
Draw a single uniform random deviate from the interval (0,1) using the chosen RNG engine...
const str & current_collider() const
Get the current collider.
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
std::string str
Shorthand for a standard string.
An exception for when Pythia fails to generate events.
A specializable, recyclable class interfacing ColliderBit and Pythia.
void request(std::string message)
Request an exception.
TODO: see if we can use this one:
A small wrapper object for 'options' nodes.
Container for event loop status data and settings.