TrigInDetArtSteps.py 14.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
#
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#

'''
Definitions of additional validation steps in Trigger ART tests relevant only for TrigInDetValidation
The main common check steps are defined in the TrigValSteering.CheckSteps module.
'''

10
import os
11
import subprocess
12
import json
13

14
from TrigValTools.TrigValSteering.ExecStep import ExecStep
15
from TrigValTools.TrigValSteering.Step import Step
16
from TrigValTools.TrigValSteering.CheckSteps import RefComparisonStep
17
from AthenaCommon.Utils.unixtools import FindFile
18
19

##################################################
20
21
22
23
# Exec (athena) steps for Reco_tf
##################################################

class TrigInDetReco(ExecStep):
24

25
    def __init__(self, name='TrigInDetReco', postinclude_file='', preinclude_file='' ):
26
        ExecStep.__init__(self, name)
27
##      super(TrigInDetReco, self).__init__(name)
28
29
30
31
32
33
34
35
36
        self.type = 'Reco_tf'
        self.max_events=-1
        self.required = True
        self.threads = 1 # TODO: change to 4
        self.concurrent_events = 1 # TODO: change to 4
        self.perfmon = False
        self.timeout = 18*3600
        self.slices = []
        self.preexec_trig = ' '
37
        self.postinclude_trig = postinclude_file
38
        self.preinclude_trig  = preinclude_file
39
        self.release = 'latest'
40
41
42
43
44
45
46
47
        self.preexec_reco =  ';'.join([
            'from RecExConfig.RecFlags import rec',
            'rec.doForwardDet=False',
            'rec.doEgamma=False',
            'rec.doMuonCombined=False',
            'rec.doJetMissingETTag=False',
            'rec.doTau=False'
        ])
48

49
50
51
52
53
54
55
56
        self.preexec_aod = ';'.join([
            self.preexec_reco,
            'from ParticleBuilderOptions.AODFlags import AODFlags',
            'AODFlags.ThinGeantTruth.set_Value_and_Lock(False)',
            'AODFlags.ThinNegativeEnergyCaloClusters.set_Value_and_Lock(False)',
            'AODFlags.ThinNegativeEnergyNeutralPFOs.set_Value_and_Lock(False)',
            'AODFlags.ThinInDetForwardTrackParticles.set_Value_and_Lock(False)'
        ])
57

58
59
60
61
        self.preexec_all = ';'.join([
            'from TriggerJobOpts.TriggerFlags import TriggerFlags',
            'TriggerFlags.AODEDMSet.set_Value_and_Lock(\\\"AODFULL\\\")',
        ])
62
        self.postexec_trig = "from AthenaCommon.AppMgr import ServiceMgr; ServiceMgr.AthenaPoolCnvSvc.MaxFileSizes=['tmp.RDO_TRIG=100000000000']"
sutt's avatar
sutt committed
63

64

65
        self.postexec_reco = "from AthenaCommon.AppMgr import ServiceMgr; ServiceMgr.AthenaPoolCnvSvc.MaxFileSizes=['tmp.ESD=100000000000']"
66
        self.args = '--outputAODFile=AOD.pool.root --steering="doRDO_TRIG"'
67
68
69
70
71
72
       
        if ( self.postinclude_trig != '' ) : 
            print( "postinclude_trig: ", self.postinclude_trig )

        if ( self.preinclude_trig != '' ) : 
            print( "preinclude_trig:  ", self.preinclude_trig  )
73
74
75
76
77
78


    def configure(self, test):
        chains = '['
        flags = ''
        for i in self.slices:
79
            if (i=='L2muonLRT') :
80
81
82
                chains += "'HLT_mu24_LRT_idperf_L1MU14FCH',"
                chains += "'HLT_mu6_LRT_idperf_L1MU5VF',"
                chains += "'HLT_mu6_idperf_L1MU5VF',"
83
                flags += 'doMuonSlice=True;'
84
            if (i=='FSLRT') :
85
                chains += "'HLT_unconvtrk0_fslrt_L1J100',"
86
                flags  += 'doUnconventionalTrackingSlice=True;'
87
            if (i=='muon') :
88
89
90
                chains += "'HLT_mu6_idperf_L1MU5VF',"
                chains += "'HLT_mu24_idperf_L1MU14FCH',"
                chains += "'HLT_mu26_ivarperf_L1MU14FCH',"
91
                flags += 'doMuonSlice=True;'
92
93
94
95
            if (i=='L2electronLRT') :
                chains += "'HLT_e5_idperf_loose_lrtloose_L1EM3',"
                chains += "'HLT_e26_idperf_loose_lrtloose_L1EM22VHI',"
                flags += 'doEgammaSlice=True;'
96
            if (i=='electron') :
97
                # chains +=  "'HLT_e5_etcut_L1EM3',"  ## need an idperf chain once one is in the menu
Harry Simpson's avatar
Harry Simpson committed
98
                # chains +=  "'HLT_e17_lhvloose_nod0_L1EM15VH',"
99
                chains += "'HLT_e26_gsf_lhtight_ivarloose_L1EM22VHI',"
100
                chains += "'HLT_e26_idperf_gsf_tight_L1EM22VHI',"
101
102
103
104
                chains += "'HLT_e26_idperf_loose_L1EM24VHI',"
                chains += "'HLT_e28_idperf_loose_L1EM24VHI',"
                chains += "'HLT_e5_idperf_loose_L1EM3',"
                chains += "'HLT_e5_idperf_tight_L1EM3',"
105
                flags += 'doEgammaSlice=True;'
106
107
            if (i=='electron-tnp') :
                chains += "'HLT_e26_gsf_lhtight_ivarloose_L1EM22VHI',"
108
                chains += "'HLT_e26_idperf_gsf_tight_L1EM22VHI',"
109
110
111
112
113
114
                chains += "'HLT_e26_idperf_loose_L1EM24VHI',"
                chains += "'HLT_e28_idperf_loose_L1EM24VHI',"
                chains += "'HLT_e5_idperf_loose_L1EM3',"
                chains += "'HLT_e5_idperf_tight_L1EM3',"
                chains += "'HLT_e26_lhtight_ivarloose_e5_lhvloose_idperf_probe_L1EM22VHI',"
                flags += 'doEgammaSlice=True;'
115
116
            if (i=='tau') :
                chains +=  "'HLT_tau25_idperf_tracktwo_L1TAU12IM',"
117
                chains +=  "'HLT_tau25_idperf_tracktwoMVA_L1TAU12IM',"
118
119
                flags += 'doTauSlice=True;'
            if (i=='bjet') :
120
#               chains += "'HLT_j45_subjesgscIS_ftf_boffperf_split_L1J20',"
121
                chains += "'HLT_j45_0eta290_020jvt_pf_ftf_boffperf_L1J20',"
122
123
124
125
                flags  += 'doBjetSlice=True;'
            if ( i=='fsjet' or i=='fs' or i=='jet' ) :
                chains += "'HLT_j45_ftf_L1J15',"
                flags  += 'doJetSlice=True;'
126
127
            if (i=='beamspot') :
                chains += "'HLT_beamspot_allTE_trkfast_BeamSpotPEB_L1J15','HLT_beamspot_trkFS_trkfast_BeamSpotPEB_L1J15',"
128
                flags  += 'doBeamspotSlice=True;'
129
130
            if (i=='minbias') :
                chains += "'HLT_mb_sptrk_L1RD0_FILLED',"
131
                flags  += "doMinBiasSlice=True;setMenu='LS2_v1';"
132
            if (i=='cosmic') :
133
                chains += "'HLT_mu4_cosmic_L1MU3V'"
134
                flags  += "doMuonSlice=True;doCosmics=True;setMenu='Cosmic_run3_v1';"
135
            if (i=='bphys') :
136
137
                chains += "'HLT_mu6_idperf_L1MU5VF',"
                chains += "'HLT_2mu4_bBmumux_BsmumuPhi_L12MU3V',"
138
                flags += 'doMuonSlice=True;doBphysicsSlice=True;'
139
140
141
        if ( flags=='' ) : 
            print( "ERROR: no chains configured" )

142
143
144
        chains += ']'
        self.preexec_trig = 'doEmptyMenu=True;'+flags+'selectChains='+chains

Mark Sutton's avatar
Mark Sutton committed
145
146
        
        AVERSION = ""
147
148
        # temporary hack until we get to the bottom of why the tests are really failing
        self.release = 'current'
Mark Sutton's avatar
Mark Sutton committed
149
        if (self.release != 'current'):
150
151
152
153
154
155
156
            # get the current atlas base release, and the previous base release
            import os
            DVERSION=os.getenv('Athena_VERSION')
            if (self.release == 'latest'):
                if ( DVERSION is None ) :
                    AVERSION = "22.0.20"
                else:
157
                    AVERSION=str(subprocess.Popen(["getrelease.sh",DVERSION],stdout=subprocess.PIPE).communicate()[0],'utf-8')
Mark Sutton's avatar
Mark Sutton committed
158
159
                    if AVERSION == "":
                        print( "cannot get last stable release - will use current release" )
160
161
            else:
                AVERSION = self.release
Mark Sutton's avatar
Mark Sutton committed
162
163
164
165

        # would use AVERSION is not None, but the return from a shell function with no printout 
        # gets set as an empty string rather than None        
        if AVERSION != "":
166
167
            self.args += ' --asetup "RAWtoESD:Athena,'+AVERSION+'" "ESDtoAOD:Athena,'+AVERSION+'" '
            print( "remapping athena base release version for offline Reco steps: ", DVERSION, " -> ", AVERSION )
Mark Sutton's avatar
Mark Sutton committed
168
169
        else:
            print( "Using current release for offline Reco steps  " )
170

171

172
173
        self.args += ' --preExec "RDOtoRDOTrigger:{:s};" "all:{:s};" "RAWtoESD:{:s};" "ESDtoAOD:{:s};"'.format(
            self.preexec_trig, self.preexec_all, self.preexec_reco, self.preexec_aod)
174
        if (self.postexec_trig != ' '):
175
            self.args += ' --postExec "RDOtoRDOTrigger:{:s};" "RAWtoESD:{:s};" '.format(self.postexec_trig, self.postexec_reco)
Julie Kirk's avatar
Julie Kirk committed
176
        if (self.postinclude_trig != ''):
177
            self.args += ' --postInclude "{:s}" '.format(self.postinclude_trig)
178
        if (self.preinclude_trig != ''):
179
            self.args += ' --preInclude "{:s}" '.format(self.preinclude_trig)
180
181
182
183
184
        super(TrigInDetReco, self).configure(test)


##################################################
# Additional exec (athena) steps - AOD to TrkNtuple
185
186
##################################################

187
class TrigInDetAna(ExecStep):
188
    def __init__(self, name='TrigInDetAna', extraArgs=None):
189
190
191
        ExecStep.__init__(self, name )
        self.type = 'athena'
        self.job_options = 'TrigInDetValidation/TrigInDetValidation_AODtoTrkNtuple.py'
192
193
        self.max_events=-1
        self.required = True
194
        self.depends_on_previous = True
195
196
        #self.input = 'AOD.pool.root'
        self.input = ''
197
198
        self.perfmon=False
        self.imf=False
199
200
201
        if extraArgs is not None:
            self.args = extraArgs

202
203
204
205
206
207
208
209
210

##################################################
# Additional exec (athena) steps - RDO to CostMonitoring
##################################################

class TrigCostStep(Step):
    def __init__(self, name='TrigCostStep'):
        super(TrigCostStep, self).__init__(name)
        self.required = True
211
        self.depends_on_previous = True
212
        self.input = 'tmp.RDO_TRIG'
213
        self.args = '  --monitorChainAlgorithm --MCCrossSection=0.5 Input.Files=\'["tmp.RDO_TRIG"]\' '
214
215
216
217
        self.executable = 'RunTrigCostAnalysis.py'



218
219
220
221
##################################################
# Additional post-processing steps
##################################################

222
class TrigInDetRdictStep(Step):
223
224
225
    '''
    Execute TIDArdict for TrkNtuple files.
    '''
226
    def __init__(self, name='TrigInDetdict', args=None, testbin='Test_bin.dat', config=False ):
227
228
        super(TrigInDetRdictStep, self).__init__(name)
        self.args=args + "  -b " + testbin + " "
229
230
231
        self.auto_report_result = True
        self.required = True
        self.executable = 'TIDArdict'
232
        self.timeout = 10*60
233
        self.config = config
234
235

    def configure(self, test):
236
237
238
239
240
241
242
243
244
        if not self.config :
            os.system( 'get_files -data TIDAbeam.dat &> /dev/null' )
            os.system( 'get_files -data Test_bin.dat &> /dev/null' )
            os.system( 'get_files -data Test_bin_larged0.dat &> /dev/null' )
            os.system( 'get_files -data Test_bin_lrt.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-larged0.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-larged0-el.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-lrt.dat &> /dev/null' )
245
            os.system( 'get_files -data TIDAdata-run3-fslrt.dat &> /dev/null' )
246
            os.system( 'get_files -data TIDAdata-run3-minbias.dat &> /dev/null' )
247
            os.system( 'get_files -data TIDAdata-run3-TnP.dat &> /dev/null' )
248
249
            os.system( 'get_files -data TIDAdata_cuts.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-offline.dat &> /dev/null' )
250
            os.system( 'get_files -data TIDAdata-run3-offline-rzMatcher.dat &> /dev/null' )
251
252
253
254
            os.system( 'get_files -data TIDAdata-run3-offline-vtxtrack.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-offline-larged0.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-offline-larged0-el.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-offline-lrt.dat &> /dev/null' )
255
            os.system( 'get_files -data TIDAdata-run3-offline-fslrt.dat &> /dev/null' )
256
            os.system( 'get_files -data TIDAdata-run3-offline-vtx.dat &> /dev/null' )
257
258
            os.system( 'get_files -data TIDAdata-run3-minbias-offline.dat &> /dev/null' )
            os.system( 'get_files -data TIDAdata-run3-offline-TnP.dat &> /dev/null' )
259
            os.system( 'get_files -data TIDAdata_cuts-offline.dat &> /dev/null' )
260
            os.system( 'get_files -data TIDAdata-chains-run3.dat &> /dev/null' )
261
262
263
264
265
266
267
268
269
270
271
272
273
        super(TrigInDetRdictStep, self).configure(test)


def json_chains( slice ) : 
    json_file     = 'TrigInDetValidation/comparitor.json'
    json_fullpath = FindFile(json_file, os.environ['DATAPATH'].split(os.pathsep), os.R_OK)

    if not json_fullpath:
        print('Failed to determine full path for input JSON %s', json_file)
        return None
        
    with open(json_fullpath) as f:
        data = json.load(f)
274

275
276
277
    chainmap = data[slice]

    return chainmap['chains']
278
279
280



281
class TrigInDetCompStep(RefComparisonStep):
282
283
284
    '''
    Execute TIDAcomparitor for data.root files.
    '''
285
    def __init__( self, name='TrigInDetComp', slice=None, args=None, file=None ):
286
        super(TrigInDetCompStep, self).__init__(name)
287
288

        self.input_file = file    
289
        self.slice = slice 
290
        self.auto_report_result = True
291
        self.required   = True
292
        self.args = args
293
        self.executable = 'TIDAcomparitor'
294
295
296
297
298
        os.system( 'get_files -data TIDAhisto-panel.dat &> /dev/null' )
        os.system( 'get_files -data TIDAhisto-panel-vtx.dat &> /dev/null' )
        os.system( 'get_files -data TIDAhistos-vtx.dat &> /dev/null' )
        os.system( 'get_files -data TIDAhisto-panel-TnP.dat &> /dev/null' )
        os.system( 'get_files -data TIDAhisto-tier0.dat &> /dev/null' )
299
    
300

301
    def configure(self, test):
302
303
304
305
306
        RefComparisonStep.configure(self, test)
        if self.reference is None :
            self.args  = self.args + " " + self.input_file + "  " + self.input_file + " --noref --oldrms "
        else:
            self.args  = self.args + " " + self.input_file + "  " + self.reference + " --oldrms "
307
308
309
        self.chains = json_chains( self.slice )
        self.args += " " + self.chains
        print( "\033[0;32mTIDAcomparitor "+self.args+" \033[0m" )
310
        Step.configure(self, test)
311

312

313
314


315
316
class TrigInDetCpuCostStep(RefComparisonStep):
    '''
317
    Execute TIDAcpucost for data.root files.
318
    '''
319
    def __init__( self, name='TrigInDetCpuCost', outdir=None, infile=None, extra=None ):
320
        super(TrigInDetCpuCostStep, self).__init__(name)
321
322
323

        self.input_file = infile
        self.output_dir = outdir
324
        self.auto_report_result = True
325
326
        self.required   = True
        self.extra = extra
327
328
        self.executable = 'TIDAcpucost'
    
329

330
    def configure(self, test):
331
332
        RefComparisonStep.configure(self, test)
        if self.reference is None :
333
            self.args  = self.input_file + " -o " + self.output_dir + " " + self.extra + " --noref  "
334
        else:
335
            self.args  = self.input_file + " " + self.reference + " -o " + self.output_dir + " " + self.extra
336
        Step.configure(self, test)
337