ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetArtSteps.py
Go to the documentation of this file.
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3#
4
5'''
6Definitions of additional validation steps in Trigger ART tests relevant only for TrigInDetValidation
7The main common check steps are defined in the TrigValSteering.CheckSteps module.
8'''
9
10import os
11import subprocess
12import json
13
14from TrigValTools.TrigValSteering.ExecStep import ExecStep
15from TrigValTools.TrigValSteering.Step import Step
16from TrigValTools.TrigValSteering.CheckSteps import RefComparisonStep
17from TrigValTools.TrigValSteering.Common import find_file
18from AthenaCommon.Utils.unixtools import FindFile
19from AthenaConfiguration.TestDefaults import defaultConditionsTags
20
21
24
25class TrigInDetReco(ExecStep):
26
27 def __init__(self, name='TrigInDetReco', postinclude_file='', preinclude_file=''):
28 ExecStep.__init__(self, name)
29
30 self.type = 'Reco_tf'
31 self.max_events=-1
32 self.required = True
33 self.threads = 1 # TODO: change to 4
34 self.concurrent_events = 1 # TODO: change to 4
35 self.perfmon = False
36 self.timeout = 18*3600
37 self.slices = []
38 self.preexec_trig = ''
39 self.postinclude_trig = postinclude_file
40 self.preinclude_trig = preinclude_file
41 self.release = 'current'
42 self.preexec_reco = ';'.join([
43 'flags.Reco.EnableEgamma=True',
44 'flags.Reco.EnableCombinedMuon=True',
45 'flags.Reco.EnableJet=False',
46 'flags.Reco.EnableMet=False',
47 'flags.Reco.EnableBTagging=False',
48 'flags.Reco.EnablePFlow=False',
49 'flags.Reco.EnableTau=False',
50 'flags.Reco.EnablePostProcessing=False',
51 ])
52 self.preexec_all = ';'.join([
53 'flags.Trigger.AODEDMSet=\'ESD\'',
54 ])
55 self.postexec_trig = ''
56 self.postexec_reco = ''
57 self.args = '--outputAODFile=AOD.pool.root --steering "doRDO_TRIG"'
58
59 if ( self.postinclude_trig != '' ) :
60 print( "postinclude_trig: ", self.postinclude_trig )
61
62 if ( self.preinclude_trig != '' ) :
63 print( "preinclude_trig: ", self.preinclude_trig )
64
65
66 def configure(self, test):
67 from TrigInDetValidation.Chains import Chains
68 tc = Chains()
69 self.preexec_trig += tc.get_compiled_flag_str(self.slices)
70
71 AVERSION = ""
72
74 if (self.release != 'current'):
75 # get the current atlas base release, and the previous base release
76 import os
77 DVERSION=os.getenv('Athena_VERSION')
78 if (self.release == 'latest'):
79 if ( DVERSION is None ) :
80 AVERSION = "22.0.20"
81 else:
82 AVERSION=str(subprocess.Popen(["getrelease.sh",DVERSION],stdout=subprocess.PIPE).communicate()[0],'utf-8')
83 if AVERSION == "":
84 print( "cannot get last stable release - will use current release" )
85 else:
86 AVERSION = self.release
87
88 # would use AVERSION is not None, but the return from a shell function with no printout
89 # gets set as an empty string rather than None
90 if AVERSION != "":
91 self.args += ' --asetup "RAWtoALL:Athena,'+AVERSION+'" '
92 print( "remapping athena base release version for offline Reco steps: ", DVERSION, " -> ", AVERSION )
93 else:
94 print( "Using current release for offline Reco steps " )
95
96 if self.preexec_trig != '' or self.preexec_reco != '' or self.preexec_all != '':
97 self.args += ' --preExec'
98 if self.preexec_trig != '':
99 self.args += ' "RDOtoRDOTrigger:{:s};"'.format(self.preexec_trig)
100 if self.preexec_reco != '':
101 self.args += ' "RAWtoALL:{:s};"'.format(self.preexec_reco)
102 if self.preexec_all != '':
103 self.args += ' "all:{:s};"'.format(self.preexec_all)
104 if self.postexec_trig != '' or self.postexec_reco != '':
105 self.args += ' --postExec'
106 if self.postexec_trig != '':
107 self.args += ' "RDOtoRDOTrigger:{:s};"'.format(self.postexec_trig)
108 if self.postexec_reco != '':
109 self.args += ' "RAWtoALL:{:s};"'.format(self.postexec_reco)
110 if (self.postinclude_trig != ''):
111 self.args += ' --postInclude "{:s}"'.format(self.postinclude_trig)
112 if (self.preinclude_trig != ''):
113 self.args += ' --preInclude "{:s}"'.format(self.preinclude_trig)
114 super(TrigInDetReco, self).configure(test)
115
116
117
120
121class TrigInDetAna(ExecStep):
122 def __init__(self, name='TrigInDetAna', extraArgs=None):
123 ExecStep.__init__(self, name )
124 self.type = 'other'
125 self.executable = 'python'
126 self.args = ' -m TrigInDetValidation.TrigInDetValidation_AODtoTrkNtuple_CA '
128 self.required = True
130 #self.input = 'AOD.pool.root'
131 self.input = ''
132 if extraArgs is not None:
133 self.args += extraArgs
134
135
136
139
140class TrigCostStep(Step):
141 def __init__(self, name='TrigCostStep'):
142 super(TrigCostStep, self).__init__(name)
143 self.required = True
145 self.input = 'tmp.RDO_TRIG'
146 self.args = ' --monitorChainAlgorithm --MCCrossSection=0.5 Input.Files=\'["tmp.RDO_TRIG"]\' '
147 self.executable = 'RunTrigCostAnalysis.py'
148
149
150
153class TrigInDetRecoData(ExecStep):
154 def __init__(self, name='TrigInDetRecoData'):
155# super(TrigInDetRecoData, self).__init__(name)
156 ExecStep.__init__(self, name)
157 self.type = 'athenaEF'
158 self.job_options = 'TriggerJobOpts.runHLT'
160 self.required = True
161 self.threads = 1 # TODO: change to 4
162 self.concurrent_events = 1 # TODO: change to 4
163 self.perfmon = False
164 self.timeout = 18*3600
165 self.input = ''
166 self.perfmon=False
167 self.imf=False
168 self.args = '-c "setMenu=\'Cosmic_run3_v1\';doCosmics=True;doL1Sim=False;forceEnableAllChains=True;"'
169 self.args = '-c "flags.Trigger.forceEnableAllChains=True;flags.Trigger.triggerMenuSetup=\'Cosmic_run3_v1\';from AthenaConfiguration.Enums import BeamType;flags.Beam.Type=BeamType.Cosmics;"'
170 self.args += ' -o output'
171
172
173
176
177class TrigTZReco(ExecStep):
178 def __init__(self, name='TrigTZReco'):
179 super(TrigTZReco, self).__init__(name)
180 self.type = 'Reco_tf'
181 tzrecoPreExec = ' '.join([
182 "flags.Trigger.triggerMenuSetup=\'Cosmic_run3_v1\';",
183 "flags.Trigger.AODEDMSet=\'AODFULL\';",
184 ])
185 self.threads = 1
187 self.input = ''
188 self.explicit_input = True
189 self.max_events = -1
190 self.args = '--inputBSFile=' + find_file('*.physics_Main.*.data') # output of the previous step
191 self.args += ' --outputAODFile=AOD.pool.root'
192 self.args += f' --conditionsTag="{defaultConditionsTags.RUN3_DATA23}" --geometryVersion=\'ATLAS-R3S-2021-03-02-00\''
193 self.args += ' --preExec="{:s}"'.format(tzrecoPreExec)
194
195
196
199
201 '''
202 Execute TIDArdict for TrkNtuple files.
203 '''
204 def __init__(self, name='TrigInDetdict', args=None, testbin='Test_bin.dat', config=False ):
205 super(TrigInDetRdictStep, self).__init__(name)
206 self.args=args + " -b " + testbin + " "
208 self.required = True
209 self.executable = 'TIDArdict'
210 self.timeout = 5*3600
211 self.config = config
212
213 def configure(self, test):
214 if not self.config :
215 os.system( 'get_files -data TIDAbeam.dat &> /dev/null' )
216 os.system( 'get_files -data Test_bin.dat &> /dev/null' )
217 os.system( 'get_files -data Test_bin_larged0.dat &> /dev/null' )
218 os.system( 'get_files -data Test_bin_lrt.dat &> /dev/null' )
219 os.system( 'get_files -data TIDAdata-run3.dat &> /dev/null' )
220 os.system( 'get_files -data TIDAdata-run3-larged0.dat &> /dev/null' )
221 os.system( 'get_files -data TIDAdata-run3-larged0-el.dat &> /dev/null' )
222 os.system( 'get_files -data TIDAdata-run3-lrt.dat &> /dev/null' )
223 os.system( 'get_files -data TIDAdata-run3-fslrt.dat &> /dev/null' )
224 os.system( 'get_files -data TIDAdata-run3-minbias.dat &> /dev/null' )
225 os.system( 'get_files -data TIDAdata_cuts.dat &> /dev/null' )
226 os.system( 'get_files -data TIDAdata-run3-offline.dat &> /dev/null' )
227 os.system( 'get_files -data TIDAdata-run3-offline-rzMatcher.dat &> /dev/null' )
228 os.system( 'get_files -data TIDAdata-run3-offline-vtxtrack.dat &> /dev/null' )
229 os.system( 'get_files -data TIDAdata-run3-offline-larged0.dat &> /dev/null' )
230 os.system( 'get_files -data TIDAdata-run3-offline-larged0-el.dat &> /dev/null' )
231 os.system( 'get_files -data TIDAdata-run3-offline-lrt.dat &> /dev/null' )
232 os.system( 'get_files -data TIDAdata-run3-offline-fslrt.dat &> /dev/null' )
233 os.system( 'get_files -data TIDAdata-run3-offline-vtx.dat &> /dev/null' )
234 os.system( 'get_files -data TIDAdata-run3-minbias-offline.dat &> /dev/null' )
235 os.system( 'get_files -data TIDAdata-run3-offline-cosmic.dat &> /dev/null' )
236 os.system( 'get_files -data TIDAdata_cuts-offline.dat &> /dev/null' )
237 os.system( 'get_files -data TIDAdata-chains-run3.dat &> /dev/null' )
238 os.system( 'get_files -data TIDAdata-chains-run3-lrt.dat &> /dev/null' )
239 os.system( 'get_files -data TIDAdata-run4.dat &> /dev/null' )
240 os.system( 'get_files -data TIDAdata-run4-offline.dat &> /dev/null' )
241 os.system( 'get_files -data TIDAdata-run4-offline-vtx.dat &> /dev/null' )
242 super(TrigInDetRdictStep, self).configure(test)
243
244
245def json_chains( slice ) :
246 json_file = 'TrigInDetValidation/comparitor.json'
247 json_fullpath = FindFile(json_file, os.environ['DATAPATH'].split(os.pathsep), os.R_OK)
248
249 if not json_fullpath:
250 print('Failed to determine full path for input JSON %s', json_file)
251 return None
252
253 with open(json_fullpath) as f:
254 try:
255 data = json.load(f)
256 except json.decoder.JSONDecodeError as e:
257 print(f"Failed to load json file {json_fullpath}")
258 raise e
259
260 chainmap = data[slice]
261
262 return chainmap['chains']
263
264
265
266class TrigInDetCompStep(RefComparisonStep):
267 '''
268 Execute TIDAcomparitor for data.root files.
269 '''
270 def __init__( self, name='TrigInDetComp', slice=None, args=None, file=None ):
271 super(TrigInDetCompStep, self).__init__(name)
272
273 self.input_file = file
274 self.slice = slice
276 self.required = True
277 self.args = args
278 self.executable = 'TIDAcomparitor'
279 os.system( 'get_files -data TIDAhisto-panel.dat &> /dev/null' )
280 os.system( 'get_files -data TIDAhisto-panel-vtx.dat &> /dev/null' )
281 os.system( 'get_files -data TIDAhistos-vtx.dat &> /dev/null' )
282 os.system( 'get_files -data TIDAhisto-panel-TnP.dat &> /dev/null' )
283 os.system( 'get_files -data TIDAhisto-tier0.dat &> /dev/null' )
284 os.system( 'get_files -data TIDAhisto-tier0-vtx.dat &> /dev/null' )
285 os.system( 'get_files -data TIDAhisto-tier0-TnP.dat &> /dev/null' )
286
287 def configure(self, test):
288 RefComparisonStep.configure(self, test)
289 if self.reference is None :
290 self.args = self.args + " " + self.input_file + " " + self.input_file + " --noref --oldrms "
291 else:
292 self.args = self.args + " " + self.input_file + " " + self.reference + " --oldrms "
293 self.chains = json_chains( self.slice )
294 self.args += " " + self.chains
295 print( "\033[0;32mTIDAcomparitor "+self.args+" \033[0m" )
296 Step.configure(self, test)
297
298
299
300
301class TrigInDetCpuCostStep(RefComparisonStep):
302 '''
303 Execute TIDAcpucost for data.root files.
304 '''
305 def __init__( self, name='TrigInDetCpuCost', outdir=None, infile=None, extra=None ):
306 super(TrigInDetCpuCostStep, self).__init__(name)
307
308 self.input_file = infile
309 self.output_dir = outdir
311 self.required = True
312 self.extra = extra
313 self.executable = 'TIDAcpucost'
314
315
316 def configure(self, test):
317 RefComparisonStep.configure(self, test)
318 if self.reference is None :
319 self.args = self.input_file + " -o " + self.output_dir + " " + self.extra + " --noref "
320 else:
321 self.args = self.input_file + " " + self.reference + " -o " + self.output_dir + " " + self.extra
322 Step.configure(self, test)
void print(char *figname, TCanvas *c1)
Additional exec (athena) steps - AOD to TrkNtuple.
__init__(self, name='TrigInDetAna', extraArgs=None)
__init__(self, name='TrigInDetComp', slice=None, args=None, file=None)
__init__(self, name='TrigInDetCpuCost', outdir=None, infile=None, extra=None)
__init__(self, name='TrigInDetdict', args=None, testbin='Test_bin.dat', config=False)
__init__(self, name='TrigInDetRecoData')
Exec (athena) steps for Reco_tf.
__init__(self, name='TrigInDetReco', postinclude_file='', preinclude_file='')
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179