ATLAS Offline Software
Loading...
Searching...
No Matches
SuperChicUtils Namespace Reference

Classes

class  SuperChicConfig

Functions

 writeInputDAT (Init)
 run_command (command, stdin=None)
 SuperChicInitialize (Init, stdin=None)
 SuperChicExecute (Init)
 SuperChicRun (Init, genSeq)

Variables

 logger = Logging.logging.getLogger("Superchic_i")
 Get handle to Athena logging.

Function Documentation

◆ run_command()

SuperChicUtils.run_command ( command,
stdin = None )
Run a command and print output continuously

Definition at line 334 of file SuperChicUtils.py.

334def run_command(command, stdin = None):
335 """
336 Run a command and print output continuously
337 """
338 process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stdin=stdin)
339 while True:
340 output = process.stdout.readline().decode("utf-8")
341 if output == '' and process.poll() is not None:
342 break
343 if output:
344 # remove ANSI escape formatting characters
345 reaesc = re.compile(r'(\x9B|\x1B\‍[)[0-?]*[ -\/]*[@-~]')
346 text = reaesc.sub('', output.strip())
347 logger.info(text)
348
349 rc = process.poll()
350 return rc
351
352

◆ SuperChicExecute()

SuperChicUtils.SuperChicExecute ( Init)

Definition at line 393 of file SuperChicUtils.py.

393def SuperChicExecute(Init):
394
395 logger.info("Starting SuperChic Itself")
396 os.makedirs('inputs', exist_ok=True)
397 os.makedirs('evrecs', exist_ok=True)
398 os.makedirs('outputs', exist_ok=True)
399
400 try:
401 inputDAT = open('input.DAT')
402 except IOError:
403 raise Exception ("problem with IO; potentially input.DAT not created correctly")
404 else:
405
406 try:
407 rc = run_command(Init.superchicpath+'/bin/superchic', stdin=inputDAT)
408
409 except OSError:
410 raise Exception("Superchic executable or file not found")
411
412 except Exception:
413 raise Exception("Non-OSError or IOError in Superchic execution block")
414
415 if rc:
416 raise Exception('Unexpected error in superchic execution')
417
418 return
419
420
421

◆ SuperChicInitialize()

SuperChicUtils.SuperChicInitialize ( Init,
stdin = None )

Definition at line 353 of file SuperChicUtils.py.

353def SuperChicInitialize(Init, stdin=None):
354
355 logger.info("Starting SuperChic Initialization")
356
357 os.makedirs('inputs', exist_ok=True)
358 os.makedirs('evrecs', exist_ok=True)
359 os.makedirs('outputs', exist_ok=True)
360 if not os.path.exists("param_card.dat"):
361 if os.path.exists(Init.superchicpath+"/share/doc/SuperChic/Cards/param_card.dat"):
362 shutil.copyfile(Init.superchicpath+"/share/doc/SuperChic/Cards/param_card.dat","param_card.dat")
363 else:
364 raise Exception('Unexpected error in superchic init execution: probably absent param_card.dat')
365 if not os.path.exists("ident_card.dat"):
366 if os.path.exists(Init.superchicpath+"/share/doc/SuperChic/Cards/ident_card.dat"):
367 shutil.copyfile(Init.superchicpath+"/share/doc/SuperChic/Cards/ident_card.dat","ident_card.dat")
368 else:
369 raise Exception('Unexpected error in superchic init execution: probably absent ident_card.dat')
370
371 try:
372 inputDAT = open('input.DAT')
373
374 except IOError:
375 raise Exception("problem with file IO; potentially input.DAT not created correctly")
376 else:
377
378 try:
379 rc = run_command(Init.superchicpath+"/bin/init", inputDAT)
380
381 except OSError:
382 raise Exception("init executable or file not found")
383
384 except Exception:
385 raise Exception("Non-OSError or IOError in init execution block")
386
387 if rc:
388 raise Exception('Unexpected error in superchic init execution')
389
390 return
391
392

◆ SuperChicRun()

SuperChicUtils.SuperChicRun ( Init,
genSeq )

Definition at line 422 of file SuperChicUtils.py.

422def SuperChicRun(Init, genSeq):
423
424 # dump the job configuration for fortran code
425 print(Init.toFortran())
426
427 # attach config to genSequence for later usin in showering
428 genSeq.SuperChicConfig = Init
429
430 writeInputDAT(Init)
431 SuperChicInitialize(Init)
432 SuperChicExecute(Init)
433
434 return
void print(char *figname, TCanvas *c1)

◆ writeInputDAT()

SuperChicUtils.writeInputDAT ( Init)

Definition at line 326 of file SuperChicUtils.py.

326def writeInputDAT(Init):
327
328 with open("input.DAT", "w") as outF:
329 outF.write(Init.toFortran())
330
331 return
332
333

Variable Documentation

◆ logger

SuperChicUtils.logger = Logging.logging.getLogger("Superchic_i")

Get handle to Athena logging.

Definition at line 10 of file SuperChicUtils.py.