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"]
281 BinDesc.region = flags.Trigger.FPGATrackSim.region
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]
292 log.error(
"Unknown Binning Setup: ",cutset[
"parSet"])
294 BinTool.BinDesc = BinDesc
295 BinTool.Steps=binsteps
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
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
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"]
329 tool.inBinFiltering = flags.Trigger.FPGATrackSim.GenScan.filterInBin
330 tool.phiChi2Weight = flags.Trigger.FPGATrackSim.GenScan.phiChi2Weight
331 tool.etaChi2Weight = flags.Trigger.FPGATrackSim.GenScan.etaChi2Weight
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
342 for (cut,val)
in cutset.items():
343 if cut
in [
"parBins",
"parSet",
"parMin",
"parMax"]:
345 setattr(tool,cut,val)
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)
357 if flags.Trigger.FPGATrackSim.GenScan.layerStudy:
358 RoadUnion.noHitFilter=
True
359 tool.binningOnly=
True
364 RF = CompFactory.FPGATrackSimRoadUnionTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
365 RF.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
367 patternRecoTool = CompFactory.FPGATrackSimGNNPatternRecoTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNPatternRecoTool"))
368 patternRecoTool.GNNGraphHitSelector = CompFactory.FPGATrackSimGNNGraphHitSelectorTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimGNNGraphHitSelectorTool"))
371 result.merge(edgeResult)
372 patternRecoTool.GNNEdgeClassifiers = edgeClassifierTools
375 patternRecoTool.doGNNRootOutput = flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput
376 patternRecoTool.regionNum =
int(flags.Trigger.FPGATrackSim.region)
378 RF.tools = [patternRecoTool]
379 result.addPublicTool(RF, primary=
True)
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))
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
397 GNNGraphConstructionTool.metricLearningR=flags.Trigger.FPGATrackSim.GNN.metricLearningR
398 GNNGraphConstructionTool.metricLearningMaxN=flags.Trigger.FPGATrackSim.GNN.metricLearningMaxN
400 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
401 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
404 flags, flags.Trigger.FPGATrackSim.GNN.MLModelPath, OnnxRuntimeType.CPU))
406 result.setPrivateTools(GNNGraphConstructionTool)
413 from AthOnnxComps.OnnxRuntimeInferenceConfig
import OnnxRuntimeInferenceToolCfg
414 from AthOnnxComps.OnnxRuntimeFlags
import OnnxRuntimeType
416 region =
int(flags.Trigger.FPGATrackSim.region)
417 model_path = f
"{flags.Trigger.FPGATrackSim.GNN.GNNModelPath}_{region}.onnx"
419 GNNEdgeClassifierTool = CompFactory.FPGATrackSimGNNEdgeClassifierTool(
420 FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags, name))
421 GNNEdgeClassifierTool.GNNInferenceTool = result.popToolsAndMerge(
424 GNNEdgeClassifierTool.regionNum = region
426 return result, [GNNEdgeClassifierTool]
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))
437 from TrigFastTrackFinder.TrigFastTrackFinderConfig
import ITkTrigL2LayerNumberToolCfg
440 result.setPrivateTools(GNNRoadMakerTool)
447 GNNRootOutputTool = CompFactory.FPGATrackSimGNNRootOutputTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
448 GNNRootOutputTool.OutputRegion =
str(flags.Trigger.FPGATrackSim.region)
450 if(flags.Trigger.FPGATrackSim.GNN.doGNNRootOutput):
451 result.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimGNNOUTPUT DATAFILE='GNNRootOutput.root', OPT='RECREATE'"]))
452 result.setPrivateTools(GNNRootOutputTool)
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)
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)
479 LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
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)
492 NNTrackTool = CompFactory.FPGATrackSimNNTrackTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
493 NNTrackTool.THistSvc = CompFactory.THistSvc()
494 NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(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
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)
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
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
523 TF_1st.fitFromRoad = flags.Trigger.FPGATrackSim.ActiveConfig.fitFromRoad
524 result.addPublicTool(TF_1st, primary=
True)
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)
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
546 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimOverlapRemovalToolMonitoringCfg
549 result.addPublicTool(OR_1st, primary=
True)
553 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag,keepOriginal=
True)
558 name=
"FPGATrackSimSpacepointRoadFilterTool_1st"
560 name=
"FPGATrackSimSpacepointRoadFilterTool_2st"
561 SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
562 SPRoadFilter.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(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
572 SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.hitThreshold
574 SPRoadFilter.threshold = 1
576 SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads
and flags.Trigger.FPGATrackSim.tracking)
577 result.setPrivateTools(SPRoadFilter)
585 kwargs.setdefault(
"name", FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,name))
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)
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
610 theFPGATrackSimLogicalHitsProcessAlg.Region = flags.Trigger.FPGATrackSim.region
612 if flags.Trigger.FPGATrackSim.tracking
and not flags.Trigger.FPGATrackSim.ActiveConfig.trackNNAnalysis:
615 if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
617 elif (flags.Trigger.FPGATrackSim.ActiveConfig.genScan):
619 elif (flags.Trigger.FPGATrackSim.ActiveConfig.GNN):
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
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
638 windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow
for i
in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
639 RoadFilter2.window = windows
641 theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
642 theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 =
True
648 LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool(FPGATrackSimDataPrepConfig.nameWithRegionSuffix(flags,
"FPGATrackSimLLPRoadFilterTool"))
649 result.addPublicTool(LRTRoadFilter)
650 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
652 theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(
LRTRoadFinderCfg(flags))
653 theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(
NNTrackToolCfg(flags))
659 theFPGATrackSimLogicalHitsProcessAlg.SpacePointTool = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimSpacePointsToolCfg(flags))
660 theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = flags.Trigger.FPGATrackSim.spacePoints
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)
668 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
670 result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
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]
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)]
681 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
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]
693 return eta_to_chi2.get(abs_etaRange, 20)
696 chi2cut_l = [0.97,0.97,0.99,
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)]
708 abs_etaRange = tuple(
round(abs(val), 1)
for val
in etaRange)
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]
719 return eta_to_chi2.get(abs_etaRange, 0.99)
724 if flags.Trigger.FPGATrackSim.regionList ==
"":
725 flags.Trigger.FPGATrackSim.regionList = [flags.Trigger.FPGATrackSim.region]
727 from FPGATrackSimConfTools.FPGATrackSimHelperFunctions
import convertRegionsExpressionToArray
729 print(f
"Running for regions: {flags.Trigger.FPGATrackSim.regionList}")
733 FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepFlagCfg(flags)
735 flags.Scheduler.ShowDataDeps=
True
736 flags.Scheduler.CheckDependencies=
True
737 flags.Debug.DumpEvtStore=
False
739 flags.Trigger.FPGATrackSim.readOfflineObjects=
False
740 flags.Trigger.FPGATrackSim.doMultiTruth=
False
742 flags.Trigger.FPGATrackSim.tracking =
False
743 flags.Trigger.FPGATrackSim.convertSPs =
False
744 flags.Tracking.ITkActsValidateF150Pass.doActsSpacePoint =
not flags.Trigger.FPGATrackSim.convertSPs
745 flags.Trigger.FPGATrackSim.Hough.secondStage =
False
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"
754 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimClusteringCfg(flags))
756 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
759 from FPGATrackSimSeeding.FPGATrackSimSeedingConfig
import FPGATrackSimSeedingCfg
763 if flags.Tracking.ActiveConfig.storeTrackSeeds:
764 from ActsConfig.ActsSeedingConfig
import ActsStoreTrackSeedsCfg
765 from InDetConfig.ITkActsHelpers
import isFastPrimaryPass
768 processPixels =
True,
778 if flags.Trigger.FPGATrackSim.writeAdditionalOutputData:
779 acc.addService(CompFactory.THistSvc(Output = [
"EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
781 if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput1st | flags.Trigger.FPGATrackSim.Hough.houghRootoutput2nd):
782 acc.addService(CompFactory.THistSvc(Output = [
"TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
784 if flags.Trigger.FPGATrackSim.Hough.writeTestOutput:
785 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
787 if (flags.Trigger.FPGATrackSim.Hough.genScan):
788 acc.addService(CompFactory.THistSvc(Output = [
"GENSCAN DATAFILE='genscan.root', OPT='RECREATE'"]))
791 if __name__ ==
"__main__":
792 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
793 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
800 FinalProtoTrackChainxAODTracksKey=
"FPGA"
801 flags.Detector.EnableCalo =
False
804 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
805 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
806 from ActsConfig.ActsCIFlags
import actsLegacyWorkflowFlags
808 flags.Acts.doRotCorrection =
False
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
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!"
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
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!")
854 if (
not flags.Trigger.FPGATrackSim.pipeline.startswith(
'F-1')):
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
878 raise AssertionError(
"ERROR Your tracking option for the pipeline = " +
str(trackingOption) +
" is not yet supported!")
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]
885 if flags.Trigger.FPGATrackSim.Hough.useVaryingChi2Cut
and flags.Trigger.FPGATrackSim.Hough.trackNNAnalysis:
886 flags.Trigger.FPGATrackSim.Hough.chi2cut =
getChi2CutNN(flags.Trigger.FPGATrackSim.region)
890 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass")
895 if not flags.Trigger.FPGATrackSim.wrapperFileName:
896 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
900 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
903 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
906 if flags.Detector.EnableCalo:
907 from CaloRec.CaloRecoConfig
import CaloRecoCfg
910 if flags.Tracking.recoChain:
911 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
913 if flags.Trigger.FPGATrackSim.writeOfflPRDInfo:
914 from InDetConfig.InDetPrepRawDataToxAODConfig
import ITkActsPrepDataToxAODCfg
916 PixelMeasurementContainer =
"ITkPixelMeasurements_offl",
917 StripMeasurementContainer =
"ITkStripMeasurements_offl" ) )
918 from InDetConfig.InDetPrepRawDataToxAODConfig
import TruthParticleIndexDecoratorAlgCfg
920 from InDetConfig.InDetPrepRawDataFormationConfig
import ITkXAODToInDetClusterConversionCfg
925 acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
927 from FPGATrackSimConfTools.FPGATrackSimMultiRegionConfig
import FPGATrackSimMultiRegionTrackingCfg
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}",
935 doSP=flags.Trigger.FPGATrackSim.convertSPs))
937 from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig
import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
939 acc.merge(
FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey))
940 if flags.Trigger.FPGATrackSim.runCKF:
941 from FPGATrackSimConfTools.FPGATrackExtensionConfig
import FPGATrackExtensionAlgCfg
943 ProtoTracksLocation=f
"ActsProtoTracks{stage}FromFPGATrack"))
945 if flags.Trigger.FPGATrackSim.writeToAOD:
946 acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
948 finalTrackParticles=f
"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
951 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
953 perEventReports = ((flags.Trigger.FPGATrackSim.sampleType !=
'skipTruth')
and flags.Exec.MaxEvents<=10 ) ))
955 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
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
963 statusCode = acc.run(flags.Exec.MaxEvents)
964 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"