ATLAS Offline Software
Classes | Functions | Variables
SuperChicUtils Namespace Reference

Classes

class  SuperChicConfig
 

Functions

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

Variables

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

Function Documentation

◆ run_command()

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

Definition at line 309 of file SuperChicUtils.py.

309 def run_command(command, stdin = None):
310  """
311  Run a command and print output continuously
312  """
313  process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stdin=stdin)
314  while True:
315  output = process.stdout.readline().decode("utf-8")
316  if output == '' and process.poll() is not None:
317  break
318  if output:
319  # remove ANSI escape formatting characters
320  reaesc = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
321  text = reaesc.sub('', output.strip())
322  logger.info(text)
323 
324  rc = process.poll()
325  return rc
326 
327 

◆ SuperChicExecute()

def SuperChicUtils.SuperChicExecute (   Init)

Definition at line 368 of file SuperChicUtils.py.

368 def SuperChicExecute(Init):
369 
370  logger.info("Starting SuperChic Itself")
371  os.makedirs('inputs', exist_ok=True)
372  os.makedirs('evrecs', exist_ok=True)
373  os.makedirs('outputs', exist_ok=True)
374 
375  try:
376  inputDAT = open('input.DAT')
377  except IOError:
378  raise Exception ("problem with IO; potentially input.DAT not created correctly")
379  else:
380 
381  try:
382  rc = run_command(Init.superchicpath+'/bin/superchic', stdin=inputDAT)
383 
384  except OSError:
385  raise Exception("Superchic executable or file not found")
386 
387  except Exception:
388  raise Exception("Non-OSError or IOError in Superchic execution block")
389 
390  if rc:
391  raise Exception('Unexpected error in superchic execution')
392 
393  return
394 
395 
396 

◆ SuperChicInitialize()

def SuperChicUtils.SuperChicInitialize (   Init,
  stdin = None 
)

Definition at line 328 of file SuperChicUtils.py.

328 def SuperChicInitialize(Init, stdin=None):
329 
330  logger.info("Starting SuperChic Initialization")
331 
332  os.makedirs('inputs', exist_ok=True)
333  os.makedirs('evrecs', exist_ok=True)
334  os.makedirs('outputs', exist_ok=True)
335  if not os.path.exists("param_card.dat"):
336  if os.path.exists(Init.superchicpath+"/share/doc/SuperChic/Cards/param_card.dat"):
337  shutil.copyfile(Init.superchicpath+"/share/doc/SuperChic/Cards/param_card.dat","param_card.dat")
338  else:
339  raise Exception('Unexpected error in superchic init execution: probably absent param_card.dat')
340  if not os.path.exists("ident_card.dat"):
341  if os.path.exists(Init.superchicpath+"/share/doc/SuperChic/Cards/ident_card.dat"):
342  shutil.copyfile(Init.superchicpath+"/share/doc/SuperChic/Cards/ident_card.dat","ident_card.dat")
343  else:
344  raise Exception('Unexpected error in superchic init execution: probably absent ident_card.dat')
345 
346  try:
347  inputDAT = open('input.DAT')
348 
349  except IOError:
350  raise Exception("problem with file IO; potentially input.DAT not created correctly")
351  else:
352 
353  try:
354  rc = run_command(Init.superchicpath+"/bin/init", inputDAT)
355 
356  except OSError:
357  raise Exception("init executable or file not found")
358 
359  except Exception:
360  raise Exception("Non-OSError or IOError in init execution block")
361 
362  if rc:
363  raise Exception('Unexpected error in superchic init execution')
364 
365  return
366 
367 

◆ SuperChicRun()

def SuperChicUtils.SuperChicRun (   Init,
  genSeq 
)

Definition at line 397 of file SuperChicUtils.py.

397 def SuperChicRun(Init, genSeq):
398 
399  # dump the job configuration for fortran code
400  print(Init.toFortran())
401 
402  # attach config to genSequence for later usin in showering
403  genSeq.SuperChicConfig = Init
404 
405  writeInputDAT(Init)
406  SuperChicInitialize(Init)
407  SuperChicExecute(Init)
408 
409  return

◆ writeInputDAT()

def SuperChicUtils.writeInputDAT (   Init)

Definition at line 301 of file SuperChicUtils.py.

301 def writeInputDAT(Init):
302 
303  with open("input.DAT", "w") as outF:
304  outF.write(Init.toFortran())
305 
306  return
307 
308 

Variable Documentation

◆ logger

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

Get handle to Athena logging.

Definition at line 9 of file SuperChicUtils.py.

AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
SuperChicUtils.writeInputDAT
def writeInputDAT(Init)
Definition: SuperChicUtils.py:301
SuperChicUtils.SuperChicInitialize
def SuperChicInitialize(Init, stdin=None)
Definition: SuperChicUtils.py:328
SuperChicUtils.SuperChicRun
def SuperChicRun(Init, genSeq)
Definition: SuperChicUtils.py:397
SuperChicUtils.SuperChicExecute
def SuperChicExecute(Init)
Definition: SuperChicUtils.py:368
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::open
@ open
Definition: BinningType.h:40
SuperChicUtils.run_command
def run_command(command, stdin=None)
Definition: SuperChicUtils.py:309