gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
collider_harvester Namespace Reference

Functions

def main (argv)
 

Variables

string toolsfile = "./Utils/scripts/harvesting_tools.py"
 

Function Documentation

◆ main()

def collider_harvester.main (   argv)

Definition at line 30 of file collider_harvester.py.

References Gambit::ColliderBit.print(), and harvesting_tools.retrieve_generic_headers().

30 def main(argv):
31 
32  model_headers=set([])
33  ignore_model_headers=["SUSY.hpp", "SUSY_extras.hpp"]
34 
35  # Handle command line options
36  verbose = False
37  try:
38  opts, args = getopt.getopt(argv,"vx:",["verbose","exclude-models="])
39  except getopt.GetoptError:
40  print('Usage: collider_harvestor.py [flags]')
41  print(' flags:')
42  print(' -v : More verbose output')
43  sys.exit(2)
44  for opt, arg in opts:
45  if opt in ('-v','--verbose'):
46  verbose = True
47  print('collider_harvester.py: verbose=True')
48 
49  # Get list of models to include in ColliderBit_model_rollcall.hpp
50  model_headers.update(retrieve_generic_headers(verbose,"./ColliderBit/include/gambit/ColliderBit/models","model", set()))
51 
52  if verbose:
53  print("ColliderBit model headers identified:")
54  for h in model_headers:
55  print(' gambit/ColliderBit/models/'+h)
56 
57  # Generate a C++ header containing all the model headers we have just harvested.
58  towrite = "\
59 // GAMBIT: Global and Modular BSM Inference Tool\n\
60 // *********************************************\n\
61 /// \\file \n\
62 /// \n\
63 /// Rollcall header for ColliderBit models. \n\
64 /// \n\
65 /// This file is automatically generated by \n\
66 /// collider_harvester.py. Do not modify. \n\
67 /// \n\
68 /// *********************************************\n\
69 /// \n\
70 /// \\author The GAMBIT Collaboration \n\
71 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
72 /// \n\
73 /// *********************************************\n\
74  \n\
75 #pragma once \n\
76  \n"
77 
78  for h in model_headers:
79  towrite+='#include \"gambit/ColliderBit/models/{0}\"\n'.format(h)
80 
81  with open("./ColliderBit/include/gambit/ColliderBit/ColliderBit_models_rollcall.hpp","w") as f:
82  f.write(towrite)
83 
84  # Generate a C++ header containing Py8Collider typedefs for all the model headers we have just harvested.
85  towrite = "\
86 // GAMBIT: Global and Modular BSM Inference Tool\n\
87 // *********************************************\n\
88 /// \\file \n\
89 /// \n\
90 /// Py8Collider typedefs for models in \n\
91 /// ColliderBit. \n\
92 /// \n\
93 /// This file is automatically generated by \n\
94 /// collider_harvester.py. Do not modify. \n\
95 /// \n\
96 /// *********************************************\n\
97 /// \n\
98 /// \\author The GAMBIT Collaboration \n\
99 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
100 /// \n\
101 /// *********************************************\n\
102  \n\
103 #pragma once \n\
104  \n\
105 #include \"gambit/ColliderBit/colliders/Pythia8/Py8Collider.hpp\"\n\
106  \n\
107 namespace Gambit \n\
108 { \n\
109  namespace ColliderBit \n\
110  { \n\
111  \n\
112  /// Typedefs for each Pythia collider \n\
113  /// @{ \n\
114  #ifdef EXCLUDE_HEPMC \n\
115  typedef Py8Collider<Pythia_default::Pythia8::Pythia, Pythia_default::Pythia8::Event, void> Py8Collider_defaultversion;\n"
116 
117  for h in model_headers:
118  if h not in ignore_model_headers:
119  m = re.sub(".hpp", "", h)
120  towrite+=' typedef Py8Collider<Pythia_{0}_default::Pythia8::Pythia, Pythia_{0}_default::Pythia8::Event, void> Py8Collider_{0}_defaultversion;\n'.format(m)
121 
122  towrite+= "\
123  #else \n\
124  typedef Py8Collider<Pythia_default::Pythia8::Pythia, Pythia_default::Pythia8::Event, Pythia_default::Pythia8::GAMBIT_hepmc_writer> Py8Collider_defaultversion;\n"
125 
126  for h in model_headers:
127  if h not in ignore_model_headers:
128  m = re.sub(".hpp", "", h)
129  towrite+=' typedef Py8Collider<Pythia_{0}_default::Pythia8::Pythia, Pythia_{0}_default::Pythia8::Event, Pythia_{0}_default::Pythia8::GAMBIT_hepmc_writer> Py8Collider_{0}_defaultversion;\n'.format(m)
130 
131  towrite+=" #endif\n /// @}\n\n }\n}\n"
132 
133  with open("./ColliderBit/include/gambit/ColliderBit/colliders/Pythia8/Py8Collider_typedefs.hpp","w") as f:
134  f.write(towrite)
135 
136  if verbose:
137  print("\nGenerated ColliderBit_models_rollcall.hpp.")
138  print("Generated Py8Collider_typedefs.hpp.\n")
139 
140 # Handle command line arguments (verbosity)
void print(MixMatrix A)
Helper function to print a matrix.
def retrieve_generic_headers(verbose, starting_dir, kind, excludes, exclude_list=[])
Here is the call graph for this function:

Variable Documentation

◆ toolsfile

string collider_harvester.toolsfile = "./Utils/scripts/harvesting_tools.py"

Definition at line 27 of file collider_harvester.py.