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
47 if flags.Trigger.FPGATrackSim.writeRegion>=0:
48 FPGATrackSimWriteOutput.RequireActivation=
True
51 FPGATrackSimWriteOutput.RWstatus =
"HEADER"
52 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
53 result.setPrivateTools(FPGATrackSimWriteOutput)
58 FPGATrackSimSlicingEngineTool = CompFactory.FPGATrackSimSlicingEngineTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
60 FPGATrackSimSlicingEngineTool.LayerMap = os.path.join(
PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),f
"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
61 FPGATrackSimSlicingEngineTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
63 FPGATrackSimSlicingEngineTool.doSecondStage = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
64 FPGATrackSimSlicingEngineTool.RootOutput = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
65 result.setPrivateTools(FPGATrackSimSlicingEngineTool)
70 FPGATrackSimBankSvc = CompFactory.FPGATrackSimBankSvc(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
71 FPGATrackSimBankSvc.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
72 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/'
74 FPGATrackSimBankSvc.constantsNoGuess_1st = [
75 f
'{pathBankSvc}corrgen_raw_8L_skipPlane0.gcon',
76 f
'{pathBankSvc}corrgen_raw_8L_skipPlane1.gcon',
77 f
'{pathBankSvc}corrgen_raw_8L_skipPlane2.gcon',
78 f
'{pathBankSvc}corrgen_raw_8L_skipPlane3.gcon',
79 f
'{pathBankSvc}corrgen_raw_8L_skipPlane4.gcon',
80 f
'{pathBankSvc}corrgen_raw_8L_skipPlane5.gcon',
81 f
'{pathBankSvc}corrgen_raw_8L_skipPlane6.gcon',
82 f
'{pathBankSvc}corrgen_raw_8L_skipPlane7.gcon']
83 FPGATrackSimBankSvc.constantsNoGuess_2nd = [
84 f
'{pathBankSvc}corrgen_raw_13L_skipPlane0.gcon',
85 f
'{pathBankSvc}corrgen_raw_13L_skipPlane1.gcon',
86 f
'{pathBankSvc}corrgen_raw_13L_skipPlane2.gcon',
87 f
'{pathBankSvc}corrgen_raw_13L_skipPlane3.gcon',
88 f
'{pathBankSvc}corrgen_raw_13L_skipPlane4.gcon',
89 f
'{pathBankSvc}corrgen_raw_13L_skipPlane5.gcon',
90 f
'{pathBankSvc}corrgen_raw_13L_skipPlane6.gcon',
91 f
'{pathBankSvc}corrgen_raw_13L_skipPlane7.gcon']
92 layers=
"5L" if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else "9L"
94 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/'
96 pmap_file = os.path.join(pathMapSvc, f
"region{flags.Trigger.FPGATrackSim.region}.pmap")
97 with open(pmap_file)
as f:
99 if 'logical_s2' in line:
100 s2_layers =
int(line.strip().
split()[0])
102 FPGATrackSimBankSvc.constants_1st = f
'{pathBankSvc}corrgen_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
103 FPGATrackSimBankSvc.constants_2nd = f
'{pathBankSvc}corrgen_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
104 FPGATrackSimBankSvc.sectorBank_1st = f
'{pathBankSvc}sectorsHW_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
105 FPGATrackSimBankSvc.sectorBank_2nd = f
'{pathBankSvc}sectorsHW_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
106 FPGATrackSimBankSvc.sectorSlices = f
'{pathBankSvc}slices_{layers}_reg{flags.Trigger.FPGATrackSim.region}.root'
107 FPGATrackSimBankSvc.phiShift = flags.Trigger.FPGATrackSim.phiShift
110 FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
111 FPGATrackSimBankSvc.qptAbsBinning =
False
113 result.addService(FPGATrackSimBankSvc, create=
True, primary=
True)
119 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
121 xBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBins
122 xBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
123 yBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBins
124 yBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
125 yMin = flags.Trigger.FPGATrackSim.ActiveConfig.qptMin
126 yMax = flags.Trigger.FPGATrackSim.ActiveConfig.qptMax
127 xMin = flags.Trigger.FPGATrackSim.ActiveConfig.phiMin
128 xMax = flags.Trigger.FPGATrackSim.ActiveConfig.phiMax
129 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
130 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
134 xBuffer = (xMax - xMin) / xBins * xBufferBins
135 xMin = xMin - xBuffer
136 xMax = xMax + xBuffer
137 yBuffer = (yMax - yMin) / yBins * yBufferBins
141 houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
142 roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
145 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
147 HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimHoughTransformTool")+
"_" +
str(number))
148 HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
150 HoughTransform.FPGATrackSimMappingSvc = FPGATrackSimMapping
151 HoughTransform.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.combineLayers
152 HoughTransform.convSize_x = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeX
153 HoughTransform.convSize_y = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeY
154 HoughTransform.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.convolution
155 HoughTransform.d0_max = 0
156 HoughTransform.d0_min = 0
157 HoughTransform.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
158 HoughTransform.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX
159 HoughTransform.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
160 HoughTransform.nBins_x = xBins + 2 * xBufferBins
161 HoughTransform.nBins_y = yBins + 2 * yBufferBins
162 HoughTransform.phi_max = xMax
163 HoughTransform.phi_min = xMin
164 HoughTransform.qpT_max = yMax
165 HoughTransform.qpT_min = yMin
166 HoughTransform.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
167 HoughTransform.subRegion = number
168 HoughTransform.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold
169 HoughTransform.traceHits =
True
170 HoughTransform.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
171 HoughTransform.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
172 HoughTransform.houghType = houghType
173 HoughTransform.roadMerge = roadMerge
174 if houghType==
'LowResource':
175 HoughTransform.requirements = flags.Trigger.FPGATrackSim.ActiveConfig.requirements
176 if houghType==
'Flexible':
177 HoughTransform.r_max=flags.Trigger.FPGATrackSim.ActiveConfig.r_max
178 HoughTransform.phi_coord_max=flags.Trigger.FPGATrackSim.ActiveConfig.phi_coord_max
179 HoughTransform.phi_range=flags.Trigger.FPGATrackSim.ActiveConfig.phi_range
180 HoughTransform.r_max_mm=flags.Trigger.FPGATrackSim.ActiveConfig.r_max_mm
181 HoughTransform.bitwise_qApt_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_qApt_conv
182 HoughTransform.bitwise_phi0_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_phi0_conv
183 HoughTransform.phi0_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.phi0_sectors
184 HoughTransform.qApt_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.qApt_sectors
185 HoughTransform.pipes_qApt=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_qApt
186 HoughTransform.pipes_phi0=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_phi0
188 tools.append(HoughTransform)
191 result.addPublicTool(RF, primary=
True)
197 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
198 splitpt=flags.Trigger.FPGATrackSim.Hough1D.splitpt
199 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
200 for ptstep
in range(splitpt):
201 qpt_min = flags.Trigger.FPGATrackSim.Hough1D.qptMin
202 qpt_max = flags.Trigger.FPGATrackSim.Hough1D.qptMax
203 lowpt = qpt_min + (qpt_max-qpt_min)/splitpt*ptstep
204 highpt = qpt_min + (qpt_max-qpt_min)/splitpt*(ptstep+1)
206 for iSlice
in range(nSlice):
207 tool = CompFactory.FPGATrackSimHough1DShiftTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
208 "Hough1DShift" +
str(iSlice)+((
"_pt{}".
format(ptstep))
if splitpt>1
else "")))
209 tool.subRegion = iSlice
if nSlice > 1
else -1
210 xMin = flags.Trigger.FPGATrackSim.Hough1D.phiMin
211 xMax = flags.Trigger.FPGATrackSim.Hough1D.phiMax
212 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
213 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
220 tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
222 tool.variableExtend =
True
223 tool.drawHitMasks =
False
224 tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
228 tool.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
229 tool.hitExtend = flags.Trigger.FPGATrackSim.Hough1D.hitExtendX
230 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
232 tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
233 tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
234 tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
239 result.addPublicTool(RF, primary=
True)
247 print(
"logLevel",flags.Trigger.FPGATrackSim.loglevel)
251 if flags.Trigger.FPGATrackSim.oldRegionDefs:
252 toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
253 if toload ==
'FPGATrackSimGenScanCuts':
254 toload =
'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
255 cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
258 cutpath = os.path.join(
260 f
"{flags.Trigger.FPGATrackSim.GenScan.genScanCuts}.py")
261 print(
"Cut File = ", cutpath)
262 spec=importlib.util.spec_from_file_location(flags.Trigger.FPGATrackSim.GenScan.genScanCuts,cutpath)
264 print(
"Failed to find Cut File")
265 cutmodule = importlib.util.module_from_spec(spec)
266 spec.loader.exec_module(cutmodule)
267 cutset=cutmodule.cuts[flags.Trigger.FPGATrackSim.region]
270 BinnnedHits = CompFactory.FPGATrackSimBinnedHits(
"BinnedHits_1stStage")
271 BinnnedHits.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
272 BinnnedHits.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
275 if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
276 if flags.Trigger.FPGATrackSim.oldRegionDefs:
277 BinnnedHits.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
280 f
"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
282 if flags.Trigger.FPGATrackSim.GenScan.useLayerRadiiFile:
283 BinnnedHits.layerRadiiFile =os.path.join(
285 f
"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
287 BinnnedHits.layerMapFile =os.path.join(
289 f
"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
295 BinTool = CompFactory.FPGATrackSimBinTool(
"BinTool_1stStage")
296 BinTool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
301 if (cutset[
"parSet"]==
"PhiSlicedKeyLyrPars") :
302 BinDesc = CompFactory.FPGATrackSimKeyLayerBinDesc(
"KeyLayerBinDesc")
303 BinDesc.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
304 BinDesc.rin=cutset[
"rin"]
305 BinDesc.rout=cutset[
"rout"]
306 if flags.Trigger.FPGATrackSim.GenScan.useLayerRadiiFile:
307 phirange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
308 phicenter = (phirange[0]+phirange[1])/2.0
309 BinDesc.PhiOffset = -1.0*phicenter
311 BinDesc.region = flags.Trigger.FPGATrackSim.region
314 step1 = CompFactory.FPGATrackSimBinStep(
"PhiBinning")
315 step1.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
316 step1.parBins = [1,1,cutset[
"parBins"][2],cutset[
"parBins"][3],cutset[
"parBins"][4]]
317 step2 = CompFactory.FPGATrackSimBinStep(
"FullBinning")
318 step2.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
319 step2.parBins = cutset[
"parBins"]
320 binsteps = [step1,step2]
322 log.error(
"Unknown Binning Setup: ",cutset[
"parSet"])
324 BinTool.BinDesc = BinDesc
325 BinTool.Steps=binsteps
329 BinTool.d0FractionalPadding =0.05
330 BinTool.z0FractionalPadding =0.05
331 BinTool.etaFractionalPadding =0.05
332 BinTool.phiFractionalPadding =0.05
333 BinTool.qOverPtFractionalPadding =0.05
334 BinTool.parMin = cutset[
"parMin"]
335 BinTool.parMax = cutset[
"parMax"]
336 BinnnedHits.BinTool = BinTool
340 Monitor = CompFactory.FPGATrackSimGenScanMonitoring(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanMonitoring"))
341 Monitor.dir =
"/GENSCAN/"+FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanMonitoring")+
"/"
342 Monitor.THistSvc = CompFactory.THistSvc()
343 Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
344 Monitor.phiScale = 10.0
345 Monitor.etaScale = 100.0
346 Monitor.drScale = 20.0
349 tool = CompFactory.FPGATrackSimGenScanTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanTool"))
350 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
351 tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
352 tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
353 tool.Monitoring = Monitor
354 tool.BinnedHits = BinnnedHits
355 tool.rin=cutset[
"rin"]
356 tool.rout=cutset[
"rout"]
359 tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
361 tool.etaChi2Weight_4hits = weights[0]
362 tool.phiChi2Weight_4hits = weights[1]
363 tool.etaChi2Weight_5hits = weights[2]
364 tool.phiChi2Weight_5hits = weights[3]
367 tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
368 tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
369 tool.applyPairFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
370 tool.applyPairSetFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
371 tool.keepHitsStrategy = flags.Trigger.FPGATrackSim.GenScan.keepHitsStrategy
375 for (cut,val)
in cutset.items():
376 if cut
in [
"parBins",
"parSet",
"parMin",
"parMax"]:
378 setattr(tool,cut,val)
382 RoadUnion = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
383 RoadUnion.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
384 RoadUnion.tools = [tool,]
385 result.addPublicTool(RoadUnion, primary=
True)
390 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
391 RoadUnion.noHitFilter=
True
392 tool.binningOnly=
True
397 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
398 RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
400 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNPatternRecoTool"))
401 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNGraphHitSelectorTool"))
404 result.merge(edgeResult)
405 patternRecoTool.GNNEdgeClassifiers = edgeClassifierTools
408 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
409 patternRecoTool.regionNum =
int(flags.Trigger.FPGATrackSim.region)
411 RF.tools = [patternRecoTool]
412 result.addPublicTool(RF, primary=
True)
419 GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
420 GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
421 GNNGraphConstructionTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
425 GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
426 GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
427 GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
430 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
431 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
433 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
434 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
437 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
439 result.setPrivateTools(GNNGraphConstructionTool)
446 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
447 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
449 region =
int(flags.Trigger.FPGATrackSim.region)
450 model_path = f
"{flags.Trigger.FPGATrackSim.GNN.GNNModelPath}_{region}.onnx"
452 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(
453 FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags, name))
454 GNNEdgeClassifierTool.GNNInferenceTool = result.popToolsAndMerge(
457 GNNEdgeClassifierTool.regionNum = region
459 return result, [GNNEdgeClassifierTool]
464 GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
465 GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
466 GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
467 GNNRoadMakerTool.doGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
468 GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
470 from TrigFastTrackFinder.TrigFastTrackFinderConfig
import ITkTrigL2LayerNumberToolCfg
473 result.setPrivateTools(GNNRoadMakerTool)
480 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
481 GNNRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
483 if(flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput):
484 result.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
485 result.setPrivateTools(GNNRootOutputTool)
491 DataFlowTool = CompFactory.FPGATrackSimDataFlowTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
492 DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
493 DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
494 DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
495 DataFlowTool.THistSvc = CompFactory.THistSvc()
496 result.setPrivateTools(DataFlowTool)
501 HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
502 HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
503 HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
504 HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
505 HoughRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
506 result.setPrivateTools(HoughRootOutputTool)
512 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
514 LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
515 LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
516 LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
517 LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
518 LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
519 LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
520 result.setPrivateTools(LRTRoadFinder)
525 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
526 NNTrackTool.THistSvc = CompFactory.THistSvc()
527 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
529 NNTrackTool.IdealGeoRoads =
False
530 NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
532 NNTrackTool.MinNumberOfRealHitsInATrack = 5
if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else 7
if flags.Trigger.FPGATrackSim.ActiveConfig.GNN
else 9
533 NNTrackTool.useSectors =
False
534 NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
535 NNTrackTool.nInputsGNN = flags.Trigger.FPGATrackSim.GNN.nInputsGNN
536 NNTrackTool.useCartesian = flags.Trigger.FPGATrackSim.NNCartesianCoordinates
537 result.setPrivateTools(NNTrackTool)
542 TF_1st = CompFactory.FPGATrackSimTrackFitterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
543 TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
544 TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
546 TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
547 TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
548 TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
549 TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
550 TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
551 TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
552 TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
553 TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
554 TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
556 TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
557 result.addPublicTool(TF_1st, primary=
True)
562 OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
563 OR_1st.ORAlgo =
"Normal"
564 OR_1st.doFastOR = flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
565 OR_1st.NumOfHitPerGrouping = 3
566 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
567 OR_1st.MinChi2 =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
568 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
569 OR_1st.MinChi2 =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
571 OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
572 if flags.Trigger.FPGATrackSim.ActiveConfig.hough
or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
573 OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
574 OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
575 OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
576 OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
578 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimOverlapRemovalToolMonitoringCfg
581 result.addPublicTool(OR_1st, primary=
True)
585 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=
True)
590 name=
"FPGATrackSimSpacepointRoadFilterTool_1st"
592 name=
"FPGATrackSimSpacepointRoadFilterTool_2st"
593 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
594 SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
596 SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
597 SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
598 SPRoadFilter.isSecondStage = secondStage
599 SPRoadFilter.dropUnpairedIfSP = flags.Trigger.FPGATrackSim.dropUnpairedIfSP
604 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
606 SPRoadFilter.threshold = 1
608 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
609 result.setPrivateTools(SPRoadFilter)
620 kwargs.setdefault(
"name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
622 theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg(**kwargs)
623 theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
624 theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
625 theFPGATrackSimLogicalHitsProcessAlg.SetTruthParametersForTracks = flags.Trigger.FPGATrackSim.SetTruthParametersForTracks
626 theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
627 theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
628 theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
629 theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
630 theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
631 theFPGATrackSimLogicalHitsProcessAlg.DoGNNTrack = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
632 theFPGATrackSimLogicalHitsProcessAlg.DoGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
633 theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
634 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
635 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
636 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
637 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
639 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
640 theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
641 theFPGATrackSimLogicalHitsProcessAlg.secondStageStrips = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
642 FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
643 theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
645 theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
647 if flags.Trigger.FPGATrackSim.tracking
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
650 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
652 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
654 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
659 if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
660 EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimEtaPatternFilterTool"))
661 EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
662 EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
663 EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+
"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+
".patt"
664 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
665 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads =
True
667 if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
668 RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimPhiRoadFilterTool"))
669 RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
670 RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
671 RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
673 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow
for i
in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
674 RoadFilter2.window = windows
676 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
677 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 =
True
682 theFPGATrackSimLogicalHitsProcessAlg.writeRegion=flags.Trigger.FPGATrackSim.writeRegion
684 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimLLPRoadFilterTool"))
685 result.addPublicTool(LRTRoadFilter)
686 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
688 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(
LRTRoadFinderCfg(flags))
689 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(
NNTrackToolCfg(flags))
691 theFPGATrackSimLogicalHitsProcessAlg.writeInputBranches=flags.Trigger.FPGATrackSim.writeAdditionalOutputData
and (flags.Trigger.FPGATrackSim.regionToWriteDPTree < 0)
696 theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
697 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
699 if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
700 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter,
'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
701 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT,
'Inconsistent LRT HT setup, need either double or strightTrack enabled'
702 theFPGATrackSimLogicalHitsProcessAlg.doLRT =
True
703 theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (
not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
707 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimTrackMonCfg
710 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage', flags, variety=
'road'))
712 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter1Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_filter_1', flags, variety=
'road'))
714 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostOverlapRemovalMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_overlap_removal', flags, variety=
'road'))
716 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_filter_2', flags, variety=
'road'))
719 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage', flags, variety=
'track'))
721 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostSetTruthMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_set_truth', flags, variety=
'track'))
723 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostChi2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_chi2', flags, variety=
'track'))
725 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostOverlapRemovalTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg (
'first_stage_post_overlap_removal', flags, variety=
'track'))
727 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
735 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]
737 side = (region >> 5) & 0x1
738 etaBin = (region >> 6) & 0x1F
739 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
741 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
744 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
745 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
746 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
747 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
748 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
749 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
750 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
753 return eta_to_chi2.get(abs_etaRange, 20)
756 chi2cut_l = [0.97,0.97,0.99,
764 side = (region >> 5) & 0x1
765 etaBin = (region >> 6) & 0x1F
766 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
768 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
771 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
772 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
773 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
774 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
775 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
776 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
777 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
779 return eta_to_chi2.get(abs_etaRange, 0.99)
784 if flags.Trigger.FPGATrackSim.regionList ==
"":
785 flags.Trigger.FPGATrackSim.regionList = [flags.Trigger.FPGATrackSim.region]
787 from FPGATrackSimConfTools.FPGATrackSimHelperFunctions
import convertRegionsExpressionToArray
789 print(f
"Running for regions: {flags.Trigger.FPGATrackSim.regionList}")
793 FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepFlagCfg(flags)
795 flags.Scheduler.ShowDataDeps=
True
796 flags.Scheduler.CheckDependencies=
True
797 flags.Debug.DumpEvtStore=
False
799 flags.Trigger.FPGATrackSim.readOfflineObjects=
False
800 flags.Trigger.FPGATrackSim.doMultiTruth=
False
802 flags.Trigger.FPGATrackSim.tracking =
False
803 flags.Trigger.FPGATrackSim.Hough.genScan =
True
804 flags.Trigger.FPGATrackSim.convertSPs =
False
805 flags.Tracking.ITkActsValidateF150Pass.doActsSpacePoint =
not flags.Trigger.FPGATrackSim.convertSPs
806 flags.Trigger.FPGATrackSim.Hough.secondStage =
False
808 flags.Trigger.FPGATrackSim.regionList=
"34,98,162,226,290,354,418,482,546,610,674,738,802,866,930,994,1058,1122,1186,1250"
815 if not flags.Trigger.FPGATrackSim.runOnPreProducedHeaderFiles:
816 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimClusteringCfg(flags))
818 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
821 from FPGATrackSimConfTools.FPGATrackSimMergeOutputsConfig
import FPGATrackSimMergeOutputsAlgCfg
824 from FPGATrackSimSeeding.FPGATrackSimSeedingConfig
import FPGATrackSimSeedingCfg
828 if flags.Tracking.ActiveConfig.storeTrackSeeds:
829 from ActsConfig.ActsSeedingConfig
import ActsStoreTrackSeedsCfg
830 from InDetConfig.ITkActsHelpers
import isFastPrimaryPass
833 processPixels =
True,
840 if(flags.Trigger.FPGATrackSim.runF150hw):
841 from EFTrackingFPGAPipeline.F100IntegrationConfig
import F100DataEncodingCfg
844 from EFTrackingFPGAPipeline.F150KernelTesterConfig
import KernelTesterCfg, F150EDMConversionAlgCfg
851 acc.printConfig(withDetails=
True, summariseProps=
True)
857 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
858 acc.addService(CompFactory.THistSvc(Output = [
"EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
860 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
861 acc.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
863 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
864 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
866 if (flags.Trigger.FPGATrackSim.Hough.genScan):
867 acc.addService(CompFactory.THistSvc(Output = [
"GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
870 if __name__ ==
"__main__":
871 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
872 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
879 FinalProtoTrackChainxAODTracksKey=
"FPGA"
880 flags.Detector.EnableCalo =
False
883 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
884 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
885 from ActsConfig.ActsCIFlags
import actsLegacyWorkflowFlags
887 flags.Acts.doRotCorrection =
False
890 flags.Concurrency.NumThreads=1
891 flags.Concurrency.NumConcurrentEvents=1
892 flags.Concurrency.NumProcs=0
893 flags.Scheduler.ShowDataDeps=
True
894 flags.Scheduler.CheckDependencies=
True
895 flags.Debug.DumpEvtStore=
False
903 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
904 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
905 assert not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-5'),
"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
907 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
908 print(
"You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
909 FPGATrackSimDataPrepConfig.runDataPrepChain()
910 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-2')):
911 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")
912 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
True
913 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
True
914 flags.Trigger.FPGATrackSim.Hough.hough1D =
True
915 flags.Trigger.FPGATrackSim.Hough.hough =
False
916 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-3')):
917 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")
918 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
False
919 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
False
920 flags.Trigger.FPGATrackSim.Hough.hough1D =
False
921 flags.Trigger.FPGATrackSim.Hough.hough =
True
922 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-4')):
923 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")
924 flags.Trigger.FPGATrackSim.Hough.GNN =
True
925 flags.Trigger.FPGATrackSim.Hough.chi2cut = 40
926 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
927 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")
928 flags.Trigger.FPGATrackSim.Hough.genScan=
True
929 flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
930 elif (flags.Trigger.FPGATrackSim.pipeline !=
""):
931 raise AssertionError(
"ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline +
" which is not yet supported!")
933 if (
not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
935 flags.Tracking.writeExtendedSi_PRDInfo =
not flags.Trigger.FPGATrackSim.writeOfflPRDInfo
936 splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split(
'-')
937 trackingOption=9999999
938 if (len(splitPipeline) > 1): trackingOption=
int(splitPipeline[1])
939 if (trackingOption < 9999999):
940 trackingOptionMod = (trackingOption % 100)
941 if (trackingOptionMod == 0):
942 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")
943 flags.Trigger.FPGATrackSim.tracking =
True
944 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
945 elif (trackingOptionMod == 10):
946 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")
947 flags.Trigger.FPGATrackSim.tracking =
True
948 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
True
949 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
950 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
951 flags.Trigger.FPGATrackSim.doNNPathFinder =
True
952 flags.Trigger.FPGATrackSim.doOverlapRemoval =
False
953 flags.Trigger.FPGATrackSim.tracking =
False
954 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
955 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
957 raise AssertionError(
"ERROR Your tracking option for the pipeline = " +
str(trackingOption) +
" is not yet supported!")
959 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
960 log.info(
"wrapperFile is string, converting to list")
961 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
962 flags.Input.Files =
lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
964 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
965 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
969 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass")
974 if not flags.Trigger.FPGATrackSim.wrapperFileName:
975 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
979 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
982 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
985 if flags.Detector.EnableCalo:
986 from CaloRec.CaloRecoConfig
import CaloRecoCfg
989 if flags.Tracking.recoChain:
990 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
992 if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
993 from InDetConfig.InDetPrepRawDataToxAODConfig
import ITkActsPrepDataToxAODCfg
995 PixelMeasurementContainer =
"ITkPixelMeasurements_offl",
996 StripMeasurementContainer =
"ITkStripMeasurements_offl" ) )
997 from InDetConfig.InDetPrepRawDataToxAODConfig
import TruthParticleIndexDecoratorAlgCfg
999 from InDetConfig.InDetPrepRawDataFormationConfig
import ITkXAODToInDetClusterConversionCfg
1004 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
1005 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
1008 if flags.Trigger.FPGATrackSim.doEDMConversion:
1009 stage =
"_2nd" if flags.Trigger.FPGATrackSim.Hough.secondStage
else "_1st"
1010 acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = f
"FPGAConversionAlg{stage}",
1013 doSP=flags.Trigger.FPGATrackSim.convertSPs))
1015 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig
import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
1017 acc.merge(
FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey))
1018 if flags.Trigger.FPGATrackSim.runCKF:
1019 from FPGATrackSimConfTools.FPGATrackExtensionConfig
import FPGATrackExtensionAlgCfg
1021 ProtoTracksLocation=f
"ActsProtoTracks{stage}FromFPGATrack"))
1023 if flags.Trigger.FPGATrackSim.writeToAOD:
1024 acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
1026 finalTrackParticles=f
"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
1029 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
1031 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType !=
'skipTruth')
and flags.Exec.MaxEvents<=10 ) ))
1033 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
1035 acc.foreach_component(
"*FPGATrackSim*").OutputLevel=flags.Trigger.FPGATrackSim.loglevel
1036 if flags.Trigger.FPGATrackSim.msgLimit!=-1:
1037 acc.getService(
"MessageSvc").debugLimit = flags.Trigger.FPGATrackSim.msgLimit
1038 acc.getService(
"MessageSvc").infoLimit = flags.Trigger.FPGATrackSim.msgLimit
1039 acc.getService(
"MessageSvc").verboseLimit = flags.Trigger.FPGATrackSim.msgLimit
1041 statusCode = acc.run(flags.Exec.MaxEvents)
1042 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"