ATLAS Offline Software
Functions
ForwardRegionPropertiesConfig Namespace Reference

Functions

def resolveTwissBeamFilePath (twiss_beam, msg)
 
def buildTwissFilePath (flags, msg, filename, twiss_path=None)
 
def ForwardRegionPropertiesCfg (flags, name="ForwardRegionProperties", **kwargs)
 

Function Documentation

◆ buildTwissFilePath()

def ForwardRegionPropertiesConfig.buildTwissFilePath (   flags,
  msg,
  filename,
  twiss_path = None 
)

Definition at line 23 of file ForwardRegionPropertiesConfig.py.

23 def buildTwissFilePath(flags, msg, filename, twiss_path=None):
24  twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001) # flags.Sim.TwissEnergy possibly obsolete?
25  twiss_beta = '%07.2fm'%(0.001*flags.Sim.TwissFileBeta) # assumes flags.Sim.TwissFileBeta is in mm
26  if not (flags.Sim.TwissFileNomReal and flags.Sim.TwissFileVersion):
27  msg.error(f"buildTwissFilePath: Need to either provide file names or set file name (currently {filename}) and file version flags (currently flags.Sim.TwissFileNomReal = {flags.Sim.TwissFileNomReal} and flags.Sim.TwissFileVersion = {flags.Sim.TwissFileVersion}.")
28  raise Exception('Not enough information to locate Twiss files. Need to either provide file names or set file name and file version flags.')
29  twiss_nomreal = flags.Sim.TwissFileNomReal
30  twiss_version = flags.Sim.TwissFileVersion
31  import os
32  if not twiss_path:
33  twiss_path = os.getenv('TwissFilesPATH')
34  if not twiss_path:
35  msg.warning("buildTwissFilePath: TwissFilesPATH environment variable is empty.")
36  twiss_beam = os.path.join(twiss_path, twiss_energy, twiss_beta, twiss_nomreal, twiss_version, filename)
37  if not os.access(twiss_beam,os.R_OK):
38  raise Exception(f'Failed to find {filename} at {twiss_beam}')
39  return twiss_beam
40 
41 
42 # NB Reconstruction jobs seem to use the default version of the tool,
43 # so maintain that behaviour for now.
44 @AccumulatorCache

◆ ForwardRegionPropertiesCfg()

def ForwardRegionPropertiesConfig.ForwardRegionPropertiesCfg (   flags,
  name = "ForwardRegionProperties",
**  kwargs 
)

Definition at line 45 of file ForwardRegionPropertiesConfig.py.

45 def ForwardRegionPropertiesCfg(flags, name="ForwardRegionProperties", **kwargs):
46  from AthenaCommon.Logging import logging
47  msg = logging.getLogger("ForwardRegionPropertiesCfg")
48  result = ComponentAccumulator()
49  # Settings of optics to be used
50  twiss_beam1 = resolveTwissBeamFilePath(flags.Sim.TwissFileBeam1, msg)
51  twiss_beam2 = resolveTwissBeamFilePath(flags.Sim.TwissFileBeam2, msg)
52  twiss_momentum = -1.
53  if twiss_beam1 is None or twiss_beam2 is None:
54  msg.info("Attempting to build TwissFileBeam paths manually")
55  # Getting paths to the twiss files, momentum calculation; you can switch to local files
56  twiss_beam1 = buildTwissFilePath(flags, msg, 'beam1.tfs')
57  twiss_beam2 = buildTwissFilePath(flags, msg, 'beam2.tfs')
58  import re,math
59  twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001)
60  twiss_momentum = math.sqrt(float(re.findall("\\d+.\\d+", twiss_energy)[0])**2 - (0.938e-3)**2)*1e3
61  else:
62  # Have to sort out twiss momentum based on file name
63  tmp = twiss_beam1.split('TeV')[0]
64  tmp_spot = len(tmp)
65  if flags.Sim.TwissEnergy:
66  twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001)
67  else:
68  while True:
69  try:
70  tmp_energy = float( tmp[tmp_spot:] ) # noqa: F841
71  tmp_spot -= 1
72  except ValueError:
73  twiss_energy = float( tmp[tmp_spot+1:] )
74  break
75  pass
76  import re,math
77  twiss_momentum = math.sqrt(float(re.findall("\\d+.\\d+", twiss_energy)[0])**2 - (0.938e-3)**2)*1e3
78 
79  # properties of the field set according to the optics settings above
80  kwargs.setdefault("twissFileB1", twiss_beam1)
81  kwargs.setdefault("twissFileB2", twiss_beam2)
82  kwargs.setdefault("momentum", twiss_momentum)
83  result.setPrivateTools(CompFactory.ForwardRegionProperties(name, **kwargs))
84  return result

◆ resolveTwissBeamFilePath()

def ForwardRegionPropertiesConfig.resolveTwissBeamFilePath (   twiss_beam,
  msg 
)

Definition at line 7 of file ForwardRegionPropertiesConfig.py.

7 def resolveTwissBeamFilePath(twiss_beam, msg):
8  import os
9  if not isinstance(twiss_beam, str):
10  return None
11  if os.access(twiss_beam,os.R_OK):
12  return twiss_beam
13  twiss_path = os.getenv('TwissFilesPATH')
14  if not twiss_path:
15  msg.warning("resolveTwissBeamFilePath: TwissFilesPATH environment variable is empty.")
16  twiss_beam_path = twiss_path + '/' + twiss_beam
17  if os.access(twiss_beam_path,os.R_OK):
18  return twiss_beam_path
19  msg.warning(f'resolveTwissBeamFilePath: Could not find twiss beam file at {twiss_beam} or {twiss_beam_path}')
20  return None
21 
22 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
ForwardRegionPropertiesConfig.resolveTwissBeamFilePath
def resolveTwissBeamFilePath(twiss_beam, msg)
Definition: ForwardRegionPropertiesConfig.py:7
ForwardRegionPropertiesConfig.buildTwissFilePath
def buildTwissFilePath(flags, msg, filename, twiss_path=None)
Definition: ForwardRegionPropertiesConfig.py:23
readCCLHist.float
float
Definition: readCCLHist.py:83
ForwardRegionPropertiesConfig.ForwardRegionPropertiesCfg
def ForwardRegionPropertiesCfg(flags, name="ForwardRegionProperties", **kwargs)
Definition: ForwardRegionPropertiesConfig.py:45