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 324 of file SuperChicUtils.py.

324def run_command(command, stdin = None):
325 """
326 Run a command and print output continuously
327 """
328 process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stdin=stdin)
329 while True:
330 output = process.stdout.readline().decode("utf-8")
331 if output == '' and process.poll() is not None:
332 break
333 if output:
334 # remove ANSI escape formatting characters
335 reaesc = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
336 text = reaesc.sub('', output.strip())
337 logger.info(text)
338
339 rc = process.poll()
340 return rc
341
342

◆ SuperChicExecute()

SuperChicUtils.SuperChicExecute ( Init)

Definition at line 383 of file SuperChicUtils.py.

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

◆ SuperChicInitialize()

SuperChicUtils.SuperChicInitialize ( Init,
stdin = None )

Definition at line 343 of file SuperChicUtils.py.

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

◆ SuperChicRun()

SuperChicUtils.SuperChicRun ( Init,
genSeq )

Definition at line 412 of file SuperChicUtils.py.

412def SuperChicRun(Init, genSeq):
413
414 # dump the job configuration for fortran code
415 print(Init.toFortran())
416
417 # attach config to genSequence for later usin in showering
418 genSeq.SuperChicConfig = Init
419
420 writeInputDAT(Init)
421 SuperChicInitialize(Init)
422 SuperChicExecute(Init)
423
424 return
void print(char *figname, TCanvas *c1)

◆ writeInputDAT()

SuperChicUtils.writeInputDAT ( Init)

Definition at line 316 of file SuperChicUtils.py.

316def writeInputDAT(Init):
317
318 with open("input.DAT", "w") as outF:
319 outF.write(Init.toFortran())
320
321 return
322
323

Variable Documentation

◆ logger

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

Get handle to Athena logging.

Definition at line 10 of file SuperChicUtils.py.