gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
getLHEvent.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
16 
17 #include "gambit/cmake/cmake_variables.hpp"
18 
19 #ifndef EXCLUDE_HEPMC
20 
21 using namespace std;
22 
26 
28 #include "HepMC3/LHEF.h"
30 
31 namespace Gambit
32 {
33 
34  namespace ColliderBit
35  {
36 
38  void getLHEvent(HEPUtils::Event& result)
39  {
40  using namespace Pipes::getLHEvent;
41 
42  result.clear();
43 
44  // Get yaml options and initialise the LHEF reader
45  const static double jet_pt_min = runOptions->getValueOrDef<double>(10.0, "jet_pt_min");
46  const static str lhef_filename = runOptions->getValue<str>("lhef_filename");
47  static bool first = true;
48  if (first)
49  {
50  if (not Utils::file_exists(lhef_filename)) throw std::runtime_error("LHE file "+lhef_filename+" not found. Quitting...");
51  first = false;
52  }
53  static LHEF::Reader lhe(lhef_filename);
54 
55  // Don't do anything during special iterations
56  if (*Loop::iteration < 0) return;
57 
58  // Attempt to read the next LHE event as a HEPUtils event. If there are no more events, wrap up the loop and skip the rest of this iteration.
59  bool event_retrieved = true;
60  #pragma omp critical (reading_LHEvent)
61  {
62  if (lhe.readEvent()) get_HEPUtils_event(lhe, result, jet_pt_min);
63  else event_retrieved = false;
64  }
65  if (not event_retrieved)
66  {
67  // Tell the MCLoopInfo instance that we have reached the end of the file
68  Dep::RunMC->report_end_of_event_file();
69  Loop::halt();
70  }
71 
72  }
73 
74  }
75 
76 }
77 
78 #endif
Pragma directives to suppress compiler warnings coming from including HepMC library headers...
void getLHEvent(HEPUtils::Event &result)
A nested function that reads in Les Houches Event files and converts them to HEPUtils::Event format...
Definition: getLHEvent.cpp:38
STL namespace.
Declarations common to all ColliderBit event loop functions.
void get_HEPUtils_event(const LHEF::Reader &, HEPUtils::Event &, double)
Extract an LHE event as a HEPUtils::Event.
General small utility functions.
EXPORT_SYMBOLS bool file_exists(const std::string &filename)
Check if a file exists.
Simple header file for turning compiler warnings back on after having included one of the begin_ignor...
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
TODO: see if we can use this one:
Definition: Analysis.hpp:33