ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimBankMergeConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2'''
3@file FPGATrackSimBankMergeConfig.py
4@author Riley Xu - rixu@cern.ch
5@date Sept 22, 2020
6@brief This file declares functions to configure components in FPGATrackSimBankMerge
7'''
8
9# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
10
11from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12from AthenaConfiguration.ComponentFactory import CompFactory
13import glob
14
15def getListOfFiles(regex):
16 path = []
17 for item in regex.split(','):
18 if ('matrix' in item and 'root' in item):
19 path += glob.glob(item)
20 return path
21
22def FPGATrackSimMatrixMergeCfg(flags, **kwargs):
23
24 acc = ComponentAccumulator()
25
26 kwargs.setdefault("nbank",flags.Trigger.FPGATrackSim.FPGATrackSimNBanks)
27 kwargs.setdefault("allregion",flags.Trigger.FPGATrackSim.FPGATrackSimallBanks)
28 kwargs.setdefault("region",flags.Trigger.FPGATrackSim.region)
29
30 theFPGATrackSimMatrixMergeAlg = CompFactory.FPGATrackSimMatrixMergeAlgo()
31 file_path = getListOfFiles(flags.Trigger.FPGATrackSim.FPGATrackSimMatrixFileRegEx)
32
33 if flags.Trigger.FPGATrackSim.FPGATrackSimMaxnMatrixInputFiles > 0:
34 theFPGATrackSimMatrixMergeAlg.file_path = file_path[0:flags.Trigger.FPGATrackSim.MaxInputFiles]
35 else:
36 theFPGATrackSimMatrixMergeAlg.file_path = file_path
37
38 acc.addEventAlgo(theFPGATrackSimMatrixMergeAlg)
39 return acc
40
41
42if __name__ == "__main__":
43 from AthenaConfiguration.AllConfigFlags import initConfigFlags
44 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
45 from AthenaCommon.Logging import logging
46 log = logging.getLogger(__name__)
47
48 flags = initConfigFlags()
49 flags.fillFromArgs()
50 flags.lock()
51
52 acc=MainServicesCfg(flags)
53
54 acc.merge(FPGATrackSimMatrixMergeCfg(flags))
55 acc.store(open('FPGATrackSimMatrixMergeConfig.pkl','wb'))
56
57 from AthenaConfiguration.Utils import setupLoggingLevels
58 setupLoggingLevels(flags, acc)
59
60 MatrixFileName=flags.Trigger.FPGATrackSim.outputMergedFPGATrackSimMatrixFile
61 acc.addService(CompFactory.THistSvc(Output = ["TRIGFPGATrackSimMATRIXOUT DATAFILE='"+MatrixFileName+"', OPT='RECREATE'"]))
62
63 statusCode = acc.run()
64 assert statusCode.isSuccess() is True, "Application execution did not succeed"
65