ATLAS Offline Software
TileRawChannelToNtupleConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.Enums import BeamType
7 
8 '''
9 @file TileRawChannelToNtupleConfig.py
10 @brief Python configuration of Tile raw channels to ntuple algorithm for the Run III
11 '''
12 
13 from AthenaConfiguration.ComponentFactory import CompFactory
14 
15 
16 def TileRawChannelToNtupleCfg(flags, outputFile=None, **kwargs):
17  ''' Function to configure Tile digits to h70 ntuple algorithm.'''
18 
19  acc = ComponentAccumulator()
20 
21  from TileGeoModel.TileGMConfig import TileGMCfg
22  acc.merge(TileGMCfg(flags))
23 
24  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
25  acc.merge( TileCablingSvcCfg(flags) )
26 
27  if not outputFile:
28  prefix = 'tiletb' if flags.Beam.Type is BeamType.TestBeam else 'tile'
29  outputFile = f'{prefix}.ntup.root'
30 
31  ntupleSvc = CompFactory.NTupleSvc()
32  ntupleSvc.Output = ["NTUP DATAFILE='%s' OPT='NEW'" % outputFile]
33  acc.addService(ntupleSvc)
34 
35  kwargs.setdefault('TileRawChannelContainer', 'TileRawChannelCnt')
36  kwargs.setdefault('NTupleLoc', '/NTUP')
37 
38  TileRawChannelToNtuple = CompFactory.TileRawChannelToNtuple
39  acc.addEventAlgo(TileRawChannelToNtuple(**kwargs), primary=True)
40 
41  acc.setAppProperty('HistogramPersistency', 'ROOT')
42 
43  return acc
44 
45 
46 if __name__ == '__main__':
47 
48  # Set the Athena configuration flags
49  from AthenaConfiguration.AllConfigFlags import initConfigFlags
50  flags = initConfigFlags()
51 
52  # Setup logs
53  from AthenaCommon.Logging import log
54  from AthenaCommon.Constants import INFO
55  log.setLevel(INFO)
56 
57  from AthenaConfiguration.TestDefaults import defaultTestFiles
58  flags.Input.Files = defaultTestFiles.RDO_RUN3
59  flags.Exec.MaxEvents = 3
60  flags.fillFromArgs()
61 
62  log.info('Final configuration flags follow:')
63  flags.dump()
64 
65  flags.lock()
66 
67  # Initialize configuration object, add accumulator, merge, and run.
68  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
69  cfg = MainServicesCfg(flags)
70 
71  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
72  cfg.merge(PoolReadCfg(flags))
73 
74  cfg.merge(TileRawChannelToNtupleCfg(flags))
75 
76  cfg.printConfig(withDetails=True, summariseProps=True)
77 
78  with open('TileRawChannelToNtupleConfig.pkl', 'wb') as f:
79  cfg.store(f)
80 
81  sc = cfg.run()
82 
83  import sys
84  # Success should be 0
85  sys.exit(0 if sc.isSuccess() else 1)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
Constants
some useful constants -------------------------------------------------—
TileRawChannelToNtuple
Definition: TileRawChannelToNtuple.h:41
Trk::open
@ open
Definition: BinningType.h:40
TileRawChannelToNtupleConfig.TileRawChannelToNtupleCfg
def TileRawChannelToNtupleCfg(flags, outputFile=None, **kwargs)
Definition: TileRawChannelToNtupleConfig.py:16
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7