ATLAS Offline Software
TileD3PDConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 from AthenaConfiguration.Enums import Format
8 
9 '''
10 @file TileD3PDConfig.py
11 @brief Python configuration of TileD3PD for the Run III
12 '''
13 
14 
15 def _args(level, name, kwin, **kw):
16  kw = kw.copy()
17  kw['level'] = level
18  for (k, v) in kwin.items():
19  if k.startswith(name + '_'):
20  kw[k[len(name)+1:]] = v
21  return kw
22 
23 
24 def TileD3PDCfg(flags, outputFile=None, saveCells=True, saveMBTS=True,
25  saveE4pr=False, saveClusters=False, saveMuId=False,
26  saveMuonFit=False, savePosition=True, saveEventInfo=False,
27  **kwargs):
28  ''' Function to configure Tile D3PD.'''
29 
30  acc = ComponentAccumulator()
31 
32  from TileGeoModel.TileGMConfig import TileGMCfg
33  acc.merge(TileGMCfg(flags))
34 
35  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
36  acc.merge(LArGMCfg(flags))
37 
38  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
39  acc.merge( TileCablingSvcCfg(flags) )
40 
41  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
42  acc.merge( TileBadChannelsCondAlgCfg(flags) )
43 
44  if not outputFile:
45  runNumber = flags.Input.RunNumbers[0]
46  outputFile = f'tile_{runNumber}.aan.root'
47 
48  from D3PDMakerCoreComps.MakerAlgConfig import MakerAlgConfig
49  alg = MakerAlgConfig(flags, acc, 'caloD3PD', outputFile, ExistDataHeader=False)
50 
51  if saveEventInfo:
52  excludeEventInfoBlocks = ['eventMu'] if flags.Input.Format is Format.BS else []
53  from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject
54  alg += EventInfoD3PDObject(**_args(0, 'EventInfo', kwargs), exclude=excludeEventInfoBlocks)
55 
56  from CaloSysD3PDMaker.TileDetailsD3PDObject import TileDetailsD3PDObject
57  from CaloSysD3PDMaker.CaloInfoD3PDObject import CaloInfoD3PDObject
58  from CaloD3PDMaker.MBTSD3PDObject import MBTSD3PDObject
59 
60  isBiGainRun = flags.Tile.RunType.isBiGain()
61 
62  if isBiGainRun:
63  if saveCells:
64  alg += TileDetailsD3PDObject(**_args(1, 'TileDetails', kwargs, sgkey='AllCaloHG',
65  prefix='tile_', Kinematics_WriteEtaPhi=True,
66  TileDetails_SavePositionInfo=savePosition))
67 
68  alg += CaloInfoD3PDObject(**_args(0, 'CaloInfo', kwargs, sgkey='AllCaloHG', prefix='calo_'))
69 
70  if saveMBTS:
71  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='mbts_', sgkey='MBTSContainerHG'))
72  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='mbtsLG_', sgkey='MBTSContainerLG'))
73 
74  if saveE4pr:
75  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='e4pr_',
76  sgkey='E4prContainerHG', MBTS_SaveEtaPhiInfo=False))
77 
78  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='e4prLG_',
79  sgkey='E4prContainerLG', MBTS_SaveEtaPhiInfo=False))
80  else:
81  if saveCells:
82  alg += TileDetailsD3PDObject(**_args(1, 'TileDetails', kwargs, sgkey='AllCalo',
83  prefix='tile_', Kinematics_WriteEtaPhi=True,
84  TileDetails_SavePositionInfo=savePosition))
85 
86  alg += CaloInfoD3PDObject(**_args(0, 'CaloInfo', kwargs, sgkey='AllCalo', prefix='calo_'))
87 
88  if saveMBTS:
89  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='mbts_', sgkey='MBTSContainer'))
90 
91  if saveE4pr:
92  alg += MBTSD3PDObject(**_args(1, 'MBTS', kwargs, prefix='e4pr_',
93  sgkey='E4prContainer', MBTS_SaveEtaPhiInfo=False))
94 
95  if saveClusters:
96  from CaloD3PDMaker.xAODClusterD3PDObject import xAODClusterD3PDObject
97  alg += xAODClusterD3PDObject(**_args(3, 'topo_cl', kwargs, sgkey='TileTopoCluster', prefix='topo_'))
98 
99  if saveMuId:
100  from CaloSysD3PDMaker.TileMuD3PDObject import TileMuD3PDObject
101  alg += TileMuD3PDObject(**_args(0, 'TileMus', kwargs, sgkey='TileMuObj', prefix='tilemuid_'))
102 
103  if saveMuonFit:
104  from CaloSysD3PDMaker.TileCosmicMuonD3PDObject import TileCosmicMuonD3PDObject
105  alg += TileCosmicMuonD3PDObject(**_args(2, 'TileCosMusHT', kwargs, sgkey='TileCosmicMuonHT', prefix='TileCosmicsHT_'))
106 
107  acc.addEventAlgo(alg.alg)
108  return acc
109 
110 
111 if __name__ == '__main__':
112 
113  # Set the Athena configuration flags
114  from D3PDMakerConfig.D3PDMakerFlags import configFlags as flags
115  parser = flags.getArgumentParser()
116  parser.add_argument('--cells', action='store_true', help='Save Tile cells in D3PD')
117  parser.add_argument('--mbts', action='store_true', help='Save Tile MBTS in D3PD')
118  parser.add_argument('--e4pr', action='store_true', help='Save Tile E4pr in D3PD')
119  parser.add_argument('--muid', action='store_true', help='Save Tile MuID in D3PD')
120  parser.add_argument('--muonfit', action='store_true', help='Save Tile Muon Fitter in D3PD')
121  parser.add_argument('--clusters', action='store_true', help='Save Tile clusters in D3PD')
122  parser.add_argument('--postExec', help='Code to execute after setup')
123  args, _ = parser.parse_known_args()
124 
125  # Setup logs
126  from AthenaCommon.Logging import log
127  from AthenaCommon.Constants import INFO
128  log.setLevel(INFO)
129 
130  from AthenaConfiguration.TestDefaults import defaultTestFiles
131  flags.Input.Files = defaultTestFiles.ESD
132  flags.Exec.MaxEvents = 3
133  flags.fillFromArgs(parser=parser)
134 
135  log.info('FINAL CONFIG FLAGS SETTINGS FOLLOW')
136  flags.dump()
137 
138  flags.lock()
139 
140  # Initialize configuration object, add accumulator, merge, and run.
141  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
142  cfg = MainServicesCfg(flags)
143 
144  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
145  cfg.merge(PoolReadCfg(flags))
146 
147  cfg.merge( TileD3PDCfg(flags,
148  saveCells=args.cells,
149  saveMBTS=args.mbts,
150  saveE4pr=args.e4pr,
151  saveMuId=args.muid,
152  saveMuonFitter=args.muonfit,
153  saveClusters=args.clusters,
154  saveEventInfo=True) )
155 
156  cfg.setAppProperty('CreateSvc', [cfg.getService('TileCablingSvc').getFullJobOptName()])
157 
158  # Any last things to do?
159  if args.postExec:
160  log.info('Executing postExec: %s', args.postExec)
161  exec(args.postExec)
162 
163  cfg.printConfig(withDetails=True, summariseProps=True)
164 
165  cfg.store( open('TileD3PDConfig.pkl', 'wb') )
166 
167  sc = cfg.run()
168 
169  import sys
170  # Success should be 0
171  sys.exit(0 if sc.isSuccess() else 1)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TileDetailsD3PDObject.TileDetailsD3PDObject
def TileDetailsD3PDObject
Definition: TileDetailsD3PDObject.py:113
python.MakerAlgConfig.MakerAlgConfig
def MakerAlgConfig(flags, acc, stream, file, clevel=D3PDMakerFlags.CompressionLevel, autoflush=D3PDMakerFlags.AutoFlush, ExistDataHeader=True, **kw)
Definition: MakerAlgConfig.py:63
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.xAODClusterD3PDObject.xAODClusterD3PDObject
xAODClusterD3PDObject
Definition: xAODClusterD3PDObject.py:11
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.CaloInfoD3PDObject.CaloInfoD3PDObject
CaloInfoD3PDObject
Definition: CaloInfoD3PDObject.py:10
TileD3PDConfig.TileD3PDCfg
def TileD3PDCfg(flags, outputFile=None, saveCells=True, saveMBTS=True, saveE4pr=False, saveClusters=False, saveMuId=False, saveMuonFit=False, savePosition=True, saveEventInfo=False, **kwargs)
Definition: TileD3PDConfig.py:24
Trk::open
@ open
Definition: BinningType.h:40
python.EventInfoD3PDObject.EventInfoD3PDObject
EventInfoD3PDObject
Definition: EventInfoD3PDObject.py:18
python.MBTSD3PDObject.MBTSD3PDObject
MBTSD3PDObject
Definition: MBTSD3PDObject.py:17
TileD3PDConfig._args
def _args(level, name, kwin, **kw)
Definition: TileD3PDConfig.py:15
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7