3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaCommon.Logging
import AthenaLogger
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
8 if (
not (flags.Trigger.FPGATrackSim.baseName ==
'')):
9 return flags.Trigger.FPGATrackSim.baseName
10 elif (flags.Trigger.FPGATrackSim.region == 0):
11 return 'eta0103phi0305'
12 elif (flags.Trigger.FPGATrackSim.region == 1):
13 return 'eta0709phi0305'
14 elif (flags.Trigger.FPGATrackSim.region == 2):
15 return 'eta1214phi0305'
16 elif (flags.Trigger.FPGATrackSim.region == 3):
17 return 'eta2022phi0305'
18 elif (flags.Trigger.FPGATrackSim.region == 4):
19 return 'eta3234phi0305'
20 elif (flags.Trigger.FPGATrackSim.region == 5):
21 return 'eta0103phi1113'
22 elif (flags.Trigger.FPGATrackSim.region == 6):
23 return 'eta0103phi1921'
24 elif (flags.Trigger.FPGATrackSim.region == 7):
25 return 'eta0103phi3436'
31 FPGATrackSimRawLogic = CompFactory.FPGATrackSimRawToLogicalHitsTool()
32 FPGATrackSimRawLogic.SaveOptional = 2
33 if (flags.Trigger.FPGATrackSim.ActiveConfig.sampleType ==
'skipTruth'):
34 FPGATrackSimRawLogic.SaveOptional = 1
35 FPGATrackSimRawLogic.TowersToMap = [0]
38 result.addPublicTool(FPGATrackSimRawLogic, primary=
True)
43 SpacePointTool = CompFactory.FPGATrackSimSpacePointsTool()
44 SpacePointTool.Filtering = flags.Trigger.FPGATrackSim.ActiveConfig.spacePointFiltering
45 SpacePointTool.FilteringClosePoints =
False
46 SpacePointTool.PhiWindow = 0.004
47 SpacePointTool.Duplication =
True
48 result.addPublicTool(SpacePointTool, primary=
True)
53 newFlags = flags.cloneAndReplace(
"Trigger.FPGATrackSim.ActiveConfig",
"Trigger.FPGATrackSim." + flags.Trigger.FPGATrackSim.algoTag)
59 FPGATrackSimWriteOutput = CompFactory.FPGATrackSimOutputHeaderTool(
"FPGATrackSimWriteOutputDataPrep")
60 FPGATrackSimWriteOutput.InFileName = [
"test.root"]
61 FPGATrackSimWriteOutput.OutputTreeName =
"FPGATrackSimDataPrepTree"
64 FPGATrackSimWriteOutput.RWstatus =
"HEADER"
65 FPGATrackSimWriteOutput.THistSvc = CompFactory.THistSvc()
66 result.addPublicTool(FPGATrackSimWriteOutput, primary=
True)
74 from StripGeoModelXml.ITkStripGeoModelConfig
import ITkStripReadoutGeometryCfg
77 kwargs.setdefault(
"FPGATrackSimClusterKey",
"FPGAClusters%s" %(stage))
78 kwargs.setdefault(
"FPGATrackSimHitKey",
"FPGAHits%s" %(stage))
79 kwargs.setdefault(
"FPGATrackSimHitInRoadsKey",
"FPGAHitsInRoads%s" %(stage))
80 kwargs.setdefault(
"FPGATrackSimRoadKey",
"FPGARoads%s" %(stage))
81 kwargs.setdefault(
"FPGATrackSimTrackKey",
"FPGATracks%s" %(stage))
82 kwargs.setdefault(
"xAODPixelClusterFromFPGAClusterKey",
"xAODPixelClusters%sFromFPGACluster" %(stage))
83 kwargs.setdefault(
"xAODStripClusterFromFPGAClusterKey",
"xAODStripClusters%sFromFPGACluster" %(stage))
84 kwargs.setdefault(
"xAODStripSpacePointFromFPGAKey",
"xAODStripSpacePoints%sFromFPGA" %(stage))
85 kwargs.setdefault(
"xAODPixelSpacePointFromFPGAKey",
"xAODPixelSpacePoints%sFromFPGA" %(stage))
86 kwargs.setdefault(
"xAODPixelClusterFromFPGAHitKey",
"xAODPixelClusters%sFromFPGAHit" %(stage))
87 kwargs.setdefault(
"xAODStripClusterFromFPGAHitKey",
"xAODStripClusters%sFromFPGAHit" %(stage))
88 kwargs.setdefault(
"ActsProtoTrackFromFPGARoadKey",
"ActsProtoTracks%sFromFPGARoad" %(stage))
89 kwargs.setdefault(
"ActsProtoTrackFromFPGATrackKey",
"ActsProtoTracks%sFromFPGATrack" %(stage))
90 kwargs.setdefault(
"doHits",
True)
91 kwargs.setdefault(
"doClusters",
True)
92 kwargs.setdefault(
"doActsTrk",
False)
96 result.addEventAlgo(CompFactory.FPGAConversionAlgorithm(name, **kwargs))
102 from SiLorentzAngleTool.ITkStripLorentzAngleConfig
import ITkStripLorentzAngleToolCfg
103 FPGAClusterConverter = CompFactory.FPGAClusterConverter(LorentzAngleTool=result.popToolsAndMerge(
ITkStripLorentzAngleToolCfg(flags)))
104 result.setPrivateTools(FPGAClusterConverter)
110 FPGAActsTrkConverter = CompFactory.FPGAActsTrkConverter()
111 result.setPrivateTools(FPGAActsTrkConverter)
118 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
119 from OutputStreamAthenaPool.OutputStreamConfig
import outputStreamName
120 from AthenaConfiguration.Enums
import MetadataCategory
124 MetadataCategory.ByteStreamMetaData,
125 MetadataCategory.LumiBlockMetaData,
126 MetadataCategory.TruthMetaData,
127 MetadataCategory.IOVMetaData,],)
129 log.info(
"AOD ItemList: %s", result.getEventAlgo(
outputStreamName(
"AOD")).ItemList)
130 log.info(
"AOD MetadataItemList: %s", result.getEventAlgo(
outputStreamName(
"AOD")).MetadataItemList)
131 log.info(
"---------- Configured AOD writing")
133 from OutputStreamAthenaPool.OutputStreamConfig
import addToAOD
135 toAOD += [f
"xAOD::PixelClusterContainer#xAODPixelClusters{stage}FromFPGACluster",f
"xAOD::PixelClusterAuxContainer#xAODPixelClusters{stage}FromFPGAClusterAux.",
136 f
"xAOD::StripClusterContainer#xAODStripClusters{stage}FromFPGACluster",f
"xAOD::StripClusterAuxContainer#xAODStripClusters{stage}FromFPGAClusterAux.",
137 f
"xAOD::TrackParticleContainer#{finalTrackParticles}",f
"xAOD::TrackParticleAuxContainer#{finalTrackParticles}Aux.",
138 f
"xAOD::SpacePointContainer#xAODPixelSpacePoints{stage}FromFPGA",f
"xAOD::SpacePointAuxContainer#xAODPixelSpacePoints{stage}FromFPGAAux.-measurements",
139 f
"xAOD::SpacePointContainer#xAODStripSpacePoints{stage}FromFPGA",f
"xAOD::SpacePointAuxContainer#xAODStripSpacePoints{stage}FromFPGAAux.-measurements.-sctSpacePointLink",
142 result.merge(
addToAOD(flags, toAOD))
149 eventSelector = CompFactory.FPGATrackSimEventSelectionSvc()
150 eventSelector.regions =
"HTT/TrigHTTMaps/V1/map_file/slices_v01_Jan21.txt"
151 eventSelector.regionID = flags.Trigger.FPGATrackSim.region
152 eventSelector.sampleType = flags.Trigger.FPGATrackSim.sampleType
153 eventSelector.withPU =
False
154 result.addService(eventSelector, create=
True, primary=
True)
160 mappingSvc = CompFactory.FPGATrackSimMappingSvc()
161 mappingSvc.mappingType =
"FILE"
162 mappingSvc.rmap = flags.Trigger.FPGATrackSim.mapsDir+
"/"+
getBaseName(flags)+
".rmap"
163 mappingSvc.subrmap = flags.Trigger.FPGATrackSim.mapsDir+
"/"+
getBaseName(flags)+
".subrmap"
164 mappingSvc.pmap = flags.Trigger.FPGATrackSim.mapsDir+
"/pmap"
165 mappingSvc.modulemap = flags.Trigger.FPGATrackSim.mapsDir+
"/moduleidmap"
166 mappingSvc.radiiFile = flags.Trigger.FPGATrackSim.mapsDir +
"/"+
getBaseName(flags)+
"_radii.txt"
167 mappingSvc.NNmap =
""
168 mappingSvc.layerOverride = []
169 result.addService(mappingSvc, create=
True, primary=
True)
175 InputTool = CompFactory.FPGATrackSimInputHeaderTool(name=
"FPGATrackSimReadInput",
176 InFileName = flags.Trigger.FPGATrackSim.wrapperFileName)
177 result.addPublicTool(InputTool, primary=
True)
182 InputTool2 = CompFactory.FPGATrackSimReadRawRandomHitsTool(name=
"FPGATrackSimReadInput2", InFileName = flags.Trigger.FPGATrackSim.wrapperFileName2)
183 result.addPublicTool(InputTool2, primary=
True)
188 HitFilteringTool = CompFactory.FPGATrackSimHitFilteringTool()
189 HitFilteringTool.barrelStubDphiCut = 3.0
190 HitFilteringTool.doRandomRemoval =
False
191 HitFilteringTool.doStubs =
False
192 HitFilteringTool.endcapStubDphiCut = 1.5
193 HitFilteringTool.pixelClusRmFrac = 0
194 HitFilteringTool.pixelHitRmFrac = 0
195 HitFilteringTool.stripClusRmFrac = 0
196 HitFilteringTool.stripHitRmFrac = 0
197 HitFilteringTool.useNstrips =
False
198 result.addPublicTool(HitFilteringTool, primary=
True)
209 theFPGATrackSimDataPrepAlg=CompFactory.FPGATrackSimDataPrepAlg()
210 theFPGATrackSimDataPrepAlg.HitFiltering = flags.Trigger.FPGATrackSim.ActiveConfig.hitFiltering
211 theFPGATrackSimDataPrepAlg.writeOutputData = flags.Trigger.FPGATrackSim.ActiveConfig.writeOutputData
212 theFPGATrackSimDataPrepAlg.Clustering = flags.Trigger.FPGATrackSim.clustering
214 theFPGATrackSimDataPrepAlg.runOnRDO =
not flags.Trigger.FPGATrackSim.wrapperFileName
217 theFPGATrackSimDataPrepAlg.FPGATrackSimMapping = FPGATrackSimMaping
221 if flags.Trigger.FPGATrackSim.wrapperFileName
and flags.Trigger.FPGATrackSim.wrapperFileName
is not None:
223 if flags.Trigger.FPGATrackSim.wrapperFileName2
and flags.Trigger.FPGATrackSim.wrapperFileName2
is not None:
225 theFPGATrackSimDataPrepAlg.SecondInputToolN = flags.Trigger.FPGATrackSim.secondInputToolN
226 theFPGATrackSimDataPrepAlg.SGInputTool =
""
228 from ActsConfig.ActsGeometryConfig
import ActsTrackingGeometryToolCfg
230 theFPGATrackSimDataPrepAlg.InputTool =
""
231 theFPGATrackSimDataPrepAlg.InputTool2 =
""
232 from FPGATrackSimSGInput.FPGATrackSimSGInputConfig
import FPGATrackSimSGInputToolCfg
239 theFPGATrackSimDataPrepAlg.ClusteringTool = CompFactory.FPGATrackSimClusteringTool()
243 if flags.Trigger.FPGATrackSim.spacePoints:
244 theFPGATrackSimDataPrepAlg.Spacepoints =
True
246 from FPGATrackSimAlgorithms.FPGATrackSimAlgorithmConfig
import FPGATrackSimLogicalHitsProcessAlgMonitoringCfg
249 result.addEventAlgo(theFPGATrackSimDataPrepAlg)
254 log = AthenaLogger(__name__)
258 ACTSTracks=
"FPGADataPrepActsTracks"
261 from ActsConfig.ActsSeedingConfig
import ActsStripSeedingAlgCfg, ActsPixelSeedingAlgCfg
263 InputSpacePoints=[
'xAODStripSpacePoints_1stFromFPGA'],
264 OutputSeeds=
"FPGADataPrepActsStripSeeds",
265 OutputEstimatedTrackParameters=
"FPGAActsStripEstimatedTrackParams"))
268 InputSpacePoints=[
'xAODPixelSpacePoints_1stFromFPGA'],
269 OutputSeeds=
"FPGADataPrepActsPixelSeeds",
270 OutputEstimatedTrackParameters=
"FPGAActsPixelEstimatedTrackParams"))
273 from ActsConfig.ActsTrackFindingConfig
import ActsMainTrackFindingAlgCfg
275 SeedContainerKeys=[
'FPGADataPrepActsPixelSeeds',
'FPGADataPrepActsStripSeeds'],
276 EstimatedTrackParametersKeys=[
'FPGAActsPixelEstimatedTrackParams',
'FPGAActsStripEstimatedTrackParams'],
277 UncalibratedMeasurementContainerKeys=[
"xAODPixelClusters_1stFromFPGACluster",
"xAODStripClusters_1stFromFPGACluster"],
278 ACTSTracksLocation=ACTSTracks))
281 from ActsConfig.ActsTruthConfig
import ActsTruthParticleHitCountAlgCfg, ActsPixelClusterToTruthAssociationAlgCfg,ActsStripClusterToTruthAssociationAlgCfg
283 name=
"FPGADataPrepActsPixelClusterToTruthAssociationAlg",
284 InputTruthParticleLinks=
"xAODFPGATruthLinks",
285 AssociationMapOut=
"ITkFPGAPixelClustersToTruthParticles",
286 Measurements=
"xAODPixelClusters_1stFromFPGACluster"))
289 name=
"FPGADataPrepActsStripClusterToTruthAssociationAlg",
290 InputTruthParticleLinks=
"xAODFPGATruthLinks",
291 AssociationMapOut=
"ITkFPGAStripClustersToTruthParticles",
292 Measurements=
"xAODStripClusters_1stFromFPGACluster"))
295 name=
"FPGADataPrepActsTruthParticleHitCountAlg",
296 PixelClustersToTruthAssociationMap=
"ITkFPGAPixelClustersToTruthParticles",
297 StripClustersToTruthAssociationMap=
"ITkFPGAStripClustersToTruthParticles",
298 TruthParticleHitCountsOut=
"FPGATruthParticleHitCounts"))
300 from ActsConfig.ActsTruthConfig
import ActsTrackToTruthAssociationAlgCfg, ActsTrackFindingValidationAlgCfg
301 acts_tracks=f
"{flags.Tracking.ActiveConfig.extension}Tracks" if not flags.Acts.doAmbiguityResolution
else f
"{flags.Tracking.ActiveConfig.extension}ResolvedTracks"
303 name=f
"{acts_tracks}FPGADataPrepTrackToTruthAssociationAlg",
304 PixelClustersToTruthAssociationMap=
"ITkFPGAPixelClustersToTruthParticles",
305 StripClustersToTruthAssociationMap=
"ITkFPGAStripClustersToTruthParticles",
306 ACTSTracksLocation=ACTSTracks,
307 AssociationMapOut=acts_tracks+
"FPGAToTruthParticleAssociation"))
311 name=f
"{acts_tracks}FPGADataPrepTrackFindingValidationAlg",
312 TrackToTruthAssociationMap=acts_tracks+
"FPGAToTruthParticleAssociation",
313 TruthParticleHitCounts=
"FPGATruthParticleHitCounts"
318 prefix = flags.Tracking.ActiveConfig.extension
319 from ActsConfig.ActsTrackFindingConfig
import ActsTrackToTrackParticleCnvAlgCfg
321 ACTSTracksLocation=[ACTSTracks,],
322 TrackParticlesOutKey=f
"{FinalTracks}TrackParticles"))
324 from ActsConfig.ActsTruthConfig
import ActsTrackParticleTruthDecorationAlgCfg
326 TrackToTruthAssociationMaps=[acts_tracks+
"FPGAToTruthParticleAssociation"],
327 TrackParticleContainerName=f
"{FinalTracks}TrackParticles",
328 TruthParticleHitCounts=
"FPGATruthParticleHitCounts",
329 ComputeTrackRecoEfficiency=
True))
335 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
336 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
339 FinalDataPrepTrackChainxAODTracksKeyPrefix=
"FPGADataPrep"
343 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
344 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
348 flags.Detector.EnableCalo =
False
351 flags.Tracking.ITkMainPass.doAthenaToActsSpacePoint=
True
352 flags.Tracking.ITkMainPass.doAthenaToActsCluster=
True
354 flags.Acts.doRotCorrection =
False
358 flags.Detector.EnableITkPixel=
True
359 flags.Detector.EnableITkStrip=
True
361 flags.Tracking.ITkMainPass.doActsSeed=
True
362 flags.Tracking.ITkMainPass.doActsTrack =
False
363 flags.Tracking.doITkFastTracking=
False
367 from InDetTrackPerfMon.InDetTrackPerfMonFlags
import initializeIDTPMConfigFlags, initializeIDTPMTrkAnaConfigFlags
370 flags.PhysVal.IDTPM.outputFilePrefix =
"myIDTPM_CA"
371 flags.PhysVal.IDTPM.plotsDefFileList =
"InDetTrackPerfMon/PlotsDefFileList_default.txt"
372 flags.PhysVal.IDTPM.plotsCommonValuesFile =
"InDetTrackPerfMon/PlotsDefCommonValues.json"
373 flags.PhysVal.OutputFileName = flags.PhysVal.IDTPM.outputFilePrefix +
'.HIST.root'
374 flags.Output.doWriteAOD_IDTPM =
True
375 flags.Output.AOD_IDTPMFileName = flags.PhysVal.IDTPM.outputFilePrefix +
'.AOD_IDTPM.pool.root'
376 flags.PhysVal.IDTPM.trkAnaCfgFile =
"InDetTrackPerfMon/EFTrkAnaConfig_example.json"
380 flags.PhysVal.IDTPM.TrkAnaEF.TrigTrkKey = f
"{FinalDataPrepTrackChainxAODTracksKeyPrefix}TrackParticles"
381 flags.PhysVal.IDTPM.TrkAnaDoubleRatio.TrigTrkKey = f
"{FinalDataPrepTrackChainxAODTracksKeyPrefix}TrackParticles"
383 flags.PhysVal.doExample =
False
386 flags.Concurrency.NumThreads=1
387 flags.Scheduler.ShowDataDeps=
True
388 flags.Debug.DumpEvtStore=
False
391 if isinstance(flags.Trigger.FPGATrackSim.wrapperFileName, str):
392 log.info(
"wrapperFile is string, converting to list")
393 flags.Trigger.FPGATrackSim.wrapperFileName = [flags.Trigger.FPGATrackSim.wrapperFileName]
394 flags.Input.Files =
lambda f: [f.Trigger.FPGATrackSim.wrapperFileName]
397 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.MainPass", keepOriginal=
True)
398 flags = flags.cloneAndReplace(
"Tracking.ActiveConfig",
"Tracking.ITkMainPass", keepOriginal=
True)
402 acc.addService(CompFactory.THistSvc(Output = [f
"EXPERT DATAFILE='{flags.Trigger.FPGATrackSim.outputMonitorFile}', OPT='RECREATE'"]))
403 acc.addService(CompFactory.THistSvc(Output = [
"FPGATRACKSIMOUTPUT DATAFILE='dataprep.root', OPT='RECREATE'"]))
406 if not flags.Trigger.FPGATrackSim.wrapperFileName:
407 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
411 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
414 from JetRecConfig.JetRecoSteering
import addTruthPileupJetsToOutputCfg
417 if flags.Detector.EnableCalo:
418 from CaloRec.CaloRecoConfig
import CaloRecoCfg
421 if not flags.Reco.EnableTrackOverlay:
422 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
425 if flags.Trigger.FPGATrackSim.connectToToITkTracking:
426 from InDetConfig.ITkTrackRecoConfig
import ITkTrackRecoCfg
432 if flags.Trigger.FPGATrackSim.doEDMConversion:
433 acc.merge(
FPGAConversionAlgCfg(flags, name =
'FPGAConversionAlg_1st', stage =
'_1st', doActsTrk=
False, doSP = flags.Trigger.FPGATrackSim.spacePoints))
434 if flags.Trigger.FPGATrackSim.convertUnmappedHits: acc.merge(
FPGAConversionAlgCfg(flags, name =
'FPGAConversionAlgUnmapped_1st', stage =
'Unmapped_1st', doClusters =
False))
436 if flags.Trigger.FPGATrackSim.connectToToITkTracking:
439 if flags.Trigger.FPGATrackSim.writeToAOD:
441 if flags.Trigger.FPGATrackSim.spacePoints : acc.merge(
WriteToAOD(flags,
443 finalTrackParticles=f
"{FinalDataPrepTrackChainxAODTracksKeyPrefix}TrackParticles"))
446 from FPGATrackSimReporting.FPGATrackSimReportingConfig
import FPGATrackSimReportingCfg
450 from InDetTrackPerfMon.InDetTrackPerfMonConfig
import InDetTrackPerfMonCfg
453 acc.store(
open(
'AnalysisConfig.pkl',
'wb'))
455 statusCode = acc.run(flags.Exec.MaxEvents)
456 assert statusCode.isSuccess()
is True,
"Application execution did not succeed"
459 if __name__ ==
"__main__":