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