2 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaCommon.Logging
import AthenaLogger
5 from PathResolver
import PathResolver
9 log = AthenaLogger(__name__)
12 from FPGATrackSimConfTools
import FPGATrackSimDataPrepConfig
16 etaBin = (flags.Trigger.FPGATrackSim.region >> 6) & 0x1f
20 weight4Eta = [563.9382667,493.23055,381.835315,264.7819679,179.555554,116.0867029,96.30409326,96.13504916,163.7278321,270.5480971,270.6937626,180.2164132,129.0011743,91.50412962,72.65953377,49.77568766,32.518927,20.38964651,12.97547848,8.05716611]
21 weight4Phi = [5291.005291,4784.688995,4739.336493,4329.004329,3508.77193,3278.688525,4366.812227,6756.756757,10752.68817,14925.37313,16666.66667,16949.15254,17543.85965,16666.66667,19230.76923,20833.33333,20408.16327,20000,20000,18181.81818]
22 weights5Eta = [217.5331768,184.2304061,148.3134888,98.13939253,66.37534817,42.93312711,33.65526204,34.33247487,47.5202135,77.16881734,110.4844013,100.8706594,83.79061435,58.69032222,44.9857434,30.5678705,18.85832071,12.76889006,8.270441607,5.426907903]
23 weights5Phi = [1302.083333,1138.952164,1068.376068,961.5384615,831.9467554,764.5259939,996.0159363,1481.481481,2857.142857,3875.968992,4504.504505,5076.142132,5681.818182,5747.126437,6493.506494,6578.947368,6622.516556,6802.721088,6849.315068,6578.947368]
25 assert(etaBin >= 0
and etaBin < 20)
26 return [weight4Eta[etaBin], weight4Phi[etaBin], weights5Eta[etaBin], weights5Phi[etaBin]]
31 assert(fields.startswith(
'towers'))
39 FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool(
"FPGATrackSimWriteOutput")
40 FPGATrackSimWriteOutput.InFileName = [
"test.root"]
41 FPGATrackSimWriteOutput.OutputTreeName = FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimLogicalEventTree")
43 if not flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
44 FPGATrackSimWriteOutput.EventLimit = 0
46 FPGATrackSimWriteOutput.EventLimit = flags.Trigger.FPGATrackSim.writeOutputEventLimit
49 FPGATrackSimWriteOutput.RWstatus =
"HEADER"
50 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
51 result.setPrivateTools(FPGATrackSimWriteOutput)
56 FPGATrackSimSlicingEngineTool = CompFactory.FPGATrackSimSlicingEngineTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
58 FPGATrackSimSlicingEngineTool.LayerMap = os.path.join(
PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),f
"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
59 FPGATrackSimSlicingEngineTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
61 FPGATrackSimSlicingEngineTool.doSecondStage = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
62 FPGATrackSimSlicingEngineTool.RootOutput = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
63 result.setPrivateTools(FPGATrackSimSlicingEngineTool)
68 FPGATrackSimBankSvc = CompFactory.FPGATrackSimBankSvc(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
69 FPGATrackSimBankSvc.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
70 pathBankSvc = flags.Trigger.FPGATrackSim.bankDir
if flags.Trigger.FPGATrackSim.bankDir !=
'' else f
'/eos/atlas/atlascerngroupdisk/det-htt/HTTsim/{flags.GeoModel.AtlasVersion}/21.9.16/'+FPGATrackSimDataPrepConfig.getBaseName(flags)+
'/SectorBanks/'
72 FPGATrackSimBankSvc.constantsNoGuess_1st = [
73 f
'{pathBankSvc}corrgen_raw_8L_skipPlane0.gcon',
74 f
'{pathBankSvc}corrgen_raw_8L_skipPlane1.gcon',
75 f
'{pathBankSvc}corrgen_raw_8L_skipPlane2.gcon',
76 f
'{pathBankSvc}corrgen_raw_8L_skipPlane3.gcon',
77 f
'{pathBankSvc}corrgen_raw_8L_skipPlane4.gcon',
78 f
'{pathBankSvc}corrgen_raw_8L_skipPlane5.gcon',
79 f
'{pathBankSvc}corrgen_raw_8L_skipPlane6.gcon',
80 f
'{pathBankSvc}corrgen_raw_8L_skipPlane7.gcon']
81 FPGATrackSimBankSvc.constantsNoGuess_2nd = [
82 f
'{pathBankSvc}corrgen_raw_13L_skipPlane0.gcon',
83 f
'{pathBankSvc}corrgen_raw_13L_skipPlane1.gcon',
84 f
'{pathBankSvc}corrgen_raw_13L_skipPlane2.gcon',
85 f
'{pathBankSvc}corrgen_raw_13L_skipPlane3.gcon',
86 f
'{pathBankSvc}corrgen_raw_13L_skipPlane4.gcon',
87 f
'{pathBankSvc}corrgen_raw_13L_skipPlane5.gcon',
88 f
'{pathBankSvc}corrgen_raw_13L_skipPlane6.gcon',
89 f
'{pathBankSvc}corrgen_raw_13L_skipPlane7.gcon']
90 layers=
"5L" if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else "9L"
92 pathMapSvc = flags.Trigger.FPGATrackSim.mapsDir
if flags.Trigger.FPGATrackSim.mapsDir !=
'' else f
'/eos/atlas/atlascerngroupdisk/det-htt/HTTsim/{flags.GeoModel.AtlasVersion}/21.9.16/'+FPGATrackSimDataPrepConfig.getBaseName(flags)+
'/SectorMaps/'
94 pmap_file = os.path.join(pathMapSvc, f
"region{flags.Trigger.FPGATrackSim.region}.pmap")
95 with open(pmap_file)
as f:
97 if 'logical_s2' in line:
98 s2_layers =
int(line.strip().
split()[0])
100 FPGATrackSimBankSvc.constants_1st = f
'{pathBankSvc}corrgen_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
101 FPGATrackSimBankSvc.constants_2nd = f
'{pathBankSvc}corrgen_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
102 FPGATrackSimBankSvc.sectorBank_1st = f
'{pathBankSvc}sectorsHW_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
103 FPGATrackSimBankSvc.sectorBank_2nd = f
'{pathBankSvc}sectorsHW_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
104 FPGATrackSimBankSvc.sectorSlices = f
'{pathBankSvc}slices_{layers}_reg{flags.Trigger.FPGATrackSim.region}.root'
105 FPGATrackSimBankSvc.phiShift = flags.Trigger.FPGATrackSim.phiShift
108 FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
109 FPGATrackSimBankSvc.qptAbsBinning =
False
111 result.addService(FPGATrackSimBankSvc, create=
True, primary=
True)
117 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
119 xBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBins
120 xBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
121 yBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBins
122 yBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
123 yMin = flags.Trigger.FPGATrackSim.ActiveConfig.qptMin
124 yMax = flags.Trigger.FPGATrackSim.ActiveConfig.qptMax
125 xMin = flags.Trigger.FPGATrackSim.ActiveConfig.phiMin
126 xMax = flags.Trigger.FPGATrackSim.ActiveConfig.phiMax
127 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
128 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
132 xBuffer = (xMax - xMin) / xBins * xBufferBins
133 xMin = xMin - xBuffer
134 xMax = xMax + xBuffer
135 yBuffer = (yMax - yMin) / yBins * yBufferBins
139 houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
140 roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
143 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
145 HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimHoughTransformTool")+
"_" +
str(number))
146 HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
148 HoughTransform.FPGATrackSimMappingSvc = FPGATrackSimMapping
149 HoughTransform.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.combineLayers
150 HoughTransform.convSize_x = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeX
151 HoughTransform.convSize_y = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeY
152 HoughTransform.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.convolution
153 HoughTransform.d0_max = 0
154 HoughTransform.d0_min = 0
155 HoughTransform.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
156 HoughTransform.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX
157 HoughTransform.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
158 HoughTransform.nBins_x = xBins + 2 * xBufferBins
159 HoughTransform.nBins_y = yBins + 2 * yBufferBins
160 HoughTransform.phi_max = xMax
161 HoughTransform.phi_min = xMin
162 HoughTransform.qpT_max = yMax
163 HoughTransform.qpT_min = yMin
164 HoughTransform.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
165 HoughTransform.subRegion = number
166 HoughTransform.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold
167 HoughTransform.traceHits =
True
168 HoughTransform.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
169 HoughTransform.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
170 HoughTransform.houghType = houghType
171 HoughTransform.roadMerge = roadMerge
172 if houghType==
'LowResource':
173 HoughTransform.requirements = flags.Trigger.FPGATrackSim.ActiveConfig.requirements
174 if houghType==
'Flexible':
175 HoughTransform.r_max=flags.Trigger.FPGATrackSim.ActiveConfig.r_max
176 HoughTransform.phi_coord_max=flags.Trigger.FPGATrackSim.ActiveConfig.phi_coord_max
177 HoughTransform.phi_range=flags.Trigger.FPGATrackSim.ActiveConfig.phi_range
178 HoughTransform.r_max_mm=flags.Trigger.FPGATrackSim.ActiveConfig.r_max_mm
179 HoughTransform.bitwise_qApt_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_qApt_conv
180 HoughTransform.bitwise_phi0_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_phi0_conv
181 HoughTransform.phi0_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.phi0_sectors
182 HoughTransform.qApt_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.qApt_sectors
183 HoughTransform.pipes_qApt=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_qApt
184 HoughTransform.pipes_phi0=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_phi0
186 tools.append(HoughTransform)
189 result.addPublicTool(RF, primary=
True)
195 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
196 splitpt=flags.Trigger.FPGATrackSim.Hough1D.splitpt
197 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
198 for ptstep
in range(splitpt):
199 qpt_min = flags.Trigger.FPGATrackSim.Hough1D.qptMin
200 qpt_max = flags.Trigger.FPGATrackSim.Hough1D.qptMax
201 lowpt = qpt_min + (qpt_max-qpt_min)/splitpt*ptstep
202 highpt = qpt_min + (qpt_max-qpt_min)/splitpt*(ptstep+1)
204 for iSlice
in range(nSlice):
205 tool = CompFactory.FPGATrackSimHough1DShiftTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
206 "Hough1DShift" +
str(iSlice)+((
"_pt{}".
format(ptstep))
if splitpt>1
else "")))
207 tool.subRegion = iSlice
if nSlice > 1
else -1
208 xMin = flags.Trigger.FPGATrackSim.Hough1D.phiMin
209 xMax = flags.Trigger.FPGATrackSim.Hough1D.phiMax
210 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
211 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
218 tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
220 tool.variableExtend =
True
221 tool.drawHitMasks =
False
222 tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
226 tool.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
227 tool.hitExtend = flags.Trigger.FPGATrackSim.Hough1D.hitExtendX
228 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
230 tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
231 tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
232 tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
237 result.addPublicTool(RF, primary=
True)
245 print(
"logLevel",flags.Trigger.FPGATrackSim.loglevel)
249 if flags.Trigger.FPGATrackSim.oldRegionDefs:
250 toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
251 if toload ==
'FPGATrackSimGenScanCuts':
252 toload =
'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
253 cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
256 cutpath = os.path.join(
258 f
"{flags.Trigger.FPGATrackSim.GenScan.genScanCuts}.py")
259 print(
"Cut File = ", cutpath)
260 spec=importlib.util.spec_from_file_location(flags.Trigger.FPGATrackSim.GenScan.genScanCuts,cutpath)
262 print(
"Failed to find Cut File")
263 cutmodule = importlib.util.module_from_spec(spec)
264 spec.loader.exec_module(cutmodule)
265 cutset=cutmodule.cuts[flags.Trigger.FPGATrackSim.region]
268 BinnnedHits = CompFactory.FPGATrackSimBinnedHits(
"BinnedHits_1stStage")
269 BinnnedHits.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
270 BinnnedHits.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
273 if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
274 if flags.Trigger.FPGATrackSim.oldRegionDefs:
275 BinnnedHits.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
278 f
"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
280 if flags.Trigger.FPGATrackSim.GenScan.useLayerRadiiFile:
281 BinnnedHits.layerRadiiFile =os.path.join(
283 f
"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
285 BinnnedHits.layerMapFile =os.path.join(
287 f
"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
293 BinTool = CompFactory.FPGATrackSimBinTool(
"BinTool_1stStage")
294 BinTool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
299 if (cutset[
"parSet"]==
"PhiSlicedKeyLyrPars") :
300 BinDesc = CompFactory.FPGATrackSimKeyLayerBinDesc(
"KeyLayerBinDesc")
301 BinDesc.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
302 BinDesc.rin=cutset[
"rin"]
303 BinDesc.rout=cutset[
"rout"]
304 if flags.Trigger.FPGATrackSim.GenScan.useLayerRadiiFile:
305 phirange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
306 phicenter = (phirange[0]+phirange[1])/2.0
307 BinDesc.PhiOffset = -1.0*phicenter
309 BinDesc.region = flags.Trigger.FPGATrackSim.region
312 step1 = CompFactory.FPGATrackSimBinStep(
"PhiBinning")
313 step1.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
314 step1.parBins = [1,1,cutset[
"parBins"][2],cutset[
"parBins"][3],cutset[
"parBins"][4]]
315 step2 = CompFactory.FPGATrackSimBinStep(
"FullBinning")
316 step2.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
317 step2.parBins = cutset[
"parBins"]
318 binsteps = [step1,step2]
320 log.error(
"Unknown Binning Setup: ",cutset[
"parSet"])
322 BinTool.BinDesc = BinDesc
323 BinTool.Steps=binsteps
327 BinTool.d0FractionalPadding =0.05
328 BinTool.z0FractionalPadding =0.05
329 BinTool.etaFractionalPadding =0.05
330 BinTool.phiFractionalPadding =0.05
331 BinTool.qOverPtFractionalPadding =0.05
332 BinTool.parMin = cutset[
"parMin"]
333 BinTool.parMax = cutset[
"parMax"]
334 BinnnedHits.BinTool = BinTool
338 Monitor = CompFactory.FPGATrackSimGenScanMonitoring(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanMonitoring"))
339 Monitor.dir =
"/GENSCAN/"+FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanMonitoring")+
"/"
340 Monitor.THistSvc = CompFactory.THistSvc()
341 Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
342 Monitor.phiScale = 10.0
343 Monitor.etaScale = 100.0
344 Monitor.drScale = 20.0
347 tool = CompFactory.FPGATrackSimGenScanTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanTool"))
348 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
349 tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
350 tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
351 tool.Monitoring = Monitor
352 tool.BinnedHits = BinnnedHits
353 tool.rin=cutset[
"rin"]
354 tool.rout=cutset[
"rout"]
357 tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
359 tool.etaChi2Weight_4hits = weights[0]
360 tool.phiChi2Weight_4hits = weights[1]
361 tool.etaChi2Weight_5hits = weights[2]
362 tool.phiChi2Weight_5hits = weights[3]
365 tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
366 tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
367 tool.applyPairFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
368 tool.applyPairSetFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
369 tool.keepHitsStrategy = flags.Trigger.FPGATrackSim.GenScan.keepHitsStrategy
373 for (cut,val)
in cutset.items():
374 if cut
in [
"parBins",
"parSet",
"parMin",
"parMax"]:
376 setattr(tool,cut,val)
380 RoadUnion = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
381 RoadUnion.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
382 RoadUnion.tools = [tool,]
383 result.addPublicTool(RoadUnion, primary=
True)
388 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
389 RoadUnion.noHitFilter=
True
390 tool.binningOnly=
True
395 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
396 RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
398 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNPatternRecoTool"))
399 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNGraphHitSelectorTool"))
402 result.merge(edgeResult)
403 patternRecoTool.GNNEdgeClassifiers = edgeClassifierTools
406 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
407 patternRecoTool.regionNum =
int(flags.Trigger.FPGATrackSim.region)
409 RF.tools = [patternRecoTool]
410 result.addPublicTool(RF, primary=
True)
417 GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
418 GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
419 GNNGraphConstructionTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
423 GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
424 GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
425 GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
428 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
429 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
431 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
432 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
435 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
437 result.setPrivateTools(GNNGraphConstructionTool)
444 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
445 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
447 region =
int(flags.Trigger.FPGATrackSim.region)
448 model_path = f
"{flags.Trigger.FPGATrackSim.GNN.GNNModelPath}_{region}.onnx"
450 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(
451 FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags, name))
452 GNNEdgeClassifierTool.GNNInferenceTool = result.popToolsAndMerge(
455 GNNEdgeClassifierTool.regionNum = region
457 return result, [GNNEdgeClassifierTool]
462 GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
463 GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
464 GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
465 GNNRoadMakerTool.doGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
466 GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
468 from TrigFastTrackFinder.TrigFastTrackFinderConfig
import ITkTrigL2LayerNumberToolCfg
471 result.setPrivateTools(GNNRoadMakerTool)
478 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
479 GNNRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
481 if(flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput):
482 result.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
483 result.setPrivateTools(GNNRootOutputTool)
489 DataFlowTool = CompFactory.FPGATrackSimDataFlowTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
490 DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
491 DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
492 DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
493 DataFlowTool.THistSvc = CompFactory.THistSvc()
494 result.setPrivateTools(DataFlowTool)
499 HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
500 HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
501 HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
502 HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
503 HoughRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
504 result.setPrivateTools(HoughRootOutputTool)
510 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
512 LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
513 LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
514 LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
515 LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
516 LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
517 LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
518 result.setPrivateTools(LRTRoadFinder)
523 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
524 NNTrackTool.THistSvc = CompFactory.THistSvc()
525 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
527 NNTrackTool.IdealGeoRoads =
False
528 NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
530 NNTrackTool.MinNumberOfRealHitsInATrack = 5
if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else 7
if flags.Trigger.FPGATrackSim.ActiveConfig.GNN
else 9
531 NNTrackTool.useSectors =
False
532 NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
533 NNTrackTool.nInputsGNN = flags.Trigger.FPGATrackSim.GNN.nInputsGNN
534 NNTrackTool.useCartesian = flags.Trigger.FPGATrackSim.NNCartesianCoordinates
535 result.setPrivateTools(NNTrackTool)
540 TF_1st = CompFactory.FPGATrackSimTrackFitterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
541 TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
542 TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
544 TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
545 TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
546 TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
547 TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
548 TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
549 TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
550 TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
551 TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
552 TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
554 TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
555 result.addPublicTool(TF_1st, primary=
True)
560 OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
561 OR_1st.ORAlgo =
"Normal"
562 OR_1st.doFastOR = flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
563 OR_1st.NumOfHitPerGrouping = 3
564 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
565 OR_1st.MinChi2 =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
566 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
567 OR_1st.MinChi2 =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
569 OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
570 if flags.Trigger.FPGATrackSim.ActiveConfig.hough
or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
571 OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
572 OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
573 OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
574 OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
576 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimOverlapRemovalToolMonitoringCfg
579 result.addPublicTool(OR_1st, primary=
True)
583 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=
True)
588 name=
"FPGATrackSimSpacepointRoadFilterTool_1st"
590 name=
"FPGATrackSimSpacepointRoadFilterTool_2st"
591 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
592 SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
594 SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
595 SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
596 SPRoadFilter.isSecondStage = secondStage
597 SPRoadFilter.dropUnpairedIfSP = flags.Trigger.FPGATrackSim.dropUnpairedIfSP
602 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
604 SPRoadFilter.threshold = 1
606 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
607 result.setPrivateTools(SPRoadFilter)
618 kwargs.setdefault(
"name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
620 theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg(**kwargs)
621 theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
622 theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
623 theFPGATrackSimLogicalHitsProcessAlg.SetTruthParametersForTracks = flags.Trigger.FPGATrackSim.SetTruthParametersForTracks
624 theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
625 theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
626 theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
627 theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
628 theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
629 theFPGATrackSimLogicalHitsProcessAlg.DoGNNTrack = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
630 theFPGATrackSimLogicalHitsProcessAlg.DoGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
631 theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
632 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
633 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
634 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
635 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
637 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
638 theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
639 theFPGATrackSimLogicalHitsProcessAlg.secondStageStrips = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
640 FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
641 theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
643 theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
645 if flags.Trigger.FPGATrackSim.tracking
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
648 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
650 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
652 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
657 if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
658 EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimEtaPatternFilterTool"))
659 EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
660 EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
661 EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+
"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+
".patt"
662 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
663 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads =
True
665 if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
666 RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimPhiRoadFilterTool"))
667 RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
668 RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
669 RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
671 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow
for i
in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
672 RoadFilter2.window = windows
674 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
675 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 =
True
681 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimLLPRoadFilterTool"))
682 result.addPublicTool(LRTRoadFilter)
683 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
685 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(
LRTRoadFinderCfg(flags))
686 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(
NNTrackToolCfg(flags))
688 theFPGATrackSimLogicalHitsProcessAlg.writeInputBranches=flags.Trigger.FPGATrackSim.writeAdditionalOutputData
and (flags.Trigger.FPGATrackSim.regionToWriteDPTree < 0)
693 theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
694 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
696 if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
697 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter,
'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
698 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT,
'Inconsistent LRT HT setup, need either double or strightTrack enabled'
699 theFPGATrackSimLogicalHitsProcessAlg.doLRT =
True
700 theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (
not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
704 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimTrackMonCfg
707 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage', flags, variety=
'road'))
709 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter1Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_filter_1', flags, variety=
'road'))
711 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostOverlapRemovalMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_overlap_removal', flags, variety=
'road'))
713 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_filter_2', flags, variety=
'road'))
716 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage', flags, variety=
'track'))
718 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostSetTruthMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_set_truth', flags, variety=
'track'))
720 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostChi2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_chi2', flags, variety=
'track'))
722 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostOverlapRemovalTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_overlap_removal', flags, variety=
'track'))
724 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
732 chi2cut_l = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 20]
734 side = (region >> 5) & 0x1
735 etaBin = (region >> 6) & 0x1F
736 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
738 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
741 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
742 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
743 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
744 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
745 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
746 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
747 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
750 return eta_to_chi2.get(abs_etaRange, 20)
753 chi2cut_l = [0.97,0.97,0.99,
761 side = (region >> 5) & 0x1
762 etaBin = (region >> 6) & 0x1F
763 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
765 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
768 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
769 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
770 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
771 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
772 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
773 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
774 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
776 return eta_to_chi2.get(abs_etaRange, 0.99)
781 if flags.Trigger.FPGATrackSim.regionList ==
"":
782 flags.Trigger.FPGATrackSim.regionList = [flags.Trigger.FPGATrackSim.region]
784 from FPGATrackSimConfTools.FPGATrackSimHelperFunctions
import convertRegionsExpressionToArray
786 print(f
"Running for regions: {flags.Trigger.FPGATrackSim.regionList}")
790 FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepFlagCfg(flags)
792 flags.Scheduler.ShowDataDeps=
True
793 flags.Scheduler.CheckDependencies=
True
794 flags.Debug.DumpEvtStore=
False
796 flags.Trigger.FPGATrackSim.readOfflineObjects=
False
797 flags.Trigger.FPGATrackSim.doMultiTruth=
False
799 flags.Trigger.FPGATrackSim.tracking =
False
800 flags.Trigger.FPGATrackSim.Hough.genScan =
True
801 flags.Trigger.FPGATrackSim.convertSPs =
False
802 flags.Tracking.ITkActsValidateF150Pass.doActsSpacePoint =
not flags.Trigger.FPGATrackSim.convertSPs
803 flags.Trigger.FPGATrackSim.Hough.secondStage =
False
805 flags.Trigger.FPGATrackSim.regionList=
"34,98,162,226,290,354,418,482,546,610,674,738,802,866,930,994,1058,1122,1186,1250"
812 if not flags.Trigger.FPGATrackSim.runOnPreProducedHeaderFiles:
813 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimClusteringCfg(flags))
815 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
818 from FPGATrackSimConfTools.FPGATrackSimMergeOutputsConfig
import FPGATrackSimMergeOutputsAlgCfg
821 from FPGATrackSimSeeding.FPGATrackSimSeedingConfig
import FPGATrackSimSeedingCfg
825 if flags.Tracking.ActiveConfig.storeTrackSeeds:
826 from ActsConfig.ActsSeedingConfig
import ActsStoreTrackSeedsCfg
827 from InDetConfig.ITkActsHelpers
import isFastPrimaryPass
830 processPixels =
True,
837 if(flags.Trigger.FPGATrackSim.runF150hw):
838 from EFTrackingFPGAPipeline.F150KernelTesterConfig
import KernelTesterCfg, F150EDMConversionAlgCfg
847 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
848 acc.addService(CompFactory.THistSvc(Output = [
"EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
850 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
851 acc.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
853 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
854 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
856 if (flags.Trigger.FPGATrackSim.Hough.genScan):
857 acc.addService(CompFactory.THistSvc(Output = [
"GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
860 if __name__ ==
"__main__":
861 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
862 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
869 FinalProtoTrackChainxAODTracksKey=
"FPGA"
870 flags.Detector.EnableCalo =
False
873 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
874 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
875 from ActsConfig.ActsCIFlags
import actsLegacyWorkflowFlags
877 flags.Acts.doRotCorrection =
False
880 flags.Concurrency.NumThreads=1
881 flags.Concurrency.NumConcurrentEvents=1
882 flags.Concurrency.NumProcs=0
883 flags.Scheduler.ShowDataDeps=
True
884 flags.Scheduler.CheckDependencies=
True
885 flags.Debug.DumpEvtStore=
False
893 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
894 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
895 assert not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-5'),
"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
897 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
898 print(
"You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
899 FPGATrackSimDataPrepConfig.runDataPrepChain()
900 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-2')):
901 print(
"You are trying to run an F-2* pipeline! I am auto-configuring the 1D bitshift for you, including eta pattern filters and phi road filters")
902 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
True
903 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
True
904 flags.Trigger.FPGATrackSim.Hough.hough1D =
True
905 flags.Trigger.FPGATrackSim.Hough.hough =
False
906 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-3')):
907 print(
"You are trying to run an F-3* pipeline! I am auto-configuring the 2D HT for you, and disabling the eta pattern filter and phi road filter. Whether you wanted to or not")
908 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
False
909 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
False
910 flags.Trigger.FPGATrackSim.Hough.hough1D =
False
911 flags.Trigger.FPGATrackSim.Hough.hough =
True
912 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-4')):
913 print(
"You are trying to run an F-4* pipeline! I am auto-configuring the GNN pattern recognition for you. Whether you wanted to or not")
914 flags.Trigger.FPGATrackSim.Hough.GNN =
True
915 flags.Trigger.FPGATrackSim.Hough.chi2cut = 40
916 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
917 print(
"You are trying to run an F-6* pipeline! I am auto-configuring the Inside-Out for you. Whether you wanted to or not")
918 flags.Trigger.FPGATrackSim.Hough.genScan=
True
919 flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
920 elif (flags.Trigger.FPGATrackSim.pipeline !=
""):
921 raise AssertionError(
"ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline +
" which is not yet supported!")
923 if (
not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
925 flags.Tracking.writeExtendedSi_PRDInfo =
not flags.Trigger.FPGATrackSim.writeOfflPRDInfo
926 splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split(
'-')
927 trackingOption=9999999
928 if (len(splitPipeline) > 1): trackingOption=
int(splitPipeline[1])
929 if (trackingOption < 9999999):
930 trackingOptionMod = (trackingOption % 100)
931 if (trackingOptionMod == 0):
932 print(
"You are trying to run the linearized chi2 fit as part of a pipeline! I am going to enable this for you whether you want to or not")
933 flags.Trigger.FPGATrackSim.tracking =
True
934 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
935 elif (trackingOptionMod == 10):
936 print(
"You are trying to run the second stage NN fake rejection as part of a pipeline! I am going to enable this for you whether you want to or not")
937 flags.Trigger.FPGATrackSim.tracking =
True
938 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
True
939 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
940 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
941 flags.Trigger.FPGATrackSim.doNNPathFinder =
True
942 flags.Trigger.FPGATrackSim.doOverlapRemoval =
False
943 flags.Trigger.FPGATrackSim.tracking =
False
944 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
945 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
947 raise AssertionError(
"ERROR Your tracking option for the pipeline = " +
str(trackingOption) +
" is not yet supported!")
949 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
950 log.info(
"wrapperFile is string, converting to list")
951 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
952 flags.Input.Files =
lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
954 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
955 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
959 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass")
964 if not flags.Trigger.FPGATrackSim.wrapperFileName:
965 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
969 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
972 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
975 if flags.Detector.EnableCalo:
976 from CaloRec.CaloRecoConfig
import CaloRecoCfg
979 if flags.Tracking.recoChain:
980 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
982 if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
983 from InDetConfig.InDetPrepRawDataToxAODConfig
import ITkActsPrepDataToxAODCfg
985 PixelMeasurementContainer =
"ITkPixelMeasurements_offl",
986 StripMeasurementContainer =
"ITkStripMeasurements_offl" ) )
987 from InDetConfig.InDetPrepRawDataToxAODConfig
import TruthParticleIndexDecoratorAlgCfg
989 from InDetConfig.InDetPrepRawDataFormationConfig
import ITkXAODToInDetClusterConversionCfg
994 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
996 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
999 if flags.Trigger.FPGATrackSim.doEDMConversion:
1000 stage =
"_2nd" if flags.Trigger.FPGATrackSim.Hough.secondStage
else "_1st"
1001 acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = f
"FPGAConversionAlg{stage}",
1004 doSP=flags.Trigger.FPGATrackSim.convertSPs))
1006 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig
import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
1008 acc.merge(
FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey))
1009 if flags.Trigger.FPGATrackSim.runCKF:
1010 from FPGATrackSimConfTools.FPGATrackExtensionConfig
import FPGATrackExtensionAlgCfg
1012 ProtoTracksLocation=f
"ActsProtoTracks{stage}FromFPGATrack"))
1014 if flags.Trigger.FPGATrackSim.writeToAOD:
1015 acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
1017 finalTrackParticles=f
"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
1020 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
1022 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType !=
'skipTruth')
and flags.Exec.MaxEvents<=10 ) ))
1024 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
1026 acc.foreach_component(
"*FPGATrackSim*").OutputLevel=flags.Trigger.FPGATrackSim.loglevel
1027 if flags.Trigger.FPGATrackSim.msgLimit!=-1:
1028 acc.getService(
"MessageSvc").debugLimit = flags.Trigger.FPGATrackSim.msgLimit
1029 acc.getService(
"MessageSvc").infoLimit = flags.Trigger.FPGATrackSim.msgLimit
1030 acc.getService(
"MessageSvc").verboseLimit = flags.Trigger.FPGATrackSim.msgLimit
1032 statusCode = acc.run(flags.Exec.MaxEvents)
1033 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"