ATLAS Offline Software
PreloadTest.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from TrigValTools.TrigValSteering import Input, ExecStep, PyStep, Test
4 from TrigP1Test import TrigP1TestSteps
5 from contextlib import suppress
6 import eformat
7 import json
8 import os
9 
10 
12  """Fully configured _preload test for given menu"""
13 
14  # Get run/LB number from input file
15  input_file = Input.get_input('data').paths[0]
16  first_event = eformat.istream(input_file)[0]
17  run = first_event.run_no()
18  lb = first_event.lumi_block()
19 
20  # 1) Delete any previous bytestream file
21  def cleanup():
22  with suppress(FileNotFoundError):
23  os.remove('raw._0001.data')
24 
25  ex_rm = PyStep.PyStep(cleanup)
26 
27  # 2) Create new bytestream file with future run number and renumber LBs
28  ex_bs = ExecStep.ExecStep('create_bs')
29  ex_bs.type = 'other'
30  ex_bs.input = ''
31  ex_bs.executable = 'trigbs_modifyEvent.py'
32  ex_bs.args = '-n 50 --runNumber 999999 --incLB 6 --firstLB 4 --eventsPerLB=3 -o raw %s' % input_file
33 
34  # 3) Create configuration JSON based on original data file
35  ex_dump = ExecStep.ExecStep('dump-config')
36  ex_dump.type = 'athenaHLT'
37  ex_dump.job_options = 'TriggerJobOpts.runHLT'
38  ex_dump.input = 'data'
39  ex_dump.args = '-M --dump-config-exit'
40  ex_dump.args += f' -C "from TriggerJobOpts import PostExec; PostExec.forceConditions({run},{lb})"'
41  ex_dump.flags = [f'Trigger.triggerMenuSetup="{menu}"',
42  'Trigger.doLVL1=True']
43  ex_dump.perfmon = False
44 
45  # 4) Fix the Json produced in the previous step
46  def fix_json():
47  # We do not load the PSK from COOL but the folder needs to at least hold some
48  # valid data, which is not the case for run 999999. Force it to an arbitrary old run.
49  with open('HLTJobOptions.json') as f:
50  cfg = json.load(f)
51 
52  cfg['properties']['IOVDbSvc']['Folders'] = cfg['properties']['IOVDbSvc']['Folders'].replace(
53  '/TRIGGER/HLT/PrescaleKey',f'/TRIGGER/HLT/PrescaleKey<forceRunNumber>{run}</forceRunNumber>')
54 
55  with open('HLTJobOptions.fixPS.json','w') as f:
56  json.dump(cfg, f)
57 
58  ex_fix = PyStep.PyStep(fix_json)
59 
60  # 5) Run athenaHLT from JSON on renumbered file
61  ex = ExecStep.ExecStep('athenaHLT')
62  ex.type = 'other'
63  ex.executable = 'athenaHLT.py'
64  ex.input = ''
65  ex.explicit_input = True
66  ex.args = '-M -f ./raw._0001.data'
67  ex.args += ' -R 999999 -L 999 --sor-time=now --detector-mask=all' # to avoid COOL lookup of non-existent run
68  ex.args += ' --imf --threads=1 --concurrent-events=1 --nprocs=1'
69  ex.args += ' HLTJobOptions.fixPS.json'
70  ex.perfmon = False # Cannot use PerfMon with -M
71 
72  # Checks
73  test = Test.Test()
74  test.art_type = 'build'
75  test.exec_steps = [ex_rm, ex_bs, ex_dump, ex_fix, ex]
76  test.check_steps = TrigP1TestSteps.default_check_steps_OHMon(test, 'r0000999999_athenaHLT_HLT-Histogramming.root:run_999999/lb_-1')
77 
78  return test
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.PreloadTest.test_trigP1_preload
def test_trigP1_preload(menu)
Definition: PreloadTest.py:11
Trk::open
@ open
Definition: BinningType.h:40