ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetArtSteps.py
Go to the documentation of this file.
2# Copyright (C) 2002-2025 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 self.args += ' --CA'
59
60 if ( self.postinclude_trig != '' ) :
61 print( "postinclude_trig: ", self.postinclude_trig )
62
63 if ( self.preinclude_trig != '' ) :
64 print( "preinclude_trig: ", self.preinclude_trig )
65
66
67 def configure(self, test):
68 from TrigInDetValidation.Chains import Chains
69 tc = Chains()
70 self.preexec_trig += tc.get_compiled_flag_str(self.slices)
71
72 AVERSION = ""
73
75 if (self.release != 'current'):
76 # get the current atlas base release, and the previous base release
77 import os
78 DVERSION=os.getenv('Athena_VERSION')
79 if (self.release == 'latest'):
80 if ( DVERSION is None ) :
81 AVERSION = "22.0.20"
82 else:
83 AVERSION=str(subprocess.Popen(["getrelease.sh",DVERSION],stdout=subprocess.PIPE).communicate()[0],'utf-8')
84 if AVERSION == "":
85 print( "cannot get last stable release - will use current release" )
86 else:
87 AVERSION = self.release
88
89 # would use AVERSION is not None, but the return from a shell function with no printout
90 # gets set as an empty string rather than None
91 if AVERSION != "":
92 self.args += ' --asetup "RAWtoALL:Athena,'+AVERSION+'" '
93 print( "remapping athena base release version for offline Reco steps: ", DVERSION, " -> ", AVERSION )
94 else:
95 print( "Using current release for offline Reco steps " )
96
97 if self.preexec_trig != '' or self.preexec_reco != '' or self.preexec_all != '':
98 self.args += ' --preExec'
99 if self.preexec_trig != '':
100 self.args += ' "RDOtoRDOTrigger:{:s};"'.format(self.preexec_trig)
101 if self.preexec_reco != '':
102 self.args += ' "RAWtoALL:{:s};"'.format(self.preexec_reco)
103 if self.preexec_all != '':
104 self.args += ' "all:{:s};"'.format(self.preexec_all)
105 if self.postexec_trig != '' or self.postexec_reco != '':
106 self.args += ' --postExec'
107 if self.postexec_trig != '':
108 self.args += ' "RDOtoRDOTrigger:{:s};"'.format(self.postexec_trig)
109 if self.postexec_reco != '':
110 self.args += ' "RAWtoALL:{:s};"'.format(self.postexec_reco)
111 if (self.postinclude_trig != ''):
112 self.args += ' --postInclude "{:s}"'.format(self.postinclude_trig)
113 if (self.preinclude_trig != ''):
114 self.args += ' --preInclude "{:s}"'.format(self.preinclude_trig)
115 super(TrigInDetReco, self).configure(test)
116
117
118
121
122class TrigInDetAna(ExecStep):
123 def __init__(self, name='TrigInDetAna', extraArgs=None):
124 ExecStep.__init__(self, name )
125 self.type = 'other'
126 self.executable = 'python'
127 self.args = ' -m TrigInDetValidation.TrigInDetValidation_AODtoTrkNtuple_CA '
129 self.required = True
131 #self.input = 'AOD.pool.root'
132 self.input = ''
133 if extraArgs is not None:
134 self.args += extraArgs
135
136
137
140
141class TrigCostStep(Step):
142 def __init__(self, name='TrigCostStep'):
143 super(TrigCostStep, self).__init__(name)
144 self.required = True
146 self.input = 'tmp.RDO_TRIG'
147 self.args = ' --monitorChainAlgorithm --MCCrossSection=0.5 Input.Files=\'["tmp.RDO_TRIG"]\' '
148 self.executable = 'RunTrigCostAnalysis.py'
149
150
151
154class TrigInDetRecoData(ExecStep):
155 def __init__(self, name='TrigInDetRecoData'):
156# super(TrigInDetRecoData, self).__init__(name)
157 ExecStep.__init__(self, name)
158 self.type = 'athenaHLT'
159 self.job_options = 'TriggerJobOpts.runHLT'
161 self.required = True
162 self.threads = 1 # TODO: change to 4
163 self.concurrent_events = 1 # TODO: change to 4
164 self.perfmon = False
165 self.timeout = 18*3600
166 self.input = ''
167 self.perfmon=False
168 self.imf=False
169 self.args = '-c "setMenu=\'Cosmic_run3_v1\';doCosmics=True;doL1Sim=False;forceEnableAllChains=True;"'
170 self.args = '-c "flags.Trigger.forceEnableAllChains=True;flags.Trigger.triggerMenuSetup=\'Cosmic_run3_v1\';from AthenaConfiguration.Enums import BeamType;flags.Beam.Type=BeamType.Cosmics;"'
171 self.args += ' -o output'
172
173
174
177
178class TrigBSExtr(ExecStep):
179 def __init__(self, name='TrigBSExtr'):
180 super(TrigBSExtr, self).__init__(name)
181 self.type = 'other'
182 self.executable = 'trigbs_extractStream.py'
183 self.input = ''
184 # the HLT step may produce several BS files, if we exceed the 2 GB file size limit
185 # process all BS files in trigbs_extractStream.py (by default, find_file only keeps the last one)
186 self.args = '-s Main ' + '`find . -name "*_HLTMPPy_output.*.data"`'
187
188
189
192
193class TrigTZReco(ExecStep):
194 def __init__(self, name='TrigTZReco'):
195 super(TrigTZReco, self).__init__(name)
196 self.type = 'Reco_tf'
197 tzrecoPreExec = ' '.join([
198 "flags.Trigger.triggerMenuSetup=\'Cosmic_run3_v1\';",
199 "flags.Trigger.AODEDMSet=\'AODFULL\';",
200 ])
201 self.threads = 1
203 self.input = ''
204 self.explicit_input = True
205 self.max_events = -1
206 self.args = '--inputBSFile=' + find_file('*.physics_Main*._athenaHLT*.data') # output of the previous step
207 self.args += ' --outputAODFile=AOD.pool.root'
208 self.args += f' --conditionsTag="{defaultConditionsTags.RUN3_DATA23}" --geometryVersion=\'ATLAS-R3S-2021-03-02-00\''
209 self.args += ' --preExec="{:s}"'.format(tzrecoPreExec)
210 self.args += ' --CA'
211
212
213
216
218 '''
219 Execute TIDArdict for TrkNtuple files.
220 '''
221 def __init__(self, name='TrigInDetdict', args=None, testbin='Test_bin.dat', config=False ):
222 super(TrigInDetRdictStep, self).__init__(name)
223 self.args=args + " -b " + testbin + " "
225 self.required = True
226 self.executable = 'TIDArdict'
227 self.timeout = 5*3600
228 self.config = config
229
230 def configure(self, test):
231 if not self.config :
232 os.system( 'get_files -data TIDAbeam.dat &> /dev/null' )
233 os.system( 'get_files -data Test_bin.dat &> /dev/null' )
234 os.system( 'get_files -data Test_bin_larged0.dat &> /dev/null' )
235 os.system( 'get_files -data Test_bin_lrt.dat &> /dev/null' )
236 os.system( 'get_files -data TIDAdata-run3.dat &> /dev/null' )
237 os.system( 'get_files -data TIDAdata-run3-larged0.dat &> /dev/null' )
238 os.system( 'get_files -data TIDAdata-run3-larged0-el.dat &> /dev/null' )
239 os.system( 'get_files -data TIDAdata-run3-lrt.dat &> /dev/null' )
240 os.system( 'get_files -data TIDAdata-run3-fslrt.dat &> /dev/null' )
241 os.system( 'get_files -data TIDAdata-run3-minbias.dat &> /dev/null' )
242 os.system( 'get_files -data TIDAdata_cuts.dat &> /dev/null' )
243 os.system( 'get_files -data TIDAdata-run3-offline.dat &> /dev/null' )
244 os.system( 'get_files -data TIDAdata-run3-offline-rzMatcher.dat &> /dev/null' )
245 os.system( 'get_files -data TIDAdata-run3-offline-vtxtrack.dat &> /dev/null' )
246 os.system( 'get_files -data TIDAdata-run3-offline-larged0.dat &> /dev/null' )
247 os.system( 'get_files -data TIDAdata-run3-offline-larged0-el.dat &> /dev/null' )
248 os.system( 'get_files -data TIDAdata-run3-offline-lrt.dat &> /dev/null' )
249 os.system( 'get_files -data TIDAdata-run3-offline-fslrt.dat &> /dev/null' )
250 os.system( 'get_files -data TIDAdata-run3-offline-vtx.dat &> /dev/null' )
251 os.system( 'get_files -data TIDAdata-run3-minbias-offline.dat &> /dev/null' )
252 os.system( 'get_files -data TIDAdata-run3-offline-cosmic.dat &> /dev/null' )
253 os.system( 'get_files -data TIDAdata_cuts-offline.dat &> /dev/null' )
254 os.system( 'get_files -data TIDAdata-chains-run3.dat &> /dev/null' )
255 os.system( 'get_files -data TIDAdata-chains-run3-lrt.dat &> /dev/null' )
256 os.system( 'get_files -data TIDAdata-run4.dat &> /dev/null' )
257 os.system( 'get_files -data TIDAdata-run4-offline.dat &> /dev/null' )
258 os.system( 'get_files -data TIDAdata-run4-offline-vtx.dat &> /dev/null' )
259 super(TrigInDetRdictStep, self).configure(test)
260
261
262def json_chains( slice ) :
263 json_file = 'TrigInDetValidation/comparitor.json'
264 json_fullpath = FindFile(json_file, os.environ['DATAPATH'].split(os.pathsep), os.R_OK)
265
266 if not json_fullpath:
267 print('Failed to determine full path for input JSON %s', json_file)
268 return None
269
270 with open(json_fullpath) as f:
271 try:
272 data = json.load(f)
273 except json.decoder.JSONDecodeError as e:
274 print(f"Failed to load json file {json_fullpath}")
275 raise e
276
277 chainmap = data[slice]
278
279 return chainmap['chains']
280
281
282
283class TrigInDetCompStep(RefComparisonStep):
284 '''
285 Execute TIDAcomparitor for data.root files.
286 '''
287 def __init__( self, name='TrigInDetComp', slice=None, args=None, file=None ):
288 super(TrigInDetCompStep, self).__init__(name)
289
290 self.input_file = file
291 self.slice = slice
293 self.required = True
294 self.args = args
295 self.executable = 'TIDAcomparitor'
296 os.system( 'get_files -data TIDAhisto-panel.dat &> /dev/null' )
297 os.system( 'get_files -data TIDAhisto-panel-vtx.dat &> /dev/null' )
298 os.system( 'get_files -data TIDAhistos-vtx.dat &> /dev/null' )
299 os.system( 'get_files -data TIDAhisto-panel-TnP.dat &> /dev/null' )
300 os.system( 'get_files -data TIDAhisto-tier0.dat &> /dev/null' )
301 os.system( 'get_files -data TIDAhisto-tier0-vtx.dat &> /dev/null' )
302 os.system( 'get_files -data TIDAhisto-tier0-TnP.dat &> /dev/null' )
303
304 def configure(self, test):
305 RefComparisonStep.configure(self, test)
306 if self.reference is None :
307 self.args = self.args + " " + self.input_file + " " + self.input_file + " --noref --oldrms "
308 else:
309 self.args = self.args + " " + self.input_file + " " + self.reference + " --oldrms "
310 self.chains = json_chains( self.slice )
311 self.args += " " + self.chains
312 print( "\033[0;32mTIDAcomparitor "+self.args+" \033[0m" )
313 Step.configure(self, test)
314
315
316
317
318class TrigInDetCpuCostStep(RefComparisonStep):
319 '''
320 Execute TIDAcpucost for data.root files.
321 '''
322 def __init__( self, name='TrigInDetCpuCost', outdir=None, infile=None, extra=None ):
323 super(TrigInDetCpuCostStep, self).__init__(name)
324
325 self.input_file = infile
326 self.output_dir = outdir
328 self.required = True
329 self.extra = extra
330 self.executable = 'TIDAcpucost'
331
332
333 def configure(self, test):
334 RefComparisonStep.configure(self, test)
335 if self.reference is None :
336 self.args = self.input_file + " -o " + self.output_dir + " " + self.extra + " --noref "
337 else:
338 self.args = self.input_file + " " + self.reference + " -o " + self.output_dir + " " + self.extra
339 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:177