ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelFlxMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4
5'''
6@file TileDigitsFlxMonitorAlgorithm.py
7@brief Python configuration of TileDigitsFlxMonitorAlgorithm algorithm for the Run III
8'''
9
10def TileRawChannelFlxMonitoringConfig(flags, fragIDs=[0x201, 0x402], topPath='TestBeam', **kwargs):
11 '''Function to configures TileRawChannelFlxMonAlg algorithms in the monitoring system.'''
12
13 kwargs.setdefault('TileRawChannelContainerLegacy', 'TileRawChannelFit')
14 kwargs.setdefault('TileRawChannelContainerFlx', 'TileRawChannelFlxFit')
15 kwargs.setdefault('FelixScale', 4)
16
17 felixScale = kwargs['FelixScale']
18
19 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
20 result = ComponentAccumulator()
21
22 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
23 result.merge( TileCablingSvcCfg(flags) )
24
25 from AthenaMonitoring import AthMonitorCfgHelper
26 helper = AthMonitorCfgHelper(flags, 'TileRawChannelFlxMonitoring')
27
28 from AthenaConfiguration.ComponentFactory import CompFactory
29 TileRawChannelFlxMonitorAlgorithm = CompFactory.TileRawChannelFlxMonitorAlgorithm
30 tileRawChannelFlxMonAlg = helper.addAlgorithm(TileRawChannelFlxMonitorAlgorithm, 'TileRawChannelFlxMonAlg')
31 tileRawChannelFlxMonAlg.TriggerChain = ''
32
33 for k, v in kwargs.items():
34 setattr(tileRawChannelFlxMonAlg, k, v)
35
36 # Configure histogram with TileRawChannelFlxMonAlg algorithm execution time
37 executeTimeGroup = helper.addGroup(tileRawChannelFlxMonAlg, 'TileRawChannelFlxMonExecuteTime', f'{topPath}/Felix')
38 executeTimeGroup.defineHistogram('TIME_execute', path = 'RawChannel', type='TH1F',
39 title = 'Time for execute TileRawChannelFlxMonAlg algorithm;time [#mus]',
40 xbins = 300, xmin = 0, xmax = 300000)
41
42 runNumber = flags.Input.RunNumbers[0]
43 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
44
45 modules = []
46 if fragIDs:
47 for fragID in fragIDs:
48 ros = fragID >> 8
49 drawer = fragID & 0x3F
50 modules += [Tile.getDrawerString(ros, drawer)]
51 else:
52 for ros in range(1, Tile.MAX_ROS):
53 for drawer in range(0, Tile.MAX_DRAWER):
54 modules += [Tile.getDrawerString(ros, drawer)]
55
56 channelLegacyGroup = helper.addGroup(tileRawChannelFlxMonAlg, 'TileRawChannelAmpLegacy', f'{topPath}/Legacy/RawChannel')
57 for moduleName in modules:
58 for gainName in ['HG', 'LG']:
59 title = f'Run {str(runNumber)} {moduleName} {gainName}: Amplitude (Legacy);Channel;Amplitude'
60 name = f'{moduleName}_{gainName}_channel,{moduleName}_{gainName}_amplitude;{moduleName}_{gainName}_amplitude_legacy'
61 path = moduleName
62 channelLegacyGroup.defineHistogram(name, title = title, path = path, type = 'TProfile',
63 xbins = 48, xmin = -0.5, xmax = 47.5)
64
65 channelFelixGroup = helper.addGroup(tileRawChannelFlxMonAlg, 'TileRawChannelAmpFlx', f'{topPath}/Felix/RawChannel')
66 for moduleName in modules:
67 for gainName in ['HG', 'LG']:
68 title = f'Run {str(runNumber)} {moduleName} {gainName}: Amplitude (FELIX);Channel;Amplitude'
69 name = f'{moduleName}_{gainName}_channel,{moduleName}_{gainName}_amplitude;{moduleName}_{gainName}_amplitude_felix'
70 path = moduleName
71 channelFelixGroup.defineHistogram(name, title = title, path = path, type = 'TProfile',
72 xbins = 48, xmin = -0.5, xmax = 47.5)
73
74 channelCompareGroup = helper.addGroup(tileRawChannelFlxMonAlg, 'TileRawChannelAmpDiff', f'{topPath}/Compare/RawChannel')
75 for moduleName in modules:
76 for gainName in ['HG', 'LG']:
77 title = f'Run {str(runNumber)} {moduleName} {gainName}: Amplitude difference (FELIX-Legacy*{felixScale});Channel;Amplitude difference [ADC]'
78 name = f'{moduleName}_{gainName}_channel,{moduleName}_{gainName}_amplitude_diff;{moduleName}_{gainName}_amplitude_diff'
79 path = moduleName
80 channelCompareGroup.defineHistogram(name, title = title, path = path, type = 'TProfile',
81 xbins = 48, xmin = -0.5, xmax = 47.5)
82
83 channelCompareVsLegacyGroup = helper.addGroup(tileRawChannelFlxMonAlg, 'TileRawChannelAmpDiffVsLegacy', f'{topPath}/Compare/RawChannel')
84 for moduleName in modules:
85 for gainName in ['HG', 'LG']:
86 title = f'Run {str(runNumber)} {moduleName} {gainName}: Amplitude difference (FELIX-Legacy*{felixScale});Amplitude (Legacy) [ADC];Amplitude difference [ADC]'
87 name = f'{moduleName}_{gainName}_amplitude,{moduleName}_{gainName}_amplitude_diff;{moduleName}_{gainName}_amplitude_diff_vs_legacy'
88 path = moduleName
89 channelCompareVsLegacyGroup.defineHistogram(name, title = title, path = path, type = 'TProfile',
90 xbins = 1024, xmin = -0.5, xmax = 1023.5)
91
92 accumalator = helper.result()
93 result.merge(accumalator)
94 return result
95
96
97
98if __name__=='__main__':
99
100 # Setup logs
101 from AthenaCommon.Logging import log
102 from AthenaCommon.Constants import INFO
103 log.setLevel(INFO)
104
105 # Set the Athena configuration flags
106 from AthenaConfiguration.AllConfigFlags import initConfigFlags
107 from AthenaConfiguration.TestDefaults import defaultTestFiles
108 flags = initConfigFlags()
109 flags.Input.Files = defaultTestFiles.RAW_RUN2
110 flags.Output.HISTFileName = 'TileRawChannelFlxMonitorOutput.root'
111 flags.DQ.useTrigger = False
112 flags.DQ.enableLumiAccess = False
113 flags.Exec.MaxEvents = 3
114 flags.fillFromArgs()
115 flags.lock()
116
117 # Initialize configuration object, add accumulator, merge, and run.
118 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
119 cfg = MainServicesCfg(flags)
120
121 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
122 cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
123
124 cfg.merge(TileRawChannelFlxMonitoringConfig(flags,
125 TileRawChannelContainerLegacy='TileRawChannelFit',
126 TileRawChannelContainerFlx='TileRawChannelFlxFit',
127 fillHistogramsForDSP=True))
128
129 flags.dump()
130
131 cfg.store( open('TileRawChannelMonitorAlgorithm.pkl','wb') )
132
133 sc = cfg.run()
134
135 import sys
136 # Success should be 0
137 sys.exit(not sc.isSuccess())
138
TileRawChannelFlxMonitoringConfig(flags, fragIDs=[0x201, 0x402], topPath='TestBeam', **kwargs)