2 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaCommon.Logging
import AthenaLogger
5 from PathResolver
import PathResolver
8 log = AthenaLogger(__name__)
11 from FPGATrackSimConfTools
import FPGATrackSimDataPrepConfig
12 from FPGATrackSimConfTools
import FPGATrackSimSecondStageConfig
17 assert(fields.startswith(
'towers'))
25 FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool(
"FPGATrackSimWriteOutput")
26 FPGATrackSimWriteOutput.InFileName = [
"test.root"]
29 FPGATrackSimWriteOutput.RWstatus =
"HEADER"
30 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
31 result.addPublicTool(FPGATrackSimWriteOutput, primary=
True)
38 FPGATrackSimBankSvc = CompFactory.FPGATrackSimBankSvc()
39 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/'
41 FPGATrackSimBankSvc.constantsNoGuess_1st = [
42 f
'{pathBankSvc}corrgen_raw_8L_skipPlane0.gcon',
43 f
'{pathBankSvc}corrgen_raw_8L_skipPlane1.gcon',
44 f
'{pathBankSvc}corrgen_raw_8L_skipPlane2.gcon',
45 f
'{pathBankSvc}corrgen_raw_8L_skipPlane3.gcon',
46 f
'{pathBankSvc}corrgen_raw_8L_skipPlane4.gcon',
47 f
'{pathBankSvc}corrgen_raw_8L_skipPlane5.gcon',
48 f
'{pathBankSvc}corrgen_raw_8L_skipPlane6.gcon',
49 f
'{pathBankSvc}corrgen_raw_8L_skipPlane7.gcon']
50 FPGATrackSimBankSvc.constantsNoGuess_2nd = [
51 f
'{pathBankSvc}corrgen_raw_13L_skipPlane0.gcon',
52 f
'{pathBankSvc}corrgen_raw_13L_skipPlane1.gcon',
53 f
'{pathBankSvc}corrgen_raw_13L_skipPlane2.gcon',
54 f
'{pathBankSvc}corrgen_raw_13L_skipPlane3.gcon',
55 f
'{pathBankSvc}corrgen_raw_13L_skipPlane4.gcon',
56 f
'{pathBankSvc}corrgen_raw_13L_skipPlane5.gcon',
57 f
'{pathBankSvc}corrgen_raw_13L_skipPlane6.gcon',
58 f
'{pathBankSvc}corrgen_raw_13L_skipPlane7.gcon']
59 layers=
"5L" if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else "9L"
60 FPGATrackSimBankSvc.constants_1st = f
'{pathBankSvc}corrgen_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
61 FPGATrackSimBankSvc.constants_2nd = f
'{pathBankSvc}corrgen_raw_13L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
62 FPGATrackSimBankSvc.sectorBank_1st = f
'{pathBankSvc}sectorsHW_raw_{layers}_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
63 FPGATrackSimBankSvc.sectorBank_2nd = f
'{pathBankSvc}sectorsHW_raw_13L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
64 FPGATrackSimBankSvc.sectorSlices = f
'{pathBankSvc}slices_{layers}_reg{flags.Trigger.FPGATrackSim.region}.root'
65 FPGATrackSimBankSvc.phiShift = flags.Trigger.FPGATrackSim.phiShift
68 FPGATrackSimBankSvc.sectorQPtBins = [-0.001, -0.0005, 0, 0.0005, 0.001]
69 FPGATrackSimBankSvc.qptAbsBinning =
False
71 result.addService(FPGATrackSimBankSvc, create=
True, primary=
True)
77 RF = CompFactory.FPGATrackSimRoadUnionTool()
79 xBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBins
80 xBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
81 yBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBins
82 yBufferBins = flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
83 yMin = flags.Trigger.FPGATrackSim.ActiveConfig.qptMin
84 yMax = flags.Trigger.FPGATrackSim.ActiveConfig.qptMax
85 xMin = flags.Trigger.FPGATrackSim.ActiveConfig.phiMin
86 xMax = flags.Trigger.FPGATrackSim.ActiveConfig.phiMax
87 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
88 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
92 xBuffer = (xMax - xMin) / xBins * xBufferBins
95 yBuffer = (yMax - yMin) / yBins * yBufferBins
99 houghType = flags.Trigger.FPGATrackSim.ActiveConfig.houghType
100 roadMerge = flags.Trigger.FPGATrackSim.ActiveConfig.roadMerge
103 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
105 HoughTransform = CompFactory.FPGATrackSimHoughTransformTool(
"HoughTransform_0_" +
str(number))
106 HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
108 HoughTransform.FPGATrackSimMappingSvc = FPGATrackSimMapping
109 HoughTransform.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.combineLayers
110 HoughTransform.convSize_x = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeX
111 HoughTransform.convSize_y = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeY
112 HoughTransform.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.convolution
113 HoughTransform.d0_max = 0
114 HoughTransform.d0_min = 0
115 HoughTransform.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
116 HoughTransform.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX
117 HoughTransform.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
118 HoughTransform.nBins_x = xBins + 2 * xBufferBins
119 HoughTransform.nBins_y = yBins + 2 * yBufferBins
120 HoughTransform.phi_max = xMax
121 HoughTransform.phi_min = xMin
122 HoughTransform.qpT_max = yMax
123 HoughTransform.qpT_min = yMin
124 HoughTransform.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
125 HoughTransform.subRegion = number
126 HoughTransform.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold
127 HoughTransform.traceHits =
True
128 HoughTransform.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
129 HoughTransform.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
130 HoughTransform.houghType = houghType
131 HoughTransform.roadMerge = roadMerge
132 if houghType==
'LowResource':
133 HoughTransform.requirements = flags.Trigger.FPGATrackSim.ActiveConfig.requirements
134 if houghType==
'Flexible':
135 HoughTransform.r_max=flags.Trigger.FPGATrackSim.ActiveConfig.r_max
136 HoughTransform.phi_coord_max=flags.Trigger.FPGATrackSim.ActiveConfig.phi_coord_max
137 HoughTransform.phi_range=flags.Trigger.FPGATrackSim.ActiveConfig.phi_range
138 HoughTransform.r_max_mm=flags.Trigger.FPGATrackSim.ActiveConfig.r_max_mm
139 HoughTransform.bitwise_qApt_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_qApt_conv
140 HoughTransform.bitwise_phi0_conv=flags.Trigger.FPGATrackSim.ActiveConfig.bitwise_phi0_conv
141 HoughTransform.phi0_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.phi0_sectors
142 HoughTransform.qApt_sectors=flags.Trigger.FPGATrackSim.ActiveConfig.qApt_sectors
143 HoughTransform.pipes_qApt=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_qApt
144 HoughTransform.pipes_phi0=flags.Trigger.FPGATrackSim.ActiveConfig.pipes_phi0
146 tools.append(HoughTransform)
149 result.addPublicTool(RF, primary=
True)
157 RF = CompFactory.FPGATrackSimRoadUnionTool()
158 splitpt=flags.Trigger.FPGATrackSim.Hough1D.splitpt
159 FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
160 for ptstep
in range(splitpt):
161 qpt_min = flags.Trigger.FPGATrackSim.Hough1D.qptMin
162 qpt_max = flags.Trigger.FPGATrackSim.Hough1D.qptMax
163 lowpt = qpt_min + (qpt_max-qpt_min)/splitpt*ptstep
164 highpt = qpt_min + (qpt_max-qpt_min)/splitpt*(ptstep+1)
166 for iSlice
in range(nSlice):
167 tool = CompFactory.FPGATrackSimHough1DShiftTool(
"Hough1DShift" +
str(iSlice)+((
"_pt{}".
format(ptstep))
if splitpt>1
else ""))
168 tool.subRegion = iSlice
if nSlice > 1
else -1
169 xMin = flags.Trigger.FPGATrackSim.Hough1D.phiMin
170 xMax = flags.Trigger.FPGATrackSim.Hough1D.phiMax
171 if (
not flags.Trigger.FPGATrackSim.oldRegionDefs):
172 phiRange = FPGATrackSimDataPrepConfig.getPhiRange(flags)
179 tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
181 tool.variableExtend =
True
182 tool.drawHitMasks =
False
183 tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
187 tool.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
188 tool.hitExtend = flags.Trigger.FPGATrackSim.Hough1D.hitExtendX
189 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
191 tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
192 tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
193 tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
198 result.addPublicTool(RF, primary=
True)
208 if flags.Trigger.FPGATrackSim.oldRegionDefs:
209 toload=flags.Trigger.FPGATrackSim.GenScan.genScanCuts
210 if toload ==
'FPGATrackSimGenScanCuts':
211 toload =
'FPGATrackSimHough.FPGATrackSimGenScanCuts_incr'
212 cutset = importlib.import_module(toload).cuts[flags.Trigger.FPGATrackSim.region]
214 cutFileName = f
"{PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir)}{flags.Trigger.FPGATrackSim.GenScan.genScanCuts}.py"
215 print(f
"Cut File = {cutFileName}")
217 spec=importlib.util.spec_from_file_location(flags.Trigger.FPGATrackSim.GenScan.genScanCuts ,cutFileName)
218 print (
"Spec = ", spec)
220 print(
"Failed to find Cut File")
221 cutmodule = importlib.util.module_from_spec(spec)
222 spec.loader.exec_module(cutmodule)
223 cutset=cutmodule.cuts[flags.Trigger.FPGATrackSim.region]
227 if (cutset[
"parSet"]==
"PhiSlicedKeyLyrPars") :
228 Binning = CompFactory.FPGATrackSimGenScanPhiSlicedKeyLyrBinning(
"GenScanBinning")
229 Binning.approxMath =
False
231 log.error(
"Unknown Binning")
232 Binning.rin=cutset[
"rin"]
233 Binning.rout=cutset[
"rout"]
234 Binning.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
237 Monitor = CompFactory.FPGATrackSimGenScanMonitoring(
"GenScanMonitoring")
238 Monitor.THistSvc = CompFactory.THistSvc()
239 Monitor.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
242 tool = CompFactory.FPGATrackSimGenScanTool(
"GenScanTool")
243 tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
245 tool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
246 tool.Monitoring = Monitor
247 tool.Binning = Binning
248 tool.OutputLevel=flags.Trigger.FPGATrackSim.loglevel
251 tool.binFilter=flags.Trigger.FPGATrackSim.GenScan.binFilter
252 tool.reversePairDir=flags.Trigger.FPGATrackSim.GenScan.reverse
253 tool.applyPairFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
254 tool.applyPairSetFilter=
not flags.Trigger.FPGATrackSim.GenScan.noCuts
258 tool.d0FractionalPadding =0.05
259 tool.z0FractionalPadding =0.05
260 tool.etaFractionalPadding =0.05
261 tool.phiFractionalPadding =0.05
262 tool.qOverPtFractionalPadding =0.05
265 for (cut,val)
in cutset.items():
266 setattr(tool,cut,val)
269 if not flags.Trigger.FPGATrackSim.GenScan.layerStudy:
270 if flags.Trigger.FPGATrackSim.oldRegionDefs:
271 tool.layerMapFile = flags.Trigger.FPGATrackSim.GenScan.layerMapFile
274 tool.layerMapFile = f
"{PathResolver.FindCalibDirectory(flags.Trigger.FPGATrackSim.mapsDir)}{FPGATrackSimDataPrepConfig.getBaseName(flags)}_lyrmap.json"
278 RoadUnion = CompFactory.FPGATrackSimRoadUnionTool()
279 RoadUnion.tools = [tool,]
280 result.addPublicTool(RoadUnion, primary=
True)
285 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
286 RoadUnion.noHitFilter=
True
287 tool.binningOnly=
True
292 RF = CompFactory.FPGATrackSimRoadUnionTool()
294 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool()
295 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool()
300 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
302 RF.tools = [patternRecoTool]
303 result.addPublicTool(RF, primary=
True)
310 GNNGraphConstructionTool = CompFactory.FPGATrackSimGNNGraphConstructionTool()
311 GNNGraphConstructionTool.graphTool = flags.Trigger.FPGATrackSim.GNN.graphTool.value
314 GNNGraphConstructionTool.moduleMapType=flags.Trigger.FPGATrackSim.GNN.moduleMapType.value
315 GNNGraphConstructionTool.moduleMapFunc=flags.Trigger.FPGATrackSim.GNN.moduleMapFunc.value
316 GNNGraphConstructionTool.moduleMapTol=flags.Trigger.FPGATrackSim.GNN.moduleMapTol
320 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
321 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
323 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
324 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
327 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
329 result.setPrivateTools(GNNGraphConstructionTool)
336 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
337 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
339 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool()
341 flags, flags.Trigger.FPGATrackSim.GNN.GNNModelPath, OnnxRuntimeType.CPU))
343 result.setPrivateTools(GNNEdgeClassifierTool)
350 GNNRoadMakerTool = CompFactory.FPGATrackSimGNNRoadMakerTool()
351 GNNRoadMakerTool.roadMakerTool = flags.Trigger.FPGATrackSim.GNN.roadMakerTool.value
352 GNNRoadMakerTool.edgeScoreCut = flags.Trigger.FPGATrackSim.GNN.edgeScoreCut
353 GNNRoadMakerTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
355 result.setPrivateTools(GNNRoadMakerTool)
362 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool()
364 result.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
365 result.setPrivateTools(GNNRootOutputTool)
371 DataFlowTool = CompFactory.FPGATrackSimDataFlowTool()
372 DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
373 DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
374 DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
375 DataFlowTool.THistSvc = CompFactory.THistSvc()
376 result.setPrivateTools(DataFlowTool)
381 HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool()
382 HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
383 HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
384 HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
385 result.setPrivateTools(HoughRootOutputTool)
390 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool()
392 LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
393 LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
394 LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
395 LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
396 LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
397 LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
398 result.setPrivateTools(LRTRoadFinder)
403 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool()
404 NNTrackTool.THistSvc = CompFactory.THistSvc()
405 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
407 NNTrackTool.IdealGeoRoads =
False
408 NNTrackTool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
and not flags.Trigger.FPGATrackSim.ActiveConfig.GNN
410 NNTrackTool.MinNumberOfRealHitsInATrack = 5
if flags.Trigger.FPGATrackSim.ActiveConfig.genScan
else 9
411 NNTrackTool.useSectors =
False
412 NNTrackTool.doGNNTracking = flags.Trigger.FPGATrackSim.GNN.doGNNTracking
413 result.setPrivateTools(NNTrackTool)
418 TF_1st = CompFactory.FPGATrackSimTrackFitterTool(
"FPGATrackSimTrackFitterTool_1st")
419 TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
420 TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
422 TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
423 TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
424 TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
425 TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
426 TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
427 TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
428 TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
429 TF_1st.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
430 TF_1st.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan
432 result.addPublicTool(TF_1st, primary=
True)
437 OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool(
"FPGATrackSimOverlapRemovalTool_1st")
438 OR_1st.ORAlgo =
"Normal"
439 OR_1st.doFastOR =flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
440 OR_1st.NumOfHitPerGrouping = 3
441 OR_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
442 OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
443 if flags.Trigger.FPGATrackSim.ActiveConfig.hough
or flags.Trigger.FPGATrackSim.ActiveConfig.hough1D:
444 OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
445 OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
446 OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
447 OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
449 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimOverlapRemovalToolMonitoringCfg
452 result.addPublicTool(OR_1st, primary=
True)
456 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag)
460 name=
"FPGATrackSimSpacepointRoadFilterTool_1st"
462 name=
"FPGATrackSimSpacepointRoadFilterTool_2st"
463 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(name)
464 SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
465 SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
466 SPRoadFilter.isSecondStage = secondStage
468 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
469 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
471 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold[0]
472 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
480 if not flags.Trigger.FPGATrackSim.wrapperFileName:
481 from InDetConfig.InDetPrepRawDataFormationConfig
import AthenaTrkClusterizationCfg
484 theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg()
485 theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.writeAdditionalOutputData
486 theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
487 theFPGATrackSimLogicalHitsProcessAlg.doOverlapRemoval = flags.Trigger.FPGATrackSim.doOverlapRemoval
488 theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
489 theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput1st = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput1st
490 theFPGATrackSimLogicalHitsProcessAlg.NumOfHitPerGrouping = flags.Trigger.FPGATrackSim.ActiveConfig.NumOfHitPerGrouping
491 theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack_1st = flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis
492 theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
493 theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
494 theFPGATrackSimLogicalHitsProcessAlg.passLowestChi2TrackOnly = flags.Trigger.FPGATrackSim.ActiveConfig.passLowestChi2TrackOnly
495 FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
496 theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
499 if flags.Trigger.FPGATrackSim.tracking
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
502 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
504 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
506 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
511 if (flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter):
512 EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool()
513 EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
514 EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
515 EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+
"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+
".patt"
516 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
517 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads =
True
519 if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
520 RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool()
521 RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
522 RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
523 RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
525 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow
for i
in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
526 RoadFilter2.window = windows
528 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
529 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 =
True
534 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool()
535 result.addPublicTool(LRTRoadFilter)
536 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
538 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(
LRTRoadFinderCfg(flags))
539 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(
NNTrackToolCfg(flags))
546 if flags.Trigger.FPGATrackSim.spacePoints
and not flags.Trigger.FPGATrackSim.ActiveConfig.genScan:
548 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints =
True
551 if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
552 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter,
'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
553 assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT,
'Inconsistent LRT HT setup, need either double or strightTrack enabled'
554 theFPGATrackSimLogicalHitsProcessAlg.doLRT =
True
555 theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (
not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
557 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
560 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
566 chi2cut_l = [12, 16, 16, 16, 16, 18, 14, 16, 16, 16, 19, 15, 18, 12, 15, 15, 14, 14, 12, 15]
568 side = (region >> 5) & 0x1
569 etaBin = (region >> 6) & 0x1F
570 etaRange = [
round(binSize * etaBin, 1),
round(binSize * (etaBin + 1), 1)]
if side
else [
round(-binSize * (etaBin + 1), 1),
round(-binSize * etaBin, 1)]
571 abs_etaRange = tuple(abs(val)
for val
in etaRange)
574 (0.0, 0.2): chi2cut_l[0], (0.2, 0.4): chi2cut_l[1], (0.4, 0.6): chi2cut_l[2],
575 (0.6, 0.8): chi2cut_l[3], (0.8, 1.0): chi2cut_l[4], (1.0, 1.2): chi2cut_l[5],
576 (1.2, 1.4): chi2cut_l[6], (1.4, 1.6): chi2cut_l[7], (1.6, 1.8): chi2cut_l[8],
577 (1.8, 2.0): chi2cut_l[9], (2.0, 2.2): chi2cut_l[10], (2.2, 2.4): chi2cut_l[11],
578 (2.4, 2.6): chi2cut_l[12], (2.6, 2.8): chi2cut_l[13], (2.8, 3.0): chi2cut_l[14],
579 (3.0, 3.2): chi2cut_l[15], (3.2, 3.4): chi2cut_l[16], (3.4, 3.6): chi2cut_l[17],
580 (3.6, 3.8): chi2cut_l[18], (3.8, 4.0): chi2cut_l[19]
583 return eta_to_chi2.get(abs_etaRange, 9)
586 if __name__ ==
"__main__":
587 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
588 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
595 FinalProtoTrackChainxAODTracksKey=
"FPGA"
596 flags.Detector.EnableCalo =
False
599 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
600 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
601 from TrkConfig.TrkConfigFlags
import TrackingComponent
602 flags.Tracking.recoChain = [TrackingComponent.ActsChain]
603 flags.Acts.doRotCorrection =
False
606 flags.Concurrency.NumThreads=1
608 flags.Scheduler.ShowDataDeps=
True
609 flags.Scheduler.CheckDependencies=
True
610 flags.Debug.DumpEvtStore=
False
615 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut:
616 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2Cut(flags.Trigger.FPGATrackSim.region)
618 assert not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-5'),
"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
620 if (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
621 print(
"You are trying to run an F-100 pipeline! I am going to run the Data Prep chain for you and nothing else!")
622 FPGATrackSimDataPrepConfig.runDataPrepChain()
623 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-2')):
624 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")
625 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
True
626 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
True
627 flags.Trigger.FPGATrackSim.Hough.hough1D =
True
628 flags.Trigger.FPGATrackSim.Hough.hough =
False
629 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-3')):
630 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")
631 flags.Trigger.FPGATrackSim.Hough.etaPatternFilter =
False
632 flags.Trigger.FPGATrackSim.Hough.phiRoadFilter =
False
633 flags.Trigger.FPGATrackSim.Hough.hough1D =
False
634 flags.Trigger.FPGATrackSim.Hough.hough =
True
635 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-4')):
636 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")
637 flags.Trigger.FPGATrackSim.Hough.GNN =
True
638 flags.Trigger.FPGATrackSim.Hough.chi2cut = 40
639 elif (flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-6')):
640 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")
641 flags.Trigger.FPGATrackSim.Hough.genScan=
True
642 flags.Trigger.FPGATrackSim.spacePoints = flags.Trigger.FPGATrackSim.Hough.secondStage
643 elif (flags.Trigger.FPGATrackSim.pipeline !=
""):
644 raise AssertionError(
"ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline +
" which is not yet supported!")
646 if (
not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
648 splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split(
'-')
649 trackingOption=9999999
650 if (len(splitPipeline) > 1): trackingOption=
int(splitPipeline[1])
651 if (trackingOption < 9999999):
652 trackingOptionMod = (trackingOption % 100)
653 if (trackingOptionMod == 0):
654 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")
655 flags.Trigger.FPGATrackSim.tracking =
True
656 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
False
657 elif (trackingOptionMod == 10):
658 print(
"You are trying to run the NN fake rejection as part of a pipeline! I am going to enable this for you whether you want to or not")
659 flags.Trigger.FPGATrackSim.tracking =
True
660 flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis =
True
662 raise AssertionError(
"ERROR Your tracking option for the pipeline = " +
str(trackingOption) +
" is not yet supported!")
664 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
665 log.info(
"wrapperFile is string, converting to list")
666 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
667 flags.Input.Files =
lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
671 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass")
674 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
675 acc.addService(CompFactory.THistSvc(Output = [
"EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
677 if (flags.Trigger.FPGATrackSim.doNNPathFinder):
678 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUTNNPATHFINDER DATAFILE='NNPathfinder.root', OPT='RECREATE'"]))
680 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
681 acc.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
683 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
684 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
686 if (flags.Trigger.FPGATrackSim.Hough.genScan):
687 acc.addService(CompFactory.THistSvc(Output = [
"GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
689 if not flags.Trigger.FPGATrackSim.wrapperFileName:
690 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
694 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
697 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
700 if flags.Detector.EnableCalo:
701 from CaloRec.CaloRecoConfig
import CaloRecoCfg
704 if flags.Tracking.recoChain:
705 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
709 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
713 if flags.Trigger.FPGATrackSim.Hough.secondStage:
714 acc.merge(FPGATrackSimSecondStageConfig.FPGATrackSimSecondStageAlgCfg(flags))
716 if flags.Trigger.FPGATrackSim.doEDMConversion:
717 stage =
"_2nd" if flags.Trigger.FPGATrackSim.Hough.secondStage
else "_1st"
718 convertTracks = flags.Trigger.FPGATrackSim.tracking
719 acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = f
"FPGAConversionAlg{stage}",
722 doSP=flags.Trigger.FPGATrackSim.spacePoints,
723 useRoads=
not flags.Trigger.FPGATrackSim.tracking))
725 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig
import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
727 useRoads=
not flags.Trigger.FPGATrackSim.tracking))
728 acc.merge(
FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey,stage=f
"{stage}"))
729 if not flags.Trigger.FPGATrackSim.wrapperFileName
and flags.Trigger.FPGATrackSim.runCKF:
730 from FPGATrackSimConfTools.FPGATrackExtensionConfig
import FPGATrackExtensionAlgCfg
732 ProtoTracksLocation=f
"ActsProtoTracks{stage}FromFPGATrack"))
734 if flags.Trigger.FPGATrackSim.writeToAOD: acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
736 finalTrackParticles=f
"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
739 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
741 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType !=
'skipTruth')
and flags.Exec.MaxEvents<=10 ) ))
743 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
745 acc.foreach_component(
"FPGATrackSim*").OutputLevel=flags.Trigger.FPGATrackSim.loglevel
746 if flags.Trigger.FPGATrackSim.msgLimit!=-1:
747 acc.getService(
"MessageSvc").debugLimit = flags.Trigger.FPGATrackSim.msgLimit
748 acc.getService(
"MessageSvc").infoLimit = flags.Trigger.FPGATrackSim.msgLimit
750 statusCode = acc.run(flags.Exec.MaxEvents)
751 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"