|
ATLAS Offline Software
|
|
def | get_cross_section (run_name, integration_jobs=1) |
| Calculate the total cross section from the integration log files. More...
|
|
def | get_repeated_pattern (pattern, repetitions) |
| Return a string made up of a certain number of repetitions of the same pattern. More...
|
|
def | get_size (path) |
| Get size of file or folder. More...
|
|
def | humanize_bytes (bytes, precision=2) |
| Convert file/folder size from bytes to units with appropriate prefixes (multiples of 1000, not 1024!) More...
|
|
def | ansi_format (text, colour='None', background_colour='None', bold=False, underline=False, italics=False, marked=False, strikethrough=False) |
| Format and colorize terminal output. More...
|
|
def | ansi_format_ok (text) |
| Green colouring. More...
|
|
def | ansi_format_info (text) |
| Blue colouring. More...
|
|
def | ansi_format_warning (text) |
| Yellow colouring. More...
|
|
def | ansi_format_error (text) |
| Red colouring. More...
|
|
◆ ansi_format()
def Herwig7Utils.ansi_format |
( |
|
text, |
|
|
|
colour = 'None' , |
|
|
|
background_colour = 'None' , |
|
|
|
bold = False , |
|
|
|
underline = False , |
|
|
|
italics = False , |
|
|
|
marked = False , |
|
|
|
strikethrough = False |
|
) |
| |
Format and colorize terminal output.
Definition at line 206 of file Herwig7Utils.py.
206 def ansi_format(text, colour='None', background_colour='None',
207 bold=False, underline=False, italics=False, marked=False, strikethrough=False):
209 format_none =
'\033[0m'
210 format_bold =
'\033[1m'
211 format_underline =
'\033[4m'
212 format_italics =
'\033[3m'
213 format_marked =
'\033[7m'
214 format_strikethrough =
'\033[9m'
220 'Red':
'\033[91m',
'DarkRed':
'\033[31m',
221 'Green':
'\033[92m',
'DarkGreen':
'\033[32m',
222 'Yellow':
'\033[93m',
'Orange':
'\033[33m',
223 'Blue':
'\033[94m',
'DarkBlue':
'\033[34m',
224 'Pink':
'\033[95m',
'DarkPink':
'\033[35m',
225 'Cyan':
'\033[96m',
'DarkCyan':
'\033[36m',
226 'White':
'\033[97m',
'LightGrey':
'\033[37m',
229 background_colours = {
234 'Orange':
'\033[43m',
241 if colour
in colours:
242 if background_colour
in background_colours:
245 + background_colours[background_colour]
246 + (format_bold
if bold
else '')
247 + (format_underline
if underline
else '')
248 + (format_italics
if italics
else '')
249 + (format_marked
if marked
else '')
250 + (format_strikethrough
if strikethrough
else '')
251 + text + format_none)
253 raise Exception(
"Could not find background colour '{}'.".
format(background_colour))
255 raise Exception(
"Could not find colour '{}'.".
format(colour))
◆ ansi_format_error()
def Herwig7Utils.ansi_format_error |
( |
|
text | ) |
|
◆ ansi_format_info()
def Herwig7Utils.ansi_format_info |
( |
|
text | ) |
|
◆ ansi_format_ok()
def Herwig7Utils.ansi_format_ok |
( |
|
text | ) |
|
◆ ansi_format_warning()
def Herwig7Utils.ansi_format_warning |
( |
|
text | ) |
|
◆ get_cross_section()
def Herwig7Utils.get_cross_section |
( |
|
run_name, |
|
|
|
integration_jobs = 1 |
|
) |
| |
Calculate the total cross section from the integration log files.
Definition at line 107 of file Herwig7Utils.py.
109 athMsgLog.info(
"Calculating cross section after integration")
110 logfiles = [run_name+
'.integrate'+
str(integration_job)+
'.log' for integration_job
in range(integration_jobs)]
115 for logfile
in logfiles:
117 athMsgLog.info(
"- %s", logfile)
120 with open(logfile,
'r')
as log: data = log.read().strip()
122 with open(logfile,
'r')
as log:
126 if 'Integrate ' in line:
127 n_subprocs =
int(line.split(
'of')[1].
replace(
':',
''))
128 athMsgLog.info(
" found %s subprocesses", n_subprocs)
131 data = data.split(
"Integrate ")[1:]
133 for s, subproc
in enumerate(data, start=1):
136 for line
in subproc.split(
"\n"):
137 if 'integrated ( ' in line:
138 _xsec =
float(line.split()[2])
139 _err =
float(line.split()[4])
140 athMsgLog.info(
" - subprocess %s: xsec = %s +/- %s nb", s, _xsec, _err)
146 if err / xsec > integration_grids_precision_threshold:
147 threshold =
'{}%'.
format(integration_grids_precision_threshold*100.0)
148 if run_name ==
"Herwig_DEBUG":
149 athMsgLog.warn(
ansi_format_warning(
'! The integration grids only have a low precision (worse than {}): xsec = {} +/- {} nb (accuracy: {:.3f}%)'.
format(threshold, xsec, err, err/xsec*100.0)))
151 athMsgLog.error(
ansi_format_error(
'! The integration grids only have a low precision (worse than {}): xsec = {} +/- {} nb (accuracy: {:.3f}%)'.
format(threshold, xsec, err, err/xsec*100.0)))
152 athMsgLog.warn(
ansi_format_warning(
'! In order to speed up the event generation you should consider improving the statistics of the integration / phase space sampling stage (see the sampler_commands() function).'))
154 athMsgLog.info(
ansi_format_info(
'After integration the estimated cross section was found to be: xsec = {} +/- {} nb (accuracy: {:.3f}%)'.
format(xsec, err, err/xsec*100.0)))
◆ get_repeated_pattern()
def Herwig7Utils.get_repeated_pattern |
( |
|
pattern, |
|
|
|
repetitions |
|
) |
| |
Return a string made up of a certain number of repetitions of the same pattern.
Definition at line 160 of file Herwig7Utils.py.
162 return(pattern.join([
'' for i
in range(repetitions+1)]))
◆ get_size()
def Herwig7Utils.get_size |
( |
|
path | ) |
|
Get size of file or folder.
Definition at line 166 of file Herwig7Utils.py.
170 if os.path.isfile(path):
171 return(os.path.getsize(path))
173 elif os.path.isdir(path):
174 for dirpath, dirs, files
in os.walk(path):
176 file_path = os.path.join(dirpath, file)
178 if os.path.isfile(file_path):
179 size += os.path.getsize(file_path)
◆ humanize_bytes()
def Herwig7Utils.humanize_bytes |
( |
|
bytes, |
|
|
|
precision = 2 |
|
) |
| |
Convert file/folder size from bytes to units with appropriate prefixes (multiples of 1000, not 1024!)
Definition at line 185 of file Herwig7Utils.py.
199 for factor, suffix
in abbrevs:
202 return '%.*f %s' % (precision, bytes / factor, suffix)
◆ athMsgLog
Herwig7Utils.athMsgLog = Logging.logging.getLogger('Herwig7Utils') |
◆ integration_grids_precision_threshold
float Herwig7Utils.integration_grids_precision_threshold = 0.0005 |
std::string replace(std::string s, const std::string &s2, const std::string &s3)
def ansi_format_warning(text)
Yellow colouring.
def get_repeated_pattern(pattern, repetitions)
Return a string made up of a certain number of repetitions of the same pattern.
def get_size(path)
Get size of file or folder.
def ansi_format_error(text)
Red colouring.
def ansi_format_ok(text)
Green colouring.
def get_cross_section(run_name, integration_jobs=1)
Calculate the total cross section from the integration log files.
def humanize_bytes(bytes, precision=2)
Convert file/folder size from bytes to units with appropriate prefixes (multiples of 1000,...
def ansi_format(text, colour='None', background_colour='None', bold=False, underline=False, italics=False, marked=False, strikethrough=False)
Format and colorize terminal output.
def ansi_format_info(text)
Blue colouring.