ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellMakerConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3"""Define method to construct configured Tile Cell maker algorithm"""
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.Enums import BeamType
7from AthenaConfiguration.ComponentFactory import CompFactory
8from TileConfiguration.TileConfigFlags import TileRunType
9from CaloCellCorrection.CaloCellCorrectionConfig import CaloCellNeighborsAverageCorrCfg
10
11
13 """Return component accumulator with configured private Calo cell container checker tool
14
15 Arguments:
16 flags -- Athena configuration flags
17 """
18
19 acc = ComponentAccumulator()
20
21 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
22 acc.merge(LArGMCfg(flags))
23
24 from TileGeoModel.TileGMConfig import TileGMCfg
25 acc.merge(TileGMCfg(flags))
26
27 CaloCellContainerCheckerTool=CompFactory.CaloCellContainerCheckerTool
28 acc.setPrivateTools( CaloCellContainerCheckerTool() )
29
30 return acc
31
32
33def TileCellMakerCfg(flags, mergeChannels=True, **kwargs):
34 """Return component accumulator with configured Tile Cell maker algorithm
35
36 Arguments:
37 flags -- Athena configuration flags
38 name -- name of Tile cell maker algorithm. Defautls to TileCellMaker
39 or TileCellMakerHG/TileCellMakerLG depending on only used gain.
40 SkipGain - skip given gain. Defaults to -1 [use all gains]. Possible values: 0 [LG], 1 [HG].
41 CaloCellsOutputName -- name of the output calo cell container. Defautls to AllCalo
42 or AllCaloHG/AllCaloLG depending on only used gain.
43 DoCaloNeighborsCorrection -- correct dead cells. Assign as energy the average energy of
44 the surrounding cells. Defaults to False.
45 mergeChannels -- merge DSP results with offline reco results. Defaults to True.
46 """
47
48 acc = ComponentAccumulator()
49
50 useGain = {0 : 'HG', 1 : 'LG'} # Key is skipped gain
51
52 skipGain = kwargs.get('SkipGain', -1) # Never skip any gain by default
53
54 defaultName = 'TileCellMaker' if skipGain == -1 else 'TileCellMaker' + useGain[skipGain]
55 name = kwargs.get('name', defaultName)
56
57 defaultOutputCells = 'AllCalo' if skipGain == -1 else 'AllCalo' + useGain[skipGain]
58 caloCellsOutputName = kwargs.get('CaloCellsOutputName', defaultOutputCells)
59
60 doCaloNeighborsCorrection = kwargs.get('DoCaloNeighborsCorrection', False)
61
62 from AthenaCommon.Logging import logging
63 msg = logging.getLogger( 'TileCellMakerCfg' )
64
65 CaloCellMaker, CaloCellContainerFinalizerTool=CompFactory.getComps("CaloCellMaker","CaloCellContainerFinalizerTool",)
66 from TileRecUtils.TileCellBuilderConfig import TileCellBuilderCfg
67 tileCellBuilder = acc.popToolsAndMerge( TileCellBuilderCfg(flags, SkipGain=skipGain, mergeChannels=mergeChannels) )
68
69 cellMakerTools = [tileCellBuilder, CaloCellContainerFinalizerTool()]
70
71 noiseFilter = flags.Tile.NoiseFilter
72
73 doCellNoiseFilter = noiseFilter - noiseFilter % 100
74 doRawChannelNoiseFilter = noiseFilter - doCellNoiseFilter - noiseFilter % 10
75
76 if doRawChannelNoiseFilter == 10:
77 msg.info('Use Tile raw channel noise filter')
78 from TileRecUtils.TileRawChannelCorrectionConfig import TileRawChannelNoiseFilterCfg
79 noiseFilter = acc.popToolsAndMerge( TileRawChannelNoiseFilterCfg(flags) )
80 tileCellBuilder.NoiseFilterTools = [noiseFilter]
81
82 if doCellNoiseFilter == 100:
83 msg.info('Use Tile cell noise filter')
84 from TileRecUtils.TileCellNoiseFilterConfig import TileCellNoiseFilterCfg
85 cellNoiseFilter = acc.popToolsAndMerge( TileCellNoiseFilterCfg(flags) )
86 cellMakerTools += [ cellNoiseFilter ]
87
88 if doCaloNeighborsCorrection:
89 msg.info('Use Calo cell neighbours average correction')
90 caloCellNeighborsAverageCorrection = acc.popToolsAndMerge( CaloCellNeighborsAverageCorrCfg(flags) )
91 cellMakerTools += [caloCellNeighborsAverageCorrection]
92
93 if flags.Beam.Type is not BeamType.TestBeam:
94 caloCellContainerChecker = acc.popToolsAndMerge( CaloCellContainerCheckerToolCfg(flags) )
95 cellMakerTools += [caloCellContainerChecker]
96
97 cellMakerAlg = CaloCellMaker(name = name, CaloCellMakerToolNames = cellMakerTools,
98 CaloCellsOutputName = caloCellsOutputName)
99
100 acc.addEventAlgo(cellMakerAlg, primary = True)
101
102 return acc
103
104
105
106if __name__ == "__main__":
107
108 from AthenaConfiguration.AllConfigFlags import initConfigFlags
109 from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
110 from AthenaCommon.Logging import log
111 from AthenaCommon.Constants import DEBUG
112
113 # Test setup
114 log.setLevel(DEBUG)
115
116 flags = initConfigFlags()
117 flags.Input.Files = defaultTestFiles.RAW_RUN2
118 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
119 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
120 flags.Tile.RunType = TileRunType.PHY
121 flags.Tile.doOptATLAS = True
122 flags.Tile.correctTimeJumps = True
123 flags.Tile.NoiseFilter = 1
124 flags.Output.ESDFileName = "myESD.pool.root"
125 flags.Exec.MaxEvents=3
126 flags.fillFromArgs()
127
128 flags.lock()
129
130 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
131 acc = MainServicesCfg(flags)
132
133 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
134 acc.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
135
136 acc.merge( TileCellMakerCfg(flags) )
137
138 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
139 acc.merge(OutputStreamCfg(flags, "ESD",
140 ItemList = [ 'CaloCellContainer#*', 'TileCellContainer#*']))
141
142 acc.getEventAlgo(outputStreamName("ESD")).ExtraInputs = {('CaloCellContainer', 'StoreGateSvc+AllCalo')}
143
144 flags.dump()
145 acc.printConfig(withDetails = True, summariseProps = True)
146 acc.store( open('TileCellMaker.pkl','wb') )
147
148 # Needed to work around cling crash in dbg build...
149 import ROOT
150 ROOT.CaloCellContainer
151
152 sc = acc.run()
153
154 import sys
155 # Success should be 0
156 sys.exit(not sc.isSuccess())
157
TileCellMakerCfg(flags, mergeChannels=True, **kwargs)