ATLAS Offline Software
Classes | Functions | Variables
python.TrigValSteering.Input Namespace Reference

Classes

class  TrigValInput
 

Functions

def load_input_json ()
 
def is_input_defined (keyword)
 
def get_input (keyword)
 

Variables

 input_json
 

Function Documentation

◆ get_input()

def python.TrigValSteering.Input.get_input (   keyword)
Common getter function to retrieve inputs by keyword

Definition at line 96 of file Input.py.

96 def get_input(keyword):
97  '''Common getter function to retrieve inputs by keyword'''
98 
99  log = get_logger()
100 
101  # use rucio dataset for grid jobs, else rely on EOS/cvmfs inputs (TrigValInputs.json)
102  import os
103  paths = os.getenv("ArtInFile",None)
104 
105  if paths:
106  source = "data" if "data" in paths else "mc"
107  format = None
108  for key,value in {'RAW':'BS', 'HITS':'HITS', 'RDO':'RDO', 'ESD':'ESD', 'AOD':'AOD'}.items():
109  if key in paths:
110  format = value
111  break
112  data_object = {"source":source, "format":format, "paths":[paths]}
113  else:
114  data = load_input_json()
115  if keyword not in data.keys():
116  log.error('Failed to find keyword "%s" in input JSON %s',keyword, input_json)
117  return None
118 
119  data_object = data[keyword]
120 
121  # for ART tests running on RAW data:
122  # - build tests use small files on cvmfs
123  # - grid tests running interactively must copy large files from EOS to the local area
124  if data_object["format"] == "BS":
125  grid = False
126  Nfiles = 0
127  import sys
128  with open(sys.argv[0], 'r') as f:
129  for line in f:
130  if "# art-type:" in line:
131  grid = line.split()[2]=="grid"
132  if "# art-input-nfiles:" in line:
133  Nfiles = int(line.split()[2])
134  if grid:
135  data_object["paths"] = [path for path in data_object["paths"] if "/eos/" in path]
136  import subprocess
137  local_files = []
138  for i in range(Nfiles):
139  f = data_object["paths"][i].split('/')[-1]
140  if not (os.path.exists(f)) and not os.environ.get('TRIGVALSTEERING_DRY_RUN'):
141  print(f'copying {data_object["paths"][i]}')
142  result = subprocess.run(['xrdcp',f'root://eosatlas.cern.ch/{data_object["paths"][i]}','.'])
143  if result.returncode != 0:
144  raise Exception("xrdcp failed, please check you have a valid kerberos ticket")
145  local_files.append(f)
146  data_object["paths"] = local_files
147  else:
148  data_object["paths"] = [path for path in data_object["paths"] if "/cvmfs/" in path]
149 
150  result = TrigValInput(
151  keyword,
152  data_object["source"],
153  data_object["format"],
154  data_object["paths"]
155  )
156 
157  if result.is_valid():
158  return result
159  else:
160  log.error('Failed to create a valid input object')
161  return None

◆ is_input_defined()

def python.TrigValSteering.Input.is_input_defined (   keyword)
Checks if the keyword exists in the input json file

Definition at line 90 of file Input.py.

90 def is_input_defined(keyword):
91  '''Checks if the keyword exists in the input json file'''
92  data = load_input_json()
93  return keyword in data
94 
95 

◆ load_input_json()

def python.TrigValSteering.Input.load_input_json ( )
Reads the json file with input definitions and returns the data as dictionary

Definition at line 75 of file Input.py.

75 def load_input_json():
76  '''Reads the json file with input definitions and returns the data as dictionary'''
77 
78  log = get_logger()
79 
80  input_json_fullpath = find_file_in_path(input_json, 'DATAPATH')
81  if not input_json_fullpath:
82  log.error('Failed to determine full path for input JSON %s', input_json)
83  return None
84 
85  log.debug('Reading %s', input_json_fullpath)
86  with open(input_json_fullpath) as data_file:
87  return json.load(data_file)
88 
89 

Variable Documentation

◆ input_json

python.TrigValSteering.Input.input_json

Definition at line 16 of file Input.py.

python.TrigValSteering.Input.get_input
def get_input(keyword)
Definition: Input.py:96
python.TrigValSteering.Common.find_file_in_path
def find_file_in_path(filename, path_env_var)
Definition: Common.py:66
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.TrigValSteering.Input.is_input_defined
def is_input_defined(keyword)
Definition: Input.py:90
python.TrigValSteering.Input.load_input_json
def load_input_json()
Definition: Input.py:75
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.TrigValSteering.Common.get_logger
def get_logger()
Definition: Common.py:33
Trk::split
@ split
Definition: LayerMaterialProperties.h:38