ATLAS Offline Software
Loading...
Searching...
No Matches
TileTMDBRawChannelMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4'''@file TileTMDBRawChannelMonitorAlgorithm.py
5@author
6@date
7@brief Python configuration of TileTMDBRawChannelMonitorAlgorithm algorithm for the Run III
8'''
9def TileMuRcvRawChannelMakerCfg(flags, MuRcvRawChCnt = "TileMuRcvRawChannelOpt2", **kwargs):
10
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 acc = ComponentAccumulator()
13
14 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
15 acc.merge( TileInfoLoaderCfg(flags) )
16
17 kwargs.setdefault('name', 'TileMuRcvRChMaker')
18 kwargs.setdefault('TileDigitsContainer', 'MuRcvDigitsCnt')
19
20 if 'TileRawChannelBuilder' not in kwargs:
21
22 from TileConditions.TilePulseShapeConfig import TileCondToolMuRcvPulseShapeCfg
23 pulseShapeTool = acc.popToolsAndMerge( TileCondToolMuRcvPulseShapeCfg(flags) )
24
25 from TileConditions.TileOFCConfig import TileCondToolOfcCfg
26 ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(flags,
27 OptFilterDeltaCorrelation = True,
28 TileCondToolPulseShape = pulseShapeTool) )
29
30 from TileRecUtils.TileRawChannelBuilderOptConfig import TileRawChannelBuilderOpt2FilterCfg
31 rawChanBuilder = acc.popToolsAndMerge( TileRawChannelBuilderOpt2FilterCfg(flags,
32 method = 'Opt2',
33 PedestalMode = 1,
34 correctTime = False,
35 NoiseFilterTools = [],
36 TileCondToolOfc = ofcTool,
37 TileRawChannelContainer = MuRcvRawChCnt) )
38
39
40 kwargs.setdefault('TileRawChannelBuilder', [rawChanBuilder])
41
42 from AthenaConfiguration.ComponentFactory import CompFactory
43 TileRawChannelMaker=CompFactory.TileRawChannelMaker
44 acc.addEventAlgo(TileRawChannelMaker(**kwargs), primary = True)
45
46 return acc
47
48def TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt = "MuRcvRawChCnt", FillRawChannelHistograms = True, FillEfficiencyHistograms = False, **kwargs):
49
50 '''Function to configure Tile TMDB raw channel monitoring algorithm.'''
51 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
52 result = ComponentAccumulator()
53
54 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
55 result.merge( TileCablingSvcCfg(flags) )
56
57 from AthenaConfiguration.Enums import Format
58 if flags.Input.Format == Format.BS:
59 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
60 result.merge(TileRawDataReadingCfg(flags, readDigits=False, readRawChannel=False,
61 readMuRcv=True, readMuRcvDigits=True, readMuRcvRawCh=True))
62
63 isDSP = (MuRcvRawChCnt == "MuRcvRawChCnt")
64 if not isDSP:
65 result.merge(TileMuRcvRawChannelMakerCfg(flags, MuRcvRawChCnt = MuRcvRawChCnt))
66
67 name = kwargs.get('name', 'TileTMDBRawChanDspMonAlg' if isDSP else 'TileTMDBRawChanMonAlg')
68
69 from AthenaMonitoring import AthMonitorCfgHelper
70 helper = AthMonitorCfgHelper(flags, 'TileTMDBRawChannelDspMonitoring' if isDSP else 'TileTMDBRawChannelMonitoring')
71
72 from AthenaConfiguration.ComponentFactory import CompFactory
73 tileTMDBRawChanMonAlg = helper.addAlgorithm(CompFactory.TileTMDBRawChannelMonitorAlgorithm, name)
74 tileTMDBRawChanMonAlg.TriggerChain = ''
75 tileTMDBRawChanMonAlg.MuRcvRawChCnt = MuRcvRawChCnt
76 tileTMDBRawChanMonAlg.DSP = isDSP
77 tileTMDBRawChanMonAlg.FillEfficiencyHistograms = FillEfficiencyHistograms
78 tileTMDBRawChanMonAlg.FillRawChannelHistograms = FillRawChannelHistograms
79
80 topPath = 'Tile/TMDBRawChannel/DSP' if isDSP else 'Tile/TMDBRawChannel'
81 run = str(flags.Input.RunNumbers[0])
82
83 if FillRawChannelHistograms:
84
85 if isDSP:
86 minAmplitude = 0
87 maxAmplitude = 80000
88 else:
89 minAmplitude = -20.5
90 maxAmplitude = 255.5
91
92 from TileMonitoring.TileMonitoringCfgHelper import addTileTMDB_1DHistogramsArray, addTileTMDB_2DHistogramsArray
93
94 addTileTMDB_2DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawAmplitude',
95 value = 'amplitude', title = 'Amplitude Map',
96 path = topPath, type='TProfile2D', run = run)
97
98 addTileTMDB_2DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawTime',
99 value = 'time', title = 'Time Map',
100 path = topPath, type='TProfile2D', run = run)
101
102 addTileTMDB_1DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawCellTime',
103 xvalue = 'time', title = 'Time;[ns]',
104 path = topPath, type='TH1D', run = run,
105 xbins = 120, xmin = -60, xmax = 60)
106
107 addTileTMDB_1DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawCellAmplitude',
108 xvalue = 'amplitude', title = 'Amplitude;[ADC]',
109 path = topPath, type='TH1D', run = run,
110 xbins = 276, xmin = minAmplitude, xmax = maxAmplitude)
111
112
113 if FillEfficiencyHistograms:
114
115 from TileConditions.TileTMDBConfig import TileTMDBCondAlgCfg
116 result.merge( TileTMDBCondAlgCfg(flags) )
117
118 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
119 from TileMonitoring.TileMonitoringCfgHelper import getLabels, getPartitionName
120
121 arrayTGC = helper.addArray([2], tileTMDBRawChanMonAlg, 'TGC_TrSec_number_Good_Muons')
122 for postfix, tool in arrayTGC.Tools.items():
123 ros = int(postfix.split('_').pop()) + 3
124 partition = getPartitionName(ros)
125
126 fullName = 'sector;TGC_TrSec_number_Good_Muons_{}'.format(partition)
127 fullTitle = 'Number of Good Muons in TGC trigger sectors {}'.format(partition)
128
129 tool.defineHistogram(fullName, path = topPath, type = 'TH1D', title = fullTitle,
130 xbins = 48, xmin = -0.5, xmax = 47.5)
131
132
133 cells = ['D6', 'D5+D6']
134 thresholds = ['500MeV','600MeV']
135 tileTMDBRawChanMonAlg.NumberOfThresholds = len(thresholds)
136 arrayThreshD = helper.addArray([2, len(thresholds), len(cells)], tileTMDBRawChanMonAlg, 'TMDB_coincidence_threshold')
137 for postfix, tool in arrayThreshD.Tools.items():
138 elements = postfix.split('_')
139 cell = int(elements.pop())
140 threshold = int(elements.pop())
141 ros = int(elements.pop()) + 3
142 partition = getPartitionName(ros)
143
144 labels = getLabels(('modules'), partition)
145
146 fullName = 'module;TMDB_{}_{}_coincidence_{}'.format(partition, cells[cell], thresholds[threshold])
147 fullTitle = 'Number coincidence from all Good Muons in TMDB {} {} over {} threshold'.format(partition, cells[cell], thresholds[threshold])
148
149 tool.defineHistogram(fullName, path = topPath, type = 'TH1D', title = fullTitle, xlabels = labels,
150 xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5)
151
152
153 accumalator = helper.result()
154 result.merge(accumalator)
155 return result
156
157
158
159if __name__=='__main__':
160 # Setup logs
161 from AthenaCommon.Logging import log
162 from AthenaCommon.Constants import INFO
163 log.setLevel(INFO)
164
165 # Set the Athena configuration flags
166 from AthenaConfiguration.AllConfigFlags import initConfigFlags
167 flags = initConfigFlags()
168 flags.Input.Files = ['/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/q431/22.0/v1/myESD.pool.root']
169 flags.Output.HISTFileName = 'TileTMDBRawChannelMonitorOutput.root'
170 flags.DQ.useTrigger = False
171 flags.DQ.enableLumiAccess = False
172 flags.Exec.MaxEvents = 3
173 flags.fillFromArgs()
174 flags.lock()
175
176 # Initialize configuration object, add accumulator, merge, and run.
177 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
178 cfg = MainServicesCfg(flags)
179
180 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
181 cfg.merge(PoolReadCfg(flags))
182
183 cfg.merge( TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt = "MuRcvRawChCnt", FillEfficiencyHistograms = True) )
184 cfg.merge( TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt = "TileMuRcvRawChannelOpt2") )
185
186 cfg.printConfig(withDetails = True, summariseProps = True)
187 flags.dump()
188
189 cfg.store( open('TileTMDBRawChannelMonitorAlgorithm.pkl','wb') )
190
191 sc = cfg.run()
192
193 import sys
194 sys.exit(not sc.isSuccess())
TileMuRcvRawChannelMakerCfg(flags, MuRcvRawChCnt="TileMuRcvRawChannelOpt2", **kwargs)
TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt="MuRcvRawChCnt", FillRawChannelHistograms=True, FillEfficiencyHistograms=False, **kwargs)