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