41def PoolWriteCfg(flags):
42 """Return ComponentAccumulator configured to Write POOL files"""
43
44
45 from AthenaCommon.Logging import logging
46 logger = logging.getLogger( 'PoolWriteCfg' )
47
48 PoolAttributes = []
49
50 PoolAttributes += ["DEFAULT_SPLITLEVEL ='0'"]
51
52
53 PoolAttributes += ["STREAM_MEMBER_WISE = '1'"]
54
55
56 PoolAttributes += ["DEFAULT_BUFFERSIZE = '32000'"]
57
58
59 PoolAttributes += ["ContainerName = 'TTree=POOLContainerForm(DataHeaderForm)'; CONTAINER_SPLITLEVEL = '0'"]
60 PoolAttributes += ["TREE_BRANCH_OFFSETTAB_LEN ='100'"]
61
62 oneDHForm = flags.Output.OneDataHeaderForm
63
64
65 from AthenaPoolCnvSvc import PoolAttributeHelper as pah
66
67
68
69 defaults = {
70 "EVNT" : [2, 1, 500, 0, 0],
71 "EVNT_TR" : [2, 1, 1, 0, 0],
72 "HITS" : [2, 1, 10, 0, 0],
73 "RDO" : [2, 1, 10, 0, 0],
74 "ESD" : [2, 1, 10, 0, 0],
75 "AOD" : [2, 1, 100, 0, 0],
76 "DAOD_PHYSVAL" : [5, 5, 100, 0, 1],
77 "DAOD_PHYS" : [5, 5, 500, 0, 1],
78 "DAOD_PHYSLITE" : [5, 5, 500, 1, 1],
79 "DAOD_TRUTH3" : [5, 5, 500, 1, 1],
80 "D2AOD_PHYSLITE" : [5, 5, 500, 1, 1],
81 }
82
83
84 OutputMetadataContainers = []
85
86
87 fileFlushSetting = {}
88 maxAutoFlush = -1
89 storageTechnologyMap = flags.Output.StorageTechnology.EventData or {'*': flags.PoolSvc.DefaultContainerType}
90 for stream in _getStreamsFromFlags(flags):
91
92
93 fileName = getattr(flags.Output, f"{stream}FileName")
94
95
96 compAlg, compLvl, autoFlush, splitLvl, dynSplitLvl = 2, 1, 10, 0, 0
97 if stream in defaults:
98 compAlg, compLvl, autoFlush, splitLvl, dynSplitLvl = defaults[stream]
99 elif "DAOD" in stream:
100 compAlg, compLvl, autoFlush, splitLvl, dynSplitLvl = 5, 5, 100, 0, 1
101 elif "D2AOD" in stream:
102 compAlg, compLvl, autoFlush, splitLvl, dynSplitLvl = 5, 5, 500, 1, 1
103
104
105
106
107
108
109
110
111 isTemporaryStream = fileName.endswith('_000') or fileName.startswith('tmp.') or stream in flags.Output.TemporaryStreams
112 tempFileCompressionSetting = (5,1)
113 if isTemporaryStream:
114
115
116
117 from AthenaConfiguration.Enums import LHCPeriod
118 if "RDO" in stream and flags.hasCategory("GeoModel") and flags.GeoModel.Run < LHCPeriod.Run3:
119 tempFileCompressionSetting = (1,1)
120 logger.info(f"Stream {stream} is marked as temporary, overwriting the compression settings to {tempFileCompressionSetting}")
121 compAlg, compLvl = tempFileCompressionSetting if isTemporaryStream else (compAlg, compLvl)
122
123
124 autoFlush = _overrideTreeAutoFlush(logger, flags, stream, autoFlush)
125
126
127 logger.debug(f"{fileName=} {stream=} {compAlg=} {compLvl=} {autoFlush=} {splitLvl=} {dynSplitLvl=}")
128
129
130 outputCollection = "POOLContainer"
131 poolContainerPrefix = "CollectionTree"
132
133
134
135 isAugmentation = flags.hasFlag(f"Output.{stream}ParentStream")
136 if not isAugmentation:
137
138 PoolAttributes += [ pah.setFileCompAlg( fileName, compAlg ) ]
139 PoolAttributes += [ pah.setFileCompLvl( fileName, compLvl ) ]
140
141
142 if "AOD" in stream:
143 PoolAttributes += [ pah.setMaxBufferSize( fileName, "131072" ) ]
144 PoolAttributes += [ pah.setMinBufferEntries( fileName, "10" ) ]
145 else:
146
147
148 PoolAttributes += [ f"DatabaseName = '{fileName}'; INDEX_MASTER = 'POOLContainer(DataHeader)'" ]
149
150
151 outputCollection += f"_{stream}"
152 poolContainerPrefix += f"_{stream}"
153 OutputMetadataContainers += [f"MetaData_{stream}"]
154
155
156 PoolAttributes += [ pah.setTreeAutoFlush( fileName, poolContainerPrefix, autoFlush ) ]
157 PoolAttributes += [ pah.setTreeAutoFlush( fileName, outputCollection, autoFlush ) ]
158 PoolAttributes += [ pah.setTreeAutoFlush( fileName, "POOLContainerForm", autoFlush ) ]
159 PoolAttributes += [ pah.setTreeMaxSize( fileName, "*", "1099511627776L" ) ]
160 if flags.MP.UseSharedWriter and flags.MP.UseParallelCompression:
161 fileFlushSetting[fileName] = ( flags.MP.SharedWriter.FileFlushSetting.get(fileName, autoFlush) )
162 logger.info(f"Setting auto write for {fileName} to {fileFlushSetting[fileName]} events")
163
164
165 PoolAttributes += [ pah.setContainerSplitLevel( fileName, poolContainerPrefix, splitLvl ) ]
166 PoolAttributes += [ pah.setContainerSplitLevel( fileName, "Aux.", splitLvl ) ]
167 PoolAttributes += [ pah.setContainerSplitLevel( fileName, "Dyn.", dynSplitLvl ) ]
168
169
170
171
172 if "EVNT" in stream or "RDO" in stream:
173 PoolAttributes += [ f"DatabaseName = '{fileName}'; FILEFORWARD_COMPATIBILITY = '1'" ]
174
175 oneDHForm = False
176
177
178 maxAutoFlush =
max(maxAutoFlush, autoFlush)
179
180
181
182 if fileName not in storageTechnologyMap and '*' not in storageTechnologyMap:
183 storageTechnologyMap[fileName] = flags.PoolSvc.DefaultContainerType
184
185
186
187 useParallelCompression = flags.MP.UseSharedWriter and flags.MP.UseParallelCompression
188 if useParallelCompression:
189
190 requestedEvents = flags.Exec.MaxEvents
191 availableEvents = flags.Input.FileNentries - flags.Exec.SkipEvents
192 totalEntries = availableEvents
if requestedEvents == -1
else min( availableEvents, requestedEvents )
193 if ( totalEntries > 0 ) and ( maxAutoFlush > 0 ) and ( maxAutoFlush * flags.Concurrency.NumProcs > totalEntries ):
194 logger.info( "Not enough events to process, disabling parallel compression for SharedWriter!" )
195 logger.info( f"Processing {totalEntries} events in {flags.Concurrency.NumProcs} workers "
196 f"and a maximum (across all outputs) AutoFlush of {maxAutoFlush}")
197 useParallelCompression = False
198
199 if flags.MP.UseSharedReader or flags.MP.UseSharedWriter:
200 from AthenaPoolCnvSvc.PoolCommonConfig import AthenaPoolSharedIOCnvSvcCfg
201 return AthenaPoolSharedIOCnvSvcCfg(flags,
202 PoolAttributes=PoolAttributes,
203 ParallelCompression=useParallelCompression,
204 StorageTechnology=storageTechnologyMap,
205 OutputMetadataContainers=OutputMetadataContainers,
206 OneDataHeaderForm=oneDHForm,
207 FileFlushSetting=fileFlushSetting)
208 else:
209 from AthenaPoolCnvSvc.PoolCommonConfig import AthenaPoolCnvSvcCfg
210 return AthenaPoolCnvSvcCfg(flags,
211 PoolAttributes=PoolAttributes,
212 StorageTechnology=storageTechnologyMap,
213 OneDataHeaderForm=oneDHForm)