ATLAS Offline Software
Loading...
Searching...
No Matches
exerciser.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from TrigHLTJetHypoUnitTests.TrigHLTJetHypoUnitTestsConf import (
4 JetHypoExerciserAlg,
5 SimpleHypoJetVectorGenerator,)
6
7from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName
8
9from TrigHLTJetHypo.TrigJetHypoToolConfig import (
10 trigJetHypoToolHelperFromDict,
11 trigJetHypoToolHelperFromDict_,)
12
13from TrigHLTJetHypo.test_cases import test_strings
14
15from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
16
17from TrigHLTJetHypo.ConditionsToolSetterTree import ConditionsToolSetterTree as ConditionsToolSetter
18
20
21 def __init__(self,
22 n_conds=6,
23 n_bkgd=4,
24 bkgd_etmax=50000., # MeV
25 run_with_partitions=False):
26
27 self.n_conds = n_conds
28 self.n_bkgd = n_bkgd
29 self.bkgd_etmax = bkgd_etmax
30 self.run_with_partitions = run_with_partitions
31
32
33 def make_chain_dict(self):
34 """Chaindicts for Partion vs flownetwork strudies"""
35
36 chainNameDecoder = DictFromChainName.DictFromChainName()
37 self.chain_name = 'HLT'
38 for i in range(self.n_conds):
39 self.chain_name += '_j80'
40
41
42 chain_dict = chainNameDecoder.getChainDict(self.chain_name)
43 assert len(chain_dict['chainParts']) == self.n_conds
44
45 if (self.run_with_partitions):
46 for cp in chain_dict['chainParts']:
47 cp['hypoScenario'] = 'simple_partition'
48
49 return chain_dict
50
51
54
55 generator.ets = [80000. + 1000.*i for i in range(self.n_sgnl)]
56 generator.etas = [0.5] * self.n_sgnl
57 generator.n_bkgd = self.n_bkgd
58 generator.bkgd_etmax = self.bkgd_etmax
59
60 return generator
61
62 def logfile_name(self, chain_name):
63 if (self.run_with_partitions):
64 lfn = self.chain_name + '_b' + str(self.n_bkgd) + '_part.log'
65 else:
66 lfn = self.chain_name + '_b' + str(self.n_bkgd) + '.log'
67
68 return lfn
69
71
72 def __init__(self,
73 n_sgnl=4,
74 n_bkgd=4,
75 bkgd_etmax=50000., # MeV
76 ):
77 self.n_sgnl = n_sgnl
78 self.n_bkgd = n_bkgd
79 self.bkgd_etmax = bkgd_etmax
80 self.chain_name = 'HLT_j80_L1J20'
81
82 def make_chain_dict(self):
83 """ChainDict to excercise modifications to CombinationsHelperTool"""
84
85 chainNameDecoder = DictFromChainName.DictFromChainName()
86
87 #make a chain dict to be perverted:
88 # its hypoScenario will be overwritten by the value
89 # 'combinationsTest'. This will result in a hardwired chain label
90 # being used.
91 chain_dict = chainNameDecoder.getChainDict(self.chain_name)
92 assert len(chain_dict['chainParts']) == 1
93
94 chain_dict['chainParts'][0]['hypoScenario'] = 'combinationsTest'
95
96 return chain_dict
97
99 chain_dict = self._make_chain_dict()
100 print(chain_dict['chainParts'][0])
101 return trigJetHypoToolHelperFromDict(chain_dict)
102
103
105 generator = SimpleHypoJetVectorGenerator()
106
107 generator.ets = [80000. + 1000.*i for i in range(self.n_sgnl)]
108 generator.etas = [0.5] * self.n_sgnl
109
110 generator.n_bkgd = self.n_bkgd
111 generator.bkgd_etmax = self.bkgd_etmax
112
113 return generator
114
115 def logfile_name(self):
116 return self.chain_name + '_b' + str(self.n_bkgd) + '_combs.log'
117
118
120
121 def __init__(self,
122 n_sgnl=4,
123 n_bkgd=4,
124 bkgd_etmax=50000., # MeV
125 ):
126 CombinationsTests.__init__(self, n_sgnl, n_bkgd, bkgd_etmax)
127
129 """ChainDict to excercise modifications to CombinationsHelperTool"""
130
131 chain_dict = CombinationsTests.make_chain_dict(self)
132 chain_dict['chainParts'][0]['hypoScenario'] = 'partitionsTest'
133
134 return chain_dict
135
137 chain_dict = self._make_chain_dict()
138 print(chain_dict['chainParts'][0])
139 return trigJetHypoToolHelperFromDict(chain_dict)
140
141
142 def logfile_name(self, chain_name):
143 return chain_name + '_b' + str(self.n_bkgd) + '_parts.log'
144
145
147
148 def __init__(self,
149 n_sgnl=4,
150 n_bkgd=4,
151 bkgd_etmax=20000., # MeV
152 ):
153 # useEtaEtNotEtaE = False
154 CombinationsTests.__init__(self, n_sgnl, n_bkgd, bkgd_etmax)
155 self.chain_name = 'HLT_DijetConditionTests'
156
158 chain_label = """
159 z([]
160 simple([(10et, 0eta320)(20et)])
161 )"""
162
163
164 toolSetter = ConditionsToolSetter(self.chain_name)
165 return trigJetHypoToolHelperFromDict_(chain_label,
166 self.chain_name,
167 toolSetter=toolSetter)
168
169
170 def logfile_name(self, chain_name):
171 return chain_name + '_s' + str(self.n_sgnl) + '_b' + str(self.n_bkgd)+'.log'
172
174 generator = SimpleHypoJetVectorGenerator()
175
176 generator.ets = [80000. + 1000.*i for i in range(self.n_sgnl)]
177 generator.etas = [0.5] * self.n_sgnl
178
179 # alternate eta signs to get high mass
180 factor = 1
181 for i in range(len(generator.etas)):
182 generator.etas[i] *= factor
183 factor *= -1
184
185 generator.n_bkgd = self.n_bkgd
186 generator.bkgd_etmax = self.bkgd_etmax
187
188 return generator
189
191
192 def __init__(self,
193 chain_label,
194 n_sgnl=4,
195 n_bkgd=4,
196 bkgd_etmax=20000., # MeV
197 label_ind=0
198 ):
199 CombinationsTests.__init__(self, n_sgnl, n_bkgd, bkgd_etmax)
200 self.chain_name = 'HLT_ConditionTests'
201 self.chain_label = chain_label
202 self.label_ind = label_ind
203
205
206 toolSetter = ConditionsToolSetter(self.chain_name)
207 return trigJetHypoToolHelperFromDict_(self.chain_label,
208 self.chain_name,
209 toolSetter=toolSetter)
210
211
212 def logfile_name(self, chain_name):
213 return '%s_s%d_b%d_l%d' % (chain_name,
214 self.n_sgnl,
215 self.n_bkgd,
216 self.label_ind)
217
218
220 generator = SimpleHypoJetVectorGenerator()
221
222 generator.ets = [80000. + 1000.*i for i in range(self.n_sgnl)]
223 generator.etas = [0.5] * self.n_sgnl
224
225
226 # alternate eta signs to get high mass
227 factor = 1
228 for i in range(len(generator.etas)):
229 generator.etas[i] *= factor
230 factor *= -1
231
232 generator.n_bkgd = self.n_bkgd
233 generator.bkgd_etmax = self.bkgd_etmax
234
235 return generator
236
237
238
240 n_signal,
241 n_background,
242 bkgdEmax,
243 label_ind=0):
244
245 # test_conditions = FlowNetworkTests_1(n_sgnl=1, n_bkgd=0)
246 # test_conditions = SimpleFlowNetworkTests(n_sgnl=4, n_bkgd=0)
247 # test_conditions = FlowNetworkVsPartitionsTestsDijets(n_sgnl=4, n_bkgd=0)
248 # test_conditions = FlowNetworkVsCombinationsTests(n_sgnl=4, n_bkgd=0)
249 # test_conditions = SimpleConditionsTests(n_sgnl=4, n_bkgd=0)
250 test_conditions = ConditionsTests(label,
251 n_signal,
252 n_background,
253 bkgdEmax,
254 label_ind)
255
256 print(test_conditions.__dict__)
257 # test_conditions = CombinationsTests()
258 chain_name = test_conditions.chain_name
259
260 ht = test_conditions.make_helper_tool()
261
262 print('ht = ', ht)
263
264 jetHypoExerciserAlg=JetHypoExerciserAlg("JetHypoExerciser")
265 jetHypoExerciserAlg.JetHypoHelperTool = ht
266 jetHypoExerciserAlg.event_generator = test_conditions.make_event_generator()
267 jetHypoExerciserAlg.visit_debug = True
268
269 lfn = test_conditions.logfile_name(chain_name)
270
271 jetHypoExerciserAlg.logname = lfn
272
273
274 print(jetHypoExerciserAlg)
275
276 result=ComponentAccumulator()
277 result.addEventAlgo(jetHypoExerciserAlg)
278 return result
279
280
281
282if __name__=="__main__":
283
284 n_signal = 4
285 n_background = 0
286 bkgdEmax = 0.
287 label_ind = 2
288
289 label = test_strings[label_ind]
290
291 from AthenaConfiguration.AllConfigFlags import initConfigFlags
292 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
293 flags = initConfigFlags()
294 flags.Exec.MaxEvents=10
295 cfg=MainServicesCfg(flags)
296 cfg.merge(JetHypoExerciserCfg(label,
297 n_signal,
298 n_background,
299 bkgdEmax,
300 label_ind)
301 )
302
303 cfg.run()
304
305 #f=open("HelloWorld.pkl","wb")
306 #cfg.store(f)
307 #f.close()
308
void print(char *figname, TCanvas *c1)
__init__(self, n_sgnl=4, n_bkgd=4, bkgd_etmax=50000.)
Definition exerciser.py:76
__init__(self, chain_label, n_sgnl=4, n_bkgd=4, bkgd_etmax=20000., label_ind=0)
Definition exerciser.py:198
logfile_name(self, chain_name)
Definition exerciser.py:212
__init__(self, n_sgnl=4, n_bkgd=4, bkgd_etmax=50000.)
Definition exerciser.py:125
logfile_name(self, chain_name)
Definition exerciser.py:142
__init__(self, n_conds=6, n_bkgd=4, bkgd_etmax=50000., run_with_partitions=False)
Definition exerciser.py:25
__init__(self, n_sgnl=4, n_bkgd=4, bkgd_etmax=20000.)
Definition exerciser.py:152
logfile_name(self, chain_name)
Definition exerciser.py:170
JetHypoExerciserCfg(label, n_signal, n_background, bkgdEmax, label_ind=0)
Definition exerciser.py:243