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