2 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaCommon.Logging
import AthenaLogger
5 from PathResolver
import PathResolver
9 log = AthenaLogger(__name__)
12 from FPGATrackSimConfTools
import FPGATrackSimDataPrepConfig
17 assert(fields.startswith(
'towers'))
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
31 FPGATrackSimWriteOutput.EventLimit = flags.Trigger.FPGATrackSim.writeOutputEventLimit
34 FPGATrackSimWriteOutput.RWstatus =
"HEADER"
35 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
36 result.setPrivateTools(FPGATrackSimWriteOutput)
41 FPGATrackSimSlicingEngineTool = CompFactory.FPGATrackSimSlicingEngineTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
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))
46 FPGATrackSimSlicingEngineTool.doSecondStage = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
47 FPGATrackSimSlicingEngineTool.RootOutput = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
48 result.setPrivateTools(FPGATrackSimSlicingEngineTool)
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/'
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"
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/'
79 pmap_file = os.path.join(pathMapSvc, f
"region{flags.Trigger.FPGATrackSim.region}.pmap")
80 with open(pmap_file)
as f:
82 if 'logical_s2' in line:
83 s2_layers =
int(line.strip().
split()[0])
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
93 FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
94 FPGATrackSimBankSvc.qptAbsBinning =
False
96 result.addService(FPGATrackSimBankSvc, create=
True, primary=
True)
102 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
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)
117 xBuffer = (xMax - xMin) / xBins * xBufferBins
118 xMin = xMin - xBuffer
119 xMax = xMax + xBuffer
120 yBuffer = (yMax - yMin) / yBins * yBufferBins
124 houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
125 roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
128 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
130 HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimHoughTransformTool")+
"_" +
str(number))
131 HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(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
171 tools.append(HoughTransform)
174 result.addPublicTool(RF, primary=
True)
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)
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)
203 tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
205 tool.variableExtend =
True
206 tool.drawHitMasks =
False
207 tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
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))
215 tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
216 tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
217 tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
222 result.addPublicTool(RF, primary=
True)
230 print(
"logLevel",flags.Trigger.FPGATrackSim.loglevel)
234 if flags.Trigger.FPGATrackSim.oldRegionDefs:
235 toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
236 if toload ==
'FPGATrackSimGenScanCuts':
237 toload =
'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
238 cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
241 cutpath = os.path.join(
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)
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]
253 BinnnedHits = CompFactory.FPGATrackSimBinnedHits(
"BinnedHits_1stStage")
254 BinnnedHits.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
255 BinnnedHits.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
258 if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
259 if flags.Trigger.FPGATrackSim.oldRegionDefs:
260 BinnnedHits.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
263 BinnnedHits.layerMapFile =os.path.join(
265 f
"{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json")
269 BinTool = CompFactory.FPGATrackSimBinTool(
"BinTool_1stStage")
270 BinTool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
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"]
282 step1 = CompFactory.FPGATrackSimBinStep(
"PhiBinning")
283 step1.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
284 step1.parBins = [1,1,cutset[
"parBins"][2],cutset[
"parBins"][3],cutset[
"parBins"][4]]
285 step2 = CompFactory.FPGATrackSimBinStep(
"FullBinning")
286 step2.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
287 step2.parBins = cutset[
"parBins"]
288 binsteps = [step1,step2]
290 log.error(
"Unknown Binning Setup: ",cutset[
"parSet"])
292 BinTool.BinDesc = BinDesc
293 BinTool.Steps=binsteps
297 BinTool.d0FractionalPadding =0.05
298 BinTool.z0FractionalPadding =0.05
299 BinTool.etaFractionalPadding =0.05
300 BinTool.phiFractionalPadding =0.05
301 BinTool.qOverPtFractionalPadding =0.05
302 BinTool.parMin = cutset[
"parMin"]
303 BinTool.parMax = cutset[
"parMax"]
304 BinnnedHits.BinTool = BinTool
308 Monitor = CompFactory.FPGATrackSimGenScanMonitoring(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanMonitoring"))
309 Monitor.dir =
"/GENSCAN/"
310 Monitor.THistSvc = CompFactory.THistSvc()
311 Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
312 Monitor.phiScale = 10.0
313 Monitor.etaScale = 100.0
314 Monitor.drScale = 20.0
317 tool = CompFactory.FPGATrackSimGenScanTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"GenScanTool"))
318 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
319 tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
320 tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
321 tool.Monitoring = Monitor
322 tool.BinnedHits = BinnnedHits
323 tool.rin=cutset[
"rin"]
324 tool.rout=cutset[
"rout"]
327 tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
328 tool.phiChi2Weight = flags.Trigger.FPGATrackSim.GenScan.phiChi2Weight
329 tool.etaChi2Weight = flags.Trigger.FPGATrackSim.GenScan.etaChi2Weight
332 tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
333 tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
334 tool.applyPairFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
335 tool.applyPairSetFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
339 for (cut,val)
in cutset.items():
340 if cut
in [
"parBins",
"parSet",
"parMin",
"parMax"]:
342 setattr(tool,cut,val)
346 RoadUnion = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
347 RoadUnion.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
348 RoadUnion.tools = [tool,]
349 result.addPublicTool(RoadUnion, primary=
True)
354 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
355 RoadUnion.noHitFilter=
True
356 tool.binningOnly=
True
361 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
362 RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
364 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNPatternRecoTool"))
365 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNGraphHitSelectorTool"))
370 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
372 RF.tools = [patternRecoTool]
373 result.addPublicTool(RF, primary=
True)
380 GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
381 GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
384 GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
385 GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
386 GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
390 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
391 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
393 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
394 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
397 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
399 result.setPrivateTools(GNNGraphConstructionTool)
406 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
407 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
409 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
411 flags, flags.Trigger.FPGATrackSim.GNN.GNNModelPath, OnnxRuntimeType.CPU))
413 result.setPrivateTools(GNNEdgeClassifierTool)
420 GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
421 GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
422 GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
423 GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
425 result.setPrivateTools(GNNRoadMakerTool)
432 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
433 GNNRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
435 result.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
436 result.setPrivateTools(GNNRootOutputTool)
442 DataFlowTool = CompFactory.FPGATrackSimDataFlowTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
443 DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
444 DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
445 DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
446 DataFlowTool.THistSvc = CompFactory.THistSvc()
447 result.setPrivateTools(DataFlowTool)
452 HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
453 HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
454 HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
455 HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
456 HoughRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
457 result.setPrivateTools(HoughRootOutputTool)
463 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
465 LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
466 LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
467 LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
468 LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
469 LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
470 LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
471 result.setPrivateTools(LRTRoadFinder)
476 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
477 NNTrackTool.THistSvc = CompFactory.THistSvc()
478 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
480 NNTrackTool.IdealGeoRoads =
False
481 NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
483 NNTrackTool.MinNumberOfRealHitsInATrack = 5
if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else 9
484 NNTrackTool.useSectors =
False
485 NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
486 NNTrackTool.nInputsGNN = flags.Trigger.FPGATrackSim.GNN.nInputsGNN
487 NNTrackTool.useCartesian = flags.Trigger.FPGATrackSim.NNCartesianCoordinates
488 result.setPrivateTools(NNTrackTool)
493 TF_1st = CompFactory.FPGATrackSimTrackFitterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
494 TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
495 TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
497 TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
498 TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
499 TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
500 TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
501 TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
502 TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
503 TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
504 TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
505 TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
507 TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
508 result.addPublicTool(TF_1st, primary=
True)
513 OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
514 OR_1st.ORAlgo =
"Normal"
515 OR_1st.doFastOR = flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
516 OR_1st.NumOfHitPerGrouping = 3
517 OR_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
518 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
519 OR_1st.MinChi2 =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
520 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
521 OR_1st.MinChi2 =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
523 OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
524 if flags.Trigger.FPGATrackSim.ActiveConfig.hough
or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
525 OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
526 OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
527 OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
528 OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
530 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimOverlapRemovalToolMonitoringCfg
533 result.addPublicTool(OR_1st, primary=
True)
537 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=
True)
542 name=
"FPGATrackSimSpacepointRoadFilterTool_1st"
544 name=
"FPGATrackSimSpacepointRoadFilterTool_2st"
545 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
546 SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
548 SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
549 SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
550 SPRoadFilter.isSecondStage = secondStage
551 SPRoadFilter.dropUnpairedIfSP = flags.Trigger.FPGATrackSim.dropUnpairedIfSP
556 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
558 SPRoadFilter.threshold = 1
560 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
561 result.setPrivateTools(SPRoadFilter)
569 kwargs.setdefault(
"name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
571 theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg(**kwargs)
572 theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
573 theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
574 theFPGATrackSimLogicalHitsProcessAlg.SetTruthParametersForTracks = flags.Trigger.FPGATrackSim.SetTruthParametersForTracks
575 theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
576 theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
577 theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
578 theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
579 theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
580 theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionSvcCfg(flags))
581 if flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
582 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
583 elif flags.Trigger.FPGATrackSim.ActiveConfig.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis2nd:
584 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
586 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
587 theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
588 theFPGATrackSimLogicalHitsProcessAlg.secondStageStrips = (
not flags.Trigger.FPGATrackSim.ActiveConfig.GNN)
589 FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
590 theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
592 theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
594 if flags.Trigger.FPGATrackSim.tracking
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
597 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
599 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
601 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
606 if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
607 EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimEtaPatternFilterTool"))
608 EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
609 EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
610 EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+
"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+
".patt"
611 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
612 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads =
True
614 if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
615 RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimPhiRoadFilterTool"))
616 RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
617 RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
618 RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
620 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow
for i
in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
621 RoadFilter2.window = windows
623 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
624 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 =
True
630 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimLLPRoadFilterTool"))
631 result.addPublicTool(LRTRoadFilter)
632 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
634 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(
LRTRoadFinderCfg(flags))
635 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(
NNTrackToolCfg(flags))
641 theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
642 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
644 if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
645 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter,
'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
646 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT,
'Inconsistent LRT HT setup, need either double or strightTrack enabled'
647 theFPGATrackSimLogicalHitsProcessAlg.doLRT =
True
648 theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (
not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
650 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
652 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
657 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]
659 side = (region >> 5) & 0x1
660 etaBin = (region >> 6) & 0x1F
661 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
663 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
666 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
667 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
668 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
669 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
670 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
671 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
672 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
675 return eta_to_chi2.get(abs_etaRange, 20)
678 chi2cut_l = [0.97,0.97,0.99,
686 side = (region >> 5) & 0x1
687 etaBin = (region >> 6) & 0x1F
688 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
690 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
693 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
694 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
695 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
696 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
697 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
698 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
699 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
701 return eta_to_chi2.get(abs_etaRange, 0.99)
706 if flags.Trigger.FPGATrackSim.regionList ==
"":
707 flags.Trigger.FPGATrackSim.regionList = [flags.Trigger.FPGATrackSim.region]
709 from FPGATrackSimConfTools.FPGATrackSimHelperFunctions
import convertRegionsExpressionToArray
711 print(f
"Running for regions: {flags.Trigger.FPGATrackSim.regionList}")
713 if __name__ ==
"__main__":
714 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
715 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
722 FinalProtoTrackChainxAODTracksKey=
"FPGA"
723 flags.Detector.EnableCalo =
False
726 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
727 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
728 from ActsConfig.ActsCIFlags
import actsLegacyWorkflowFlags
730 flags.Acts.doRotCorrection =
False
733 flags.Concurrency.NumThreads=1
734 flags.Concurrency.NumConcurrentEvents=1
735 flags.Concurrency.NumProcs=0
736 flags.Scheduler.ShowDataDeps=
True
737 flags.Scheduler.CheckDependencies=
True
738 flags.Debug.DumpEvtStore=
False
746 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and not flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
747 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
748 assert not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-5'),
"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
750 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
751 print(
"You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
752 FPGATrackSimDataPrepConfig.runDataPrepChain()
753 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-2')):
754 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")
755 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
True
756 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
True
757 flags.Trigger.FPGATrackSim.Hough.hough1D =
True
758 flags.Trigger.FPGATrackSim.Hough.hough =
False
759 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-3')):
760 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")
761 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
False
762 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
False
763 flags.Trigger.FPGATrackSim.Hough.hough1D =
False
764 flags.Trigger.FPGATrackSim.Hough.hough =
True
765 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-4')):
766 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")
767 flags.Trigger.FPGATrackSim.Hough.GNN =
True
768 flags.Trigger.FPGATrackSim.Hough.chi2cut = 40
769 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
770 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")
771 flags.Trigger.FPGATrackSim.Hough.genScan=
True
772 flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
773 elif (flags.Trigger.FPGATrackSim.pipeline !=
""):
774 raise AssertionError(
"ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline +
" which is not yet supported!")
776 if (
not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
778 flags.Tracking.writeExtendedSi_PRDInfo =
not flags.Trigger.FPGATrackSim.writeOfflPRDInfo
779 splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split(
'-')
780 trackingOption=9999999
781 if (len(splitPipeline) > 1): trackingOption=
int(splitPipeline[1])
782 if (trackingOption < 9999999):
783 trackingOptionMod = (trackingOption % 100)
784 if (trackingOptionMod == 0):
785 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")
786 flags.Trigger.FPGATrackSim.tracking =
True
787 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
788 elif (trackingOptionMod == 10):
789 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")
790 flags.Trigger.FPGATrackSim.tracking =
True
791 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
True
792 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
793 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
794 flags.Trigger.FPGATrackSim.doNNPathFinder =
True
795 flags.Trigger.FPGATrackSim.doOverlapRemoval =
False
796 flags.Trigger.FPGATrackSim.tracking =
False
797 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
798 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis2nd = flags.Trigger.FPGATrackSim.Hough.secondStage
800 raise AssertionError(
"ERROR Your tracking option for the pipeline = " +
str(trackingOption) +
" is not yet supported!")
802 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
803 log.info(
"wrapperFile is string, converting to list")
804 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
805 flags.Input.Files =
lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
807 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
808 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
812 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass")
815 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
816 acc.addService(CompFactory.THistSvc(Output = [
"EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
818 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
819 acc.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
821 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
822 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
824 if (flags.Trigger.FPGATrackSim.Hough.genScan):
825 acc.addService(CompFactory.THistSvc(Output = [
"GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
827 if not flags.Trigger.FPGATrackSim.wrapperFileName:
828 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
832 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
835 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
838 if flags.Detector.EnableCalo:
839 from CaloRec.CaloRecoConfig
import CaloRecoCfg
842 if flags.Tracking.recoChain:
843 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
845 if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
846 from InDetConfig.InDetPrepRawDataToxAODConfig
import ITkActsPrepDataToxAODCfg
848 PixelMeasurementContainer =
"ITkPixelMeasurements_offl",
849 StripMeasurementContainer =
"ITkStripMeasurements_offl" ) )
850 from InDetConfig.InDetPrepRawDataToxAODConfig
import TruthParticleIndexDecoratorAlgCfg
852 from InDetConfig.InDetPrepRawDataFormationConfig
import ITkXAODToInDetClusterConversionCfg
857 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
859 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
862 if flags.Trigger.FPGATrackSim.doEDMConversion:
863 stage =
"_2nd" if flags.Trigger.FPGATrackSim.Hough.secondStage
else "_1st"
864 acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = f
"FPGAConversionAlg{stage}",
868 useRoads=
not flags.Trigger.FPGATrackSim.tracking))
870 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig
import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
872 useRoads=
not flags.Trigger.FPGATrackSim.tracking))
873 acc.merge(
FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey))
874 if flags.Trigger.FPGATrackSim.runCKF:
875 from FPGATrackSimConfTools.FPGATrackExtensionConfig
import FPGATrackExtensionAlgCfg
877 ProtoTracksLocation=f
"ActsProtoTracks{stage}FromFPGATrack"))
879 if flags.Trigger.FPGATrackSim.writeToAOD:
880 acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
882 finalTrackParticles=f
"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
885 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
887 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType !=
'skipTruth')
and flags.Exec.MaxEvents<=10 ) ))
889 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
891 acc.foreach_component(
"*FPGATrackSim*").OutputLevel=flags.Trigger.FPGATrackSim.loglevel
892 if flags.Trigger.FPGATrackSim.msgLimit!=-1:
893 acc.getService(
"MessageSvc").debugLimit = flags.Trigger.FPGATrackSim.msgLimit
894 acc.getService(
"MessageSvc").infoLimit = flags.Trigger.FPGATrackSim.msgLimit
895 acc.getService(
"MessageSvc").verboseLimit = flags.Trigger.FPGATrackSim.msgLimit
897 statusCode = acc.run(flags.Exec.MaxEvents)
898 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"