ATLAS Offline Software
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 
4 import re
5 
6 from TrigValTools.TrigValSteering import Test, CheckSteps
7 from TrigInDetValidation.TrigInDetArtSteps import TrigInDetAna, TrigCostStep, TrigInDetRdictStep, TrigInDetCompStep, TrigInDetCpuCostStep, TrigInDetRecoData, TrigBSExtr, TrigTZReco
8 
9 import os,sys,getopt
10 
11 try:
12  opts, args = getopt.getopt(sys.argv[1:],"cxptirmn:",["config"])
13 except 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 
25 Events_local = 0
26 exclude = False
27 costplot = False
28 postproc = False
29 testconfig = False
30 dry_run = False
31 runstuff = True
32 abort_dry_run = True
33 
34 
35 if "Art_type" not in locals(): Art_type = 'grid'
36 if "Malloc" not in locals(): Malloc=False
37 if "AbortDryRun" in locals(): abort_dry_run=AbortDryRun
38 if "MultipleLB" not in locals(): MultipleLB=False
39 
40 for 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 
58 vdry_run = os.environ.get('TRIGVALSTEERING_DRY_RUN')
59 
60 if 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 
74 hlt = TrigInDetRecoData()
75 
76 # test specific variables ...
77 
78 hlt.slices = Slices
79 hlt.threads = Threads
80 hlt.concurrent_events = Slots
81 hlt.config_only = testconfig
82 if 'Release' in dir():
83  hlt.release = Release
84 
85 
86 if "Args" not in locals() :
87  Args = " "
88 
89 
90 # allow command line to override programed number of events to process
91 
92 if Events_local != 0 :
93  hlt.max_events = Events_local
94 else :
95  hlt.max_events = Events
96 
97 
98 hlt.perfmon = False
99 hlt.costmon = True
100 hlt.timeout = 18*3600
101 
102 
103 # use rucio dataset for grid jobs, else use EOS/cvmfs input
104 if os.getenv("ArtInFile",None):
105  hlt.input = os.getenv('ArtInFile')
106 else:
107  hlt.input = Input # should match definition in TrigValTools/share/TrigValInputs.json
108 
109 
110 if (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 
128 filter_bs = TrigBSExtr()
129 
130 if MultipleLB:
131  filter_bs.args += ' -l 0'
132 
133 
134 tzreco = TrigTZReco()
135 tzreco.threads = Threads
136 tzreco.concurrent_events = Slots
137 
138 
139 if 'ExtraAna' not in locals() :
140  ExtraAna = None
141 aod_to_ntup = TrigInDetAna(extraArgs = ExtraAna)
142 
143 
144 # Run athena analysis to produce TrkNtuple
145 
146 test = Test.Test()
147 test.art_type = Art_type
148 
149 
150 if dry_run:
151  if abort_dry_run:
152  sys.exit(0)
153  test.dry_run = True
154 if (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 
163 if ((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 
176 for _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"
182 cputest = [ ( "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 
196 import sys
197 sys.exit(test.run())
beamspotman.dir
string dir
Definition: beamspotman.py:621
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45