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