ATLAS Offline Software
FPGATrackSimAnalysisConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaCommon.Logging import AthenaLogger
6 from PathResolver import PathResolver
7 
8 log = AthenaLogger(__name__)
9 
10 
11 from FPGATrackSimConfTools import FPGATrackSimDataPrepConfig
12 from FPGATrackSimConfTools import FPGATrackSimSecondStageConfig
13 
14 def getNSubregions(filePath):
15  with open(PathResolver.FindCalibFile(filePath), 'r') as f:
16  fields = f.readline()
17  assert(fields.startswith('towers'))
18  n = fields.split()[1]
19  return int(n)
20 
21 
22 
23 # Need to figure out if we have two output writers or somehow only one.
25  result=ComponentAccumulator()
26  FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool("FPGATrackSimWriteOutput")
27  FPGATrackSimWriteOutput.InFileName = ["test.root"]
28  # RECREATE means that that this tool opens the file.
29  # HEADER would mean that something else (e.g. THistSvc) opens it and we just add the object.
30  FPGATrackSimWriteOutput.RWstatus = "HEADER"
31  FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
32  result.addPublicTool(FPGATrackSimWriteOutput, primary=True)
33  return result
34 
35 
36 
38  result=ComponentAccumulator()
39  FPGATrackSimBankSvc = CompFactory.FPGATrackSimBankSvc()
40  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  FPGATrackSimBankSvc.constants_1st = f'{pathBankSvc}corrgen_raw_9L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
60  FPGATrackSimBankSvc.constants_2nd = f'{pathBankSvc}corrgen_raw_13L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.gcon'
61  FPGATrackSimBankSvc.sectorBank_1st = f'{pathBankSvc}sectorsHW_raw_9L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
62  FPGATrackSimBankSvc.sectorBank_2nd = f'{pathBankSvc}sectorsHW_raw_13L_reg{flags.Trigger.FPGATrackSim.region}_checkGood1.patt'
63  FPGATrackSimBankSvc.sectorSlices = f'{pathBankSvc}slices_9L_reg{flags.Trigger.FPGATrackSim.region}.root'
64 
65  # These should be configurable. The tag system needs updating though.
66  import FPGATrackSimConfTools.FPGATrackSimTagConfig as FPGATrackSimTagConfig
67  bank_tag = FPGATrackSimTagConfig.getTags(stage='bank')['bank']
68  FPGATrackSimBankSvc.sectorQPtBins = bank_tag['sectorQPtBins']
69  FPGATrackSimBankSvc.qptAbsBinning = bank_tag['qptAbsBinning']
70 
71  result.addService(FPGATrackSimBankSvc, create=True, primary=True)
72  return result
73 
74 
76  result=ComponentAccumulator()
77  RF = CompFactory.FPGATrackSimRoadUnionTool()
78 
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  xMin = flags.Trigger.FPGATrackSim.ActiveConfig.phiMin
84  xMax = flags.Trigger.FPGATrackSim.ActiveConfig.phiMax
85  xBuffer = (xMax - xMin) / xBins * xBufferBins
86  xMin = xMin - xBuffer
87  xMax = xMax + xBuffer
88  yMin = flags.Trigger.FPGATrackSim.ActiveConfig.qptMin
89  yMax = flags.Trigger.FPGATrackSim.ActiveConfig.qptMax
90  yBuffer = (yMax - yMin) / yBins * yBufferBins
91  yMin -= yBuffer
92  yMax += yBuffer
93  tools = []
94 
95  FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
96  for number in range(getNSubregions(FPGATrackSimMapping.subrmap)):
97  HoughTransform = CompFactory.FPGATrackSimHoughTransformTool("HoughTransform_0_" + str(number))
98  HoughTransform.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
99  HoughTransform.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
100  HoughTransform.FPGATrackSimMappingSvc = FPGATrackSimMapping
101  HoughTransform.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.combineLayers
102  HoughTransform.convSize_x = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeX
103  HoughTransform.convSize_y = flags.Trigger.FPGATrackSim.ActiveConfig.convSizeY
104  HoughTransform.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.convolution
105  HoughTransform.d0_max = 0
106  HoughTransform.d0_min = 0
107  HoughTransform.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
108  HoughTransform.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX
109  HoughTransform.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
110  HoughTransform.nBins_x = xBins + 2 * xBufferBins
111  HoughTransform.nBins_y = yBins + 2 * yBufferBins
112  HoughTransform.phi_max = xMax
113  HoughTransform.phi_min = xMin
114  HoughTransform.qpT_max = yMax
115  HoughTransform.qpT_min = yMin
116  HoughTransform.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
117  HoughTransform.subRegion = number
118  HoughTransform.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold
119  HoughTransform.traceHits = True
120  HoughTransform.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
121  HoughTransform.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
122 
123  tools.append(HoughTransform)
124 
125  RF.tools = tools
126  result.addPublicTool(RF, primary=True)
127  return result
128 
130  result=ComponentAccumulator()
131  tools = []
132  RF = CompFactory.FPGATrackSimRoadUnionTool()
133  splitpt=flags.Trigger.FPGATrackSim.Hough1D.splitpt
134  FPGATrackSimMapping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
135  for ptstep in range(splitpt):
136  qpt_min = flags.Trigger.FPGATrackSim.Hough1D.qptMin
137  qpt_max = flags.Trigger.FPGATrackSim.Hough1D.qptMax
138  lowpt = qpt_min + (qpt_max-qpt_min)/splitpt*ptstep
139  highpt = qpt_min + (qpt_max-qpt_min)/splitpt*(ptstep+1)
140  nSlice = getNSubregions(FPGATrackSimMapping.subrmap)
141  for iSlice in range(nSlice):
142  tool = CompFactory.FPGATrackSimHough1DShiftTool("Hough1DShift" + str(iSlice)+(("_pt{}".format(ptstep)) if splitpt>1 else ""))
143  tool.subRegion = iSlice if nSlice > 1 else -1
144  tool.phiMin = flags.Trigger.FPGATrackSim.Hough1D.phiMin
145  tool.phiMax = flags.Trigger.FPGATrackSim.Hough1D.phiMax
146  tool.qptMin = lowpt
147  tool.qptMax = highpt
148  tool.nBins = flags.Trigger.FPGATrackSim.Hough1D.xBins
149  tool.useDiff = True
150  tool.variableExtend = True
151  tool.drawHitMasks = False
152  tool.phiRangeCut = flags.Trigger.FPGATrackSim.Hough1D.phiRangeCut
153  tool.d0spread=-1.0 # mm
154  tool.iterStep = 0 # auto, TODO put in tag
155  tool.iterLayer = 7 # TODO put in tag
156  tool.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
157  tool.hitExtend = flags.Trigger.FPGATrackSim.Hough1D.hitExtendX
158  tool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
159  tool.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
160  tool.FPGATrackSimMappingSvc = FPGATrackSimMapping
161  tool.IdealGeoRoads = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
162  tool.useSpacePoints = flags.Trigger.FPGATrackSim.spacePoints
163 
164  tools.append(tool)
165 
166  RF.tools = tools
167  result.addPublicTool(RF, primary=True)
168  return result
169 
171  result=ComponentAccumulator()
172  DataFlowTool = CompFactory.FPGATrackSimDataFlowTool()
173  DataFlowTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
174  DataFlowTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
175  DataFlowTool.Chi2ndofCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
176  DataFlowTool.THistSvc = CompFactory.THistSvc()
177  result.setPrivateTools(DataFlowTool)
178  return result
179 
181  result=ComponentAccumulator()
182  HoughRootOutputTool = CompFactory.FPGATrackSimHoughRootOutputTool()
183  HoughRootOutputTool.FPGATrackSimEventSelectionSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
184  HoughRootOutputTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
185  HoughRootOutputTool.THistSvc = CompFactory.THistSvc()
186  result.setPrivateTools(HoughRootOutputTool)
187  return result
188 
189 def LRTRoadFinderCfg(flags):
190  result=ComponentAccumulator()
191  LRTRoadFinder =CompFactory.FPGATrackSimHoughTransform_d0phi0_Tool()
192  LRTRoadFinder.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
193  LRTRoadFinder.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
194  LRTRoadFinder.combine_layers = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackCombineLayers
195  LRTRoadFinder.convolution = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackConvolution
196  LRTRoadFinder.hitExtend_x = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackHitExtendX
197  LRTRoadFinder.scale = flags.Trigger.FPGATrackSim.ActiveConfig.scale
198  LRTRoadFinder.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.lrtStraighttrackThreshold
199  result.setPrivateTools(LRTRoadFinder)
200  return result
201 
202 def NNTrackToolCfg(flags):
203  result=ComponentAccumulator()
204  NNTrackTool = CompFactory.FPGATrackSimNNTrackTool()
205  NNTrackTool.THistSvc = CompFactory.THistSvc()
206  NNTrackTool.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
207  result.setPrivateTools(NNTrackTool)
208  return result
209 
211  result=ComponentAccumulator()
212  TF_1st = CompFactory.FPGATrackSimTrackFitterTool("FPGATrackSimTrackFitterTool_1st")
213  TF_1st.GuessHits = flags.Trigger.FPGATrackSim.ActiveConfig.guessHits
214  TF_1st.IdealCoordFitType = flags.Trigger.FPGATrackSim.ActiveConfig.idealCoordFitType
215  TF_1st.FPGATrackSimBankSvc = result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
216  TF_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
217  TF_1st.chi2DofRecoveryMax = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMax
218  TF_1st.chi2DofRecoveryMin = flags.Trigger.FPGATrackSim.ActiveConfig.chi2DoFRecoveryMin
219  TF_1st.doMajority = flags.Trigger.FPGATrackSim.ActiveConfig.doMajority
220  TF_1st.nHits_noRecovery = flags.Trigger.FPGATrackSim.ActiveConfig.nHitsNoRecovery
221  TF_1st.DoDeltaGPhis = flags.Trigger.FPGATrackSim.ActiveConfig.doDeltaGPhis
222  TF_1st.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
223  result.addPublicTool(TF_1st, primary=True)
224  return result
225 
227  result=ComponentAccumulator()
228  OR_1st = CompFactory.FPGATrackSimOverlapRemovalTool("FPGATrackSimOverlapRemovalTool_1st")
229  OR_1st.ORAlgo = "Normal"
230  OR_1st.doFastOR =flags.Trigger.FPGATrackSim.ActiveConfig.doFastOR
231  OR_1st.NumOfHitPerGrouping = 5
232  OR_1st.FPGATrackSimMappingSvc = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
233  OR_1st.MinChi2 = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
234  if flags.Trigger.FPGATrackSim.ActiveConfig.hough:
235  OR_1st.nBins_x = flags.Trigger.FPGATrackSim.ActiveConfig.xBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.xBufferBins
236  OR_1st.nBins_y = flags.Trigger.FPGATrackSim.ActiveConfig.yBins + 2 * flags.Trigger.FPGATrackSim.ActiveConfig.yBufferBins
237  OR_1st.localMaxWindowSize = flags.Trigger.FPGATrackSim.ActiveConfig.localMaxWindowSize
238  OR_1st.roadSliceOR = flags.Trigger.FPGATrackSim.ActiveConfig.roadSliceOR
239 
240  result.addPublicTool(OR_1st, primary=True)
241  return result
242 
244  newFlags = flags.cloneAndReplace("Trigger.FPGATrackSim.ActiveConfig", "Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag)
245  return newFlags
246 
248 
250 
251  result=ComponentAccumulator()
252  if not flags.Trigger.FPGATrackSim.wrapperFileName:
253  from InDetConfig.InDetPrepRawDataFormationConfig import AthenaTrkClusterizationCfg
254  result.merge(AthenaTrkClusterizationCfg(flags))
255 
256  theFPGATrackSimLogicalHitsProcessAlg=CompFactory.FPGATrackSimLogicalHitsProcessAlg()
257  theFPGATrackSimLogicalHitsProcessAlg.writeOutputData = flags.Trigger.FPGATrackSim.ActiveConfig.writeOutputData
258  theFPGATrackSimLogicalHitsProcessAlg.tracking = flags.Trigger.FPGATrackSim.tracking
259  theFPGATrackSimLogicalHitsProcessAlg.DoMissingHitsChecks = flags.Trigger.FPGATrackSim.ActiveConfig.doMissingHitsChecks
260  theFPGATrackSimLogicalHitsProcessAlg.DoHoughRootOutput = flags.Trigger.FPGATrackSim.ActiveConfig.houghRootoutput
261  theFPGATrackSimLogicalHitsProcessAlg.DoNNTrack = False
262  theFPGATrackSimLogicalHitsProcessAlg.runOnRDO = not flags.Trigger.FPGATrackSim.wrapperFileName
263  theFPGATrackSimLogicalHitsProcessAlg.eventSelector = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimEventSelectionCfg(flags))
264  theFPGATrackSimLogicalHitsProcessAlg.TrackScoreCut = flags.Trigger.FPGATrackSim.ActiveConfig.chi2cut
265 
266  FPGATrackSimMaping = result.getPrimaryAndMerge(FPGATrackSimDataPrepConfig.FPGATrackSimMappingCfg(flags))
267  theFPGATrackSimLogicalHitsProcessAlg.FPGATrackSimMapping = FPGATrackSimMaping
268 
269  # If tracking is set to False, don't configure the bank service
270  if flags.Trigger.FPGATrackSim.tracking:
271  result.getPrimaryAndMerge(FPGATrackSimBankSvcCfg(flags))
272 
273  if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
274  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionTool1DCfg(flags))
275  else:
276  theFPGATrackSimLogicalHitsProcessAlg.RoadFinder = result.getPrimaryAndMerge(FPGATrackSimRoadUnionToolCfg(flags))
277 
278  if flags.Trigger.FPGATrackSim.ActiveConfig.etaPatternFilter:
279  EtaPatternFilter = CompFactory.FPGATrackSimEtaPatternFilterTool()
280  EtaPatternFilter.FPGATrackSimMappingSvc = FPGATrackSimMaping
281  EtaPatternFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
282  EtaPatternFilter.EtaPatterns = flags.Trigger.FPGATrackSim.mapsDir+"/"+FPGATrackSimDataPrepConfig.getBaseName(flags)+".patt"
283  theFPGATrackSimLogicalHitsProcessAlg.RoadFilter = EtaPatternFilter
284  theFPGATrackSimLogicalHitsProcessAlg.FilterRoads = True
285 
286  if (flags.Trigger.FPGATrackSim.ActiveConfig.phiRoadFilter):
287  RoadFilter2 = CompFactory.FPGATrackSimPhiRoadFilterTool()
288  RoadFilter2.FPGATrackSimMappingSvc = FPGATrackSimMaping
289  RoadFilter2.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
290  RoadFilter2.fieldCorrection = flags.Trigger.FPGATrackSim.ActiveConfig.fieldCorrection
291 
292  windows = [flags.Trigger.FPGATrackSim.Hough1D.phifilterwindow for i in range(len(flags.Trigger.FPGATrackSim.ActiveConfig.hitExtendX))]
293  RoadFilter2.window = windows
294 
295  theFPGATrackSimLogicalHitsProcessAlg.RoadFilter2 = RoadFilter2
296  theFPGATrackSimLogicalHitsProcessAlg.FilterRoads2 = True
297 
298 
299  theFPGATrackSimLogicalHitsProcessAlg.HoughRootOutputTool = result.getPrimaryAndMerge(FPGATrackSimHoughRootOutputToolCfg(flags))
300 
301  LRTRoadFilter = CompFactory.FPGATrackSimLLPRoadFilterTool()
302  result.addPublicTool(LRTRoadFilter)
303  theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFilter = LRTRoadFilter
304 
305  theFPGATrackSimLogicalHitsProcessAlg.LRTRoadFinder = result.getPrimaryAndMerge(LRTRoadFinderCfg(flags))
306  theFPGATrackSimLogicalHitsProcessAlg.NNTrackTool = result.getPrimaryAndMerge(NNTrackToolCfg(flags))
307 
308  theFPGATrackSimLogicalHitsProcessAlg.OutputTool = result.getPrimaryAndMerge(FPGATrackSimWriteOutputCfg(flags))
309  theFPGATrackSimLogicalHitsProcessAlg.TrackFitter_1st = result.getPrimaryAndMerge(FPGATrackSimTrackFitterToolCfg(flags))
310  theFPGATrackSimLogicalHitsProcessAlg.OverlapRemoval_1st = result.getPrimaryAndMerge(FPGATrackSimOverlapRemovalToolCfg(flags))
311 
312  # Create SPRoadFilterTool if spacepoints are turned on. TODO: make things configurable?
313  if flags.Trigger.FPGATrackSim.spacePoints:
314  SPRoadFilter = CompFactory.FPGATrackSimSpacepointRoadFilterTool("FPGATrackSimSpacepointRoadFilterTool_1st")
315  SPRoadFilter.filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
316  SPRoadFilter.minSpacePlusPixel = flags.Trigger.FPGATrackSim.minSpacePlusPixel
317  # TODO guard here against threshold being more than one value?
318  if (flags.Trigger.FPGATrackSim.ActiveConfig.hough1D):
319  SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.Hough1D.threshold[0]
320  else:
321  SPRoadFilter.threshold = flags.Trigger.FPGATrackSim.ActiveConfig.threshold[0]
322  SPRoadFilter.setSectors = (flags.Trigger.FPGATrackSim.ActiveConfig.IdealGeoRoads and flags.Trigger.FPGATrackSim.tracking)
323 
324  theFPGATrackSimLogicalHitsProcessAlg.SPRoadFilterTool = SPRoadFilter
325  theFPGATrackSimLogicalHitsProcessAlg.Spacepoints = True
326 
327 
328  if flags.Trigger.FPGATrackSim.ActiveConfig.lrt:
329  assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseBasicHitFilter != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseMlHitFilter, 'Inconsistent LRT hit filtering setup, need either ML of Basic filtering enabled'
330  assert flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseStraightTrackHT != flags.Trigger.FPGATrackSim.ActiveConfig.lrtUseDoubletHT, 'Inconsistent LRT HT setup, need either double or strightTrack enabled'
331  theFPGATrackSimLogicalHitsProcessAlg.doLRT = True
332  theFPGATrackSimLogicalHitsProcessAlg.LRTHitFiltering = (not flags.Trigger.FPGATrackSim.ActiveConfig.lrtSkipHitFiltering)
333 
334  from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
335  theFPGATrackSimLogicalHitsProcessAlg.MonTool = result.getPrimaryAndMerge(FPGATrackSimLogicalHitsProcessAlgMonitoringCfg(flags))
336 
337  result.addEventAlgo(theFPGATrackSimLogicalHitsProcessAlg)
338 
339  return result
340 
341 
342 
343 
344 if __name__ == "__main__":
345  from AthenaConfiguration.AllConfigFlags import initConfigFlags
346  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
347 
348  flags = initConfigFlags()
349 
350 
351  from AthenaConfiguration.TestDefaults import defaultGeometryTags
352  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
353 
354 
356  FinalProtoTrackChainxAODTracksKey="xAODFPGAProtoTracks"
357  flags.Detector.EnableCalo = False
358 
359  # ensure that the xAOD SP and cluster containers are available
360  flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=True
361  flags.Tracking.ITkMainPass.doAthenaToActsCluster=True
362  from TrkConfig.TrkConfigFlags import TrackingComponent
363  flags.Tracking.recoChain = [TrackingComponent.ActsChain] # another viable option is TrackingComponent.AthenaChain
364  flags.Acts.doRotCorrection = False
365 
366  # IDTPM flags
367  from InDetTrackPerfMon.InDetTrackPerfMonFlags import initializeIDTPMConfigFlags, initializeIDTPMTrkAnaConfigFlags
368  flags = initializeIDTPMConfigFlags(flags)
369 
370  flags.PhysVal.IDTPM.outputFilePrefix = "myIDTPM_CA"
371  flags.PhysVal.IDTPM.plotsDefFileList = "InDetTrackPerfMon/PlotsDefFileList_default.txt" # default value - not needed
372  flags.PhysVal.IDTPM.plotsCommonValuesFile = "InDetTrackPerfMon/PlotsDefCommonValues.json" # default value - not needed
373  flags.PhysVal.OutputFileName = flags.PhysVal.IDTPM.outputFilePrefix + '.HIST.root' # automatically set in IDTPM config - not needed
374  flags.Output.doWriteAOD_IDTPM = True
375  flags.Output.AOD_IDTPMFileName = flags.PhysVal.IDTPM.outputFilePrefix + '.AOD_IDTPM.pool.root' # automatically set in IDTPM config - not needed
376  flags.PhysVal.IDTPM.trkAnaCfgFile = "InDetTrackPerfMon/EFTrkAnaConfig_example.json"
377 
378  flags = initializeIDTPMTrkAnaConfigFlags(flags)
379 
380  flags.PhysVal.IDTPM.TrkAnaEF.TrigTrkKey = f"{FinalProtoTrackChainxAODTracksKey}TrackParticles"
381  flags.PhysVal.IDTPM.TrkAnaDoubleRatio.TrigTrkKey = f"{FinalProtoTrackChainxAODTracksKey}TrackParticles"
382 
383  flags.PhysVal.doExample = False
384 
385  flags.Concurrency.NumThreads=1
386  #flags.Concurrency.NumProcs=0
387  flags.Scheduler.ShowDataDeps=True
388  flags.Scheduler.CheckDependencies=True
389 
390  # flags.Exec.DebugStage="exec" # useful option to debug the execution of the job - we want it commented out for production
391  flags.fillFromArgs()
392 
393  assert not flags.Trigger.FPGATrackSim.pipeline.startswith('F-4'),"ERROR You are trying to run an F-4* pipeline! This is not yet supported!"
394  assert not flags.Trigger.FPGATrackSim.pipeline.startswith('F-5'),"ERROR You are trying to run an F-5* pipeline! This is not yet supported!"
395 
396  if (flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
397  print("You are trying to run an F-!* pipeline! I am going to run the Data Prep chain for you and nothing else!")
398  FPGATrackSimDataPrepConfig.runDataPrepChain()
399  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-2')):
400  print("You are trying to run an F-2* pipeline! I am auto-configuring the 1D bitshift for you, iuncluding eta pattern filters and phi road filters")
401  flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = True
402  flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = True
403  flags.Trigger.FPGATrackSim.Hough.hough1D = True
404  flags.Trigger.FPGATrackSim.Hough.hough = False
405  elif (flags.Trigger.FPGATrackSim.pipeline.startswith('F-3')):
406  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")
407  flags.Trigger.FPGATrackSim.Hough.etaPatternFilter = False
408  flags.Trigger.FPGATrackSim.Hough.phiRoadFilter = False
409  flags.Trigger.FPGATrackSim.Hough.hough1D = False
410  flags.Trigger.FPGATrackSim.Hough.hough = True
411  elif (flags.Trigger.FPGATrackSim.pipeline != ""):
412  raise AssertionError("ERROR You are trying to run the pipeline " + flags.Trigger.FPGATrackSim.pipeline + " which is not yet supported!")
413 
414  if (not flags.Trigger.FPGATrackSim.pipeline.startswith('F-1')):
415 
416  splitPipeline=flags.Trigger.FPGATrackSim.pipeline.split('-')
417  trackingOption=9999999
418  if (len(splitPipeline) > 1): trackingOption=int(splitPipeline[1])
419  if (trackingOption < 9999999):
420  trackingOptionMod = (trackingOption % 100)
421  if (trackingOptionMod == 0):
422  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")
423  flags.Trigger.FPGATrackSim.tracking = True
424  elif (trackingOptionMod == 1):
425  raise AssertionError("ERROR You are trying to run the NN fake removal as part of a pipeline! This is not yet supported!")
426  else:
427  raise AssertionError("ERROR Your tracking option for the pipeline = " + str(trackingOption) + " is not yet supported!")
428 
429 
430  if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
431  log.info("wrapperFile is string, converting to list")
432  flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
433  flags.Input.Files = lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
434 
435  flags.lock()
436  flags = flags.cloneAndReplace("Tracking.ActiveConfig","Tracking.MainPass")
437  acc=MainServicesCfg(flags)
438 
439  acc.addService(CompFactory.THistSvc(Output = ["EXPERT DATAFILE='monitoring.root', OPT='RECREATE'"]))
440 
441  if (flags.Trigger.FPGATrackSim.Hough.houghRootoutput):
442  acc.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimHOUGHOUTPUT DATAFILE='HoughRootOutput.root', OPT='RECREATE'"]))
443 
444  acc.addService(CompFactory.THistSvc(Output = ["FPGATRACKSIMOUTPUT DATAFILE='test.root', OPT='RECREATE'"]))
445 
446 
447  if not flags.Trigger.FPGATrackSim.wrapperFileName:
448  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
449  acc.merge(PoolReadCfg(flags))
450 
451  if flags.Input.isMC:
452  from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
453  acc.merge(GEN_AOD2xAODCfg(flags))
454 
455  from JetRecConfig.JetRecoSteering import addTruthPileupJetsToOutputCfg # TO DO: check if this is indeed necessary for pileup samples
456  acc.merge(addTruthPileupJetsToOutputCfg(flags))
457 
458  if flags.Detector.EnableCalo:
459  from CaloRec.CaloRecoConfig import CaloRecoCfg
460  acc.merge(CaloRecoCfg(flags))
461 
462  if flags.Tracking.recoChain:
463  from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
464  acc.merge(InDetTrackRecoCfg(flags))
465 
466  # Configure both the dataprep and logical hits algorithms.
467  acc.merge(FPGATrackSimDataPrepConfig.FPGATrackSimDataPrepAlgCfg(flags))
468  acc.merge(FPGATrackSimLogicalHitsProcessAlgCfg(flags))
469 
470  # If second stage is turned on, turn that algorithm on too.
471  if flags.Trigger.FPGATrackSim.Hough.secondStage:
472  acc.merge(FPGATrackSimSecondStageConfig.FPGATrackSimSecondStageAlgCfg(flags))
473 
474  if flags.Trigger.FPGATrackSim.doEDMConversion:
475  acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = 'FPGAConversionAlg_1st', stage = '_1st', doActsTrk=True, doSP=flags.Trigger.FPGATrackSim.spacePoints))
476  from FPGATrackSimPrototrackFitter.FPGATrackSimPrototrackFitterConfig import FPGATruthDecorationCfg, FPGAProtoTrackFitCfg
477  acc.merge(FPGAProtoTrackFitCfg(flags,stage='_1st')) # Run ACTS KF for 1st stage
478  acc.merge(FPGATruthDecorationCfg(flags,FinalProtoTrackChainxAODTracksKey=FinalProtoTrackChainxAODTracksKey,stage='_1st')) # Run ACTS KF for 1st stage
479  if not flags.Trigger.FPGATrackSim.wrapperFileName:
480  from FPGATrackSimConfTools.FPGATrackExtensionConfig import FPGATrackExtensionAlgCfg
481  acc.merge(FPGATrackExtensionAlgCfg(flags, enableTrackStatePrinter=False, name="FPGATrackExtension", ProtoTracksLocation="ActsProtoTracks_1stFromFPGATrack")) # run CKF track extension on FPGA tracks
482 
483  if flags.Trigger.FPGATrackSim.writeToAOD: acc.merge(FPGATrackSimDataPrepConfig.WriteToAOD(flags,
484  stage = '_1st',
485  finalTrackParticles=f"{FinalProtoTrackChainxAODTracksKey}TrackParticles"))
486  if flags.Trigger.FPGATrackSim.Hough.secondStage : acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = 'FPGAConversionAlg_2nd', stage = '_2nd')) # Default disabled, doesn't work if enabled
487  if flags.Trigger.FPGATrackSim.convertUnmappedHits: acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = 'FPGAConversionAlgUnmapped_1st', stage = 'Unmapped_1st', doClusters = False))
488  if flags.Trigger.FPGATrackSim.Hough.hitFiltering : acc.merge(FPGATrackSimDataPrepConfig.FPGAConversionAlgCfg(flags, name = 'FPGAConversionAlgFiltered_1st', stage = 'Filtered_1st', doHits = False)) # Default disabled, works if enabled
489 
490  # Reporting algorithm (used for debugging - can be disabled)
491  from FPGATrackSimReporting.FPGATrackSimReportingConfig import FPGATrackSimReportingCfg
492  acc.merge(FPGATrackSimReportingCfg(flags,perEventReports=True))
493 
494  # IDTPM running
495  from InDetTrackPerfMon.InDetTrackPerfMonConfig import InDetTrackPerfMonCfg
496  acc.merge( InDetTrackPerfMonCfg(flags) )
497 
498  acc.store(open('AnalysisConfig.pkl','wb'))
499 
500  statusCode = acc.run(flags.Exec.MaxEvents)
501  assert statusCode.isSuccess() is True, "Application execution did not succeed"
FPGATrackSimPrototrackFitterConfig.FPGAProtoTrackFitCfg
def FPGAProtoTrackFitCfg(flags, name="FPGAPrototrackFitterConfig", stage='', **kwargs)
Definition: FPGATrackSimPrototrackFitterConfig.py:46
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:108
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
python.FPGATrackSimAnalysisConfig.FPGATrackSimBankSvcCfg
def FPGATrackSimBankSvcCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:37
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
FPGATrackSimPrototrackFitterConfig.FPGATruthDecorationCfg
def FPGATruthDecorationCfg(flags, FinalProtoTrackChainxAODTracksKey="xAODFPGAPrototracks", stage='', **kwargs)
Definition: FPGATrackSimPrototrackFitterConfig.py:62
xAODTruthCnvConfig.GEN_AOD2xAODCfg
def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:15
python.FPGATrackSimAnalysisConfig.FPGATrackSimTrackFitterToolCfg
def FPGATrackSimTrackFitterToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:210
python.FPGATrackSimAnalysisConfig.FPGATrackSimDataFlowToolCfg
def FPGATrackSimDataFlowToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:170
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionTool1DCfg
def FPGATrackSimRoadUnionTool1DCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:129
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
FPGATrackSimReportingConfig.FPGATrackSimReportingCfg
def FPGATrackSimReportingCfg(flags, name='FPGATrackSimReportingAlg', **kwargs)
Definition: FPGATrackSimReportingConfig.py:12
python.FPGATrackSimAnalysisConfig.prepareFlagsForFPGATrackSimLogicalHitsProcessAlg
def prepareFlagsForFPGATrackSimLogicalHitsProcessAlg(flags)
Definition: FPGATrackSimAnalysisConfig.py:243
python.FPGATrackSimAnalysisConfig.LRTRoadFinderCfg
def LRTRoadFinderCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:189
python.FPGATrackSimAnalysisConfig.FPGATrackSimWriteOutputCfg
def FPGATrackSimWriteOutputCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:24
python.JetRecoSteering.addTruthPileupJetsToOutputCfg
def addTruthPileupJetsToOutputCfg(flags, toAOD=True, toESD=True)
Definition: JetRecoSteering.py:7
python.FPGATrackSimAnalysisConfig.FPGATrackSimRoadUnionToolCfg
def FPGATrackSimRoadUnionToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:75
python.FPGATrackSimAnalysisConfig.NNTrackToolCfg
def NNTrackToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:202
FPGATrackSimAlgorithmConfig.FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
def FPGATrackSimLogicalHitsProcessAlgMonitoringCfg(flags)
Definition: FPGATrackSimAlgorithmConfig.py:246
python.FPGATrackSimAnalysisConfig.getNSubregions
def getNSubregions(filePath)
Definition: FPGATrackSimAnalysisConfig.py:14
python.TrackRecoConfig.InDetTrackRecoCfg
def InDetTrackRecoCfg(flags)
Main ID tracking config #####################.
Definition: TrackRecoConfig.py:791
python.FPGATrackSimAnalysisConfig.FPGATrackSimOverlapRemovalToolCfg
def FPGATrackSimOverlapRemovalToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:226
Trk::open
@ open
Definition: BinningType.h:40
python.InDetPrepRawDataFormationConfig.AthenaTrkClusterizationCfg
def AthenaTrkClusterizationCfg(flags)
Definition: InDetPrepRawDataFormationConfig.py:306
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
InDetTrackPerfMonFlags.initializeIDTPMConfigFlags
def initializeIDTPMConfigFlags(flags)
General config flag category for IDTPM tool job configuration.
Definition: InDetTrackPerfMonFlags.py:145
python.FPGATrackExtensionConfig.FPGATrackExtensionAlgCfg
def FPGATrackExtensionAlgCfg(flags, enableTrackStatePrinter=False, **kwargs)
Definition: FPGATrackExtensionConfig.py:6
python.FPGATrackSimAnalysisConfig.FPGATrackSimLogicalHitsProcessAlgCfg
def FPGATrackSimLogicalHitsProcessAlgCfg(inputFlags)
Definition: FPGATrackSimAnalysisConfig.py:247
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
InDetTrackPerfMonFlags.initializeIDTPMTrkAnaConfigFlags
def initializeIDTPMTrkAnaConfigFlags(flags)
Create flags category and corresponding set of flags.
Definition: InDetTrackPerfMonFlags.py:155
python.FPGATrackSimAnalysisConfig.FPGATrackSimHoughRootOutputToolCfg
def FPGATrackSimHoughRootOutputToolCfg(flags)
Definition: FPGATrackSimAnalysisConfig.py:180
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
InDetTrackPerfMonConfig.InDetTrackPerfMonCfg
def InDetTrackPerfMonCfg(flags)
Definition: InDetTrackPerfMonConfig.py:216