ATLAS Offline Software
FPGATrackSimAnalysisConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 from AthenaCommon.Logging import AthenaLogger
5 from PathResolver import PathResolver
6 import importlib
7 import os
8 
9 log = AthenaLogger(__name__)
10 
11 
12 from FPGATrackSimConfTools import FPGATrackSimDataPrepConfig
13 
14 def getNSubregions(filePath):
15  with open(PathResolver.FindCalibFile(filePath), 'r') as f:
16  fields = f.readline()
17  assert(fields.startswith('towers'))
18  n = fields.split()[1]
19  return int(n)
20 
21 
22 # Need to figure out if we have two output writers or somehow only one.
24  result=ComponentAccumulator()
25  FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool("FPGATrackSimWriteOutput")
26  FPGATrackSimWriteOutput.InFileName = ["test.root"]
27  FPGATrackSimWriteOutput.OutputTreeName = FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimLogicalEventTree")
28  if not flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
29  FPGATrackSimWriteOutput.EventLimit = 0
30  else:
31  FPGATrackSimWriteOutput.EventLimit = flags.Trigger.FPGATrackSim.writeOutputEventLimit
32  # RECREATE means that that this tool opens the file.
33  # HEADER would mean that something else (e.g. THistSvc) opens it and we just add the object.
34  FPGATrackSimWriteOutput.RWstatus = "HEADER"
35  FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
36  result.setPrivateTools(FPGATrackSimWriteOutput)
37  return result
38 
39 def FPGATrackSimSlicingEngineCfg(flags,name="FPGATrackSimSlicingEngineTool"):
40  result = ComponentAccumulator()
41  FPGATrackSimSlicingEngineTool = CompFactory.FPGATrackSimSlicingEngineTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
42  # this is the same as the layer map used by the genscan/inside out tool below.
43  FPGATrackSimSlicingEngineTool.LayerMap = os.path.join(PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),f"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
44  FPGATrackSimSlicingEngineTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
45  # If the GNN is enabled (i.e. this is F-4xx) then we don't want to separate first vs second stage.
46  FPGATrackSimSlicingEngineTool.doSecondStage = (not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
47  FPGATrackSimSlicingEngineTool.RootOutput = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
48  result.setPrivateTools(FPGATrackSimSlicingEngineTool)
49  return result
50 
51 def FPGATrackSimBankSvcCfg(flags,name="FPGATrackSimBankSvc"):
52  result=ComponentAccumulator()
53  FPGATrackSimBankSvc = CompFactory.FPGATrackSimBankSvc(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
54  FPGATrackSimBankSvc.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
55  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/'
56  pathBankSvc=PathResolver.FindCalibDirectory(pathBankSvc)
57  FPGATrackSimBankSvc.constantsNoGuess_1st = [
58  f'{pathBankSvc}corrgen_raw_8L_skipPlane0.gcon',
59  f'{pathBankSvc}corrgen_raw_8L_skipPlane1.gcon',
60  f'{pathBankSvc}corrgen_raw_8L_skipPlane2.gcon',
61  f'{pathBankSvc}corrgen_raw_8L_skipPlane3.gcon',
62  f'{pathBankSvc}corrgen_raw_8L_skipPlane4.gcon',
63  f'{pathBankSvc}corrgen_raw_8L_skipPlane5.gcon',
64  f'{pathBankSvc}corrgen_raw_8L_skipPlane6.gcon',
65  f'{pathBankSvc}corrgen_raw_8L_skipPlane7.gcon']
66  FPGATrackSimBankSvc.constantsNoGuess_2nd = [
67  f'{pathBankSvc}corrgen_raw_13L_skipPlane0.gcon',
68  f'{pathBankSvc}corrgen_raw_13L_skipPlane1.gcon',
69  f'{pathBankSvc}corrgen_raw_13L_skipPlane2.gcon',
70  f'{pathBankSvc}corrgen_raw_13L_skipPlane3.gcon',
71  f'{pathBankSvc}corrgen_raw_13L_skipPlane4.gcon',
72  f'{pathBankSvc}corrgen_raw_13L_skipPlane5.gcon',
73  f'{pathBankSvc}corrgen_raw_13L_skipPlane6.gcon',
74  f'{pathBankSvc}corrgen_raw_13L_skipPlane7.gcon']
75  layers="5L" if flags.Trigger.FPGATrackSim.ActiveConfig.genScan else "9L"
76  s2_layers = 13
77  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/'
78  pathMapSvc = PathResolver.FindCalibDirectory(pathMapSvc)
79  pmap_file = os.path.join(pathMapSvc, f"region{flags.Trigger.FPGATrackSim.region}.pmap")
80  with open(pmap_file) as f:
81  for line in f:
82  if 'logical_s2' in line:
83  s2_layers = int(line.strip().split()[0])
84  break
85  FPGATrackSimBankSvc.constants_1st = f'{pathBankSvc}corrgen_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
86  FPGATrackSimBankSvc.constants_2nd = f'{pathBankSvc}corrgen_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
87  FPGATrackSimBankSvc.sectorBank_1st = f'{pathBankSvc}sectorsHW_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
88  FPGATrackSimBankSvc.sectorBank_2nd = f'{pathBankSvc}sectorsHW_raw_{s2_layers}L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
89  FPGATrackSimBankSvc.sectorSlices = f'{pathBankSvc}slices_{layers}_reg{flags.Trigger.FPGATrackSim.region}.root'
90  FPGATrackSimBankSvc.phiShift = flags.Trigger.FPGATrackSim.phiShift
91 
92  # These should be configurable. The tag system needs updating though.
93  FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
94  FPGATrackSimBankSvc.qptAbsBinning = False
95 
96  result.addService(FPGATrackSimBankSvc, create=True, primary=True)
97  return result
98 
99 
100 def FPGATrackSimRoadUnionToolCfg(flags,name="FPGATrackSimRoadUnionTool"):
101  result=ComponentAccumulator()
102  RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
103 
104  xBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBins
105  xBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
106  yBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBins
107  yBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
108  yMin = flags.Trigger.FPGATrackSim.ActiveConfig.qptMin
109  yMax = flags.Trigger.FPGATrackSim.ActiveConfig.qptMax
110  xMin = flags.Trigger.FPGATrackSim.ActiveConfig.phiMin
111  xMax = flags.Trigger.FPGATrackSim.ActiveConfig.phiMax
112  if (not flags.Trigger.FPGATrackSim.oldRegionDefs):
113  phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
114  xMin = phiRange[0]
115  xMax = phiRange[1]
116 
117  xBuffer = (xMax - xMin) / xBins * xBufferBins
118  xMin = xMin - xBuffer
119  xMax = xMax + xBuffer
120  yBuffer = (yMax - yMin) / yBins * yBufferBins
121  yMin -= yBuffer
122  yMax += yBuffer
123  tools = []
124  houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
125  roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
126 
127 
128  FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
129  for number in range(getNSubregions(FPGATrackSimMapping.subrmap)):
130  HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimHoughTransformTool")+"_" + str(number))
131  HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
132  HoughTransform.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
133  HoughTransform.FPGATrackSimMappingSvc = FPGATrackSimMapping
134  HoughTransform.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.combineLayers
135  HoughTransform.convSize_x = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeX
136  HoughTransform.convSize_y = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeY
137  HoughTransform.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.convolution
138  HoughTransform.d0_max = 0
139  HoughTransform.d0_min = 0
140  HoughTransform.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
141  HoughTransform.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX
142  HoughTransform.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
143  HoughTransform.nBins_x = xBins + 2 * xBufferBins
144  HoughTransform.nBins_y = yBins + 2 * yBufferBins
145  HoughTransform.phi_max = xMax
146  HoughTransform.phi_min = xMin
147  HoughTransform.qpT_max = yMax
148  HoughTransform.qpT_min = yMin
149  HoughTransform.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
150  HoughTransform.subRegion = number
151  HoughTransform.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold
152  HoughTransform.traceHits = True
153  HoughTransform.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
154  HoughTransform.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
155  HoughTransform.houghType = houghType
156  HoughTransform.roadMerge = roadMerge
157  if houghType=='LowResource':
158  HoughTransform.requirements = flags.Trigger.FPGATrackSim.ActiveConfig.requirements
159  if houghType=='Flexible':
160  HoughTransform.r_max=flags.Trigger.FPGATrackSim.ActiveConfig.r_max
161  HoughTransform.phi_coord_max=flags.Trigger.FPGATrackSim.ActiveConfig.phi_coord_max
162  HoughTransform.phi_range=flags.Trigger.FPGATrackSim.ActiveConfig.phi_range
163  HoughTransform.r_max_mm=flags.Trigger.FPGATrackSim.ActiveConfig.r_max_mm
164  HoughTransform.bitwise_qApt_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_qApt_conv
165  HoughTransform.bitwise_phi0_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_phi0_conv
166  HoughTransform.phi0_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.phi0_sectors
167  HoughTransform.qApt_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.qApt_sectors
168  HoughTransform.pipes_qApt=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_qApt
169  HoughTransform.pipes_phi0=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_phi0
170 
171  tools.append(HoughTransform)
172 
173  RF.tools = tools
174  result.addPublicTool(RF, primary=True)
175  return result
176 
177 def FPGATrackSimRoadUnionTool1DCfg(flags,name="FPGATrackSimRoadUnionTool1D"):
178  result=ComponentAccumulator()
179  tools = []
180  RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
181  splitpt=flags.Trigger.FPGATrackSim.Hough1D.splitpt
182  FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
183  for ptstep in range(splitpt):
184  qpt_min = flags.Trigger.FPGATrackSim.Hough1D.qptMin
185  qpt_max = flags.Trigger.FPGATrackSim.Hough1D.qptMax
186  lowpt = qpt_min + (qpt_max-qpt_min)/splitpt*ptstep
187  highpt = qpt_min + (qpt_max-qpt_min)/splitpt*(ptstep+1)
188  nSlice = getNSubregions(FPGATrackSimMapping.subrmap)
189  for iSlice in range(nSlice):
190  tool = CompFactory.FPGATrackSimHough1DShiftTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
191  "Hough1DShift" + str(iSlice)+(("_pt{}".format(ptstep)) if splitpt>1 else "")))
192  tool.subRegion = iSlice if nSlice > 1 else -1
193  xMin = flags.Trigger.FPGATrackSim.Hough1D.phiMin
194  xMax = flags.Trigger.FPGATrackSim.Hough1D.phiMax
195  if (not flags.Trigger.FPGATrackSim.oldRegionDefs):
196  phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
197  xMin = phiRange[0]
198  xMax = phiRange[1]
199  tool.phiMin = xMin
200  tool.phiMax = xMax
201  tool.qptMin = lowpt
202  tool.qptMax = highpt
203  tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
204  tool.useDiff = True
205  tool.variableExtend = True
206  tool.drawHitMasks = False
207  tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
208  tool.d0spread=-1.0 # mm
209  tool.iterStep = 0 # auto, TODO put in tag
210  tool.iterLayer = 7 # TODO put in tag
211  tool.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
212  tool.hitExtend = flags.Trigger.FPGATrackSim.Hough1D.hitExtendX
213  tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
214  tool.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
215  tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
216  tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
217  tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
218 
219  tools.append(tool)
220 
221  RF.tools = tools
222  result.addPublicTool(RF, primary=True)
223  return result
224 
225 
226 
227 def FPGATrackSimRoadUnionToolGenScanCfg(flags,name="FPGATrackSimRoadUnionToolGenScan"):
228  result=ComponentAccumulator()
229 
230  print("logLevel",flags.Trigger.FPGATrackSim.loglevel)
231 
232  # read the cuts from a seperate python file specified by FPGATrackSim.GenScan.genScanCuts
233  cutset=None
234  if flags.Trigger.FPGATrackSim.oldRegionDefs:
235  toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
236  if toload == 'FPGATrackSimGenScanCuts': # its on the newRegion default so it hasn't been set
237  toload = 'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
238  cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
239  else:
240  # this allows the cut file defined in python to be loaded from the map directory
241  cutpath = os.path.join(
242  PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
243  f"{flags.Trigger.FPGATrackSim.GenScan.genScanCuts}.py")
244  print("Cut File = ", cutpath)
245  spec=importlib.util.spec_from_file_location(flags.Trigger.FPGATrackSim.GenScan.genScanCuts,cutpath)
246  if spec is None:
247  print("Failed to find Cut File")
248  cutmodule = importlib.util.module_from_spec(spec)
249  spec.loader.exec_module(cutmodule)
250  cutset=cutmodule.cuts[flags.Trigger.FPGATrackSim.region]
251 
252  # make the binned hits class
253  BinnnedHits = CompFactory.FPGATrackSimBinnedHits("BinnedHits_1stStage")
254  BinnnedHits.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
255  BinnnedHits.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
256 
257  # set layer map
258  if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
259  if flags.Trigger.FPGATrackSim.oldRegionDefs:
260  BinnnedHits.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
261  else:
262  # now assumed to be in the map directory with name = basename for region + _lyrmap.json
263  BinnnedHits.layerMapFile =os.path.join(
264  PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir),
265  f"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
266 
267 
268  # make the bintool class
269  BinTool = CompFactory.FPGATrackSimBinTool("BinTool_1stStage")
270  BinTool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
271 
272  # Inputs for the BinTool
273  binsteps=[]
274  BinDesc=None
275  if (cutset["parSet"]=="PhiSlicedKeyLyrPars") :
276  BinDesc = CompFactory.FPGATrackSimKeyLayerBinDesc("KeyLayerBinDesc")
277  BinDesc.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
278  BinDesc.rin=cutset["rin"]
279  BinDesc.rout=cutset["rout"]
280 
281  BinDesc.region = flags.Trigger.FPGATrackSim.region
282 
283  # parameters for key layer bindesc are :"zR1", "zR2", "phiR1", "phiR2", "xm"
284  step1 = CompFactory.FPGATrackSimBinStep("PhiBinning")
285  step1.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
286  step1.parBins = [1,1,cutset["parBins"][2],cutset["parBins"][3],cutset["parBins"][4]]
287  step2 = CompFactory.FPGATrackSimBinStep("FullBinning")
288  step2.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
289  step2.parBins = cutset["parBins"]
290  binsteps = [step1,step2]
291  else:
292  log.error("Unknown Binning Setup: ",cutset["parSet"])
293 
294  BinTool.BinDesc = BinDesc
295  BinTool.Steps=binsteps
296 
297 
298  # configure the padding around the nominal region
299  BinTool.d0FractionalPadding =0.05
300  BinTool.z0FractionalPadding =0.05
301  BinTool.etaFractionalPadding =0.05
302  BinTool.phiFractionalPadding =0.05
303  BinTool.qOverPtFractionalPadding =0.05
304  BinTool.parMin = cutset["parMin"]
305  BinTool.parMax = cutset["parMax"]
306  BinnnedHits.BinTool = BinTool
307 
308 
309  # make the monitoring class
310  Monitor = CompFactory.FPGATrackSimGenScanMonitoring(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"GenScanMonitoring"))
311  Monitor.dir = "/GENSCAN/"
312  Monitor.THistSvc = CompFactory.THistSvc()
313  Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
314  Monitor.phiScale = 10.0
315  Monitor.etaScale = 100.0
316  Monitor.drScale = 20.0
317 
318  # make the main tool
319  tool = CompFactory.FPGATrackSimGenScanTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"GenScanTool"))
320  tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
321  tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
322  tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
323  tool.Monitoring = Monitor
324  tool.BinnedHits = BinnnedHits
325  tool.rin=cutset["rin"]
326  tool.rout=cutset["rout"]
327 
328  # For the 'track fitter' part of GenScanTool.
329  tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
330  tool.phiChi2Weight = flags.Trigger.FPGATrackSim.GenScan.phiChi2Weight
331  tool.etaChi2Weight = flags.Trigger.FPGATrackSim.GenScan.etaChi2Weight
332 
333  # configure which filers and thresholds to apply
334  tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
335  tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
336  tool.applyPairFilter= not flags.Trigger.FPGATrackSim.GenScan.noCuts
337  tool.applyPairSetFilter= not flags.Trigger.FPGATrackSim.GenScan.noCuts
338  tool.keepHitsStrategy = flags.Trigger.FPGATrackSim.GenScan.keepHitsStrategy
339  tool.threshold = 4
340 
341  # set cuts
342  for (cut,val) in cutset.items():
343  if cut in ["parBins","parSet","parMin","parMax"]:
344  continue
345  setattr(tool,cut,val)
346 
347  # even though we are not actually doing a Union, we need the
348  # RoadUnionTool because mapping is now there
349  RoadUnion = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
350  RoadUnion.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
351  RoadUnion.tools = [tool,]
352  result.addPublicTool(RoadUnion, primary=True)
353 
354  # special configuration for studing layer definitions
355  # pass through all hits, but turn off pairing because
356  # it won't be able to run
357  if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
358  RoadUnion.noHitFilter=True
359  tool.binningOnly=True
360  return result
361 
362 def FPGATrackSimRoadUnionToolGNNCfg(flags,name="FPGATrackSimRoadUnionToolGNN"):
363  result = ComponentAccumulator()
364  RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
365  RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
366 
367  patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimGNNPatternRecoTool"))
368  patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimGNNGraphHitSelectorTool"))
369  patternRecoTool.GNNGraphConstruction = result.popToolsAndMerge(FPGATrackSimGNNGraphConstructionToolCfg(flags))
370  edgeResult, edgeClassifierTools = FPGATrackSimGNNEdgeClassifierToolCfg(flags)
371  result.merge(edgeResult)
372  patternRecoTool.GNNEdgeClassifiers = edgeClassifierTools
373  patternRecoTool.GNNRoadMaker = result.popToolsAndMerge(FPGATrackSimGNNRoadMakerToolCfg(flags))
374  patternRecoTool.GNNRootOutput = result.popToolsAndMerge(FPGATrackSimGNNRootOutputToolCfg(flags))
375  patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
376  patternRecoTool.regionNum = int(flags.Trigger.FPGATrackSim.region)
377 
378  RF.tools = [patternRecoTool]
379  result.addPublicTool(RF, primary=True)
380 
381  return result
382 
383 def FPGATrackSimGNNGraphConstructionToolCfg(flags,name="FPGATrackSimGNNGraphConstructionTool"):
384  result = ComponentAccumulator()
385 
386  GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
387  GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
388  GNNGraphConstructionTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
389 
390 
391  # Module Map Configuration
392  GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
393  GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
394  GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
395 
396  # Metric Learning Configuration
397  GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
398  GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
399 
400  from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
401  from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
402 
403  GNNGraphConstructionTool.MLInferenceTool = result.popToolsAndMerge(OnnxRuntimeInferenceToolCfg(
404  flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
405 
406  result.setPrivateTools(GNNGraphConstructionTool)
407 
408  return result
409 
410 def FPGATrackSimGNNEdgeClassifierToolCfg(flags, name="FPGATrackSimGNNEdgeClassifierTool"):
411  result = ComponentAccumulator()
412 
413  from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
414  from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
415 
416  region = int(flags.Trigger.FPGATrackSim.region)
417  model_path = f"{flags.Trigger.FPGATrackSim.GNN.GNNModelPath}_{region}.onnx"
418 
419  GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(
420  FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags, name))
421  GNNEdgeClassifierTool.GNNInferenceTool = result.popToolsAndMerge(
422  OnnxRuntimeInferenceToolCfg(flags, model_path, OnnxRuntimeType.CPU, name=f"OnnxInferenceTool_{region}")
423  )
424  GNNEdgeClassifierTool.regionNum = region
425 
426  return result, [GNNEdgeClassifierTool]
427 
428 def FPGATrackSimGNNRoadMakerToolCfg(flags,name="FPGATrackSimGNNRoadMakerTool"):
429  result = ComponentAccumulator()
430 
431  GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
432  GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
433  GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
434  GNNRoadMakerTool.doGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
435  GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
436 
437  from TrigFastTrackFinder.TrigFastTrackFinderConfig import ITkTrigL2LayerNumberToolCfg
438  GNNRoadMakerTool.LayerNumberTool = result.getPrimaryAndMerge(ITkTrigL2LayerNumberToolCfg(flags))
439 
440  result.setPrivateTools(GNNRoadMakerTool)
441 
442  return result
443 
444 def FPGATrackSimGNNRootOutputToolCfg(flags,name="FPGATrackSimGNNRootOutputTool"):
445  result = ComponentAccumulator()
446 
447  GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
448  GNNRootOutputTool.OutputRegion = str(flags.Trigger.FPGATrackSim.region)
449 
450  if(flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput):
451  result.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
452  result.setPrivateTools(GNNRootOutputTool)
453 
454  return result
455 
456 def FPGATrackSimDataFlowToolCfg(flags,name="FPGATrackSimDataFlowTool"):
457  result=ComponentAccumulator()
458  DataFlowTool = CompFactory.FPGATrackSimDataFlowTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
459  DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
460  DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
461  DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
462  DataFlowTool.THistSvc = CompFactory.THistSvc()
463  result.setPrivateTools(DataFlowTool)
464  return result
465 
466 def FPGATrackSimHoughRootOutputToolCfg(flags,name="FPGATrackSimHoughRootOutputTool"):
467  result=ComponentAccumulator()
468  HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
469  HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
470  HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
471  HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
472  HoughRootOutputTool.OutputRegion = str(flags.Trigger.FPGATrackSim.region)
473  result.setPrivateTools(HoughRootOutputTool)
474  return result
475 
476 def LRTRoadFinderCfg(flags,name="LRTRoadFinder"):
477 
478  result=ComponentAccumulator()
479  LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
480  LRTRoadFinder.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
481  LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
482  LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
483  LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
484  LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
485  LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
486  LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
487  result.setPrivateTools(LRTRoadFinder)
488  return result
489 
490 def NNTrackToolCfg(flags,name="FPGATrackSimNNTrackTool"):
491  result=ComponentAccumulator()
492  NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
493  NNTrackTool.THistSvc = CompFactory.THistSvc()
494  NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
495  NNTrackTool.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
496  NNTrackTool.IdealGeoRoads = False
497  NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
498  NNTrackTool.SPRoadFilterTool = result.popToolsAndMerge(SPRoadFilterToolCfg(flags))
499  NNTrackTool.MinNumberOfRealHitsInATrack = 5 if flags.Trigger.FPGATrackSim.ActiveConfig.genScan else 7 if flags.Trigger.FPGATrackSim.ActiveConfig.GNN else 9
500  NNTrackTool.useSectors = False
501  NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
502  NNTrackTool.nInputsGNN = flags.Trigger.FPGATrackSim.GNN.nInputsGNN
503  NNTrackTool.useCartesian = flags.Trigger.FPGATrackSim.NNCartesianCoordinates
504  result.setPrivateTools(NNTrackTool)
505  return result
506 
507 def FPGATrackSimTrackFitterToolCfg(flags,name="FPGATrackSimTrackFitterTool"):
508  result=ComponentAccumulator()
509  TF_1st = CompFactory.FPGATrackSimTrackFitterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
510  TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
511  TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
512  TF_1st.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
513  TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
514  TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
515  TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
516  TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
517  TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
518  TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
519  TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
520  TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
521  TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
522  TF_1st.SPRoadFilterTool = result.popToolsAndMerge(SPRoadFilterToolCfg(flags))
523  TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
524  result.addPublicTool(TF_1st, primary=True)
525  return result
526 
527 def FPGATrackSimOverlapRemovalToolCfg(flags,name="FPGATrackSimOverlapRemovalTool"):
528  result=ComponentAccumulator()
529  OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
530  OR_1st.ORAlgo = "Normal"
531  OR_1st.doFastOR = flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
532  OR_1st.NumOfHitPerGrouping = 3
533  OR_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
534  if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
535  OR_1st.MinChi2 = getChi2Cut(flags.Trigger.FPGATrackSim.region)
536  elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
537  OR_1st.MinChi2 = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
538  else:
539  OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
540  if flags.Trigger.FPGATrackSim.ActiveConfig.hough or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
541  OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
542  OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
543  OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
544  OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
545 
546  from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig import FPGATrackSimOverlapRemovalToolMonitoringCfg
547  OR_1st.MonTool = result.getPrimaryAndMerge(FPGATrackSimOverlapRemovalToolMonitoringCfg(flags))
548 
549  result.addPublicTool(OR_1st, primary=True)
550  return result
551 
553  newFlags = flags.cloneAndReplace("Trigger.FPGATrackSim.ActiveConfig", "Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=True)
554  return newFlags
555 
556 def SPRoadFilterToolCfg(flags,secondStage=False,name="FPGATrackSimSpacepointRoadFilterTool"):
557  result=ComponentAccumulator()
558  name="FPGATrackSimSpacepointRoadFilterTool_1st"
559  if secondStage:
560  name="FPGATrackSimSpacepointRoadFilterTool_2st"
561  SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
562  SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
563  SPRoadFilter.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
564  SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
565  SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
566  SPRoadFilter.isSecondStage = secondStage
567  SPRoadFilter.dropUnpairedIfSP = flags.Trigger.FPGATrackSim.dropUnpairedIfSP
568 
569  # This threshold is the number of *missing* hits allowed. For now, assume that if 1st stage this is always 1.
570  # We don't actually run this tool in the first stage anymore, so this is more to preserve backwards compatibility
571  if secondStage:
572  SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
573  else:
574  SPRoadFilter.threshold = 1
575 
576  SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
577  result.setPrivateTools(SPRoadFilter)
578  return result
579 
580 def FPGATrackSimLogicalHitsProcessAlgCfg(inputFlags,name="FPGATrackSimLogicalHitsProcessAlg",**kwargs):
581 
583 
584  result=ComponentAccumulator()
585  kwargs.setdefault("name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
586 
587  theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg(**kwargs)
588  theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
589  theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
590  theFPGATrackSimLogicalHitsProcessAlg.SetTruthParametersForTracks = flags.Trigger.FPGATrackSim.SetTruthParametersForTracks
591  theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
592  theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
593  theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
594  theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
595  theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
596  theFPGATrackSimLogicalHitsProcessAlg.DoGNNTrack = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
597  theFPGATrackSimLogicalHitsProcessAlg.DoGNNPixelSeeding = flags.Trigger.FPGATrackSim.GNN.doGNNPixelSeeding
598  theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
599  if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
600  theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = getChi2Cut(flags.Trigger.FPGATrackSim.region)
601  elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
602  theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
603  else:
604  theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
605  theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
606  theFPGATrackSimLogicalHitsProcessAlg.secondStageStrips = (not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
607  FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
608  theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
609  # Adding region so we can set it for tracks, then get the bfield
610  theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
611  # If tracking is set to False or if we do the NN analysis, don't configure the bank service
612  if flags.Trigger.FPGATrackSim.tracking and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
613  result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
614 
615  if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
616  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionTool1DCfg(flags))
617  elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
618  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolGenScanCfg(flags))
619  elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
620  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolGNNCfg(flags))
621  else:
622  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolCfg(flags))
623 
624  if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
625  EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimEtaPatternFilterTool"))
626  EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
627  EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
628  EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+".patt"
629  theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
630  theFPGATrackSimLogicalHitsProcessAlg.FilterRoads = True
631 
632  if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
633  RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimPhiRoadFilterTool"))
634  RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
635  RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
636  RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
637 
638  windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow for i in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
639  RoadFilter2.window = windows
640 
641  theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
642  theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 = True
643 
644  theFPGATrackSimLogicalHitsProcessAlg.SlicingEngineTool = result.getPrimaryAndMerge(FPGATrackSimSlicingEngineCfg(flags))
645 
646  theFPGATrackSimLogicalHitsProcessAlg.HoughRootOutputTool = result.getPrimaryAndMerge(FPGATrackSimHoughRootOutputToolCfg(flags))
647 
648  LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,"FPGATrackSimLLPRoadFilterTool"))
649  result.addPublicTool(LRTRoadFilter)
650  theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
651 
652  theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(LRTRoadFinderCfg(flags))
653  theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(NNTrackToolCfg(flags))
654 
655  theFPGATrackSimLogicalHitsProcessAlg.OutputTool = result.popToolsAndMerge(FPGATrackSimWriteOutputCfg(flags))
656  theFPGATrackSimLogicalHitsProcessAlg.TrackFitter_1st = result.getPrimaryAndMerge(FPGATrackSimTrackFitterToolCfg(flags))
657  theFPGATrackSimLogicalHitsProcessAlg.OverlapRemoval_1st = result.getPrimaryAndMerge(FPGATrackSimOverlapRemovalToolCfg(flags))
658 
659  theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
660  theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
661 
662  if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
663  assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter, 'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
664  assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT, 'Inconsistent LRT HT setup, need either double or strightTrack enabled'
665  theFPGATrackSimLogicalHitsProcessAlg.doLRT = True
666  theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
667 
668  from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
669  theFPGATrackSimLogicalHitsProcessAlg.MonTool = result.getPrimaryAndMerge(FPGATrackSimLogicalHitsProcessAlgMonitoringCfg(flags))
670  result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
671 
672  return result
673 
674 def getChi2Cut(region):
675  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
676  binSize = 0.2
677  side = (region >> 5) & 0x1
678  etaBin = (region >> 6) & 0x1F
679  etaRange = [round(binSize * etaBin, 1), round(binSize * (etaBin + 1), 1)] if side else [round(-binSize * (etaBin + 1), 1), round(-binSize * etaBin, 1)]
680 
681  abs_etaRange = tuple(round(abs(val), 1) for val in etaRange)
682 
683  eta_to_chi2 = {
684  (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
685  (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
686  (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
687  (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
688  (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
689  (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
690  (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
691  }
692 
693  return eta_to_chi2.get(abs_etaRange, 20)
694 
695 def getChi2CutNN(region):
696  chi2cut_l = [0.97,0.97,0.99,
697  0.7,0.86,0.99,
698  0.98,0.92,0.98,
699  0.95,0.93,0.4,
700  0.4,0.4,0.7,
701  0.6,0.5,0.4,
702  0.4,0.4]
703  binSize = 0.2
704  side = (region >> 5) & 0x1
705  etaBin = (region >> 6) & 0x1F
706  etaRange = [round(binSize * etaBin, 1), round(binSize * (etaBin + 1), 1)] if side else [round(-binSize * (etaBin + 1), 1), round(-binSize * etaBin, 1)]
707 
708  abs_etaRange = tuple(round(abs(val), 1) for val in etaRange)
709 
710  eta_to_chi2 = {
711  (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
712  (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
713  (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
714  (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
715  (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
716  (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
717  (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
718  }
719  return eta_to_chi2.get(abs_etaRange, 0.99)
720 
721 
723  # convert regex to array of regions
724  if flags.Trigger.FPGATrackSim.regionList == "": # in case of empty list just use the region set to flags.Trigger.FPGATrackSim.region
725  flags.Trigger.FPGATrackSim.regionList = [flags.Trigger.FPGATrackSim.region]
726  else: # otherwise use the regionList (this overrides the region flag)
727  from FPGATrackSimConfTools.FPGATrackSimHelperFunctions import convertRegionsExpressionToArray
728  flags.Trigger.FPGATrackSim.regionList = convertRegionsExpressionToArray(flags.Trigger.FPGATrackSim.regionList)
729  print(f"Running for regions: {flags.Trigger.FPGATrackSim.regionList}")
730 
731 
733  FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepFlagCfg(flags)
734 
735  flags.Scheduler.ShowDataDeps=True
736  flags.Scheduler.CheckDependencies=True
737  flags.Debug.DumpEvtStore=False
738 
739  flags.Trigger.FPGATrackSim.readOfflineObjects=False
740  flags.Trigger.FPGATrackSim.doMultiTruth=False
741 
742  flags.Trigger.FPGATrackSim.tracking = False
743  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)
744  flags.Tracking.ITkActsValidateF150Pass.doActsSpacePoint = not flags.Trigger.FPGATrackSim.convertSPs
745  flags.Trigger.FPGATrackSim.Hough.secondStage = False
746 
747  flags.Trigger.FPGATrackSim.regionList="34,98,162,226,290,354,418,482,546,610,674,738,802,866,930,994,1058,1122,1186,1250"
749 
750  return flags
751 
754  acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimClusteringCfg(flags))
755 
756  from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig import FPGATrackSimMultiRegionTrackingCfg
757  acc.merge(FPGATrackSimMultiRegionTrackingCfg(flags))
758 
759  from FPGATrackSimSeeding.FPGATrackSimSeedingConfig import FPGATrackSimSeedingCfg
760  acc.merge(FPGATrackSimSeedingCfg(flags))
761 
762 
763  if flags.Tracking.ActiveConfig.storeTrackSeeds:
764  from ActsConfig.ActsSeedingConfig import ActsStoreTrackSeedsCfg
765  from InDetConfig.ITkActsHelpers import isFastPrimaryPass
766 
767  acc.merge(ActsStoreTrackSeedsCfg(flags,
768  processPixels = True,
769  processStrips = not isFastPrimaryPass(flags)))
770 
771 
772  acc.merge(WriteAdditionalFPGATrackSimOutputCfg(flags))
773 
774  return acc
775 
778  if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
779  acc.addService(CompFactory.THistSvc(Output = ["EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
780 
781  if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
782  acc.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
783 
784  if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
785  acc.addService(CompFactory.THistSvc(Output = ["FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
786 
787  if (flags.Trigger.FPGATrackSim.Hough.genScan):
788  acc.addService(CompFactory.THistSvc(Output = ["GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
789  return acc
790 
791 if __name__ == "__main__":
792  from AthenaConfiguration.AllConfigFlags import initConfigFlags
793  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
794 
795 
796  flags = initConfigFlags()
797 
798 
800  FinalProtoTrackChainxAODTracksKey="FPGA"
801  flags.Detector.EnableCalo = False
802 
803  # ensure that the xAOD SP and cluster containers are available
804  flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=True
805  flags.Tracking.ITkMainPass.doAthenaToActsCluster=True
806  from ActsConfig.ActsCIFlags import actsLegacyWorkflowFlags
808  flags.Acts.doRotCorrection = False
809 
810 
811  flags.Concurrency.NumThreads=1
812  flags.Concurrency.NumConcurrentEvents=1
813  flags.Concurrency.NumProcs=0
814  flags.Scheduler.ShowDataDeps=True
815  flags.Scheduler.CheckDependencies=True
816  flags.Debug.DumpEvtStore=False
817 
818  # flags.Exec.DebugStage="exec" # useful option to debug the execution of the job - we want it commented out for production
819  flags.fillFromArgs()
820 
822 
823 
824  if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut and not flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
825  flags.Trigger.FPGATrackSim.Hough.chi2cut = getChi2Cut(flags.Trigger.FPGATrackSim.region)
826  assert not flags.Trigger.FPGATrackSim.pipeline.startswith('F-5'),"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
827 
828  if (flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
829  print("You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
830  FPGATrackSimDataPrepConfig.runDataPrepChain()
831  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-2')):
832  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")
833  flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = True
834  flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = True
835  flags.Trigger.FPGATrackSim.Hough.hough1D = True
836  flags.Trigger.FPGATrackSim.Hough.hough = False
837  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-3')):
838  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")
839  flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = False
840  flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = False
841  flags.Trigger.FPGATrackSim.Hough.hough1D = False
842  flags.Trigger.FPGATrackSim.Hough.hough = True
843  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-4')):
844  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")
845  flags.Trigger.FPGATrackSim.Hough.GNN = True
846  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
847  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-6')):
848  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")
849  flags.Trigger.FPGATrackSim.Hough.genScan=True
850  flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
851  elif (flags.Trigger.FPGATrackSim.pipeline != ""):
852  raise AssertionError("ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline + " which is not yet supported!")
853 
854  if (not flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
855 
856  flags.Tracking.writeExtendedSi_PRDInfo = not flags.Trigger.FPGATrackSim.writeOfflPRDInfo
857  splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split('-')
858  trackingOption=9999999
859  if (len(splitPipeline) > 1): trackingOption=int(splitPipeline[1])
860  if (trackingOption < 9999999):
861  trackingOptionMod = (trackingOption % 100)
862  if (trackingOptionMod == 0):
863  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")
864  flags.Trigger.FPGATrackSim.tracking = True
865  flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = False
866  elif (trackingOptionMod == 10):
867  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")
868  flags.Trigger.FPGATrackSim.tracking = True
869  flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = True
870  flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
871  if (flags.Trigger.FPGATrackSim.pipeline.startswith('F-6')):
872  flags.Trigger.FPGATrackSim.doNNPathFinder = True
873  flags.Trigger.FPGATrackSim.doOverlapRemoval = False
874  flags.Trigger.FPGATrackSim.tracking = False
875  flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis = False
876  flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
877  else:
878  raise AssertionError("ERROR Your tracking option for the pipeline = " + str(trackingOption) + " is not yet supported!")
879 
880  if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
881  log.info("wrapperFile is string, converting to list")
882  flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
883  flags.Input.Files = lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
884 
885  if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
886  flags.Trigger.FPGATrackSim.Hough.chi2cut = getChi2CutNN(flags.Trigger.FPGATrackSim.region)
887 
888  flags.lock()
889  flags.dump()
890  flags = flags.cloneAndReplace("Tracking.ActiveConfig","Tracking.MainPass")
891  acc=MainServicesCfg(flags)
892 
893  acc.merge(WriteAdditionalFPGATrackSimOutputCfg(flags))
894 
895  if not flags.Trigger.FPGATrackSim.wrapperFileName:
896  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
897  acc.merge(PoolReadCfg(flags))
898 
899  if flags.Input.isMC:
900  from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
901  acc.merge(GEN_AOD2xAODCfg(flags))
902 
903  from JetRecConfig.JetRecoSteering import addTruthPileupJetsToOutputCfg # TO DO: check if this is indeed necessary for pileup samples
904  acc.merge(addTruthPileupJetsToOutputCfg(flags))
905 
906  if flags.Detector.EnableCalo:
907  from CaloRec.CaloRecoConfig import CaloRecoCfg
908  acc.merge(CaloRecoCfg(flags))
909 
910  if flags.Tracking.recoChain:
911  from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
912  acc.merge(InDetTrackRecoCfg(flags))
913  if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
914  from InDetConfig.InDetPrepRawDataToxAODConfig import ITkActsPrepDataToxAODCfg
915  acc.merge( ITkActsPrepDataToxAODCfg( flags,
916  PixelMeasurementContainer = "ITkPixelMeasurements_offl",
917  StripMeasurementContainer = "ITkStripMeasurements_offl" ) )
918  from InDetConfig.InDetPrepRawDataToxAODConfig import TruthParticleIndexDecoratorAlgCfg
919  acc.merge( TruthParticleIndexDecoratorAlgCfg(flags) )
920  from InDetConfig.InDetPrepRawDataFormationConfig import ITkXAODToInDetClusterConversionCfg
921  acc.merge(ITkXAODToInDetClusterConversionCfg(flags))
922 
923 
924  # Configure both the dataprep and logical hits algorithms.
925  acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
926 
927  from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig import FPGATrackSimMultiRegionTrackingCfg
928  acc.merge(FPGATrackSimMultiRegionTrackingCfg(flags))
929 
930  if flags.Trigger.FPGATrackSim.doEDMConversion:
931  stage = "_2nd" if flags.Trigger.FPGATrackSim.Hough.secondStage else "_1st"
932  acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = f"FPGAConversionAlg{stage}",
933  stage = f"{stage}",
934  doActsTrk=True,
935  doSP=flags.Trigger.FPGATrackSim.convertSPs))
936 
937  from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
938  acc.merge(FPGAProtoTrackFitCfg(flags,stage=f"{stage}")) # Run ACTS KF
939  acc.merge(FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey)) # Run Truth Matching/Decoration chain
940  if flags.Trigger.FPGATrackSim.runCKF:
941  from FPGATrackSimConfTools.FPGATrackExtensionConfig import FPGATrackExtensionAlgCfg
942  acc.merge(FPGATrackExtensionAlgCfg(flags, enableTrackStatePrinter=False, name="FPGATrackExtension",
943  ProtoTracksLocation=f"ActsProtoTracks{stage}FromFPGATrack")) # run CKF track extension on FPGA tracks
944 
945  if flags.Trigger.FPGATrackSim.writeToAOD:
946  acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
947  stage = f"{stage}",
948  finalTrackParticles=f"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
949 
950  # Reporting algorithm (used for debugging - can be disabled)
951  from FPGATrackSimReporting.FPGATrackSimReportingConfig import FPGATrackSimReportingCfg
952  acc.merge(FPGATrackSimReportingCfg(flags, stage=f"{stage}",
953  perEventReports = ((flags.Trigger.FPGATrackSim.sampleType != 'skipTruth') and flags.Exec.MaxEvents<=10 ) )) # disable perEventReports for pileup samples or many events
954 
955  acc.store(open('AnalysisConfig.pkl','wb'))
956 
957  acc.foreach_component("*FPGATrackSim*").OutputLevel=flags.Trigger.FPGATrackSim.loglevel
958  if flags.Trigger.FPGATrackSim.msgLimit!=-1:
959  acc.getService("MessageSvc").debugLimit = flags.Trigger.FPGATrackSim.msgLimit
960  acc.getService("MessageSvc").infoLimit = flags.Trigger.FPGATrackSim.msgLimit
961  acc.getService("MessageSvc").verboseLimit = flags.Trigger.FPGATrackSim.msgLimit
962 
963  statusCode = acc.run(flags.Exec.MaxEvents)
964  assert statusCode.isSuccess() is True, "Application execution did not succeed"
python.FPGATrackSimAnalysisConfig.NNTrackToolCfg
def NNTrackToolCfg(flags, name="FPGATrackSimNNTrackTool")
Definition: FPGATrackSimAnalysisConfig.py:490
python.FPGATrackSimAnalysisConfig.FPGATrackSimF150FlagCfg
def FPGATrackSimF150FlagCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:732
FPGATrackSimPrototrackFitterConfig.FPGAProtoTrackFitCfg
def FPGAProtoTrackFitCfg(flags, name="FPGAPrototrackFitterConfig", stage='', **kwargs)
Definition: FPGATrackSimPrototrackFitterConfig.py:42
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:63
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
ActsSeedingConfig.ActsStoreTrackSeedsCfg
ComponentAccumulator ActsStoreTrackSeedsCfg(flags, *bool processPixels, bool processStrips, **dict kwargs)
Definition: ActsSeedingConfig.py:557
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionTool1DCfg
def FPGATrackSimRoadUnionTool1DCfg(flags, name="FPGATrackSimRoadUnionTool1D")
Definition: FPGATrackSimAnalysisConfig.py:177
xAODTruthCnvConfig.GEN_AOD2xAODCfg
def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:22
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
python.FPGATrackSimAnalysisConfig.FPGATrackSimHoughRootOutputToolCfg
def FPGATrackSimHoughRootOutputToolCfg(flags, name="FPGATrackSimHoughRootOutputTool")
Definition: FPGATrackSimAnalysisConfig.py:466
python.FPGATrackSimAnalysisConfig.FPGATrackSimGNNRootOutputToolCfg
def FPGATrackSimGNNRootOutputToolCfg(flags, name="FPGATrackSimGNNRootOutputTool")
Definition: FPGATrackSimAnalysisConfig.py:444
FPGATrackSimHelperFunctions.convertRegionsExpressionToArray
def convertRegionsExpressionToArray(expression, min_value=0, max_value=1279)
Definition: FPGATrackSimHelperFunctions.py:6
python.InDetPrepRawDataToxAODConfig.TruthParticleIndexDecoratorAlgCfg
def TruthParticleIndexDecoratorAlgCfg(flags, name='TruthParticleIndexDecoratorAlg', **kwargs)
Definition: InDetPrepRawDataToxAODConfig.py:6
python.FPGATrackSimMultiRegionConfig.FPGATrackSimMultiRegionTrackingCfg
def FPGATrackSimMultiRegionTrackingCfg(flags)
Definition: FPGATrackSimMultiRegionConfig.py:6
python.FPGATrackSimAnalysisConfig.FPGATrackSimTrackFitterToolCfg
def FPGATrackSimTrackFitterToolCfg(flags, name="FPGATrackSimTrackFitterTool")
Definition: FPGATrackSimAnalysisConfig.py:507
PathResolver::FindCalibDirectory
static std::string FindCalibDirectory(const std::string &logical_file_name)
Definition: PathResolver.h:64
TrigFastTrackFinderConfig.ITkTrigL2LayerNumberToolCfg
ComponentAccumulator ITkTrigL2LayerNumberToolCfg(AthConfigFlags flags, **kwargs)
Definition: TrigFastTrackFinderConfig.py:259
python.FPGATrackSimAnalysisConfig.ConfigureMultiRegionFlags
def ConfigureMultiRegionFlags(flags)
Definition: FPGATrackSimAnalysisConfig.py:722
python.FPGATrackSimAnalysisConfig.FPGATrackSimLogicalHitsProcessAlgCfg
def FPGATrackSimLogicalHitsProcessAlgCfg(inputFlags, name="FPGATrackSimLogicalHitsProcessAlg", **kwargs)
Definition: FPGATrackSimAnalysisConfig.py:580
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionToolGenScanCfg
def FPGATrackSimRoadUnionToolGenScanCfg(flags, name="FPGATrackSimRoadUnionToolGenScan")
Definition: FPGATrackSimAnalysisConfig.py:227
python.FPGATrackSimAnalysisConfig.FPGATrackSimGNNEdgeClassifierToolCfg
def FPGATrackSimGNNEdgeClassifierToolCfg(flags, name="FPGATrackSimGNNEdgeClassifierTool")
Definition: FPGATrackSimAnalysisConfig.py:410
python.FPGATrackSimAnalysisConfig.getChi2Cut
def getChi2Cut(region)
Definition: FPGATrackSimAnalysisConfig.py:674
python.FPGATrackSimAnalysisConfig.FPGATrackSimSeedingCfg
def FPGATrackSimSeedingCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:752
python.FPGATrackSimAnalysisConfig.FPGATrackSimDataFlowToolCfg
def FPGATrackSimDataFlowToolCfg(flags, name="FPGATrackSimDataFlowTool")
Definition: FPGATrackSimAnalysisConfig.py:456
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.FPGATrackSimAnalysisConfig.prepareFlagsForFPGATrackSimLogicalHitsProcessAlg
def prepareFlagsForFPGATrackSimLogicalHitsProcessAlg(flags)
Definition: FPGATrackSimAnalysisConfig.py:552
python.FPGATrackSimAnalysisConfig.FPGATrackSimBankSvcCfg
def FPGATrackSimBankSvcCfg(flags, name="FPGATrackSimBankSvc")
Definition: FPGATrackSimAnalysisConfig.py:51
python.InDetPrepRawDataFormationConfig.ITkXAODToInDetClusterConversionCfg
def ITkXAODToInDetClusterConversionCfg(flags, name="ITkXAODToInDetClusterConversion", **kwargs)
Definition: InDetPrepRawDataFormationConfig.py:47
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionToolCfg
def FPGATrackSimRoadUnionToolCfg(flags, name="FPGATrackSimRoadUnionTool")
Definition: FPGATrackSimAnalysisConfig.py:100
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
python.InDetPrepRawDataToxAODConfig.ITkActsPrepDataToxAODCfg
ComponentAccumulator ITkActsPrepDataToxAODCfg(flags, *str PixelClusterContainer="ITkPixelClusters", str StripClusterContainer="ITkStripClusters", str PixelMeasurementContainer="ITkPixelMeasurements", str StripMeasurementContainer="ITkStripMeasurements", list[str] TrackParticles=None)
Definition: InDetPrepRawDataToxAODConfig.py:46
python.FPGATrackSimAnalysisConfig.FPGATrackSimWriteOutputCfg
def FPGATrackSimWriteOutputCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:23
python.JetRecoSteering.addTruthPileupJetsToOutputCfg
def addTruthPileupJetsToOutputCfg(flags, toAOD=True, toESD=True)
Definition: JetRecoSteering.py:7
python.FPGATrackSimAnalysisConfig.WriteAdditionalFPGATrackSimOutputCfg
def WriteAdditionalFPGATrackSimOutputCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:776
python.OnnxRuntimeInferenceConfig.OnnxRuntimeInferenceToolCfg
def OnnxRuntimeInferenceToolCfg(flags, str model_fname=None, Optional[OnnxRuntimeType] execution_provider=None, name="OnnxRuntimeInferenceTool", **kwargs)
Definition: OnnxRuntimeInferenceConfig.py:9
python.FPGATrackSimAnalysisConfig.LRTRoadFinderCfg
def LRTRoadFinderCfg(flags, name="LRTRoadFinder")
Definition: FPGATrackSimAnalysisConfig.py:476
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionToolGNNCfg
def FPGATrackSimRoadUnionToolGNNCfg(flags, name="FPGATrackSimRoadUnionToolGNN")
Definition: FPGATrackSimAnalysisConfig.py:362
FPGATrackSimAlgorithmConfig.FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
def FPGATrackSimLogicalHitsProcessAlgMonitoringCfg(flags)
Definition: FPGATrackSimAlgorithmConfig.py:246
python.FPGATrackSimAnalysisConfig.getNSubregions
def getNSubregions(filePath)
Definition: FPGATrackSimAnalysisConfig.py:14
python.TrackRecoConfig.InDetTrackRecoCfg
def InDetTrackRecoCfg(flags)
Main ID tracking config #####################.
Definition: TrackRecoConfig.py:804
python.FPGATrackSimAnalysisConfig.FPGATrackSimOverlapRemovalToolCfg
def FPGATrackSimOverlapRemovalToolCfg(flags, name="FPGATrackSimOverlapRemovalTool")
Definition: FPGATrackSimAnalysisConfig.py:527
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.FPGATrackExtensionConfig.FPGATrackExtensionAlgCfg
def FPGATrackExtensionAlgCfg(flags, enableTrackStatePrinter=False, **kwargs)
Definition: FPGATrackExtensionConfig.py:6
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
ActsCIFlags.actsLegacyWorkflowFlags
None actsLegacyWorkflowFlags(flags)
Definition: ActsCIFlags.py:6
python.FPGATrackSimAnalysisConfig.SPRoadFilterToolCfg
def SPRoadFilterToolCfg(flags, secondStage=False, name="FPGATrackSimSpacepointRoadFilterTool")
Definition: FPGATrackSimAnalysisConfig.py:556
FPGATrackSimPrototrackFitterConfig.FPGATruthDecorationCfg
def FPGATruthDecorationCfg(flags, FinalProtoTrackChainxAODTracksKey="xAODFPGAPrototracks", **kwargs)
Definition: FPGATrackSimPrototrackFitterConfig.py:58
str
Definition: BTagTrackIpAccessor.cxx:11
DataPrepConfig.FPGATrackSimReportingCfg
def FPGATrackSimReportingCfg(flags, name='FPGATrackSimReportingAlg', **kwargs)
Definition: DataPrepConfig.py:6
python.ITkActsHelpers.isFastPrimaryPass
bool isFastPrimaryPass(flags)
Definition: ITkActsHelpers.py:6
python.FPGATrackSimAnalysisConfig.FPGATrackSimGNNRoadMakerToolCfg
def FPGATrackSimGNNRoadMakerToolCfg(flags, name="FPGATrackSimGNNRoadMakerTool")
Definition: FPGATrackSimAnalysisConfig.py:428
python.FPGATrackSimAnalysisConfig.getChi2CutNN
def getChi2CutNN(region)
Definition: FPGATrackSimAnalysisConfig.py:695
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.FPGATrackSimAnalysisConfig.FPGATrackSimGNNGraphConstructionToolCfg
def FPGATrackSimGNNGraphConstructionToolCfg(flags, name="FPGATrackSimGNNGraphConstructionTool")
Definition: FPGATrackSimAnalysisConfig.py:383
FPGATrackSimAlgorithmConfig.FPGATrackSimOverlapRemovalToolMonitoringCfg
def FPGATrackSimOverlapRemovalToolMonitoringCfg(flags)
Definition: FPGATrackSimAlgorithmConfig.py:304
python.FPGATrackSimAnalysisConfig.FPGATrackSimSlicingEngineCfg
def FPGATrackSimSlicingEngineCfg(flags, name="FPGATrackSimSlicingEngineTool")
Definition: FPGATrackSimAnalysisConfig.py:39