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