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

Functions

def Suspicious_Points (isStandalone)
 
def main (argv)
 

Variables

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

Function Documentation

◆ main()

def elements_extras.main (   argv)

Definition at line 68 of file elements_extras.py.

References Gambit::ColliderBit.print(), Suspicious_Points(), and harvesting_tools.update_only_if_different().

68 def main(argv):
69 
70  # Handle command line options
71  verbose = False
72  try:
73  opts, args = getopt.getopt(argv,"v:",["verbose"])
74 
75  # Extract flag for standalone
76  target = args[0]
77  isStandalone = 1 if "standalone" in target or "CBS" in target else 0
78 
79  except :
80  print('Usage: elements_extras.py [flags] <isStandalone>')
81  print(' flags:')
82  print(' -v : More verbose output')
83  sys.exit(2)
84 
85  for opt, arg in opts:
86  if opt in ('-v','--verbose'):
87  verbose = True
88  print('elements_extras.py: verbose=True')
89 
90  contents = "\
91 // GAMBIT: Global and Modular BSM Inference Tool\n\
92 // *********************************************\n\
93 /// \\file\n\
94 ///\n\
95 /// Compile-time generation of extra code in Elements\n\
96 /// that uses the Printers. Required to avoid the use\n\
97 /// of printers in the standalones.\n\
98 ///\n\
99 /// Classes added:\n\
100 /// - Suspicious point exception class.\n\
101 ///\n\
102 /// This file was automatically generated by \n\
103 /// elements_extras.py. Do not modify. \n\
104 ///\n\
105 /// *********************************************\n\
106 ///\n\
107 /// Authors:\n\
108 ///\n\
109 /// \\author The GAMBIT Collaboration \n\
110 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
111 ///\n\
112 /// *********************************************\n\
113 \n\
114 #ifndef __elements_extras_hpp__\n\
115 #define __elements_extras_hpp__\n\
116 \n\
117 #include <map>\n\
118 #include <set>\n\
119 #include <string>\n\
120 #include <exception>\n\
121 #include <vector>\n\
122 #include <utility>\n\
123 \n\
124 #include \"gambit/Utils/util_macros.hpp\"\n\
125 #include \"gambit/Logs/log_tags.hpp\"\n\
126 \n"
127 
128  if not isStandalone:
129  contents += "\
130 #include \"gambit/Printers/printermanager.hpp\"\n\
131 #include \"gambit/Printers/baseprinter.hpp\"\n\
132 \n"
133 
134  contents += "\
135 namespace Gambit\n\
136 {\n\
137 \n"
138 
139  # Here add calls for all functions that generate code #
140 
141 
142  # Suspicious points, avoid using the printers when building standalones
143  if verbose: print("Writing suspicious points code")
144  contents += Suspicious_Points(isStandalone)
145 
146  contents += "\
147 }\n\
148 \n\
149 #endif\n"
150 
151 
152  # Don't touch any existing file unless it is actually different from what we will create
153  header = "./Elements/include/gambit/Elements/elements_extras.hpp"
154  candidate = "./scratch/build_time/" + target + ".hpp.candidate"
155  with open(candidate,"w") as f: f.write(contents)
156  update_only_if_different(header, candidate, verbose=False)
157 
158 
void print(MixMatrix A)
Helper function to print a matrix.
def update_only_if_different(existing, candidate, verbose=True)
def Suspicious_Points(isStandalone)
Here is the call graph for this function:

◆ Suspicious_Points()

def elements_extras.Suspicious_Points (   isStandalone)

Definition at line 35 of file elements_extras.py.

Referenced by main().

35 def Suspicious_Points(isStandalone):
36 
37  contents = "\
38  /// Gambit suspicious point exception class.\n\
39  class Suspicious_point_exception\n\
40  {\n\
41 \n\
42  public:\n\
43 \n\
44  /// Constructor\n\
45  Suspicious_point_exception() {}\n\
46 \n\
47  /// Raise the suspicious point exception. Print it with a message and a code. The default code is 1.\n\
48  void raise(const std::string &msg, int code=1, bool debug=false)\n\
49  {\n"
50 
51  if not isStandalone:
52  contents += "\
53  // get the printer pointer\n\
54  Printers::BaseBasePrinter& printer = *(get_global_printer_manager()->printerptr);\n\
55 \n\
56  printer.print(code, \"Suspicious Point Code\", Printers::get_main_param_id(\"Suspicious Point Code\"), printer.getRank(), Printers::get_point_id());\n\
57 \n"
58  contents += "\
59  if (debug) std::cout << \"Point Suspicious (\" << code << \"): \" << msg << std::endl;\n\
60  }\n\
61 \n\
62  };\n\
63 \n"
64 
65  return(contents)
66 
67 # Main function
def Suspicious_Points(isStandalone)
Here is the caller graph for this function:

Variable Documentation

◆ toolsfile

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

Definition at line 31 of file elements_extras.py.