6 @file TileInputFiles.py
7 @brief Python configuration of Tile input files
10 from AthenaCommon.Logging
import logging
11 from subprocess
import check_output
12 from subprocess
import CalledProcessError
17 Function to find input directory with Tile Calorimeter input data files: calibrations, ...
21 project -- data project
22 suffix -- directory suffix
23 skipBadFiles -- skip known bad files
27 log = logging.getLogger(
'TileInputFiles.getInputDirectory' )
33 yr={ 2023:441536, 2022:408681, 2021:387034, 2020:374260,
34 2019:367983, 2018:342531, 2017:314451, 2016:288032, 2015:248505,
35 2014:224307, 2013:216705, 2012:194688, 2011:171194, 2010:142682,
36 2009:99717, 2008:35430, 2007:0}
37 for year,beg
in yr.items():
41 if stream
or project
or suffix:
43 stream =
'physics_Main'
44 log.warning(
'%s is not set up and will be used: %s' ,
'Run stream', stream)
45 elif stream ==
'Tile':
46 stream =
'calibration_Tile'
48 if 'calibration' in stream
and 'Tile' not in stream:
49 project = f
'data{year%100}_calib'
51 project = f
'data{year%100}_13p6TeV'
52 log.warning(
'%s is not set up and will be used: %s' ,
'Data project', project)
53 elif 'data' not in project:
54 project = f
'data{year%100}_{project}'
56 if stream ==
'physics_Main' or stream ==
'physics_MinBias' or stream.startswith(
'calibration'):
60 log.warning(
'%s is not set up and will be used: %s' ,
'Directory suffix', suffix)
63 directory = f
'/eos/atlas/atlastier0/rucio/{project}/{stream}/{run}/{project}.{run}.{stream}.{suffix}'
66 directory = f
'/eos/atlas/atlascerngroupdisk/det-tile/online/{year}/daq'
71 def findFiles(run, path=None, filter='.', stream=None, project=None, suffix=None, year=None, skipBadFiles=True):
73 Function to find Tile Calorimeter input data files: calibrations, ...
76 path -- input directory
77 filter -- data file filter
79 project -- data project
80 suffix -- directory suffix
81 year -- year, data taken in
82 skipBadFiles - skip known bad files
85 log = logging.getLogger(
'TileInputFiles.findFiles' )
91 log.warning(
'There is no input directory')
94 log.info(
'Input directory: %s', path)
96 run=
str(run).zfill(7)
if int(run) > 0
else str(run)
97 if (path.startswith(
'/eos/')):
98 listRunFiles = f
'xrdfs eosatlas ls -l {path} | grep -e {run} | grep -v "#" '
99 listRunFiles += f
'| grep -v -e " [ 0-9][ 0-9][0-9] " | grep {filter} | sed "s|^.*/||" '
102 listRunFiles = f
'ls {path} | grep -e {run} | grep {filter}'
106 files = check_output(listRunFiles, shell =
True).splitlines()
107 except CalledProcessError:
108 log.warning(
'It seems that there are no such directory: %s', path)
112 for badDataFiles
in [
'/afs/cern.ch/user/t/tilebeam/ARR/bad_data_files',
'/afs/cern.ch/user/t/tiledaq/public/bad_data_files']:
114 badFiles +=
open(badDataFiles).
read()
116 log.warning(
'Can not read file with bad data files: %s => It is ignored', badDataFiles)
119 files = [six.ensure_str(f)
for f
in files]
120 for file_name
in (files):
121 good = (file_name
not in badFiles)
123 if (path.startswith(
'/eos/')):
124 fullNames.append(f
'root://eosatlas.cern.ch/{path}/{file_name}')
126 fullNames.append(f
'{path}/{file_name}')
128 log.warning(
'Excluding known bad data file: %s', file_name)
135 Function to find Tile Calorimeter input data files (calibrations, ...) from arguments
137 args -- arguments prepared by argument parser
139 files =
findFiles(run=args.run, path=args.inputDirectory, filter=args.filter, stream=args.stream,
140 project=args.project, suffix=args.suffix, year=args.year, skipBadFiles=args.skipBadFiles)
146 Function to construct and return argument parser
150 parser= argparse.ArgumentParser(
'Script to find Tile Calorimeter input data files: calibrations, ...', **kwargs)
151 files = parser.add_argument_group(
'Tile find input files')
152 files.add_argument(
"-r",
"--run", type=int, default=
None, help=
"Run number")
153 files.add_argument(
"--inputDirectory", type=str, default=
None, help=
"Input directory")
154 files.add_argument(
"-s",
"--stream", type=str, default=
None, help=
"Run stream")
155 files.add_argument(
"-p",
"--project", type=str, default=
None, help=
"Data project")
156 files.add_argument(
"-f",
"--filter", type=str, default=
".", help=
"Data file filter")
157 files.add_argument(
"--suffix", type=str, default=
None, help=
"Directory suffix")
158 files.add_argument(
"--skipBadFiles", type=bool, default=
True, help=
"Skip bad data files?")
159 files.add_argument(
"-y",
"--year", type=int, default=
None, help=
"Year, data taken in")
164 if __name__==
'__main__':
166 log = logging.getLogger(
'TileInputFiles' )
169 args = parser.parse_args()
173 log.info(
'Input files: %s', files)
175 log.warning(
"No run data files are found")