ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetValidation_Base.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# Slices = ['fsjet']
5# Events = 10
6# Threads = 1
7# Slots = 1
8# Input = 'ttbar' # defined in TrigValTools/share/TrigValInputs.json
9# TrackReference = 'Truth'
10
11import re
12
13from TrigValTools.TrigValSteering import Test, CheckSteps
14from TrigInDetValidation.TrigInDetArtSteps import TrigInDetReco, TrigInDetAna, TrigCostStep, TrigInDetRdictStep, TrigInDetCompStep, TrigInDetCpuCostStep
15
16import os,sys,getopt
17
18try:
19 opts, args = getopt.getopt(sys.argv[1:],"cxptirmn:",["config"])
20except getopt.GetoptError:
21 print("Usage: ")
22 print("-x don't run athena or post post-processing, only plotting")
23 print("-m run cost monitoring plotting, even if -x is set")
24 print("-r run only ntuple building stage")
25 print("-p run post-processing, even if -x is set")
26 print("-n N run only on N events per job")
27 print("-c | --config run with config_only and print to a pkl file")
28 print("-t test steering, dry run for all steps")
29 print("-i force the dry AbortDryRun flag to be False")
30 print("")
31 sys.exit(1)
32
33Events_local = 0
34exclude = False
35costplot = False
36postproc = False
37testconfig = False
38dry_run = False
39runstuff = True
40abort_dry_run = True
41
42
43if "Art_type" not in locals(): Art_type = 'grid'
44if "Malloc" not in locals(): Malloc=False
45if "AbortDryRun" in locals(): abort_dry_run=AbortDryRun
46
47for opt,arg in opts:
48 if opt=="-x":
49 exclude=True
50 if opt=="-p":
51 postproc=True
52 if opt=="-m":
53 costplot=True
54 if opt=="-n":
55 Events_local=int(arg)
56 if opt=="-r":
57 runstuff=False
58 if opt in ("-c", "--config"):
59 testconfig = True
60 if opt=="-t":
61 dry_run=True
62 if opt=="-i":
63 abort_dry_run=False
64
65vdry_run = os.environ.get('TRIGVALSTEERING_DRY_RUN')
66
67if vdry_run == '1':
68 dry_run=True
69
70
71if 'postinclude_file' in dir() :
72 if 'preinclude_file' in dir() :
73 rdo2aod = TrigInDetReco( postinclude_file=postinclude_file, preinclude_file=preinclude_file )
74 else :
75 rdo2aod = TrigInDetReco( postinclude_file=postinclude_file )
76else :
77 if 'preinclude_file' in dir() :
78 rdo2aod = TrigInDetReco( preinclude_file=preinclude_file )
79 else :
80 rdo2aod = TrigInDetReco()
81
82# test specific variables ...
83
84rdo2aod.slices = Slices
85rdo2aod.threads = Threads
86rdo2aod.concurrent_events = Slots
87rdo2aod.config_only = testconfig
88if 'Release' in dir():
89 rdo2aod.release = Release
90
91
92if "Args" not in locals() :
93 Args = " "
94
95
96# allow command line to override programed number of events to process
97
98if Events_local != 0 :
99 rdo2aod.max_events = Events_local
100else :
101 rdo2aod.max_events = Events
102
103
104rdo2aod.perfmon = False
105rdo2aod.costmon = True
106rdo2aod.timeout = 18*3600
107
108# use rucio dataset for grid jobs, else use EOS/cvmfs input
109if os.getenv("ArtInFile",None):
110 rdo2aod.input = ''
111 rdo2aod.args += ' --inputRDOFile=$ArtInFile '
112else:
113 rdo2aod.input = Input # should match definition in TrigValTools/share/TrigValInputs.json
114
115# temporary conditions override: force MC23e global tag by default and Run4 global tag for Run4 inputs, until input RDOs are updated
116from AthenaConfiguration.TestDefaults import defaultConditionsTags
117
118if "conditionsOverride" not in locals():
119 rdo2aod.args += f' --conditionsTag "default:{defaultConditionsTags.RUN3_MC}"'
120elif conditionsOverride == "Run4":
121 rdo2aod.args += f' --conditionsTag "default:{defaultConditionsTags.RUN4_MC}"'
122
123
124if (Malloc):
125 import os
126 os.environ["MALLOC_CHECK_"] = "3"
127 rdo2aod.malloc = True
128
129for a in ["preexec_trig", "preexec_reco", "preexec_all", "postexec_trig", "postexec_reco"]:
130 if a in locals():
131 v = locals()[a]
132 if type(v) is list: v = ";".join(v)
133 v0 = getattr (rdo2aod, a)
134 if v0 is None or v0 == "":
135 v0 = v
136 else:
137 v0 += ";"+v
138 setattr (rdo2aod, a, v0)
139
140# Run athena analysis to produce TrkNtuple
141
142test = Test.Test()
143test.art_type = Art_type
144
145
146if 'ExtraAna' not in locals() :
147 ExtraAna = None
148aod_to_ntup = TrigInDetAna(extraArgs = ExtraAna)
149
150
151rdo_to_cost = TrigCostStep()
152
153if dry_run:
154 if abort_dry_run:
155 sys.exit(0)
156 test.dry_run = True
157if (not exclude):
158 if runstuff:
159 test.exec_steps = [rdo2aod, aod_to_ntup, rdo_to_cost]
160 else:
161 test.exec_steps = [aod_to_ntup]
162 test.check_steps = CheckSteps.default_check_steps(test)
163
164# Run TIDArdict
165
166if ((not exclude) or postproc ):
167 for job in Jobs :
168 if len(job) >= 3:
169 rdict = TrigInDetRdictStep( name=job[0], args=job[1], testbin=job[2], config=(testconfig or dry_run) )
170 else:
171 rdict = TrigInDetRdictStep( name=job[0], args=job[1], config=(testconfig or dry_run) )
172 print( "\n\033[0;32m TIDArdict "+job[1]+" \033[0m" )
173 test.check_steps.append(rdict)
174
175
176
177
178
179for _slice in Comp :
180 compstep = TrigInDetCompStep( name=_slice[0], slice=_slice[1], file=_slice[2], args=_slice[3] )
181 test.check_steps.append(compstep)
182
183# CPU cost steps
184# cputest defined with "name" "output directory" "filename" "args"
185cputest = [ ( "CpuCostStep1", " times ", "expert-monitoring.root", " --auto -p TIME" ),
186 ( "CpuCostStep2", " times-FTF ", "expert-monitoring.root", " --auto -p TIME -d TrigFastTrackFinder_" ),
187 ( "CpuCostStep3", " cost-perCall ", "TrigCostRoot_Results.root", " --auto -p _Time_perCall -d /Algorithm --logx " ),
188 ( "CpuCostStep4", " cost-perEvent ", "TrigCostRoot_Results.root", " --auto -p _Time_perEvent -d /Algorithm --logx " ),
189 ( "CpuCostStep5", " cost-perCall-chain ", "TrigCostRoot_Results.root", " --auto -p _Time_perCall -d /Chain_Algorithm --logx " ),
190 ( "CpuCostStep6", " cost-perEvent-chain ", "TrigCostRoot_Results.root", " --auto -p _Time_perEvent -d /Chain_Algorithm --logx " ) ]
191
192
193if ((not exclude) or postproc or costplot ):
194 for job in cputest :
195 cpucost = TrigInDetCpuCostStep( name=job[0], outdir=job[1], infile=job[2], extra=job[3] )
196 test.check_steps.append(cpucost)
197
198
199import sys
200sys.exit(test.run())
void print(char *figname, TCanvas *c1)