ATLAS Offline Software
Loading...
Searching...
No Matches
TileDigitsToNtupleConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3#
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.Enums import BeamType
7
8'''
9@file TileDigitsToNtupleConfig.py
10@brief Python configuration of Tile digits to ntuple algorithm for the Run III
11'''
12
13from AthenaConfiguration.ComponentFactory import CompFactory
14
15
16def TileDigitsToNtupleCfg(flags, outputFile=None, **kwargs):
17 ''' Function to configure Tile digits to h40 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 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
28 acc.merge( TileInfoLoaderCfg(flags) )
29
30 if not outputFile:
31 prefix = 'tiletb' if flags.Beam.Type is BeamType.TestBeam else 'tile'
32 outputFile = f'{prefix}.ntup.root'
33
34 ntupleSvc = CompFactory.NTupleSvc()
35 ntupleSvc.Output = ["NTUP DATAFILE='%s' OPT='NEW'" % outputFile]
36 acc.addService(ntupleSvc)
37
38 kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
39 kwargs.setdefault('NTupleLoc', '/NTUP')
40
41 TileDigitsToNtuple = CompFactory.TileDigitsToNtuple
42 acc.addEventAlgo(TileDigitsToNtuple(**kwargs), primary=True)
43
44 acc.setAppProperty('HistogramPersistency', 'ROOT')
45
46 return acc
47
48
49if __name__ == '__main__':
50
51 # Set the Athena configuration flags
52 from AthenaConfiguration.AllConfigFlags import initConfigFlags
53 flags = initConfigFlags()
54
55 # Setup logs
56 from AthenaCommon.Logging import log
57 from AthenaCommon.Constants import INFO
58 log.setLevel(INFO)
59
60 from AthenaConfiguration.TestDefaults import defaultTestFiles
61 flags.Input.Files = defaultTestFiles.RDO_RUN3
62 flags.Exec.MaxEvents = 3
63 flags.fillFromArgs()
64
65 log.info('Final configuration flags follow:')
66 flags.dump()
67
68 flags.lock()
69
70 # Initialize configuration object, add accumulator, merge, and run.
71 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
72 cfg = MainServicesCfg(flags)
73
74 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
75 cfg.merge(PoolReadCfg(flags))
76
77 cfg.merge(TileDigitsToNtupleCfg(flags, TileDigitsContainer='TileDigitsFlt'))
78
79 cfg.printConfig(withDetails=True, summariseProps=True)
80
81 with open('TileDigitsToNtupleConfig.pkl', 'wb') as f:
82 cfg.store(f)
83
84 sc = cfg.run()
85
86 import sys
87 # Success should be 0
88 sys.exit(0 if sc.isSuccess() else 1)
TileDigitsToNtupleCfg(flags, outputFile=None, **kwargs)