5def setupHistSvcCfg(flags, outFile: str, outStream: str, autoFlush: int = -30000000, autoSave: int = -30000000):
6 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
7 result = ComponentAccumulator()
9 raise ValueError(
"The output file must not be empty")
10 if len(outStream) == 0:
11 raise ValueError(
"The outstream must not be empty")
13 from AthenaConfiguration.ComponentFactory
import CompFactory
14 histSvc = CompFactory.THistSvc(Output=[f
"{outStream} DATAFILE='{outFile}', OPT='RECREATE'"], AutoFlush=autoFlush, AutoSave=autoSave)
15 print(f
"Register new stream {outStream} piped to {outFile}")
16 result.addService(histSvc, primary=
True)
24 from AthenaCommon.Logging
import logging
25 log = logging.getLogger(
'GeometryConfiguration')
27 if not flags.GeoModel.AtlasVersion:
28 if not flags.GeoModel.SQLiteDB:
29 raise ValueError(
"Default tag configuration only works for SQLite")
31 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
32 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
33 from AthenaConfiguration.Enums
import LHCPeriod
34 if flags.GeoModel.Run == LHCPeriod.Run3:
35 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
36 elif flags.GeoModel.Run == LHCPeriod.Run4:
37 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
39 raise ValueError(f
"Invalid run period {flags.GeoModel.Run}")
43 log.info(f
"Setup {flags.GeoModel.AtlasVersion} geometry loading {flags.GeoModel.SQLiteDBFullPath}")
44 log.info(f
"Use conditions tag {flags.IOVDb.GlobalTag}")
47 if not flags.GeoModel.AtlasVersion:
48 raise ValueError(
"No ATLAS version is configured")
50 from AthenaConfiguration.Enums
import LHCPeriod
51 from AthenaConfiguration.TestDefaults
import defaultConditionsTags
52 if flags.GeoModel.Run == LHCPeriod.Run2:
53 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
if flags.Input.isMC
else defaultConditionsTags.RUN2_DATA
54 elif flags.GeoModel.Run == LHCPeriod.Run3:
55 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
if flags.Input.isMC
else defaultConditionsTags.RUN3_DATA
56 elif flags.GeoModel.Run == LHCPeriod.Run4:
57 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
59 raise ValueError(f
"Invalid run period {flags.GeoModel.Run}")
63 flags.Input.Files = []
66 from os
import path, listdir
67 for fileArg
in inputTokens:
68 if path.isdir(fileArg):
69 flags.Input.Files += [
"{dir}/{file}".format(dir=fileArg, file=y)
for y
in listdir(fileArg) ]
71 if fileArg[fileArg.rfind(
".")+1 :]
not in [
"txt",
"conf"]:
72 flags.Input.Files+=[fileArg]
74 with open(fileArg)
as inStream:
76 if isinstance(inStream, str)
and "," in inStream:
77 flags.Input.Files += inStream.split(
",")
79 flags.Input.Files+=[ line.strip()
for line
in inStream
if line[0]!=
'#']
84 Setup flags necessary for Muon standalone.
86 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
87 flags = initConfigFlags()
88 flags.Detector.GeometryMDT =
True
89 flags.Detector.GeometryTGC =
True
91 flags.Detector.GeometryRPC =
True
93 flags.Detector.GeometryCalo =
False
94 flags.Detector.GeometryID =
False
97 flags.Muon.makePRDs =
False
99 flags.Exec.MaxEvents = 20
100 flags.Scheduler.ShowDataDeps =
True
101 flags.Scheduler.CheckDependencies =
True
102 flags.Scheduler.ShowDataFlow =
True
103 flags.Scheduler.ShowControlFlow =
True
104 flags.Concurrency.NumThreads = 1
105 flags.Concurrency.NumConcurrentEvents = 1
110 if flags.Input.Files == [
'_ATHENA_GENERIC_INPUTFILE_NAME_']
or len(flags.Input.Files) == 0:
112 from AthenaConfiguration.TestDefaults
import defaultTestFiles
113 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
117 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
118 setupDetectorFlags(flags)
120 if flags.Output.ESDFileName ==
'':
121 flags.Output.ESDFileName=
'newESD.pool.root'
124 flags.dump(evaluate =
True)
130 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
131 cfg = MainServicesCfg(flags)
132 msgService = cfg.getService(
'MessageSvc')
133 msgService.Format =
"S:%s E:%e % F%128W%S%7W%R%T %0W%M"
134 msgService.debugLimit = 2147483647
135 msgService.verboseLimit = 2147483647
136 msgService.infoLimit = 2147483647
139 from AthenaConfiguration.Enums
import Format
140 if not flags.Input.Files:
143 elif flags.Input.Format
is Format.POOL:
144 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
145 cfg.merge(PoolReadCfg(flags))
146 elif flags.Input.Format == Format.BS:
147 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
148 cfg.merge(ByteStreamReadCfg(flags))
151 if (
"TruthEvents" in flags.Input.Collections):
152 from xAODTruthCnv.RedoTruthLinksConfig
import RedoTruthLinksAlgCfg
153 cfg.merge( RedoTruthLinksAlgCfg(flags) )
154 elif (
"TruthEvent" in flags.Input.Collections):
155 from xAODTruthCnv.xAODTruthCnvConfig
import GEN_AOD2xAODCfg
156 cfg.merge(GEN_AOD2xAODCfg(flags))
159 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
160 cfg.merge(MuonGeoModelCfg(flags))
161 from MuonConfig.MuonGeometryConfig
import MuonIdHelperSvcCfg
162 cfg.merge(MuonIdHelperSvcCfg(flags))
168 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg, outputStreamName
170 cfg.merge( OutputStreamCfg( flags,
'ESD', ItemList=itemsToRecord) )
171 outstream = cfg.getEventAlgo(outputStreamName(
"ESD"))
172 outstream.ForceRead =
True
175 from TrkEventCnvTools.TrkEventCnvToolsConfig
import (
176 TrkEventCnvSuperToolCfg)
177 cfg.merge(TrkEventCnvSuperToolCfg(flags))
setupHistSvcCfg(flags, str outFile, str outStream, int autoFlush=-30000000, int autoSave=-30000000)
Configuration snippet to setup the THistSvc.