3 """Define method to construct configured Tile digits maker algorithm"""
5 from TileSimAlgs.TileHitVecToCntConfig
import TileHitVecToCntCfg
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaConfiguration.Enums
import ProductionStep
8 from TileConfiguration.TileConfigFlags
import TileRunType
11 """Return component accumulator with configured Tile digits maker algorithm
14 flags -- Athena configuration flags
16 name -- name of TileDigitsMaker algorithm. Defaults to TileDigitsMaker.
17 UseCoolPulseShapes -- flag to use pulse shape from database. Defaults to True.
18 RndmEvtOverlay -- flag to add PileUp or noise by overlaying random events.
19 True if flag.Common.isOverlay equals to True.
20 MaskBadChannels -- flag to mask channels tagged bad. Defaults to False.
23 kwargs.setdefault(
'name',
'TileDigitsMaker')
24 kwargs.setdefault(
'UseCoolPulseShapes',
True)
25 kwargs.setdefault(
'MaskBadChannels',
False)
26 kwargs.setdefault(
'RndmEvtOverlay', flags.Common.isOverlay)
27 kwargs.setdefault(
'OnlyUseContainerName',
not flags.Common.isOverlay)
31 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
33 infoLoader = infoLoaderAcc.getPrimary()
34 acc.merge( infoLoaderAcc )
36 infoLoaderProperties = infoLoader._properties.items()
38 if 'TileNoise' in infoLoaderProperties:
39 tileNoise = infoLoaderProperties[
'TileNoise']
41 tileNoise = infoLoader._descriptors[
'TileNoise'].default
43 if 'TileCoherNoise' in infoLoaderProperties:
44 tileCoherNoise = infoLoaderProperties[
'TileCoherNoise']
46 tileCoherNoise = infoLoader._descriptors[
'TileCoherNoise'].default
48 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
51 from TileConditions.TileSampleNoiseConfig
import TileSampleNoiseCondAlgCfg
54 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
57 from TileConditions.TileSamplingFractionConfig
import TileSamplingFractionCondAlgCfg
60 if kwargs[
'RndmEvtOverlay']:
62 tileCoherNoise =
False
64 kwargs[
'InputTileDigitContainer'] = f
'{flags.Overlay.BkgPrefix}TileDigitsCnt'
65 kwargs[
'TileDQstatus'] =
'TileDQstatus'
67 if flags.Overlay.ByteStream:
68 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
71 from SGComps.SGInputLoaderConfig
import SGInputLoaderCfg
72 acc.merge(
SGInputLoaderCfg(flags, [f
'TileDigitsContainer#{kwargs["InputTileDigitContainer"]}']))
74 from TileRecUtils.TileDQstatusConfig
import TileDQstatusAlgCfg
77 if tileNoise
or tileCoherNoise
or kwargs[
'RndmEvtOverlay']:
78 if 'RndmSvc' not in kwargs:
79 from RngComps.RngCompsConfig
import AthRNGSvcCfg
80 kwargs[
'RndmSvc'] = acc.getPrimaryAndMerge(
AthRNGSvcCfg(flags) ).name
82 kwargs[
'RndmSvc'] =
None
84 if kwargs[
'UseCoolPulseShapes']:
85 from TileConditions.TilePulseShapeConfig
import TilePulseShapeCondAlgCfg
88 if kwargs[
'MaskBadChannels']
or kwargs[
'RndmEvtOverlay']:
89 from TileConditions.TileBadChannelsConfig
import TileBadChannelsCondAlgCfg
92 if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
93 kwargs.setdefault(
'TileDigitsContainer', flags.Overlay.BkgPrefix +
'TileDigitsCnt')
95 kwargs.setdefault(
'TileDigitsContainer',
'TileDigitsCnt')
97 kwargs.setdefault(
'DoHSTruthReconstruction', flags.Digitization.EnableCaloHSTruthRecoInputs)
98 if kwargs[
'DoHSTruthReconstruction']:
99 kwargs.setdefault(
'TileHitContainer_DigiHSTruth',
'TileHitCnt_DigiHSTruth')
100 kwargs.setdefault(
'TileDigitsContainer_DigiHSTruth',
'TileDigitsCnt_DigiHSTruth')
102 kwargs.setdefault(
'TileHitContainer_DigiHSTruth',
'')
103 kwargs.setdefault(
'TileDigitsContainer_DigiHSTruth',
'')
106 kwargs.setdefault(
'IntegerDigits', flags.Common.ProductionStep != ProductionStep.PileUpPresampling)
108 TileDigitsMaker=CompFactory.TileDigitsMaker
111 acc.addEventAlgo(digitsMaker, primary =
True)
116 """Return component accumulator with configured Tile digits maker algorithm and Output Stream
119 flags -- Athena configuration flags
121 name -- name of TileDigitsMaker algorithm. Defaults to TileDigitsMaker.
122 UseCoolPulseShapes -- flag to use pulse shape from database. Defaults to True.
123 RndmEvtOverlay -- flag to add PileUp or noise by overlaying random events.
124 True if Common.ProductionStep equals to ProductionStep.Overlay.
125 MaskBadChannels -- flag to mask channels tagged bad. Defaults to False.
129 tileDigitsMaker = acc.getPrimary()
131 if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
132 if hasattr(tileDigitsMaker,
'TileDigitsContainer'):
133 tileDigitsContainer = tileDigitsMaker.TileDigitsContainer
135 tileDigitsContainer = tileDigitsMaker.getDefaultProperty(
'TileDigitsContainer')
137 if hasattr(tileDigitsMaker,
'TileFilteredContainer'):
138 tileDigitsContainer = tileDigitsMaker.TileFilteredContainer
140 tileDigitsContainer = tileDigitsMaker.getDefaultProperty(
'TileFilteredContainer')
142 tileDigitsContainer =
str(tileDigitsContainer).
split(
'+').pop()
143 if flags.Digitization.AddCaloDigi:
144 outputItemList = [
'TileDigitsContainer#*']
146 outputItemList = [
'TileDigitsContainer#' + tileDigitsContainer]
148 if flags.Output.doWriteRDO:
149 if flags.Digitization.EnableTruth:
150 outputItemList += [
"CaloCalibrationHitContainer#*"]
151 from DigitizationConfig.TruthDigitizationOutputConfig
import TruthDigitizationOutputCfg
153 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
154 acc.merge(
OutputStreamCfg(flags, streamName =
'RDO', ItemList = outputItemList) )
159 if __name__ ==
"__main__":
161 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
162 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultTestFiles
163 from AthenaCommon.Logging
import log
170 flags.Input.Files = defaultTestFiles.HITS_RUN2
171 flags.Tile.RunType = TileRunType.PHY
172 flags.Output.RDOFileName =
'myRDO-TileDigitsMaker.pool.root'
173 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
174 flags.Digitization.PileUp =
False
175 flags.Exec.MaxEvents = 3
183 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
186 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
189 if 'EventInfo' not in flags.Input.Collections:
190 from xAODEventInfoCnv.xAODEventInfoCnvConfig
import EventInfoCnvAlgCfg
192 inputKey=
'McEventInfo',
193 outputKey=
'EventInfo'))
197 acc.printConfig(withDetails =
True, summariseProps =
True)
198 acc.store(
open(
'TileDigitsMaker.pkl',
'wb') )
203 sys.exit(
not sc.isSuccess())