ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimAnalysisConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3from AthenaConfiguration.ComponentFactory import CompFactory
4from AthenaCommon.Logging import AthenaLogger
5from PathResolver import PathResolver
6import importlib
7import os
8
9log = AthenaLogger(__name__)
10
11
12from FPGATrackSimConfTools import FPGATrackSimDataPrepConfig
13
14
15def getEtaBin(flags):
16 etaBin = (flags.Trigger.FPGATrackSim.region >> 6) & 0x1f
17 return etaBin
18
19def getFitWeights(etaBin):
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]
24
25 assert(etaBin >= 0 and etaBin < 20)
26 return [weight4Eta[etaBin], weight4Phi[etaBin], weights5Eta[etaBin], weights5Phi[etaBin]]
27
28def getNSubregions(filePath):
29 with open(PathResolver.FindCalibFile(filePath), 'r') as f:
30 fields = f.readline()
31 assert(fields.startswith('towers'))
32 n = fields.split()[1]
33 return int(n)
34
35
36# Need to figure out if we have two output writers or somehow only one.
38 result=ComponentAccumulator()
39 FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool("FPGATrackSimWriteOutput")
40 FPGATrackSimWriteOutput.InFileName = ["test.root"]
41 FPGATrackSimWriteOutput.OutputTreeName = FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimLogicalEventTree")
42
43 if not flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
44 FPGATrackSimWriteOutput.EventLimit = 0
45 else:
46 FPGATrackSimWriteOutput.EventLimit = flags.Trigger.FPGATrackSim.writeOutputEventLimit
47 if flags.Trigger.FPGATrackSim.writeRegion>=0: # negative is off
48 FPGATrackSimWriteOutput.RequireActivation=True
49 # RECREATE means that that this tool opens the file.
50 # HEADER would mean that something else (e.g. THistSvc) opens it and we just add the object.
51 FPGATrackSimWriteOutput.RWstatus = "HEADER"
52 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
53 result.setPrivateTools(FPGATrackSimWriteOutput)
54 return result
55
56def FPGATrackSimSlicingEngineCfg(flags,name="FPGATrackSimSlicingEngineTool"):
57 result = ComponentAccumulator()
58 FPGATrackSimSlicingEngineTool = CompFactory.FPGATrackSimSlicingEngineTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
59 # this is the same as the layer map used by the genscan/inside out tool below.
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))
62 # If the GNN is enabled (i.e. this is F-4xx) then we don't want to separate first vs second stage.
63 FPGATrackSimSlicingEngineTool.doSecondStage = (not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
64 FPGATrackSimSlicingEngineTool.RootOutput = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
65 result.setPrivateTools(FPGATrackSimSlicingEngineTool)
66 return result
67
68def FPGATrackSimBankSvcCfg(flags,name="FPGATrackSimBankSvc"):
69 result=ComponentAccumulator()
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/'
73 pathBankSvc=PathResolver.FindCalibDirectory(pathBankSvc)
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"
93 s2_layers = 13
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/'
95 pathMapSvc = PathResolver.FindCalibDirectory(pathMapSvc)
96 pmap_file = os.path.join(pathMapSvc, f"region{flags.Trigger.FPGATrackSim.region}.pmap")
97 with open(pmap_file) as f:
98 for line in f:
99 if 'logical_s2' in line:
100 s2_layers = int(line.strip().split()[0])
101 break
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
108
109 # These should be configurable. The tag system needs updating though.
110 FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
111 FPGATrackSimBankSvc.qptAbsBinning = False
112
113 result.addService(FPGATrackSimBankSvc, create=True, primary=True)
114 return result
115
116
117def FPGATrackSimRoadUnionToolCfg(flags,name="FPGATrackSimRoadUnionTool"):
118 result=ComponentAccumulator()
119 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
120
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)
131 xMin = phiRange[0]
132 xMax = phiRange[1]
133
134 xBuffer = (xMax - xMin) / xBins * xBufferBins
135 xMin = xMin - xBuffer
136 xMax = xMax + xBuffer
137 yBuffer = (yMax - yMin) / yBins * yBufferBins
138 yMin -= yBuffer
139 yMax += yBuffer
140 tools = []
141 houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
142 roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
143
144
145 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
146 for number in range(getNSubregions(FPGATrackSimMapping.subrmap)):
147 HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimHoughTransformTool")+"_" + str(number))
148 HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
149 HoughTransform.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(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
187
188 tools.append(HoughTransform)
189
190 RF.tools = tools
191 result.addPublicTool(RF, primary=True)
192 return result
193
194def FPGATrackSimRoadUnionTool1DCfg(flags,name="FPGATrackSimRoadUnionTool1D"):
195 result=ComponentAccumulator()
196 tools = []
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)
205 nSlice = getNSubregions(FPGATrackSimMapping.subrmap)
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)
214 xMin = phiRange[0]
215 xMax = phiRange[1]
216 tool.phiMin = xMin
217 tool.phiMax = xMax
218 tool.qptMin = lowpt
219 tool.qptMax = highpt
220 tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
221 tool.useDiff = True
222 tool.variableExtend = True
223 tool.drawHitMasks = False
224 tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
225 tool.d0spread=-1.0 # mm
226 tool.iterStep = 0 # auto, TODO put in tag
227 tool.iterLayer = 7 # TODO put in tag
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))
231 tool.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(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
235
236 tools.append(tool)
237
238 RF.tools = tools
239 result.addPublicTool(RF, primary=True)
240 return result
241
242
243
244def FPGATrackSimRoadUnionToolGenScanCfg(flags,name="FPGATrackSimRoadUnionToolGenScan"):
245 result=ComponentAccumulator()
246
247 print("logLevel",flags.Trigger.FPGATrackSim.loglevel)
248
249 # read the cuts from a seperate python file specified by FPGATrackSim.GenScan.genScanCuts
250 cutset=None
251 if flags.Trigger.FPGATrackSim.oldRegionDefs:
252 toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
253 if toload == 'FPGATrackSimGenScanCuts': # its on the newRegion default so it hasn't been set
254 toload = 'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
255 cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
256 else:
257 # this allows the cut file defined in python to be loaded from the map directory
258 cutpath = os.path.join(
259 PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
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)
263 if spec is None:
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]
268
269 # make the binned hits class
270 BinnnedHits = CompFactory.FPGATrackSimBinnedHits("BinnedHits_1stStage")
271 BinnnedHits.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
272 BinnnedHits.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
273
274 # set layer map
275 if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
276 if flags.Trigger.FPGATrackSim.oldRegionDefs:
277 BinnnedHits.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
278 else:
279 print("Loading Layer Radii from ", PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
280 f"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
281 # now assumed to be in the map directory with name = basename for region + _lyrmap.json
282 if flags.Trigger.FPGATrackSim.GenScan.useLayerRadiiFile:
283 BinnnedHits.layerRadiiFile =os.path.join(
284 PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
285 f"regioneta{FPGATrackSimDataPrepConfig.getEtaSideBits(flags)}_lyrradii.json")
286 else:
287 BinnnedHits.layerMapFile =os.path.join(
288 PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
289 f"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
290
291
292
293
294 # make the bintool class
295 BinTool = CompFactory.FPGATrackSimBinTool("BinTool_1stStage")
296 BinTool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
297
298 # Inputs for the BinTool
299 binsteps=[]
300 BinDesc=None
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
310
311 BinDesc.region = flags.Trigger.FPGATrackSim.region
312 # parameters for key layer bindesc are :"zR1", "zR2", "phiR1", "phiR2", "xm"
313 step1 = CompFactory.FPGATrackSimBinStep("PhiBinning")
314 step1.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
315 step1.parBins = [1,1,cutset["parBins"][2],cutset["parBins"][3],cutset["parBins"][4]]
316 step2 = CompFactory.FPGATrackSimBinStep("FullBinning")
317 step2.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
318 step2.parBins = cutset["parBins"]
319 binsteps = [step1,step2]
320 else:
321 log.error("Unknown Binning Setup: ",cutset["parSet"])
322
323 BinTool.BinDesc = BinDesc
324 BinTool.Steps=binsteps
325
326
327 # configure the padding around the nominal region
328 BinTool.d0FractionalPadding =0.05
329 BinTool.z0FractionalPadding =0.05
330 BinTool.etaFractionalPadding =0.05
331 BinTool.phiFractionalPadding =0.05
332 BinTool.qOverPtFractionalPadding =0.05
333 BinTool.parMin = cutset["parMin"]
334 BinTool.parMax = cutset["parMax"]
335 BinnnedHits.BinTool = BinTool
336
337
338 # make the monitoring class
339 Monitor = CompFactory.FPGATrackSimGenScanMonitoring(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"GenScanMonitoring"))
340 Monitor.dir = "/GENSCAN/"+FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"GenScanMonitoring")+"/"
341 Monitor.THistSvc = CompFactory.THistSvc()
342 Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
343 Monitor.phiScale = 10.0
344 Monitor.etaScale = 100.0
345 Monitor.drScale = 20.0
346
347 # make the main tool
348 tool = CompFactory.FPGATrackSimGenScanTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"GenScanTool"))
349 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
350 tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
351 tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
352 tool.Monitoring = Monitor
353 tool.BinnedHits = BinnnedHits
354 tool.rin=cutset["rin"]
355 tool.rout=cutset["rout"]
356
357 # For the 'track fitter' part of GenScanTool.
358 tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
359 weights = getFitWeights(getEtaBin(flags))
360 tool.etaChi2Weight_4hits = weights[0]
361 tool.phiChi2Weight_4hits = weights[1]
362 tool.etaChi2Weight_5hits = weights[2]
363 tool.phiChi2Weight_5hits = weights[3]
364
365 # configure which filers and thresholds to apply
366 tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
367 tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
368 tool.applyPairFilter= not flags.Trigger.FPGATrackSim.GenScan.noCuts
369 tool.applyPairSetFilter= not flags.Trigger.FPGATrackSim.GenScan.noCuts
370 tool.keepHitsStrategy = flags.Trigger.FPGATrackSim.GenScan.keepHitsStrategy
371 tool.threshold = 4
372
373 # set cuts
374 for (cut,val) in cutset.items():
375 if cut in ["parBins","parSet","parMin","parMax"]:
376 continue
377 setattr(tool,cut,val)
378
379 # even though we are not actually doing a Union, we need the
380 # RoadUnionTool because mapping is now there
381 RoadUnion = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
382 RoadUnion.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
383 RoadUnion.tools = [tool,]
384 result.addPublicTool(RoadUnion, primary=True)
385
386 # special configuration for studing layer definitions
387 # pass through all hits, but turn off pairing because
388 # it won't be able to run
389 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
390 RoadUnion.noHitFilter=True
391 tool.binningOnly=True
392 return result
393
394def FPGATrackSimRoadUnionToolGNNCfg(flags,name="FPGATrackSimRoadUnionToolGNN"):
395 result = ComponentAccumulator()
396 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
397 RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
398
399 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimGNNPatternRecoTool"))
400 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimGNNGraphHitSelectorTool"))
401 patternRecoTool.GNNGraphConstruction = result.popToolsAndMerge(FPGATrackSimGNNGraphConstructionToolCfg(flags))
402 edgeResult, edgeClassifierTools = FPGATrackSimGNNEdgeClassifierToolCfg(flags)
403 result.merge(edgeResult)
404 patternRecoTool.GNNEdgeClassifiers = edgeClassifierTools
405 patternRecoTool.GNNRoadMaker = result.popToolsAndMerge(FPGATrackSimGNNRoadMakerToolCfg(flags))
406 patternRecoTool.GNNRootOutput = result.popToolsAndMerge(FPGATrackSimGNNRootOutputToolCfg(flags))
407 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
408 patternRecoTool.regionNum = int(flags.Trigger.FPGATrackSim.region)
409
410 RF.tools = [patternRecoTool]
411 result.addPublicTool(RF, primary=True)
412
413 return result
414
415def FPGATrackSimGNNGraphConstructionToolCfg(flags,name="FPGATrackSimGNNGraphConstructionTool"):
416 result = ComponentAccumulator()
417
418 GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
419 GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
420 GNNGraphConstructionTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
421
422
423 # Module Map Configuration
424 GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
425 GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
426 GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
427
428 # Metric Learning Configuration
429 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
430 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
431
432 from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
433 from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
434
435 GNNGraphConstructionTool.MLInferenceTool = result.popToolsAndMerge(OnnxRuntimeInferenceToolCfg(
436 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
437
438 result.setPrivateTools(GNNGraphConstructionTool)
439
440 return result
441
442def FPGATrackSimGNNEdgeClassifierToolCfg(flags, name="FPGATrackSimGNNEdgeClassifierTool"):
443 result = ComponentAccumulator()
444
445 from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
446 from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
447
448 region = int(flags.Trigger.FPGATrackSim.region)
449 model_path = f"{flags.Trigger.FPGATrackSim.GNN.GNNModelPath}_{region}.onnx"
450
451 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(
452 FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags, name))
453 GNNEdgeClassifierTool.GNNInferenceTool = result.popToolsAndMerge(
454 OnnxRuntimeInferenceToolCfg(flags, model_path, OnnxRuntimeType.CPU, name=f"OnnxInferenceTool_{region}")
455 )
456 GNNEdgeClassifierTool.regionNum = region
457
458 return result, [GNNEdgeClassifierTool]
459
460def FPGATrackSimGNNRoadMakerToolCfg(flags,name="FPGATrackSimGNNRoadMakerTool"):
461 result = ComponentAccumulator()
462
463 GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
464 GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
465 GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
466 GNNRoadMakerTool.doGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
467 GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
468
469 from TrigFastTrackFinder.TrigFastTrackFinderConfig import ITkTrigL2LayerNumberToolCfg
470 GNNRoadMakerTool.LayerNumberTool = result.getPrimaryAndMerge(ITkTrigL2LayerNumberToolCfg(flags))
471
472 result.setPrivateTools(GNNRoadMakerTool)
473
474 return result
475
476def FPGATrackSimGNNRootOutputToolCfg(flags,name="FPGATrackSimGNNRootOutputTool"):
477 result = ComponentAccumulator()
478
479 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
480 GNNRootOutputTool.OutputRegion = str(flags.Trigger.FPGATrackSim.region)
481
482 if(flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput):
483 result.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
484 result.setPrivateTools(GNNRootOutputTool)
485
486 return result
487
488def FPGATrackSimDataFlowToolCfg(flags,name="FPGATrackSimDataFlowTool"):
489 result=ComponentAccumulator()
490 DataFlowTool = CompFactory.FPGATrackSimDataFlowTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
491 DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
492 DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
493 DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
494 DataFlowTool.THistSvc = CompFactory.THistSvc()
495 result.setPrivateTools(DataFlowTool)
496 return result
497
498def FPGATrackSimHoughRootOutputToolCfg(flags,name="FPGATrackSimHoughRootOutputTool"):
499 result=ComponentAccumulator()
500 HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
501 HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
502 HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
503 HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
504 HoughRootOutputTool.OutputRegion = str(flags.Trigger.FPGATrackSim.region)
505 result.setPrivateTools(HoughRootOutputTool)
506 return result
507
508def LRTRoadFinderCfg(flags,name="LRTRoadFinder"):
509
510 result=ComponentAccumulator()
511 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
512 LRTRoadFinder.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
513 LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
514 LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
515 LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
516 LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
517 LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
518 LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
519 result.setPrivateTools(LRTRoadFinder)
520 return result
521
522def NNTrackToolCfg(flags,name="FPGATrackSimNNTrackTool"):
523 result=ComponentAccumulator()
524 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
525 NNTrackTool.THistSvc = CompFactory.THistSvc()
526 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
527 NNTrackTool.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
528 NNTrackTool.IdealGeoRoads = False
529 NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
530 NNTrackTool.SPRoadFilterTool = result.popToolsAndMerge(SPRoadFilterToolCfg(flags))
531 NNTrackTool.MinNumberOfRealHitsInATrack = 5 if flags.Trigger.FPGATrackSim.ActiveConfig.genScan else 7 if flags.Trigger.FPGATrackSim.ActiveConfig.GNN else 9
532 NNTrackTool.useSectors = False
533 NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
534 NNTrackTool.nInputsGNN = flags.Trigger.FPGATrackSim.GNN.nInputsGNN
535 NNTrackTool.useCartesian = flags.Trigger.FPGATrackSim.NNCartesianCoordinates
536 result.setPrivateTools(NNTrackTool)
537 return result
538
539def FPGATrackSimTrackFitterToolCfg(flags,name="FPGATrackSimTrackFitterTool"):
540 result=ComponentAccumulator()
541 TF_1st = CompFactory.FPGATrackSimTrackFitterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
542 TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
543 TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
544 TF_1st.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
545 TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
546 TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
547 TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
548 TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
549 TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
550 TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
551 TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
552 TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
553 TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
554 TF_1st.SPRoadFilterTool = result.popToolsAndMerge(SPRoadFilterToolCfg(flags))
555 TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
556 result.addPublicTool(TF_1st, primary=True)
557 return result
558
559def FPGATrackSimOverlapRemovalToolCfg(flags,name="FPGATrackSimOverlapRemovalTool"):
560 result=ComponentAccumulator()
561 OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
562 OR_1st.ORAlgo = "Normal"
563 OR_1st.doFastOR = flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
564 OR_1st.NumOfHitPerGrouping = 3
565 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
566 OR_1st.MinChi2 = getChi2Cut(flags.Trigger.FPGATrackSim.region)
567 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
568 OR_1st.MinChi2 = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
569 else:
570 OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
571 if flags.Trigger.FPGATrackSim.ActiveConfig.hough or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
572 OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
573 OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
574 OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
575 OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
576
577 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig import FPGATrackSimOverlapRemovalToolMonitoringCfg
578 OR_1st.MonTool = result.getPrimaryAndMerge(FPGATrackSimOverlapRemovalToolMonitoringCfg(flags))
579
580 result.addPublicTool(OR_1st, primary=True)
581 return result
582
584 newFlags = flags.cloneAndReplace("Trigger.FPGATrackSim.ActiveConfig", "Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=True)
585 return newFlags
586
587def SPRoadFilterToolCfg(flags,secondStage=False,name="FPGATrackSimSpacepointRoadFilterTool"):
588 result=ComponentAccumulator()
589 name="FPGATrackSimSpacepointRoadFilterTool_1st"
590 if secondStage:
591 name="FPGATrackSimSpacepointRoadFilterTool_2st"
592 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
593 SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
594 SPRoadFilter.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
595 SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
596 SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
597 SPRoadFilter.isSecondStage = secondStage
598 SPRoadFilter.dropUnpairedIfSP = flags.Trigger.FPGATrackSim.dropUnpairedIfSP
599
600 # This threshold is the number of *missing* hits allowed. For now, assume that if 1st stage this is always 1.
601 # We don't actually run this tool in the first stage anymore, so this is more to preserve backwards compatibility
602 if secondStage:
603 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
604 else:
605 SPRoadFilter.threshold = 1
606
607 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
608 result.setPrivateTools(SPRoadFilter)
609 return result
610
611
612
613
614def FPGATrackSimLogicalHitsProcessAlgCfg(inputFlags,name="FPGATrackSimLogicalHitsProcessAlg",**kwargs):
615
617
618 result=ComponentAccumulator()
619 kwargs.setdefault("name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
620
621 theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg(**kwargs)
622 theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
623 theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
624 theFPGATrackSimLogicalHitsProcessAlg.SetTruthParametersForTracks = flags.Trigger.FPGATrackSim.SetTruthParametersForTracks
625 theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
626 theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
627 theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
628 theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
629 theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
630 theFPGATrackSimLogicalHitsProcessAlg.DoGNNTrack = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
631 theFPGATrackSimLogicalHitsProcessAlg.DoGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
632 theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
633 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
634 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = getChi2Cut(flags.Trigger.FPGATrackSim.region)
635 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
636 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
637 else:
638 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
639 theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
640 theFPGATrackSimLogicalHitsProcessAlg.secondStageStrips = (not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
641 FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
642 theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
643 # Adding region so we can set it for tracks, then get the bfield
644 theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
645 # If tracking is set to False or if we do the NN analysis, don't configure the bank service
646 if flags.Trigger.FPGATrackSim.tracking and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
647 result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
648
649 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
650 theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionTool1DCfg(flags))
651 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
652 theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolGenScanCfg(flags))
653 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
654 theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolGNNCfg(flags))
655 else:
656 theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolCfg(flags))
657
658 if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
659 EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimEtaPatternFilterTool"))
660 EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
661 EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
662 EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+".patt"
663 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
664 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads = True
665
666 if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
667 RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimPhiRoadFilterTool"))
668 RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
669 RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
670 RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
671
672 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow for i in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
673 RoadFilter2.window = windows
674
675 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
676 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 = True
677
678 theFPGATrackSimLogicalHitsProcessAlg.SlicingEngineTool = result.getPrimaryAndMerge(FPGATrackSimSlicingEngineCfg(flags))
679
680 theFPGATrackSimLogicalHitsProcessAlg.HoughRootOutputTool = result.getPrimaryAndMerge(FPGATrackSimHoughRootOutputToolCfg(flags))
681 theFPGATrackSimLogicalHitsProcessAlg.writeRegion=flags.Trigger.FPGATrackSim.writeRegion
682
683 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimLLPRoadFilterTool"))
684 result.addPublicTool(LRTRoadFilter)
685 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
686
687 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(LRTRoadFinderCfg(flags))
688 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(NNTrackToolCfg(flags))
689
690 theFPGATrackSimLogicalHitsProcessAlg.writeInputBranches=flags.Trigger.FPGATrackSim.writeAdditionalOutputData and (flags.Trigger.FPGATrackSim.regionToWriteDPTree < 0)
691 theFPGATrackSimLogicalHitsProcessAlg.OutputTool = result.popToolsAndMerge(FPGATrackSimWriteOutputCfg(flags))
692 theFPGATrackSimLogicalHitsProcessAlg.TrackFitter_1st = result.getPrimaryAndMerge(FPGATrackSimTrackFitterToolCfg(flags))
693 theFPGATrackSimLogicalHitsProcessAlg.OverlapRemoval_1st = result.getPrimaryAndMerge(FPGATrackSimOverlapRemovalToolCfg(flags))
694
695 theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
696 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
697
698 if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
699 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter, 'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
700 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT, 'Inconsistent LRT HT setup, need either double or strightTrack enabled'
701 theFPGATrackSimLogicalHitsProcessAlg.doLRT = True
702 theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
703
704
705
706 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig import FPGATrackSimTrackMonCfg
707
708
709 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage', flags, variety='road'))
710
711 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter1Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_filter_1', flags, variety='road'))
712
713 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostOverlapRemovalMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_overlap_removal', flags, variety='road'))
714
715 theFPGATrackSimLogicalHitsProcessAlg.FirstStageRoadPostFilter2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_filter_2', flags, variety='road'))
716
717
718 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage', flags, variety='track'))
719
720 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostSetTruthMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_set_truth', flags, variety='track'))
721
722 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostChi2Monitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_chi2', flags, variety='track'))
723
724 theFPGATrackSimLogicalHitsProcessAlg.FirstStageTrackPostOverlapRemovalTrackMonitor = result.getPrimaryAndMerge(FPGATrackSimTrackMonCfg ('first_stage_post_overlap_removal', flags, variety='track'))
725
726 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
727
728 return result
729
730
731
732
733def getChi2Cut(region):
734 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] #from most recent run on this branch with new maps/banks, all chi2's are under 1
735 binSize = 0.2
736 side = (region >> 5) & 0x1
737 etaBin = (region >> 6) & 0x1F
738 etaRange = [round(binSize * etaBin, 1), round(binSize * (etaBin + 1), 1)] if side else [round(-binSize * (etaBin + 1), 1), round(-binSize * etaBin, 1)]
739
740 abs_etaRange = tuple(round(abs(val), 1) for val in etaRange)
741
742 eta_to_chi2 = {
743 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
744 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
745 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
746 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
747 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
748 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
749 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
750 }
751
752 return eta_to_chi2.get(abs_etaRange, 20)
753
754def getChi2CutNN(region):
755 chi2cut_l = [0.97,0.97,0.99,
756 0.7,0.86,0.99,
757 0.98,0.92,0.98,
758 0.95,0.93,0.4,
759 0.4,0.4,0.7,
760 0.6,0.5,0.4,
761 0.4,0.4]
762 binSize = 0.2
763 side = (region >> 5) & 0x1
764 etaBin = (region >> 6) & 0x1F
765 etaRange = [round(binSize * etaBin, 1), round(binSize * (etaBin + 1), 1)] if side else [round(-binSize * (etaBin + 1), 1), round(-binSize * etaBin, 1)]
766
767 abs_etaRange = tuple(round(abs(val), 1) for val in etaRange)
768
769 eta_to_chi2 = {
770 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
771 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
772 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
773 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
774 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
775 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
776 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
777 }
778 return eta_to_chi2.get(abs_etaRange, 0.99)
779
780
782 FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepFlagCfg(flags)
783
784 flags.Scheduler.ShowDataDeps=True
785 flags.Scheduler.CheckDependencies=True
786 flags.Debug.DumpEvtStore=False
787
788 flags.Trigger.FPGATrackSim.readOfflineObjects=False
789 flags.Trigger.FPGATrackSim.doMultiTruth=False
790
791 flags.Trigger.FPGATrackSim.tracking = False
792 flags.Trigger.FPGATrackSim.Hough.genScan = True
793 flags.Trigger.FPGATrackSim.convertSPs = False # in case we need the conversion to take place on hw we'll have to convert to SPs after the cluster-sorting (will probably need new algorithm)
794 flags.Tracking.ITkActsValidateF150Pass.doActsSpacePoint = not flags.Trigger.FPGATrackSim.convertSPs
795 flags.Trigger.FPGATrackSim.Hough.secondStage = False
796 flags.Trigger.FPGATrackSim.loadRadii=False
797 flags.Trigger.FPGATrackSim.FakeNNonnxFile1st=''
798 flags.Trigger.FPGATrackSim.ParamNNonnxFile1st=''
799 flags.Trigger.FPGATrackSim.FakeNNonnxFile2nd=''
800 flags.Trigger.FPGATrackSim.ParamNNonnxFile2nd=''
801 flags.Trigger.FPGATrackSim.ExtensionNNVolonnxFile=''
802 flags.Trigger.FPGATrackSim.ExtensionNNHitonnxFile=''
803
804 return flags
805
807 acc=ComponentAccumulator()
808 if not flags.Trigger.FPGATrackSim.runOnPreProducedHeaderFiles:
809 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimClusteringCfg(flags))
810
811 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig import FPGATrackSimMultiRegionTrackingCfg
812 acc.merge(FPGATrackSimMultiRegionTrackingCfg(flags))
813 else:
814 from FPGATrackSimConfTools.FPGATrackSimMergeOutputsConfig import FPGATrackSimMergeOutputsAlgCfg
815 acc.merge(FPGATrackSimMergeOutputsAlgCfg(flags))
816
817 from FPGATrackSimSeeding.FPGATrackSimSeedingConfig import FPGATrackSimSeedingCfg
818 acc.merge(FPGATrackSimSeedingCfg(flags))
819
820
821 if flags.Tracking.ActiveConfig.storeTrackSeeds:
822 from ActsConfig.ActsSeedingConfig import ActsStoreTrackSeedsCfg
823 from InDetConfig.ITkActsHelpers import isFastPrimaryPass
824
825 acc.merge(ActsStoreTrackSeedsCfg(flags,
826 processPixels = True,
827 processStrips = not isFastPrimaryPass(flags)))
828
829
831
832 # for testing hardware run in F150
833 if(flags.Trigger.FPGATrackSim.runF150hw):
834 from EFTrackingFPGAPipeline.F100IntegrationConfig import F100DataEncodingCfg
835 acc.merge(F100DataEncodingCfg(flags))
836
837 from EFTrackingFPGAPipeline.F150KernelTesterConfig import KernelTesterCfg, F150EDMConversionAlgCfg
838 acc.merge(KernelTesterCfg(flags))
839 acc.merge(F150EDMConversionAlgCfg(flags))
840
841
842
843
844 acc.printConfig(withDetails=True, summariseProps=True)
845
846 return acc
847
849 acc=ComponentAccumulator()
850 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
851 acc.addService(CompFactory.THistSvc(Output = ["EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
852
853 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
854 acc.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
855
856 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
857 acc.addService(CompFactory.THistSvc(Output = ["FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
858
859 if (flags.Trigger.FPGATrackSim.Hough.genScan):
860 acc.addService(CompFactory.THistSvc(Output = ["GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
861 return acc
862
863if __name__ == "__main__":
864 from AthenaConfiguration.AllConfigFlags import initConfigFlags
865 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
866
867
868 flags = initConfigFlags()
869
870
872 FinalProtoTrackChainxAODTracksKey="FPGA"
873 flags.Detector.EnableCalo = False
874
875 # ensure that the xAOD SP and cluster containers are available
876 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=True
877 flags.Tracking.ITkMainPass.doAthenaToActsCluster=True
878 from ActsConfig.ActsCIFlags import actsLegacyWorkflowFlags
879 actsLegacyWorkflowFlags(flags)
880 flags.Acts.doRotCorrection = False
881
882
883 flags.Concurrency.NumThreads=1
884 flags.Concurrency.NumConcurrentEvents=1
885 flags.Concurrency.NumProcs=0
886 flags.Scheduler.ShowDataDeps=True
887 flags.Scheduler.CheckDependencies=True
888 flags.Debug.DumpEvtStore=False
889
890 # flags.Exec.DebugStage="exec" # useful option to debug the execution of the job - we want it commented out for production
891 flags.fillFromArgs()
892
893
894 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
895 flags.Trigger.FPGATrackSim.Hough.chi2cut = getChi2Cut(flags.Trigger.FPGATrackSim.region)
896 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
898 if (flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
899 print("You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
900 FPGATrackSimDataPrepConfig.runDataPrepChain()
901 elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-2')):
902 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")
903 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = True
904 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = True
905 flags.Trigger.FPGATrackSim.Hough.hough1D = True
906 flags.Trigger.FPGATrackSim.Hough.hough = False
907 elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-3')):
908 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")
909 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = False
910 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = False
911 flags.Trigger.FPGATrackSim.Hough.hough1D = False
912 flags.Trigger.FPGATrackSim.Hough.hough = True
913 elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-4')):
914 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")
915 flags.Trigger.FPGATrackSim.Hough.GNN = True
916 flags.Trigger.FPGATrackSim.Hough.chi2cut = 40 # All of the track candidates have chi2 values around 20 for some reason. Needs further investigation. For now move the default cut value to 40
917 elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-6')):
918 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")
919 flags.Trigger.FPGATrackSim.Hough.genScan=True
920 flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
921 elif (flags.Trigger.FPGATrackSim.pipeline != ""):
922 raise AssertionError("ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline + " which is not yet supported!")
923
924 if (not flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
925
926 flags.Tracking.writeExtendedSi_PRDInfo = not flags.Trigger.FPGATrackSim.writeOfflPRDInfo
927 splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split('-')
928 trackingOption=9999999
929 if (len(splitPipeline) > 1): trackingOption=int(splitPipeline[1])
930 if (trackingOption < 9999999):
931 trackingOptionMod = (trackingOption % 100)
932 if (trackingOptionMod == 0):
933 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")
934 flags.Trigger.FPGATrackSim.tracking = True
935 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = False
936 elif (trackingOptionMod == 10):
937 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")
938 flags.Trigger.FPGATrackSim.tracking = True
939 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = True
940 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
941 if (flags.Trigger.FPGATrackSim.pipeline.startswith('F-6')):
942 flags.Trigger.FPGATrackSim.doNNPathFinder = True
943 flags.Trigger.FPGATrackSim.doOverlapRemoval = False
944 flags.Trigger.FPGATrackSim.tracking = False
945 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = False
946 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
947 else:
948 raise AssertionError("ERROR Your tracking option for the pipeline = " + str(trackingOption) + " is not yet supported!")
949
950 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
951 log.info("wrapperFile is string, converting to list")
952 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
953 flags.Input.Files = lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
954
955 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
956 flags.Trigger.FPGATrackSim.Hough.chi2cut = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
957
958 flags.lock()
959 flags.dump()
960 flags = flags.cloneAndReplace("Tracking.ActiveConfig","Tracking.MainPass")
961 acc=MainServicesCfg(flags)
962
964
965 if not flags.Trigger.FPGATrackSim.wrapperFileName:
966 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
967 acc.merge(PoolReadCfg(flags))
968
969 if flags.Input.isMC:
970 from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
971 acc.merge(GEN_AOD2xAODCfg(flags))
972
973 from JetRecConfig.JetRecoSteering import addTruthPileupJetsToOutputCfg # TO DO: check if this is indeed necessary for pileup samples
974 acc.merge(addTruthPileupJetsToOutputCfg(flags))
975
976 if flags.Detector.EnableCalo:
977 from CaloRec.CaloRecoConfig import CaloRecoCfg
978 acc.merge(CaloRecoCfg(flags))
979
980 if flags.Tracking.recoChain:
981 from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
982 acc.merge(InDetTrackRecoCfg(flags))
983 if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
984 from InDetConfig.InDetPrepRawDataToxAODConfig import ITkActsPrepDataToxAODCfg
985 acc.merge( ITkActsPrepDataToxAODCfg( flags,
986 PixelMeasurementContainer = "ITkPixelMeasurements_offl",
987 StripMeasurementContainer = "ITkStripMeasurements_offl" ) )
988 from InDetConfig.InDetPrepRawDataToxAODConfig import TruthParticleIndexDecoratorAlgCfg
989 acc.merge( TruthParticleIndexDecoratorAlgCfg(flags) )
990 from InDetConfig.InDetPrepRawDataFormationConfig import ITkXAODToInDetClusterConversionCfg
991 acc.merge(ITkXAODToInDetClusterConversionCfg(flags))
992
993
994 # Configure both the dataprep and logical hits algorithms.
995 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
996 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig import FPGATrackSimMultiRegionTrackingCfg
997 acc.merge(FPGATrackSimMultiRegionTrackingCfg(flags))
998
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}",
1002 stage = f"{stage}",
1003 doActsTrk=True,
1004 doSP=flags.Trigger.FPGATrackSim.convertSPs))
1005
1006 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
1007 acc.merge(FPGAProtoTrackFitCfg(flags,stage=f"{stage}")) # Run ACTS KF
1008 acc.merge(FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey)) # Run Truth Matching/Decoration chain
1009 if flags.Trigger.FPGATrackSim.runCKF:
1010 from FPGATrackSimConfTools.FPGATrackExtensionConfig import FPGATrackExtensionAlgCfg
1011 acc.merge(FPGATrackExtensionAlgCfg(flags, enableTrackStatePrinter=False, name="FPGATrackExtension",
1012 ProtoTracksLocation=f"ActsProtoTracks{stage}FromFPGATrack")) # run CKF track extension on FPGA tracks
1013
1014 if flags.Trigger.FPGATrackSim.writeToAOD:
1015 acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
1016 stage = f"{stage}",
1017 finalTrackParticles=f"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
1018
1019 # Reporting algorithm (used for debugging - can be disabled)
1020 from FPGATrackSimReporting.FPGATrackSimReportingConfig import FPGATrackSimReportingCfg
1021 acc.merge(FPGATrackSimReportingCfg(flags, stage=f"{stage}",
1022 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType != 'skipTruth') and flags.Exec.MaxEvents<=10 ) )) # disable perEventReports for pileup samples or many events
1023
1024 acc.store(open('AnalysisConfig.pkl','wb'))
1025
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
1031
1032 statusCode = acc.run(flags.Exec.MaxEvents)
1033 assert statusCode.isSuccess() is True, "Application execution did not succeed"
if(febId1==febId2)
void print(char *figname, TCanvas *c1)
static std::string FindCalibFile(const std::string &logical_file_name)
static std::string FindCalibDirectory(const std::string &logical_file_name)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
FPGATrackSimRoadUnionToolGenScanCfg(flags, name="FPGATrackSimRoadUnionToolGenScan")
FPGATrackSimRoadUnionToolCfg(flags, name="FPGATrackSimRoadUnionTool")
FPGATrackSimRoadUnionTool1DCfg(flags, name="FPGATrackSimRoadUnionTool1D")
FPGATrackSimRoadUnionToolGNNCfg(flags, name="FPGATrackSimRoadUnionToolGNN")
FPGATrackSimGNNEdgeClassifierToolCfg(flags, name="FPGATrackSimGNNEdgeClassifierTool")
FPGATrackSimGNNGraphConstructionToolCfg(flags, name="FPGATrackSimGNNGraphConstructionTool")
FPGATrackSimTrackFitterToolCfg(flags, name="FPGATrackSimTrackFitterTool")
FPGATrackSimBankSvcCfg(flags, name="FPGATrackSimBankSvc")
FPGATrackSimOverlapRemovalToolCfg(flags, name="FPGATrackSimOverlapRemovalTool")
SPRoadFilterToolCfg(flags, secondStage=False, name="FPGATrackSimSpacepointRoadFilterTool")
FPGATrackSimHoughRootOutputToolCfg(flags, name="FPGATrackSimHoughRootOutputTool")
FPGATrackSimGNNRoadMakerToolCfg(flags, name="FPGATrackSimGNNRoadMakerTool")
NNTrackToolCfg(flags, name="FPGATrackSimNNTrackTool")
getEtaBin(flags)
return a number 0-19, 0 is most central bin, 19 is most forward (based on absolute value of eta)
FPGATrackSimLogicalHitsProcessAlgCfg(inputFlags, name="FPGATrackSimLogicalHitsProcessAlg", **kwargs)
FPGATrackSimGNNRootOutputToolCfg(flags, name="FPGATrackSimGNNRootOutputTool")
FPGATrackSimSlicingEngineCfg(flags, name="FPGATrackSimSlicingEngineTool")
LRTRoadFinderCfg(flags, name="LRTRoadFinder")
FPGATrackSimDataFlowToolCfg(flags, name="FPGATrackSimDataFlowTool")