ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigCost
RatesAnalysis
share
RatesAnalysisProcessingWrapper.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
#
5
6
from
glob
import
glob
7
import
subprocess
8
import
os, shutil
9
10
import
argparse
11
12
parser = argparse.ArgumentParser(description=
'Run trigger rate analysis with prescale keys'
)
13
parser.add_argument(
'aod_dir'
, type=str,
14
help=
'Directory containing AOD files from a rate reprocessing'
)
15
parser.add_argument(
'--hlt_ps'
, type=str, help=
'HLT Prescale JSON'
)
16
parser.add_argument(
'--l1_ps'
, type=str, help=
'L1 Prescale JSON'
)
17
parser.add_argument(
'--targetlumi'
, type=float, default=2.0e34, help=
'Target luminosity'
)
18
parser.add_argument(
'--maxEvents'
, type=int, default=-1, help=
'Target luminosity'
)
19
parser.add_argument(
'--workdir'
, type=str, default=
'rate_analysis/'
, help=
'Working directory'
)
20
21
args = parser.parse_args()
22
23
# Glob input files with abs path
24
filesIn=glob(f
'{os.path.abspath(args.aod_dir)}/*'
)
25
print
(f
"Found {len(filesIn)} input files in '{args.aod_dir}'"
)
26
27
# Make working dir if needed
28
if
not
os.path.isdir(args.workdir):
29
os.makedirs(args.workdir)
30
31
hlt_ps_filen=args.hlt_ps.split(
'/'
,1)[1]
if
'/'
in
args.hlt_ps
else
args.hlt_ps
32
l1_ps_filen=args.l1_ps.split(
'/'
,1)[1]
if
'/'
in
args.l1_ps
else
args.l1_ps
33
shutil.copy(args.hlt_ps, f
"{args.workdir}/{hlt_ps_filen}"
)
34
shutil.copy(args.l1_ps, f
"{args.workdir}/{l1_ps_filen}"
)
35
36
origdir = os.getcwd()
37
os.chdir(args.workdir)
38
39
# Execute analysis commands
40
filesIn_str =
","
.join(filesIn)
41
cmd_analysis = [
42
'RatesAnalysisFullMenu.py'
,
43
'--inputPrescalesHLTJSON'
, hlt_ps_filen,
44
'--inputPrescalesL1JSON'
, l1_ps_filen,
45
'--outputHist=TrigCostRoot_Results.root'
,
46
'--targetLuminosity'
, str(args.targetlumi),
47
'--filesInput'
, filesIn_str
48
]
49
if
args.maxEvents>0:
50
cmd_analysis += [
'--evtMax'
,str(args.maxEvents)]
51
cmd_postproc = [
52
'RatesAnalysisPostProcessing.py'
,
53
'--file=TrigCostRoot_Results.root'
,
54
]
55
56
print
(f
"Analysis cmd > {' '.join(cmd_analysis)}"
)
57
with
open(
"log_RatesAnalysis.txt"
,
'w'
)
as
log_analysis:
58
assert(subprocess.run(cmd_analysis, stdout=log_analysis, stderr=subprocess.STDOUT, text=
True
).returncode==0)
59
log_analysis.close()
60
print
(f
"Postprocess cmd > {' '.join(cmd_postproc)}"
)
61
with
open(
"log_RatesPostProcess.txt"
,
'w'
)
as
log_postproc:
62
assert(subprocess.run(cmd_postproc, stdout=log_postproc, stderr=subprocess.STDOUT, text=
True
).returncode==0)
63
log_postproc.close()
64
65
if
not
os.path.isdir(
'output/csv'
):
66
os.makedirs(
'output/csv'
)
67
else
:
68
shutil.rmtree(
'output'
)
69
os.makedirs(
'output/csv'
)
70
for
csv
in
[
'Table_Rate_Group_HLT_All.csv'
,
'Table_Rate_ChainL1_HLT_All.csv'
,
'Table_Rate_ChainHLT_HLT_All.csv'
]:
71
shutil.move(csv,
'output/csv/'
)
72
for
f
in
[
'TrigCostRoot_Results.root'
,
'metadata.json'
,
'rates.json'
]:
73
shutil.move(f,
'output'
)
74
75
os.chdir(origdir)
76
77
print
(f
"Output placed in {args.workdir}/output"
)
78
print
(
"Format for trig-cost page dirs: costMonitoring_[tag]_[runNumber]"
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
Generated on
for ATLAS Offline Software by
1.17.0