ATLAS Offline Software
cmd-l1calo-dq-file.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 
4 import glob
5 import sys
6 
7 if __name__=="__main__":
8 
9  import argparse
10  parser = argparse.ArgumentParser(prog="l1calo-dq-file",description="Tries to obtain a path to a DQ HIST file",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
11  parser.add_argument("run",help="run number")
12  parser.add_argument("stream",nargs='?',default="express_express",help="stream name")
13  parser.add_argument("--bulk",action='store_true',help="Look for bulk processing (f-tags, not x-tags)")
14  args = parser.parse_args()
15  files = glob.glob(f"/eos/atlas/atlastier0/rucio/*/{args.stream}/*{args.run}/*merge.HIST.{'f' if args.bulk else 'x'}*/*")
16  if len(files)==1:
17  print(files[0])
18  exit(0)
19 
20  if len(files)==0:
21  import subprocess
22  # determine the project from folders
23  folders = glob.glob(f"/eos/atlas/atlastier0/rucio/*/{args.stream}/*{args.run}")
24  if len(folders)==0:
25  print("Cannot determine project for run",args.run,file=sys.stderr)
26  exit(1)
27  project = folders[0].split("/")[5]
28  pattern = f"{project}:{project}.{int(args.run):08}.{args.stream}.merge.HIST.{'f' if args.bulk else 'x'}*"
29  try:
30  datasets = [d for d in subprocess.run(["rucio","list-dids","--short", pattern],stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n') if d !='']
31  except FileNotFoundError:
32  print("No file found. 'lsetup rucio' if you want to look further for the files",file=sys.stderr)
33  exit(1)
34  files = [f.split(",")[0] for f in subprocess.run(["rucio","list-files","--csv"]+datasets,stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n') if f!='']
35  if len(files)!=1:
36  print("files:",*files,file=sys.stderr)
37  exit(1)
38  filePaths = [f[29:] for f in subprocess.run(["rucio", "list-file-replicas", "--pfns", "--rses", "CERN-PROD_DATADISK"]+files,stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n')]
39  filePaths = [f for f in filePaths if f != '']
40  if len(filePaths)!=1:
41  print("filePaths:",*filePaths,file=sys.stderr)
42  exit(1)
43  print(filePaths[0])
44  else:
45  print(*files)
calibdata.exit
exit
Definition: calibdata.py:235
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::split
@ split
Definition: LayerMaterialProperties.h:38